-#define WALK_UNTIL_MUST(point,coord,increm,last,edge) \
- do { \
- WALK_UNTIL(point,coord,increm,last,edge); \
- eassert((point).coord != (last)+(increm)); \
- } while(0)
-
-static void find_structure(void) {
- Rect whole = { {0,0}, {width-1,height-1} };
-
- WALK_UNTIL_MUST(mainr.tl, x,-1, whole.tl.x, '*');
- WALK_UNTIL_MUST(mainr.tl, y,-1, whole.tl.y, '*');
- WALK_UNTIL_MUST(mainr.br, x,+1, whole.br.x, '*');
- WALK_UNTIL_MUST(mainr.br, y,+1, whole.br.y, '*');
-
- require_rectangle(mainr.tl.x-1, mainr.tl.y, mainr.tl.x-1, mainr.br.y, "*");
- require_rectangle(mainr.br.x+1, mainr.tl.y, mainr.br.x+1, mainr.br.y, "*");
- require_rectangle(mainr.tl.x, mainr.tl.y-1, mainr.br.x, mainr.tl.y-1, "*");
- require_rectangle(mainr.tl.x, mainr.br.y+1, mainr.br.x, mainr.br.y+1, "*");
-
-#define CHECK_STRIP_BORDER(tlbr,xy,increm) \
- do { \
- Point csb_p; \
- Rect csb_r; \
- csb_p= mainr.tl; \
- csb_p.xy= mainr.tlbr.xy; \
- if (get_p(csb_p)=='+') { \
- csb_r= mainr; \
- csb_r.tl.xy= csb_p.xy; \
- csb_r.br.xy= csb_p.xy; \
- require_rectangle_r(csb_r, "+"); \
- mainr.tlbr.xy += increm; \
- } \
- } while(0)
-
- debug_rect("mainr",0, mainr);
-
- CHECK_STRIP_BORDER(tl,x,+1);
- CHECK_STRIP_BORDER(tl,y,+1);
- CHECK_STRIP_BORDER(br,x,-1);
- CHECK_STRIP_BORDER(br,y,-1);
-
- debug_rect("mainr",1, mainr);
-
- Point up = START_MAIN;
- WALK_UNTIL_MUST(up, y,-1, mainr.tl.y, '+');
-
- Point down = START_MAIN;
- down.y++;
- WALK_UNTIL_MUST(down, y,+1, mainr.br.y, '+');
-
- int xscaleunit, y,x;
- for (y=0, xscaleunit=1; y<4; y++, xscaleunit*=10) {
- fprintf(debug," ");
- for (x=0; x<=width; x++) {
- if (x % xscaleunit) fputc(' ',debug);
- else fprintf(debug,"%d",(x / xscaleunit)%10);
+ /* Defaults */
+
+ set_server("YPPSC_PCTB_PCTB",
+ "http://", "pctb.ilk.org" /*pctb.crabdance.com*/,
+ "pctb.ilk.org",
+ o_serv_pctb, o_flags & (ff_needisland|ff_upload));
+
+ set_server("YPPSC_PCTB_DICT_UPDATE",
+ "rsync://", "rsync.pctb.chiark.greenend.org.uk/pctb",
+ "rsync.pctb.chiark.greenend.org.uk/pctb/test",
+ o_serv_dict_fetch, o_flags & ff_dict_fetch);
+
+ set_server("YPPSC_PCTB_DICT_SUBMIT",
+ "http://", "dictup.pctb.chiark.greenend.org.uk",
+ "dictup.pctb.chiark.greenend.org.uk/test",
+ o_serv_dict_submit, o_flags & ff_dict_submit);
+
+ if (!o_screenshot_fn)
+ o_screenshot_fn= masprintf("%s/#pages#.ppm",get_vardir());
+
+ /* Actually do the work */
+
+ if (o_mode & mf_findwindow) {
+ screenshot_startup();
+ find_yppclient_window();
+ }
+ if (!ocean) ocean= o_ocean;
+ if (!pirate) pirate= o_pirate;
+
+ if (o_flags & ff_needisland)
+ if (!ocean)
+ badusage("need --ocean option when replaying images"
+ " (consider supplying --pirate too)");
+ if (ocean)
+ sysassert(! setenv("YPPSC_OCEAN",ocean,1) );
+ if (pirate && (o_flags & ff_dict_pirate))
+ sysassert(! setenv("YPPSC_PIRATE",pirate,1) );
+
+ if (o_mode & mf_screenshot) {
+ open_screenshot_file("w");
+ if (o_flags & ff_singlepage) take_one_screenshot();
+ else take_screenshots();
+ progress_log("OK for you to move the mouse now.");
+ }
+ if (o_mode & mf_readscreenshot) {
+ open_screenshot_file("r");
+ if (o_flags & ff_singlepage) read_one_screenshot();
+ else read_screenshots();
+ }
+ if (o_mode & mf_analyse) {
+ if (o_flags & ff_needisland) {
+ find_islandname(page0_rgbimage);
+ if (o_flags & ff_printisland)
+ printf("%s, %s\n", archipelago, island);
+ }
+ switch (o_outmode_kind) {
+ case omk_upload: case omk_str: run_analysis(); break;
+ case omk_raw: analyse(stdout); break;
+ case omk_none: break;
+ default: abort();