#include #include #include #include #ifndef DEBUG #include #endif #define HUNK_UNIT 0xe7 #define HUNK_HEADER 0xf3 #define KNOWN_FILE_TYPES 6 #define INVALID_FILE -2 #define UNKNOWN_FILE -1 #define EXECUTABLE_FILE 0 #define OBJECT_FILE 1 #define ASCII_FILE 2 #define IFF_ILBM_FILE 3 #define IFF_8SVX_FILE 4 #define IFF_ANIM_FILE 5 BOOL use_quotes = TRUE, use_prompt = TRUE; UBYTE Type[KNOWN_FILE_TYPES][25] = { "executable", "object module", "ascii text", "IFF picture (ILBM)", "IFF sound (8SVX)", "IFF animation (ANIM)", }; UBYTE Viewer[KNOWN_FILE_TYPES][21] = { /*--- Max len 20 ---*/ "", "DISABLED", "etc:less", "etc:show", "etc:play", "etc:movie" }; UBYTE ToolType[KNOWN_FILE_TYPES][8] = { "", "OBJECT", "TEXT", "PICTURE", "SOUND", "ANIM" }; VOID Help() { printf("Usage: smallbench [?] [ [-h|p|q] [-r|o|t|i|s|a |DISABLED] ... ]\n"); printf(" -h : printf this reminder\n"); printf(" -p : disable file type verification, default on\n"); printf(" -q : disable quotes around filename, default on\n"); printf(" -t : text file viewer, default etc:less\n"); printf(" -o : object file application, default DISABLED\n"); printf(" -i : IFF ILBM viewer, default etc:show\n"); printf(" -s : IFF 8SVX player, default etc:play\n"); printf(" -a : IFF ANIM player, default etc:movie\n"); printf(" Using DISABLED instead of disables action.\n"); printf("Version 1.1, written by Gauthier Groult, 89.1020\n"); } BYTE ParseCLIArgs(argc, argv) UBYTE argc, **argv; { UBYTE arg = 1, viewer; while (argsm_ArgList; diskobj=(struct DiskObject *)GetDiskObject(wbArg->wa_Name); if(diskobj) { toolarray = (char **)diskobj->do_ToolTypes; for(i=1; i0x7E && buffer[i]<0xA0) flag = 0; if (flag) rc = ASCII_FILE; else rc = UNKNOWN_FILE; } Close(filep); SetPointerNum(window, WBENCH_POINTER); return(rc); } BOOL TypePrompt(window, filename, type) struct Window *window; UBYTE *filename, type; { if (AutoSmartRequest(window, 3, BaseName(filename), "supposed type is:", Type[type], 0, "Ok", "Cancel", NULL, NULL) ) return(TRUE); return(FALSE); } VOID DisplayFile(window, filename, type) struct Window *window; UBYTE *filename, type; { UBYTE command[80]; struct FileHandle *nil = (struct FileHandle *)Open("NIL:", MODE_NEWFILE); /* always succesfull */ if (use_prompt && !(TypePrompt(window, filename, type))) return; if (StrCmp(Viewer[type], "DISABLED")) { StrCpy(command, "c:run >NIL: NIL: