/*
- */
+ * Parsing of the structure of the YPP client's displayed image
+ */
+/*
+ * This is part of ypp-sc-tools, a set of third-party tools for assisting
+ * players of Yohoho Puzzle Pirates.
+ *
+ * Copyright (C) 2009 Ian Jackson <ijackson@chiark.greenend.org.uk>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Yohoho and Puzzle Pirates are probably trademarks of Three Rings and
+ * are used without permission. This program is not endorsed or
+ * sponsored by Three Rings.
+ */
#include "structure.h"
require_rectangle_r(*cellr, " o");
}
-static void ocr_rectangle(Rect r, const OcrCellType ct) {
+static void ocr_rectangle(Rect r, const OcrCellType ct, FILE *tsv_output) {
OcrResultGlyph *results, *res;
int w= r.br.x - r.tl.x + 1;
results= ocr(rd,ct,w,cols);
for (res=results; res->s; res++)
- printf("%s",res->s);
+ fputs(res->s,tsv_output);
}
-void analyse(void) {
+void analyse(FILE *tsv_output) {
Rect thisr, entryr;
int page, tryrect, colno;
const char *tab= "";
for (colno=0; colno<columns; colno++) {
find_table_entry(thisr,colno,&entryr);
- fputs(tab, stdout);
+ fputs(tab, tsv_output);
ocr_rectangle(entryr,
colno<TEXT_COLUMNS
? &ocr_celltype_text
- : &ocr_celltype_number);
+ : &ocr_celltype_number,
+ tsv_output);
tab= "\t";
}
- fputs("\n", stdout);
- sysassert(!ferror(stdout));
- sysassert(!fflush(stdout));
+ fputs("\n", tsv_output);
+ sysassert(!ferror(tsv_output));
+ sysassert(!fflush(tsv_output));
}
}
}