/*---------------------------------------------------------* | Author: Maurizio Loreti, aka MLO or I3NOO. | | Address: University of Padova - Department of Physics | | Via F. Marzolo, 8 - 35131 PADOVA - Italy | | Phone: (39)(49) 844-313 FAX: (39)(49) 844-245 | | E-Mail: LORETI at IPDINFN (BITNET); or VAXFPD::LORETI | | (DECnet) - VAXFPD is node 38.257 i.e. 39169; or | | LORETI@PADOVA.INFN.IT (INTERNET). | | Home: Via G. Donizetti 6 - 35010 CADONEGHE (PD) - Italy | *---------------------------------------------------------*/ /*--------------------------------* | PF.c - Short for PRINTFILES.c | | See the Read.Me file for help. | *--------------------------------*/ #include /* Standard library */ #include #include /* Amiga specific */ #include #include #include #if defined(ASL) | defined(BOTH) #include #endif #include #include #include #if defined(ASL) | defined(BOTH) #include #endif #if defined(REQ) | defined(BOTH) #include #endif #include "mlo.h" /* This program's stuff */ #include "pf2.h" #include "global.h" #include "asl_fr.h" static char Version_Tag[] = "\0$VER: PF2 v" VERSION " - MLO " LAST_CHANGE; void main( int argc, char **argv ){ /** | Main program: look if we were started from CLI or Workbench; | then process printer parameters; last, print selected files. | The file requester is either the req.library file requester or | the asl.library file requester; the latter is used if running | under Kickstart 2.04, the former otherwise (check done in SetupWB()). **/ int i; Boolean select = False; /* 'Some file selected' flag */ if (argc) { IntuitionBase = LibOpen("intuition.library", REVISION, LO_ABORT | LO_MESSAGE); FromCLI = True; argv = Setup(&argc, argv); } else { FromCLI = False; SetupWB(); /** | Setup the asl.library or the req.library file requester | (only if called from the Workbench, of course) **/ #ifdef ASL if ((pFR = AllocAslRequest(ASL_FileRequest, FilReqTags)) == NULL) { fprintf(stderr, "Can't obtain a File Requester ...\n"); Cleanup(SYS_ABORT_CODE); } #endif #ifdef REQ fr.Title = fr_Title; fr.Dir = dirName; fr.File = fileName; fr.Flags = FRQSHOWINFOM | FRQCACHINGM | FRQINFOGADGETM | FRQEXTSELECTM | FRQSAVINGM; fr.MaxExtendedSelect = MAX_FILES; fr.dirnamescolor = fr.devicenamescolor = RED_PEN; fr.stringnamecolor = fr.stringgadgetcolor = BLACK_PEN; fr.boxbordercolor = fr.gadgetboxcolor = BLACK_PEN; #endif #ifdef BOTH if (AslBase != NULL) { if ((pFR = AllocAslRequest(ASL_FileRequest, FilReqTags)) == NULL) { fprintf(stderr, "Can't obtain a File Requester ...\n"); Cleanup(SYS_ABORT_CODE); } } else { fr.Title = fr_Title; fr.Dir = dirName; fr.File = fileName; fr.Flags = FRQSHOWINFOM | FRQCACHINGM | FRQINFOGADGETM | FRQEXTSELECTM | FRQSAVINGM; fr.MaxExtendedSelect = MAX_FILES; fr.dirnamescolor = fr.devicenamescolor = RED_PEN; fr.stringnamecolor = fr.stringgadgetcolor = BLACK_PEN; fr.boxbordercolor = fr.gadgetboxcolor = BLACK_PEN; } #endif } InitPrinter(); bufferLength -= nBlanks; if (FromCLI) { for (; argc--; argv++) { DoOutput(*argv); } } else { FOREVER { #ifdef ASL if (AslRequest(pFR, FilReqTags1)) { select = True; strcpy(target, pFR->rf_Dir); if ((i = strlen(target)) && target[i-1] != ':') { target[i++] = '/'; } if (!pFR->rf_NumArgs) { strcpy(target+i, pFR->rf_File); DoOutput(target); } else { int n; struct WBArg *arg = pFR->rf_ArgList; for (n=0; nrf_NumArgs; n++) { strcpy(target+i, arg[n].wa_Name); DoOutput(target); } } } else { break; } #endif #ifdef REQ fileName[0] = NIHIL; if (FileRequester(&fr)) { select = True; strcpy(target, dirName); if ((i = strlen(target)) && target[i-1] != ':') { target[i++] = '/'; } if ((pESS = fr.ExtendedSelect) == NULL) { strcpy(target+i, fileName); DoOutput(target); } else { do { strcpy(target+i, pESS->thefilename); DoOutput(target); } while ( (pESS = pESS->NextFile) != NULL); } } else { break; } #endif #ifdef BOTH if (AslBase != NULL) { if (AslRequest(pFR, FilReqTags1)) { select = True; strcpy(target, pFR->rf_Dir); if ((i = strlen(target)) && target[i-1] != ':') { target[i++] = '/'; } if (!pFR->rf_NumArgs) { strcpy(target+i, pFR->rf_File); DoOutput(target); } else { int n; struct WBArg *arg = pFR->rf_ArgList; for (n=0; nrf_NumArgs; n++) { strcpy(target+i, arg[n].wa_Name); DoOutput(target); } } } else { break; } } else { fileName[0] = NIHIL; if (FileRequester(&fr)) { select = True; strcpy(target, dirName); if ((i = strlen(target)) && target[i-1] != ':') { target[i++] = '/'; } if ((pESS = fr.ExtendedSelect) == NULL) { strcpy(target+i, fileName); DoOutput(target); } else { do { strcpy(target+i, pESS->thefilename); DoOutput(target); } while ( (pESS = pESS->NextFile) != NULL); } } else { break; } } #endif } if (!select) { puts("Printer initialised ... Good bye!"); Cleanup(SYS_NORMAL_CODE); } } FlushBuffers(); ExitProgram(); }