2 * general header file for yarrg
5 * This is part of ypp-sc-tools, a set of third-party tools for assisting
6 * players of Yohoho Puzzle Pirates.
8 * Copyright (C) 2009 Ian Jackson <ijackson@chiark.greenend.org.uk>
10 * This program is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <http://www.gnu.org/licenses/>.
23 * Yohoho and Puzzle Pirates are probably trademarks of Three Rings and
24 * are used without permission. This program is not endorsed or
25 * sponsored by Three Rings.
31 #define DEBUG_FLAG_LIST \
57 /*----- from rgbimage.c -----*/
59 #define MAXIMGIDENT 100
61 typedef uint32_t Rgb; /* red<<0 | green<<8 | blue<<16 */
63 typedef struct RgbImage {
65 Rgb data[]; /* data[ y*w + x ] */
68 void identify_rgbimage(const RgbImage *base, Rect portion,
69 char result[MAXIMGIDENT], const char *what);
70 RgbImage *alloc_rgb_image(int w, int h);
71 void fwrite_ppmraw(FILE *f, const RgbImage *ri);
73 #define RI_PIXEL32(ri,x,y) ((ri)->data + ((y)*(ri)->w + (x)))
75 static inline Rgb ri_rgb(const RgbImage *ri, int x, int y) {
76 return *RI_PIXEL32(ri,x,y);
79 /*----- from structure.c -----*/
81 typedef struct PageStruct PageStruct;
83 void find_structure(const CanonImage *im,
84 PageStruct **pagestruct_r, /* caller must free() */
85 int *max_relevant_y_r,
86 Point *commod_focus_point_r,
87 Point *commod_page_point_r,
88 Point *commod_focuslast_point_r);
89 void store_current_page(CanonImage *ci /*pointer saved*/,
90 PageStruct *pagestruct, /*freed*/
91 RgbImage *rgb /*freed*/);
92 void adjust_colours(CanonImage *ci, const RgbImage *rgb);
94 void select_page(int page);
95 void check_pager_motion(int first, int stop);
97 Rect find_sunshine_widget(void);
99 void canon_colour_prepare(void);
100 void find_islandname(void);
101 void check_correct_commodities(void);
102 void read_screenshots(void);
103 void read_one_screenshot(void);
104 void analyse(FILE *tsv_output);
106 /*----- from convert.c -----*/
108 extern FILE *screenshot_file;
109 void fetch_with_rsync(const char *stem);
110 void fetch_with_rsync_gz(const char *stem);
113 ff_singlepage= 000002,
114 ff_testservers= 000004,
116 ff_charset_edit= 000010,
117 ff_charset_allowedit= 000020,
118 ff_charset_havelocal= 000040,
121 ff_dict_fetch= 000100,
122 ff_dict_submit= 000200,
123 ff_dict_pirate= 000400,
126 ff_needisland= 001000,
127 ff_printisland= 002000,
130 ff_use_yarrg= 010000,
134 ffs_printisland= 003000,
137 extern enum flags o_flags;
140 mf_findwindow= 00001,
141 mf_screenshot= 00010,
142 mf_readscreenshot= 00020,
144 mf_printoceanpirate= 00200,
147 mode_findwindow= 00201,
148 mode_screenshot= 00011,
150 mode_showcharset= 01000,
154 extern enum mode o_mode;
156 extern const char *o_ocean, *o_pirate;
160 #define dbassert(x) ((x) ? (void)0 : dbfile_assertfail(__FILE__,__LINE__,#x))
161 void dbfile_assertfail(const char *file, int line, const char *m) NORET;
164 void dbfile_getsline(char *lbuf, size_t lbufsz, const char *file, int line);
165 int dbfile_open(const char *tpath); /* 0: ENOENT; 1: worked */
166 int dbfile_gzopen(const char *tpath); /* 0: ENOENT; 1: worked */
167 void dbfile_close(void); /* idempotent */
169 int dbfile_scanf(const char *fmt, ...) SCANFMT(1,2);
170 int dbfile_vscanf(const char *fmt, va_list al) SCANFMT(1,0);
172 int gzopen(const char *zpath, int oflags, FILE **f_r, pid_t *pid_r,
173 const char *gziplevel /* 0 for read; may be 0, or "-1" etc. */);
174 /* returns errno value from open */
175 void gzclose(FILE **f, pid_t *p, const char *what);
176 /* also OK with f==0, or p==-1 */
179 const char *get_vardir(void);
180 const char *get_libdir(void);
183 #define EXECLP_HELPER(helper, ...) do{ \
184 char *helper_path= masprintf("%s/%s",get_libdir(),helper); \
185 execlp(helper_path,helper, __VA_ARGS__); \
186 sysassert(errno==ENOENT); \
187 fatal("Failed to find helper program %s.\n" \
188 "(Are you in the correct directory?)", helper); \
192 /*----- from pages.c -----*/
194 void screenshot_startup(void);
195 void set_yppclient_window(unsigned long wul);
196 void find_yppclient_window(void);
197 void take_screenshots(void);
198 void take_one_screenshot(void);
200 #define MAX_PAGES 1000
202 extern const CanonImage *page_images[MAX_PAGES];
203 extern const RgbImage *page0_rgbimage;
206 extern const char *ocean, *pirate;
207 extern char *archipelago, *island;