tomwalters@0: /* tomwalters@0: Copyright (c) Applied Psychology Unit, Medical Research Council. 1993 tomwalters@0: =========================================================================== tomwalters@0: tomwalters@0: Permission to use, copy, modify, and distribute this software without fee tomwalters@0: is hereby granted for research purposes, provided that this copyright tomwalters@0: notice appears in all copies and in all supporting documentation, and that tomwalters@0: the software is not redistributed for any fee (except for a nominal tomwalters@0: shipping charge). Anyone wanting to incorporate all or part of this tomwalters@0: software in a commercial product must obtain a license from the Medical tomwalters@0: Research Council. tomwalters@0: tomwalters@0: The MRC makes no representations about the suitability of this tomwalters@0: software for any purpose. It is provided "as is" without express or tomwalters@0: implied warranty. tomwalters@0: tomwalters@0: THE MRC DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING tomwalters@0: ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL tomwalters@0: THE A.P.U. BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES tomwalters@0: OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, tomwalters@0: WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, tomwalters@0: ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS tomwalters@0: SOFTWARE. tomwalters@0: */ tomwalters@0: tomwalters@0: /* tomwalters@0: * xreview tomwalters@0: * ---------- tomwalters@0: * tomwalters@0: * A program for animating an AIM 'cartoon bitmap'. tomwalters@0: * Requires X windows, but most varieties, r4, r5, Sun OpenWindows tomwalters@0: * (but see also the makefile) tomwalters@0: * tomwalters@0: * The underlying algorithm is: tomwalters@0: * 1. load the entire cartoon into memory, as one contiguos block. tomwalters@0: * 2. compute, and save, the memory locations of each frame's start. tomwalters@0: * 3. Set the memory pointer of an XImage structure to the first one, and draw tomwalters@0: * 4. Reset the pointer to the next frame, and redraw ... tomwalters@0: * 5. Continue for however many frames there are. tomwalters@0: * tomwalters@0: * tomwalters@0: * tomwalters@0: * A large proportion of this was inspired by the "basic window" tomwalters@0: * program of the O'Reilly X manuals, vol 1. More inspiritaion came from tomwalters@0: * John Holdsworth's code. tomwalters@0: * tomwalters@0: * tomwalters@0: * M.Akeroyd July 1993. version 1.00 tomwalters@0: * tomwalters@0: * revisions: MAA: Christmas 1993. rewrites for public release, also some tomwalters@0: * bug fixes. tomwalters@0: * Includes the linux hacks. tomwalters@0: */ tomwalters@0: tomwalters@0: tomwalters@0: #include tomwalters@0: #include tomwalters@0: #include tomwalters@0: #include tomwalters@0: #include tomwalters@0: #include tomwalters@0: #include tomwalters@0: tomwalters@0: #include tomwalters@0: #include tomwalters@0: #include tomwalters@0: #include tomwalters@0: #include tomwalters@0: tomwalters@0: #include "xreview.h" tomwalters@0: #include "./stipple_a" /* for the Control Window background */ tomwalters@0: tomwalters@0: tomwalters@0: tomwalters@0: tomwalters@0: /* Function declarations */ tomwalters@0: /*-------------------------------------------------------------------------*/ tomwalters@0: tomwalters@0: void parsecommandline (int argc, char *argv[], char inputfn[], char titlestring[], char fontname[]); tomwalters@0: int readheader(FILE *inputfp, char filefn[]); tomwalters@0: FILE *open_file (char filefn[], FILE *dir_default, int streamtype); tomwalters@0: void close_files (FILE *fp); tomwalters@0: tomwalters@0: tomwalters@0: void initialise_control_window(char *inputfn, char *titlestring, FILE *inputfp, char *argv[], int argc); tomwalters@0: void initialise_axes_window(char *inputfn, char *titlestring, FILE *inputfp, char *argv[], int argc); tomwalters@0: void initialise_buttons(); tomwalters@0: void initialise_image(); tomwalters@0: tomwalters@0: tomwalters@0: void drawimage(int frame); tomwalters@0: void drawtext(Window win, GC gc, XFontStruct *font_info, unsigned int width, \ tomwalters@0: unsigned int height, char *text); tomwalters@0: void drawbutton(Window control_win, Window button_local, GC *button_local_gc,\ tomwalters@0: int width, int height, char *text, int fill_ground, \ tomwalters@0: int text_ground); tomwalters@0: void flashbutton(Window top_win, Window button_local, GC *button_local_gc, \ tomwalters@0: int width, int height, char *text); tomwalters@0: tomwalters@0: void initialise_X_screen(); tomwalters@0: void load_font(); tomwalters@0: tomwalters@0: tomwalters@0: tomwalters@0: /* Data arrays: global */ tomwalters@0: /*-------------------------------------------------------------------------*/ tomwalters@0: tomwalters@0: char *data_pointer; tomwalters@0: char *data_pointer_sideways; tomwalters@0: long location[MAX_FRAMES]; /* frames: a reasonably big number */ tomwalters@0: int frame = 1; /* start frame */ tomwalters@0: FILE *inputfp; tomwalters@0: char inputfn[MAX_STRING_LENGTH]; tomwalters@0: tomwalters@0: /* .ctn header */ tomwalters@0: /*-------------------------------------------------------------------------*/ tomwalters@0: tomwalters@0: char header[MAX_LINES_HEADER][MAX_LINE_LENGTH]; tomwalters@0: int header_lines; tomwalters@0: tomwalters@0: int no_frames; tomwalters@0: int frameheight; /* number of channels */ tomwalters@0: int framewidth_samples; /* pwidth + nwidth * samplerate */ tomwalters@0: int frameshift_samples; /* frstep_aid * samplerate */ tomwalters@0: double frstep_aid; /* msecs */ tomwalters@0: double pwidth; /* msecs */ tomwalters@0: double nwidth; /* msecs: NEGATIVE */ tomwalters@0: int width_ctn; /* pixels */ tomwalters@0: int height_ctn; /* pixels */ tomwalters@0: int x_ctn; /* pixels */ tomwalters@0: int y_ctn; /* pixels */ tomwalters@0: long samplerate; /* samples per sec */ tomwalters@0: int mincf; /* Hz */ tomwalters@0: int maxcf; /* Hz */ tomwalters@0: tomwalters@0: tomwalters@0: /* misc */ tomwalters@0: /*-------------------------------------------------------------------------*/ tomwalters@0: tomwalters@0: char progname[MAX_STRING_LENGTH]; tomwalters@0: char fontname[MAX_STRING_LENGTH]; tomwalters@0: char display_name[MAX_STRING_LENGTH]; tomwalters@0: tomwalters@0: int verboseflag = OFF; /* -v option */ tomwalters@0: int axes_xflag = OFF; /* -image_x option */ tomwalters@0: int axes_yflag = OFF; /* -image_y option */ tomwalters@0: int controls_xflag = OFF; /* -controls_x option */ tomwalters@0: int controls_yflag = OFF; /* -controls_y option */ tomwalters@0: int titleflag = OFF; /* -title option */ tomwalters@0: int bytesflag = OFF; /* -lsb, -msb options */ tomwalters@0: int bitmap_pad_flag = OFF; /* ditto */ tomwalters@0: int new_axes_x, new_axes_y; tomwalters@0: int new_control_x, new_control_y; tomwalters@0: int controlwindowflag = OFF; /* -controls option */ tomwalters@0: double scale = 1.0; tomwalters@0: tomwalters@0: long waittime_millisecs = 1; /* time to wait imbetween frames */ tomwalters@0: long waittime_microsecs ; tomwalters@0: tomwalters@0: int animate_start = 1; /* animation start frame */ tomwalters@0: int animate_stop = 9999; /* animation end frame: gets set to EOF */ tomwalters@0: int animate_skip = 1; /* animation skip */ tomwalters@0: tomwalters@0: int sidewaysflag = OFF; tomwalters@0: tomwalters@0: tomwalters@0: tomwalters@0: /* X variables */ tomwalters@0: /*-------------------------------------------------------------------------*/ tomwalters@0: /* There are 3 classes of window: tomwalters@0: * "axes window": where the cartoon itself is. Called "axes" for historical tomwalters@0: * reasons. Button presses cause (1) animations, or (2) mapping tomwalters@0: * of the Controls Window, or (3) exit. This window CANNOT tomwalters@0: * be resized. tomwalters@0: * Used, reasonably interchangealby, with 'image' tomwalters@0: * "controls window": where the Animation Control buttons are. Button presses tomwalters@0: * --- if not on a 'button' --- do nothing. This window tomwalters@0: * can't be resized either. tomwalters@0: * "buttons": there are lots of them. eg button_startf. These are subwindows tomwalters@0: * of the Controls Window. Pressing the left mouse button causes tomwalters@0: * something exciting to happen. tomwalters@0: * There are also 'information buttons', which say things tomwalters@0: * like the filename, number of frames, etc. Pressing one of these tomwalters@0: * doesn't do anything. tomwalters@0: */ tomwalters@0: tomwalters@0: Display *display; tomwalters@0: int screen_num; tomwalters@0: Screen *screen_ptr; tomwalters@0: int depth = 1; tomwalters@0: unsigned int display_width_X, display_height_X; tomwalters@0: unsigned int display_width, display_height; tomwalters@0: tomwalters@0: Pixmap stipple_pixmap; tomwalters@0: tomwalters@0: tomwalters@0: /* Windows */ tomwalters@0: tomwalters@0: toplevelWindow axes; tomwalters@0: toplevelWindow control; tomwalters@0: tomwalters@0: buttonWindow button_quit, button_close; tomwalters@0: buttonWindow button_animate; tomwalters@0: buttonWindow button_startf, button_startb, button_stopf, button_stopb; tomwalters@0: buttonWindow button_skipf, button_skipb, button_faster, button_slower; tomwalters@0: buttonWindow button_firstframe, button_lastframe, button_middle; tomwalters@0: buttonWindow button_stepb, button_stepbb; tomwalters@0: buttonWindow button_stepf, button_stepff; tomwalters@0: buttonWindow info_speed, info_start, info_stop, info_skip; tomwalters@0: buttonWindow info_title, info_frame; tomwalters@0: buttonWindow info_time, info_freq, info_frstep; tomwalters@0: tomwalters@0: XFontStruct *font_info; tomwalters@0: int pointsize = DEFAULT_POINTSIZE; tomwalters@0: GC button_gc; tomwalters@0: int button_borderwidth = 0; tomwalters@0: tomwalters@0: XImage *reviewimage; tomwalters@0: int reviewimage_bytesperline = BYTES_PER_LINE; tomwalters@0: int reviewimage_bitmap_pad = BITMAP_PAD; tomwalters@0: tomwalters@0: Cursor cursor; tomwalters@0: tomwalters@0: XEvent report; tomwalters@0: int depthflag = MONO; /* assume a monochrome screen */ tomwalters@0: int planemask = 0x1; /* works with my colour sparc */ tomwalters@0: int xsyncflag = OFF; tomwalters@0: int reversevideoflag = OFF; /* gets set to ON if DECstation */ tomwalters@0: int byteorderflag = SERVER; /* ie, the physical screen */ tomwalters@0: tomwalters@0: tomwalters@0: tomwalters@0: tomwalters@0: tomwalters@0: /* ...................... Main ..............................*/ tomwalters@0: /* .........................................................................*/ tomwalters@0: /* .........................................................................*/ tomwalters@0: tomwalters@0: tomwalters@0: tomwalters@0: tomwalters@0: void main (int argc, char *argv[]) tomwalters@0: { tomwalters@0: int n; tomwalters@0: int header_bytes = 0; tomwalters@0: int alreadydrawnflag = OFF; tomwalters@0: tomwalters@0: char titlestring[MAX_STRING_LENGTH]; tomwalters@0: char tempstring[MAX_STRING_LENGTH]; tomwalters@0: tomwalters@0: tomwalters@0: int required_bytes; tomwalters@0: long status; tomwalters@0: long starttime, localtime; tomwalters@0: long x; tomwalters@0: tomwalters@0: tomwalters@0: /*-----------------------------*/ tomwalters@0: tomwalters@0: strcpy(progname, argv[0]); tomwalters@0: strcpy(fontname, ""); tomwalters@0: strcpy(inputfn, ""); tomwalters@0: strcpy(titlestring, ""); tomwalters@0: tomwalters@0: /* Machine specific defaults */ tomwalters@0: #ifdef HOST_SPARC tomwalters@0: byteorderflag = SUN; tomwalters@0: reversevideoflag = OFF; tomwalters@0: #endif tomwalters@0: #ifdef HOST_DECSTATION tomwalters@0: byteorderflag = DEC; tomwalters@0: reversevideoflag = ON; tomwalters@0: #endif tomwalters@0: #ifdef HOST_LINUXPC tomwalters@0: byteorderflag = DEC; tomwalters@0: reversevideoflag = ON; tomwalters@0: #endif tomwalters@0: tomwalters@0: parsecommandline(argc, argv, inputfn, titlestring, fontname); tomwalters@0: tomwalters@0: /*-----------------------------*/ tomwalters@0: tomwalters@0: /* Open Display: this also finds the screen size */ tomwalters@0: initialise_X_screen(); tomwalters@0: tomwalters@0: /*-----------------------------*/ tomwalters@0: tomwalters@0: tomwalters@0: if (xsyncflag == ON) { tomwalters@0: XSynchronize(display, True); tomwalters@0: fprintf(stderr, "XSynchronize on \n");} tomwalters@0: tomwalters@0: inputfp = open_file(inputfn, stdin, READ); tomwalters@0: header_bytes = readheader(inputfp, inputfn); tomwalters@0: tomwalters@0: /*-----------------------------*/ tomwalters@0: tomwalters@0: /* define bytes_per_line of the XImage. This seems to be, at least on a tomwalters@0: * Colour SS-10, to be tomwalters@0: * (width-1) tomwalters@0: * ( --------- +1 ) *4 tomwalters@0: * 32 tomwalters@0: * where the INTEGER part of the division is all that is needed. tomwalters@0: * tomwalters@0: * Examples: tomwalters@0: * width=100 to 128 bytes=16 (100 is the smallest AIM window allowed.- tomwalters@0: * 129 -- 160 20 tomwalters@0: * 161 -- 192 24 tomwalters@0: * 193 -- 224 28 tomwalters@0: */ tomwalters@0: tomwalters@0: reviewimage_bytesperline = (int) ((int) ((width_ctn -1) / 32) +1) *4; tomwalters@0: tomwalters@0: /*-----------------------------*/ tomwalters@0: tomwalters@0: /* Allocate lots of space: tomwalters@0: * no of frames by .ctn size tomwalters@0: */ tomwalters@0: tomwalters@0: if (depthflag == MONO) tomwalters@0: depth = 1; tomwalters@0: else tomwalters@0: depth = DefaultDepth(display, screen_num); tomwalters@0: tomwalters@0: required_bytes = no_frames*height_ctn*reviewimage_bytesperline*depth; tomwalters@0: tomwalters@0: if (verboseflag == ON) { tomwalters@0: fprintf(stderr, "xreview : reserving %i * %i * %i = %i bytes.\n", no_frames, (height_ctn*reviewimage_bytesperline), depth, required_bytes); } tomwalters@0: tomwalters@0: data_pointer = (char *) malloc((size_t) required_bytes); tomwalters@0: if (data_pointer == NULL) { tomwalters@0: fprintf(stderr, "xreview : unable to allocate %i bytes for XImage.\n", required_bytes); tomwalters@0: fclose(inputfp); tomwalters@0: exit(-1);} tomwalters@0: tomwalters@0: /* sideways scroll */ tomwalters@0: if (sidewaysflag == ON) { tomwalters@0: required_bytes = no_frames*height_ctn*reviewimage_bytesperline*depth; tomwalters@0: if (verboseflag == ON) { tomwalters@0: fprintf(stderr, "xreview : reserving %i * %i = %i bytes.\n", (no_frames*height_ctn*reviewimage_bytesperline), depth, required_bytes); } tomwalters@0: data_pointer_sideways = (char *) malloc((size_t) required_bytes); tomwalters@0: if (data_pointer_sideways == NULL) { tomwalters@0: fprintf(stderr, "xreview : unable to allocate %i bytes for XImage.\n", required_bytes); tomwalters@0: fclose(inputfp); tomwalters@0: exit(-1);}} tomwalters@0: tomwalters@0: /*-----------------------------*/ tomwalters@0: tomwalters@0: /* load .ctn data */ tomwalters@0: loaddata(inputfp); tomwalters@0: close_files(inputfp); tomwalters@0: if (animate_stop == 9999) tomwalters@0: animate_stop = no_frames; tomwalters@0: tomwalters@0: if (sidewaysflag == ON) { tomwalters@0: for (x=location[0]; x<=location[0]+required_bytes-1; x++) tomwalters@0: data_pointer_sideways[x] = data_pointer[x];} tomwalters@0: tomwalters@0: /*-----------------------------*/ tomwalters@0: tomwalters@0: /* Find a font, in this order: tomwalters@0: * 1. command-line tomwalters@0: * 2. Times family tomwalters@0: * 3. Lucida family. tomwalters@0: * If can't find any, should crash. tomwalters@0: */ tomwalters@0: tomwalters@0: font_info = NULL; tomwalters@0: tomwalters@0: if ((strcmp(fontname, "") == 0 ) || tomwalters@0: ((font_info = XLoadQueryFont(display, fontname)) == NULL)) { tomwalters@0: sprintf(fontname, "-adobe-times-medium-r-normal--%i-*-*-*-*-*-*-*", pointsize); tomwalters@0: if ((font_info = XLoadQueryFont(display, fontname)) == NULL) { tomwalters@0: sprintf(fontname, "-b&h-lucida-medium-r-normal-sans-%i-*-*-*-*-*-*-*", pointsize); tomwalters@0: if ((font_info = XLoadQueryFont(display, fontname)) == NULL) { tomwalters@0: fprintf(stderr, "xreview : unable to find fonts.\n"); tomwalters@0: exit(-1); }}} tomwalters@0: tomwalters@0: /*-----------------------------*/ tomwalters@0: tomwalters@0: /* define a cursor */ tomwalters@0: cursor = XCreateFontCursor(display, XC_top_left_arrow); tomwalters@0: tomwalters@0: /*-----------------------------*/ tomwalters@0: tomwalters@0: initialise_axes_window(inputfn, titlestring, inputfp, argv, argc); tomwalters@0: XMapWindow(display, axes.win); tomwalters@0: tomwalters@0: /* define the background pixmap */ tomwalters@0: stipple_pixmap = XCreatePixmapFromBitmapData(display, \ tomwalters@0: RootWindow(display, screen_num), stipple_a_bits, \ tomwalters@0: stipple_a_width, stipple_a_height, \ tomwalters@0: BlackPixel(display, screen_num), \ tomwalters@0: WhitePixel(display, screen_num), \ tomwalters@0: DefaultDepth(display, screen_num)); tomwalters@0: tomwalters@0: initialise_control_window(inputfn, titlestring, inputfp, argv, argc); tomwalters@0: if (controlwindowflag == ON) tomwalters@0: XMapWindow(display, control.win); tomwalters@0: tomwalters@0: initialise_buttons(); tomwalters@0: tomwalters@0: initialise_image(); tomwalters@0: tomwalters@0: /*------------------------------*/ tomwalters@0: tomwalters@0: tomwalters@0: tomwalters@0: /*----------------------------- tomwalters@0: * EVENT LOOP tomwalters@0: *----------------------------- tomwalters@0: */ tomwalters@0: tomwalters@0: tomwalters@0: tomwalters@0: while (1) { tomwalters@0: XNextEvent(display, &report); tomwalters@0: tomwalters@0: if (report.xany.window == axes.win) tomwalters@0: switch_axes(); tomwalters@0: else if (report.xany.window == control.win) tomwalters@0: switch_control(); tomwalters@0: else tomwalters@0: switch_buttons(); tomwalters@0: tomwalters@0: } /* while */ tomwalters@0: tomwalters@0: tomwalters@0: /*---------------------------------------------------------*/ tomwalters@0: tomwalters@0: tomwalters@0: } /* main */ tomwalters@0: tomwalters@0: tomwalters@0: tomwalters@0: tomwalters@0: tomwalters@0: /*......................................................................*/ tomwalters@0: /*......................................................................*/ tomwalters@0: tomwalters@0: tomwalters@0: tomwalters@0: tomwalters@0: tomwalters@0: void parsecommandline(int argc, char *argv[], char inputfn[], char titlestring[], char fontname[]) tomwalters@0: { tomwalters@0: int x=1, helpflag = OFF; tomwalters@0: int control_width =0; tomwalters@0: char control_size[MAX_STRING_LENGTH]; tomwalters@0: tomwalters@0: strcpy(control_size, ""); tomwalters@0: tomwalters@0: while (x < argc){ tomwalters@0: if (!strcmp(argv[x], "-input")) {strcpy(inputfn, argv[x+1]); x+=2;} tomwalters@0: else if (!strcmp(argv[x], "-inp")) {strcpy(inputfn, argv[x+1]); x+=2;} tomwalters@0: else if (!strcmp(argv[x], "-i")) {strcpy(inputfn, argv[x+1]); x+=2;} tomwalters@0: tomwalters@0: else if (!strcmp(argv[x], "-help")) {helpflag = ON; x+=1;} tomwalters@0: else if (!strcmp(argv[x], "-h")) {helpflag = ON; x+=1;} tomwalters@0: else if (!strcmp(argv[x], "-verbose")) {verboseflag = ON; x+=1;} tomwalters@0: else if (!strcmp(argv[x], "-ver")) {verboseflag = ON; x+=1;} tomwalters@0: else if (!strcmp(argv[x], "-v")) {verboseflag = ON; x+=1;} tomwalters@0: tomwalters@0: else if (!strcmp(argv[x], "-side")) {sidewaysflag = ON; x+=1;} tomwalters@0: else if (!strcmp(argv[x], "-sideways")) {sidewaysflag = ON; x+=1;} tomwalters@0: else if (!strcmp(argv[x], "-controls")) {controlwindowflag = ON; x+=1;} tomwalters@0: else if (!strcmp(argv[x], "-con")) {controlwindowflag = ON; x+=1;} tomwalters@0: else if (!strcmp(argv[x], "-c")) {controlwindowflag = ON; x+=1;} tomwalters@0: else if (!strcmp(argv[x], "-controls_x")) {controls_xflag = ON; new_control_x = atoi(argv[x+1]); x+=2;} tomwalters@0: else if (!strcmp(argv[x], "-cx")) {controls_xflag = ON; new_control_x = atoi(argv[x+1]); x+=2;} tomwalters@0: else if (!strcmp(argv[x], "-controls_y")) {controls_yflag = ON; new_control_y = atoi(argv[x+1]); x+=2;} tomwalters@0: else if (!strcmp(argv[x], "-cy")) {controls_yflag = ON; new_control_y = atoi(argv[x+1]); x+=2;} tomwalters@0: else if (!strcmp(argv[x], "-image_x")) {axes_xflag = ON; new_axes_x = atoi(argv[x+1]); x+=2;} tomwalters@0: else if (!strcmp(argv[x], "-ix")) {axes_xflag = ON; new_axes_x = atoi(argv[x+1]); x+=2;} tomwalters@0: else if (!strcmp(argv[x], "-image_y")) {axes_yflag = ON; new_axes_y = atoi(argv[x+1]); x+=2;} tomwalters@0: else if (!strcmp(argv[x], "-iy")) {axes_yflag = ON; new_axes_y = atoi(argv[x+1]); x+=2;} tomwalters@0: else if (!strcmp(argv[x], "-controls_scale")) {scale = atof(argv[x+1]); x+=2;} tomwalters@0: else if (!strcmp(argv[x], "-cscale")) {scale = atof(argv[x+1]); x+=2;} tomwalters@0: else if (!strcmp(argv[x], "-controls_width")) {control_width = atoi(argv[x+1]); x+=2;} tomwalters@0: else if (!strcmp(argv[x], "-cw")) {control_width = atoi(argv[x+1]); x+=2;} tomwalters@0: else if (!strcmp(argv[x], "-controls_size")) {strcpy(control_size, argv[x+1]); x+=2;} tomwalters@0: else if (!strcmp(argv[x], "-csize")) {strcpy(control_size, argv[x+1]); x+=2;} tomwalters@0: tomwalters@0: else if (!strcmp(argv[x], "-display")) {strcpy(display_name, argv[x+1]); x+=2;} tomwalters@0: else if (!strcmp(argv[x], "-d")) {strcpy(display_name, argv[x+1]); x+=2;} tomwalters@0: else if (!strcmp(argv[x], "-font")) {strcpy(fontname, argv[x+1]); x+=2;} tomwalters@0: else if (!strcmp(argv[x], "-fn")) {strcpy(fontname, argv[x+1]); x+=2;} tomwalters@0: else if (!strcmp(argv[x], "-point")) {pointsize = atoi(argv[x+1]); x+=2;} tomwalters@0: else if (!strcmp(argv[x], "-p")) {pointsize = atoi(argv[x+1]); x+=2;} tomwalters@0: tomwalters@0: else if (!strcmp(argv[x], "-wait")) {waittime_millisecs = atol(argv[x+1]); x+=2;} tomwalters@0: else if (!strcmp(argv[x], "-w")) {waittime_millisecs = atol(argv[x+1]); x+=2;} tomwalters@0: else if (!strcmp(argv[x], "-speed")) {waittime_millisecs = atol(argv[x+1]); x+=2;} tomwalters@0: else if (!strcmp(argv[x], "-start")) {animate_start = atoi(argv[x+1]); x+=2;} tomwalters@0: else if (!strcmp(argv[x], "-stop")) {animate_stop = atoi(argv[x+1]); x+=2;} tomwalters@0: else if (!strcmp(argv[x], "-skip")) {animate_skip = atoi(argv[x+1]); x+=2;} tomwalters@0: else if (!strcmp(argv[x], "-frame")) {frame = atoi(argv[x+1]); x+=2;} tomwalters@0: else if (!strcmp(argv[x], "-fra")) {frame = atoi(argv[x+1]); x+=2;} tomwalters@0: tomwalters@0: else if (!strcmp(argv[x], "-title")) {titleflag = ON; strcpy(titlestring, argv[x+1]); x+=2;} tomwalters@0: else if (!strcmp(argv[x], "-tit")) {titleflag = ON; strcpy(titlestring, argv[x+1]); x+=2;} tomwalters@0: else if (!strcmp(argv[x], "-t")) {titleflag = ON; strcpy(titlestring, argv[x+1]); x+=2;} tomwalters@0: else if (!strcmp(argv[x], "-mono")) {depthflag = MONO; x+=1;} tomwalters@0: else if (!strcmp(argv[x], "-colour")) {depthflag = COLOUR; planemask = AllPlanes; x+=1; } tomwalters@0: else if (!strcmp(argv[x], "-planemask")) {planemask = atoi(argv[x+1]); x+=2;} tomwalters@0: else if (!strcmp(argv[x], "-xsync")) {xsyncflag = ON; x+=1;} tomwalters@0: else if (!strcmp(argv[x], "-rv")) {if (reversevideoflag == ON) tomwalters@0: reversevideoflag = OFF; tomwalters@0: else tomwalters@0: reversevideoflag = ON; tomwalters@0: x+=1;} tomwalters@0: else if (!strcmp(argv[x], "-lsb")) {byteorderflag = DEC; x+=1;} tomwalters@0: else if (!strcmp(argv[x], "-msb")) {byteorderflag = SUN; x+=1;} tomwalters@0: else if (!strcmp(argv[x], "-dec")) {byteorderflag = DEC; reversevideoflag = ON; x+=1;} tomwalters@0: else if (!strcmp(argv[x], "-sun")) {byteorderflag = SUN; reversevideoflag = OFF; x+=1;} tomwalters@0: else if (x = (argc-1)) {strcpy(inputfn, argv[x]); x+=1;} tomwalters@0: tomwalters@0: else {fprintf(stderr, "xreview: unknown option %s\n", argv[x]); tomwalters@0: exit(-1);} tomwalters@0: tomwalters@0: } tomwalters@0: tomwalters@0: if (helpflag == ON) tomwalters@0: { tomwalters@0: fprintf(stderr, "\n"); tomwalters@0: fprintf(stderr, "--------------------------------------------------------------------------------\n"); tomwalters@0: fprintf(stderr, " xreview\n"); tomwalters@0: fprintf(stderr, "--------------------------------------------------------------------------------\n\n"); tomwalters@0: fprintf(stderr, " usage: xreview -input 'filename.ctn' \n"); tomwalters@0: fprintf(stderr, " or xreview 'filename.ctn' \n"); tomwalters@0: fprintf(stderr, " or cat 'filename.ctn' | xreview \n\n\n"); tomwalters@0: fprintf(stderr, " Command line options Abbrev.\n"); tomwalters@0: fprintf(stderr, "--------------------------------------------------------------------------------\n"); tomwalters@0: fprintf(stderr, "-input <.ctn file> Input file (default = stdin). -i\n"); tomwalters@0: fprintf(stderr, "\n"); tomwalters@0: fprintf(stderr, "-controls Map Controls window. -con\n"); tomwalters@0: fprintf(stderr, "-controls_x Controls window position (pixels). -cx\n"); tomwalters@0: fprintf(stderr, "-controls_y Controls window position (pixels). -cy\n"); tomwalters@0: fprintf(stderr, "-controls_width Controls window width (pixels). -cw\n"); tomwalters@0: fprintf(stderr, "-controls_scale Scale factor for size of Controls Window. -cscale\n"); tomwalters@0: fprintf(stderr, "-controls_size Controls Window size: 'tiny', 'small' or 'normal'. -csize\n"); tomwalters@0: fprintf(stderr, "-image_x Image position (pixels). -ix\n"); tomwalters@0: fprintf(stderr, "-image_y Image position (pixels). -iy\n"); tomwalters@0: fprintf(stderr, "\n"); tomwalters@0: fprintf(stderr, "-display X Display server to use. -d\n"); tomwalters@0: fprintf(stderr, "-font Font. -fn\n"); tomwalters@0: fprintf(stderr, "-point Point-size of default font (Times, medium weight). -p\n"); tomwalters@0: fprintf(stderr, "-title Title of Image window & icon. -t\n"); tomwalters@0: fprintf(stderr, "-mono Assume Monochrome (single-plane) cartoons. (default) \n"); tomwalters@0: fprintf(stderr, "-colour Assume Colour (multiplane) cartoons. \n"); tomwalters@0: fprintf(stderr, "-planemask Value of PlaneMask for copying XImage (default=1) \n"); tomwalters@0: fprintf(stderr, "-rv Reverse-video the cartoon window colours. \n"); tomwalters@0: fprintf(stderr, "-lsb Assume cartoon's bit & byte orders are LSBFirst (ie, DEC).\n"); tomwalters@0: fprintf(stderr, "-msb Assume cartoon's bit & byte orders are MSBFirst (ie, Sun).\n"); tomwalters@0: fprintf(stderr, "-dec Alias for -lsb -rv \n"); tomwalters@0: fprintf(stderr, "-sun Alias for -msb \n"); tomwalters@0: fprintf(stderr, "\n"); tomwalters@0: fprintf(stderr, "-speed Wait-time between frames (msecs) (default = %i). -speed\n", waittime_millisecs); tomwalters@0: fprintf(stderr, "-start Animation start (frames) (default=1). -start\n"); tomwalters@0: fprintf(stderr, "-stop Animation stop (frames) (default=last frame). -stop\n"); tomwalters@0: fprintf(stderr, "-skip Animation skip (frames) (default=1). -skip\n"); tomwalters@0: fprintf(stderr, "-frame Initial display frame (default=1). -fra\n"); tomwalters@0: fprintf(stderr, "-sideways Scroll cartoon sideways (right->left) -side\n"); tomwalters@0: fprintf(stderr, "\n"); tomwalters@0: fprintf(stderr, "-verbose Print some running information (to stderr). -v\n"); tomwalters@0: fprintf(stderr, "-help Print this page (to stderr). -h\n"); tomwalters@0: fprintf(stderr, "\n\n" ); tomwalters@0: fprintf(stderr, " Image Window Controls \n"); tomwalters@0: fprintf(stderr, "--------------------------------------------------------------------------------\n"); tomwalters@0: fprintf(stderr, " Left button Animate cartoon. \n"); tomwalters@0: fprintf(stderr, " Middle button Map Controls window. \n"); tomwalters@0: fprintf(stderr, " Right button Quit. \n\n"); tomwalters@0: fprintf(stderr, " SPACE or RET Animate cartoon. \n"); tomwalters@0: fprintf(stderr, " F or f Set speed faster by x2. \n"); tomwalters@0: fprintf(stderr, " S or s Set speed slower by x2. \n"); tomwalters@0: fprintf(stderr, " N or n Next frame. \n"); tomwalters@0: fprintf(stderr, " P or p Previous frame. \n"); tomwalters@0: fprintf(stderr, " Q or q Quit. \n"); tomwalters@0: fprintf(stderr, "\n\n"); tomwalters@0: exit(-1);} tomwalters@0: tomwalters@0: if (strcmp(control_size, "") != 0){ tomwalters@0: if (strcmp(control_size, "normal") == 0) { tomwalters@0: scale=1.00; tomwalters@0: pointsize=18;} tomwalters@0: else if (strcmp(control_size, "small") == 0) { tomwalters@0: scale=0.80; tomwalters@0: pointsize=14;} tomwalters@0: else if (strcmp(control_size, "tiny") == 0) { tomwalters@0: scale=0.60; tomwalters@0: pointsize=10;} tomwalters@0: else { tomwalters@0: fprintf(stderr, "xreview : illegal control_size value.\n"); tomwalters@0: exit(-1);} tomwalters@0: } tomwalters@0: tomwalters@0: if (control_width != 0) tomwalters@0: scale = (double) control_width / CONTROL_WIDTH; tomwalters@0: tomwalters@0: tomwalters@0: } tomwalters@0: tomwalters@0: tomwalters@0: /* The end.*/ tomwalters@0: tomwalters@0: tomwalters@0: /*-------------------------------------------------------------------------*/ tomwalters@0: /*-------------------------------------------------------------------------*/ tomwalters@0: tomwalters@0: tomwalters@0: tomwalters@0: tomwalters@0: tomwalters@0: