#include "global.h" #ifdef __MWERKS__ pascal void MyItemProc(WindowPtr theDlg, short theItem) { Rect iRect; Handle iHndl; short iType; GetDItem(theDlg, 1, &iType, (Handle *)&iHndl, &iRect); /* item #1 */ PenSize(3,3); InsetRect(&iRect, -4, -4); FrameRoundRect(&iRect,16,16); } void CenterDialog ( short theID ); check_for_options() { EventRecord theEvent; short itemHit; DialogPtr myDlg; ControlHandle iHndl; Rect iRect; short iType; GetNextEvent(everyEvent, &theEvent); if (theEvent.modifiers & optionKey) { CenterDialog(128); myDlg = GetNewDialog(128,0,(WindowPtr) -1); GetDItem(myDlg,7,&iType, (Handle *)&iHndl, &iRect); SetDItem(myDlg,7,iType,(Handle)MyItemProc,&iRect); ShowWindow(myDlg); do { ModalDialog(0, &itemHit); switch (itemHit){ case 1: break; case 2: { GetDItem(myDlg,2,&iType,(Handle *)&iHndl,&iRect); tex_flag = !tex_flag; SetCtlValue(iHndl,!tex_flag); break;} case 3: { GetDItem(myDlg,3,&iType,(Handle *)&iHndl,&iRect); output_flag = !output_flag; SetCtlValue(iHndl,!output_flag); break;} case 4: { GetDItem(myDlg,4,&iType,(Handle *)&iHndl,&iRect); compare_flag = !compare_flag; SetCtlValue(iHndl,!compare_flag); break;} case 5: { GetDItem(myDlg,5,&iType,(Handle *)&iHndl,&iRect); verbose_flag = !verbose_flag; SetCtlValue(iHndl,verbose_flag); break;} case 6: { GetDItem(myDlg,6,&iType,(Handle *)&iHndl,&iRect); number_flag = !number_flag; SetCtlValue(iHndl,number_flag); break;} } } while (itemHit != ok); DisposDialog(myDlg); } } void process_file(char *filename) { char source_name[256]; char tex_name[256]; char aux_name[256]; char *p = filename; char *q = source_name; char *trim = q; char *dot = NULL; char c; command_name = "nuweb"; c = *p++; while (c) { *q++ = c; if (c == '.') dot = q - 1; c = *p++; } *q = '\0'; if (dot) { *dot = '\0'; sprintf(tex_name, "%s.tex", trim); sprintf(aux_name, "%s.aux", trim); *dot = '.'; } else { sprintf(tex_name, "%s.tex", trim); sprintf(aux_name, "%s.aux", trim); *q++ = '.'; *q++ = 'w'; *q = '\0'; } { pass1(source_name); if (tex_flag) { collect_numbers(aux_name); write_tex(source_name, tex_name); } if (output_flag) write_files(file_names); arena_free(); } } int error(FILE *stream, const char *format, ...) { Str255 msg; int i = 0; va_list args; va_start(args, format); vsprintf((char *)msg, format, args); while (msg[i]) { if (msg[i] == '\n') msg[i] = '\r'; i++; } c2pstr((char *)msg); ParamText ( msg, NULL, NULL, NULL ); CenterAlert ( kAlertID ); va_end(args); } #else void main(argc, argv) int argc; char **argv; { int arg = 1; command_name = argv[0]; while (arg < argc) { char *s = argv[arg]; if (*s++ == '-') { { char c = *s++; while (c) { switch (c) { case 'c': compare_flag = FALSE; break; case 'n': number_flag = TRUE; break; case 'o': output_flag = FALSE; break; case 't': tex_flag = FALSE; break; case 'v': verbose_flag = TRUE; break; default: error(stderr, "%s: unexpected argument ignored. " "Usage is: %s [-cnotv] file...\n", command_name, command_name); break; } c = *s++; } } arg++; } else break; } { if (arg >= argc) { error( stderr, "%s: expected a file name. " "Usage is: %s [-cnotv] file-name...\n", command_name, command_name); exit(-1); } do { { char source_name[256]; char tex_name[256]; char aux_name[256]; { char *p = argv[arg]; char *q = source_name; char *trim = q; char *dot = NULL; char c = *p++; while (c) { *q++ = c; if (c == '/') { trim = q; dot = NULL; } else if (c == '.') dot = q - 1; c = *p++; } *q = '\0'; if (dot) { *dot = '\0'; sprintf(tex_name, "%s.tex", trim); sprintf(aux_name, "%s.aux", trim); *dot = '.'; } else { sprintf(tex_name, "%s.tex", trim); sprintf(aux_name, "%s.aux", trim); *q++ = '.'; *q++ = 'w'; *q = '\0'; } } { pass1(source_name); if (tex_flag) { collect_numbers(aux_name); write_tex(source_name, tex_name); } if (output_flag) write_files(file_names); arena_free(); } } arg++; } while (arg < argc); } exit(0); } #endif