int main (int argc, char *argv[]) { int rc; /* R�ckgabewert */ initialize (); /* Initialisierung */ rc = ArgStandard (argc, /* CLI-Parameter parsen */ argv, TabArguments, &Options.fsHelp); if (rc != NO_ERROR) { ToolsErrorDos(rc); /* print error message */ exit(1); /* abort program */ } if ( Options.fsHelp ) /* help requested ? */ { help(); ArgHelp(TabArguments); return (NO_ERROR); } rc = ProfileTest(); /* Los geht's */ if (rc != NO_ERROR) ToolsErrorDos(rc); return (rc); }
int main (int argc, char *argv[]) { int rc; /* R�ckgabewert */ initialize (); /* Initialisierung */ rc = ArgStandard (argc, /* CLI-Parameter parsen */ argv, TabArguments, &Options.fsHelp); if (rc != NO_ERROR) { ToolsErrorDos(rc); /* print error message */ exit(1); /* abort program */ } if (Options.fsHelp) /* check if help is to be displayed */ { help(); ArgHelp(TabArguments); return (NO_ERROR); } rc = TestMemory(); /* Perform the memory tests */ if (rc != NO_ERROR) ToolsErrorDos(rc); return (rc); }
int main (int argc, char *argv[]) { int rc; /* R�ckgabewert */ rc = initialize (); /* Initialisierung */ if (rc != NO_ERROR) { ToolsErrorDos(rc); /* print error message */ exit(1); /* abort program */ } rc = ArgStandard (argc, /* CLI-Parameter parsen */ argv, TabArguments, &Options.fsHelp); if (rc != NO_ERROR) { ToolsErrorDos(rc); /* print error message */ exit(1); /* abort program */ } if ( Options.fsHelp ) /* user requests help */ { help(); ArgHelp(TabArguments); return (NO_ERROR); } rc = UserDel(); /* this is our main routine */ if (rc != NO_ERROR) ToolsErrorDos(rc); return (rc); }
VOID ArgsHelp( IN OUT PARG_BASE *Options, IN int count) { int i; for (i = 0; i < count; i++) { ArgHelp(Options[i]); } }
int main (int argc, char *argv[]) { int rc; /* R�ckgabewert */ initialize (); /* Initialisierung */ rc = ArgStandard(argc, /* parse command line parameters */ argv, TabArguments, &Options.fsHelp); if ( Options.fsHelp ) /* check if user specified file */ { help(); ArgHelp(TabArguments); return (NO_ERROR); } rc = KbdProcess(); /* do the work */ if (rc != NO_ERROR) ToolsErrorDos(rc); return (rc); }
int main (int argc, char *argv[]) { int rc; /* R�ckgabewert */ int iAnswer; /* answer from the user on the security confirmation prompt */ PERFSTRUCT psStart; /* structure for the performance counters */ PERFSTRUCT psEnd; float fSeconds; /* total duration of the process */ initialize (); /* Initialisierung */ rc = ArgStandard (argc, /* CLI-Parameter parsen */ argv, TabArguments, &Options.fsHelp); if (rc != NO_ERROR) { ToolsErrorDos(rc); /* print error message */ exit(1); /* abort program */ } if ( Options.fsHelp ) /* check if user specified file */ { help(); ArgHelp(TabArguments); return (NO_ERROR); } /* build up a root path */ if (Options.fsPath) strcpy (Globals.szRootPath, /* copy the user supplied path */ Options.pszPath); else { fprintf (stderr, "\nError: you must supply a directory path."); return (ERROR_PATH_NOT_FOUND); /* abort program */ } if (!Options.fsScanSingle) /* determine find scan number */ { Globals.ulFindNumberMaximum = 65535 / sizeof(FILEFINDBUF3); Globals.ulFileFindBufferSize = 65535; /* 64k, best performance */ } else { Globals.ulFindNumberMaximum = 1; /* for windows 95 ... uarg ! */ Globals.ulFileFindBufferSize = 1024; /* 1k, sufficient */ } if (Options.fsFileAge) /* check for extended delete functionality */ { DATETIME dtDateTime; /* structure to hold current date and time */ DosGetDateTime(&dtDateTime); /* query system time */ Globals.ulFileDate = ToolsDateToAge(dtDateTime.day, /* transform it */ dtDateTime.month, dtDateTime.year) - Options.ulFileAge; } Globals.ulFileMask = FILE_NORMAL | FILE_SYSTEM | FILE_READONLY | FILE_HIDDEN | FILE_DIRECTORY; rc = ProcessRootPath(Globals.szRootPath); /* get qualified root path */ if (rc != NO_ERROR) { ToolsErrorDos(rc); /* abort processing here, don't accidentually go to wrong path */ return (rc); } if (!Options.fsFileNameMask) printf ("\nDeleting [%s]", Globals.szRootPath); else printf ("\nDeleting [%s\\%s]", Globals.szRootPath, Options.pszFileNameMask); if (!Options.fsConfirmationSkip) /* skip initial confirmation ? */ { iAnswer = ToolsConfirmationQuery(); /* ask the user */ switch (iAnswer) { case 0: /* no */ return (NO_ERROR); /* abort processing */ case 1: /* yes */ break; /* continue ... */ case 2: /* escape */ exit (1); /* PH: urgs, terminate the process */ } } /* now perform a little bit parameter mapping */ if (Options.fsFileNameMask) /* if the user supplied special file name mask */ { Options.fsDontDeleteDirs = TRUE; /* makes no sense */ Options.fsDontDeleteRoot = TRUE; /* makes no sense */ Options.fsShowFiles = TRUE; /* display the filenames */ } ToolsPerfQuery(&psStart); /* start the performance counter */ rc=ProcessScan (Globals.szRootPath); /* do it ... */ if (rc != NO_ERROR) ToolsErrorDos(rc); else { if (!Options.fsDontDeleteRoot && /* if we have to delete the root dir */ !Options.fsDontDeleteDirs) { rc=DeleteDir(Globals.szRootPath); /* now remove root path */ if (rc != NO_ERROR) ToolsErrorDos(rc); } } ToolsPerfQuery(&psEnd); /* stop the performance counter */ /* now print the statistics */ fSeconds = psEnd.fSeconds - psStart.fSeconds; /* calculate duration */ if (Options.fsStatistics) /* if we have to print statistics */ if (fSeconds != 0.0) /* avoid division by zero */ { CHAR szValueBytes[20]; /* local string buffers */ CHAR szValueAlloc[20]; StrValueToSize(szValueBytes, Globals.ulDeletedBytes); StrValueToSize(szValueAlloc, Globals.ulDeletedAlloc); printf ("\nTime needed : %10.3f seconds" "\nDeleted bytes : %-10s" "\nFreed bytes : %-10s (allocation)" "\nFiles scanned : %10u (%10.3f files per sec)" "\nFiles deleted : %10u (%10.3f files per sec)" "\nDirectories scanned: %10u (%10.3f files per sec)" "\nDirectories removed: %10u (%10.3f files per sec)", fSeconds, szValueBytes, szValueAlloc, Globals.ulFilesScanned, Globals.ulFilesScanned / fSeconds, Globals.ulFilesDeleted, Globals.ulFilesDeleted / fSeconds, Globals.ulDirectoriesScanned, Globals.ulDirectoriesScanned / fSeconds, Globals.ulDirectoriesDeleted, Globals.ulDirectoriesDeleted / fSeconds); } return (rc); }
int main (int argc, PSZ argv[]) { PERFSTRUCT TS_Start; /* time information about start */ PERFSTRUCT TS_End; /* time information about finish */ float seconds; /* elapsed seconds */ ANALYSE total; APIRET rc; /* API-Returncode */ ULONG ulCounter; /* loop counter */ DATETIME dtDateTime; /* structure to hold current date and time */ /**************************************************************************** * Initialize Globals * ****************************************************************************/ memset (&total, /* reset variable structure */ 0, sizeof(ANALYSE)); memset (&Globals, /* reset variable structure */ 0, sizeof(GLOBALS)); Globals.ulFileMask = FILE_NORMAL | FILE_DIRECTORY | FILE_SYSTEM | FILE_READONLY | FILE_HIDDEN; Globals.fTotalAgeCreation = 0.0; Globals.fTotalAgeLastWrite = 0.0; Globals.fTotalAgeLastAccess = 0.0; Globals.fTotalAgeCurrent = DosGetDateTime(&dtDateTime); /* query system time */ Globals.fTotalAgeCurrent = ToolsDateToAge(dtDateTime.day, /* transform it */ dtDateTime.month, dtDateTime.year); Globals.fTotalCompression = 0.0; Options.ulRecursionDepthMaximum = -1; /* maximum */ /*************************************************************************** * Parse arguments * ***************************************************************************/ rc = ArgStandard (argc, /* CLI-Parameter parsen */ argv, TabArguments, &Options.fsHelp); if (rc != NO_ERROR) { ToolsErrorDos(rc); /* print error message */ exit(1); /* abort program */ } if (Options.fsHelp) /* check if user specified help */ { help(); ArgHelp(TabArguments); return (NO_ERROR); } /*************************************************************************** * Map arguments * ***************************************************************************/ if (!Options.fsPath) /* user specified no path, take current */ strcpy (Globals.DUPathStr,"."); /* current, default */ else strcpy (Globals.DUPathStr,Options.pszPath); /* user path */ if (!Options.fsFind) /* user did not specify maximum find number */ Options.ulFindNumberMaximum = 65535 / sizeof(FILEFINDBUF3); else Options.ulFindNumberMaximum = 1; /* for some Windows 95 requester */ /* OS/2 2.x, 3.x provide by far best performance when avoiding 64k switches */ Globals.ulFileFindBufferSize = sizeof(FILEFINDBUF3) * /* our target struct */ Options.ulFindNumberMaximum; if (!Options.fsSpeedNr) /* if user only wants to scan once */ Options.ulSpeedNr = 1; /* this is the default */ if (Options.fsFiles2) /* whenever user wants more file information, */ Options.fsFiles = TRUE; /* also map the basic level */ /**************************************************************************** * Processing ... * ****************************************************************************/ ProcessRootPath(Globals.DUPathStr); /* get fully qualified path name */ printf ("\nScanning [%s]", Globals.DUPathStr); if (Options.fsSpeed) /* measure scanning speed */ { printf (" (measuring scanning speed %ux)", Options.ulSpeedNr); ToolsPerfQuery (&TS_Start); /* exact time measurement */ for (ulCounter = 1; ulCounter <= Options.ulSpeedNr; ulCounter++) ProcessScanSpeed (Globals.DUPathStr); ToolsPerfQuery (&TS_End); /* exact time measurement */ seconds = TS_End.fSeconds - TS_Start.fSeconds; /* calculate duration */ } else { if (Options.fsIterate) /* iteration mode ? */ printf (" (iterative)"); ToolsPerfQuery (&TS_Start); /* exact time measurement */ /* ... attributes ... */ rc = ProcessScan (Globals.DUPathStr, &total); if (rc != NO_ERROR) /* check for errors */ ToolsErrorDosEx(rc, /* and the operating system error message */ Globals.DUPathStr); ToolsPerfQuery (&TS_End); /* exact time measurement */ seconds = TS_End.fSeconds - TS_Start.fSeconds; /* calculate duration */ StrValueToSizeFloat (Globals.szBuf_1, total.llBytesSize); StrValueToSizeFloat (Globals.szBuf_2, total.llBytesAllocated); printf ("\nTotal : [%7.0f files, %s filesize, %s allocated]", total.llFiles, Globals.szBuf_1, Globals.szBuf_2); if (Options.fsAttributes) /* Attribute anzeigen ? */ { printf ("\nStatistics" "\n� Attributes"); if (Globals.attrNormal) printf ("\n � Files without attributes: [%8u]", Globals.attrNormal); if (Globals.attrArchived) printf ("\n � Files archived: [%8u]", Globals.attrArchived); if (Globals.attrReadonly) printf ("\n � Files read-only: [%8u]", Globals.attrReadonly); if (Globals.attrHidden) printf ("\n � Files hidden: [%8u]", Globals.attrHidden); if (Globals.attrSystem) printf ("\n � Files system: [%8u]", Globals.attrSystem); if (Globals.attrCompressed) printf ("\n � Files compressed: [%8u]", Globals.attrCompressed); if (Globals.attrDirectory) { printf ("\n � Directories: [%8u]" "\n � '.' and '..' included: [%8u]" "\n � remaining rest: [%8u]", Globals.attrDirectory, Globals.attrDirpseudo, Globals.attrDirectory - Globals.attrDirpseudo); } if (Globals.attrUndefined) printf ("\n � WARNING: files with undefined attributes: [%8u]", Globals.attrUndefined); /*********************************************************************** * Averages * ***********************************************************************/ if (total.llFiles != 0) { printf ("\n� Averages" "\n � File Ages and Dates" "\n � Average file creation %6.1f days ago" "\n � Average last file access %6.1f days ago" "\n � Average last file modification %6.1f days ago", -Globals.fTotalAgeCreation / (float)total.llFiles, -Globals.fTotalAgeLastAccess / (float)total.llFiles, -Globals.fTotalAgeLastWrite / (float)total.llFiles); printf ("\n � File Size and Allocation" "\n � Average file size %10.0fb" "\n � Average allocation size %10.0fb" "\n � Average slack space %10.0fb", (float)total.llBytesSize / (float)total.llFiles, (float)total.llBytesAllocated / (float)total.llFiles, ( (float)total.llBytesAllocated - (float)total.llBytesSize) / (float)total.llFiles); if (Globals.attrCompressed != 0) printf ("\n � Compression" "\n � Average file compression (compressed only) 1:%2.2f" "\n � Average file compression (total) 1:%2.2f", Globals.fTotalCompression / (float)Globals.attrCompressed, Globals.fTotalCompression / (float)total.llFiles); } /*********************************************************************** * Superlatives, Records, Minima and Maxima * ***********************************************************************/ printf ("\n� Superlatives"); /*************** * Compression * ***************/ if (Globals.bMaximumCompression || Globals.bMinimumCompression) printf ("\n � Compression"); if (Globals.bMaximumCompression) printf ("\n � Maximum Ratio 1:%2.2f %s", Globals.fMaximumCompression, Globals.pszMaximumCompression); if (Globals.bMinimumCompression) printf ("\n � Minimum Ratio 1:%2.2f %s", Globals.fMinimumCompression, Globals.pszMinimumCompression); /***************************** * Files size and allocation * *****************************/ printf ("\n � File Size and Allocation"); if (Globals.bMaximumFileSize) printf ("\n � Maximum File Size %9ub %s", Globals.ulMaximumFileSize, Globals.pszMaximumFileSize); if (Globals.bMaximumAllocationSize) printf ("\n � Maximum Allocation Size %9ub %s", Globals.ulMaximumAllocationSize, Globals.pszMaximumAllocationSize); if (Globals.bMaximumSlackSpace) printf ("\n � Maximum Slack Space %9ib %s", Globals.iMaximumSlackSpace, Globals.pszMaximumSlackSpace); if (Globals.bMinimumFileSize) printf ("\n � Minimum File Size %9ub %s", Globals.ulMinimumFileSize, Globals.pszMinimumFileSize); if (Globals.bMinimumAllocationSize) printf ("\n � Minimum Allocation Size %9ub %s", Globals.ulMinimumAllocationSize, Globals.pszMinimumAllocationSize); if (Globals.bMaximumSlackSpace) printf ("\n � Minimum Slack Space %9ib %s", Globals.iMinimumSlackSpace, Globals.pszMinimumSlackSpace); /************************ * Files ages and dates * ************************/ printf ("\n � File Ages and Dates"); if (Globals.bMaximumCreation) { StrFDateTimeToString(Globals.fdateMaximumCreation, /* map the date */ Globals.ftimeMaximumCreation, Globals.szFileDate); printf ("\n � Most recently created %s %s", Globals.szFileDate, Globals.pszMaximumCreation); } if (Globals.bMaximumLastAccess) { StrFDateTimeToString(Globals.fdateMaximumLastAccess, /* map the date */ Globals.ftimeMaximumLastAccess, Globals.szFileDate); printf ("\n � Most recently accessed %s %s", Globals.szFileDate, Globals.pszMaximumLastAccess); } if (Globals.bMaximumLastWrite) { StrFDateTimeToString(Globals.fdateMaximumLastWrite, /* map the date */ Globals.ftimeMaximumLastWrite, Globals.szFileDate); printf ("\n � Most recently modified %s %s", Globals.szFileDate, Globals.pszMaximumLastWrite); } if (Globals.bMinimumCreation) { StrFDateTimeToString(Globals.fdateMinimumCreation, /* map the date */ Globals.ftimeMinimumCreation, Globals.szFileDate); printf ("\n � Least recently created %s %s", Globals.szFileDate, Globals.pszMinimumCreation); } if (Globals.bMinimumLastAccess) { StrFDateTimeToString(Globals.fdateMinimumLastAccess, /* map the date */ Globals.ftimeMinimumLastAccess, Globals.szFileDate); printf ("\n � Least recently accessed %s %s", Globals.szFileDate, Globals.pszMinimumLastAccess); } if (Globals.bMinimumLastWrite) { StrFDateTimeToString(Globals.fdateMinimumLastWrite, /* map the date */ Globals.ftimeMinimumLastWrite, Globals.szFileDate); printf ("\n � Least recently modified %s %s", Globals.szFileDate, Globals.pszMinimumLastWrite); } } } if (seconds) printf ("\n[%8u] files, [%9.4f] sec, [%9.3f] files/sec\n", Globals.ulFilesScanned, seconds, ((float)Globals.ulFilesScanned / seconds)); return NO_ERROR; }
int main (int argc, char *argv[]) { APIRET rc = NO_ERROR; /* R�ckgabewert der Funktionen */ PERFSTRUCT tsStart; PERFSTRUCT tsEnd; float dSeconds; memset (&Options,0,sizeof(Options)); /* Initialisierung */ memset (&Globals,0,sizeof(Globals)); /* Initialisierung */ Globals.piobufInput = malloc(IOBUFFERSIZE); /* allocate I/O buffer */ if (Globals.piobufInput == NULL) /* check allocation */ return (ERROR_NOT_ENOUGH_MEMORY); Globals.piobufOutput = malloc(IOBUFFERSIZE); /* allocate I/O buffer */ if (Globals.piobufOutput == NULL) /* check allocation */ return (ERROR_NOT_ENOUGH_MEMORY); rc = ArgStandard (argc, /* CLI-Parameter parsen */ argv, TabArguments, &Options.fHelp); if (rc != NO_ERROR) { ToolsErrorDos(rc); /* print error message */ exit(1); /* abort program */ } if (Options.fHelp) /* check if user specified help */ { help(); ArgHelp(TabArguments); return (NO_ERROR); } rc = RulesRead(Options.pszFileRules, &Globals.pReplacementRoot); /* scan the rules */ if (rc == NO_ERROR) /* check if anything is OK */ { if (Options.fQuiet != TRUE) /* check if output is OK ? */ printf ("\n%u rules apply.", /* print message about rules that apply */ Globals.ulRules); /* preload header and footer files if necessary */ if (Options.fFileHeader == TRUE) { /* memory map the header */ rc = ToolsReadFileToBuffer (Options.pszFileHeader, &Globals.pBufferHeader, &Globals.ulHeaderSize); if (rc != NO_ERROR) /* check for errors */ ToolsErrorDos(rc); /* display error message */ } if (Options.fFileFooter == TRUE) { /* memory map the header */ rc = ToolsReadFileToBuffer (Options.pszFileFooter, &Globals.pBufferFooter, &Globals.ulFooterSize); if (rc != NO_ERROR) /* check for errors */ ToolsErrorDos(rc); /* display error message */ } if (!Options.fFileOutput) { // if nothing else is specified, write output back to the input file Options.pszFileOutput = Options.pszFileInput; Options.fFileOutput = TRUE; } /* now process the files (wildcards shall apply) */ ToolsPerfQuery(&tsStart); /* measure starting time */ rc = ProcessFiles (); /* process the files */ ToolsPerfQuery(&tsEnd); /* measure ending time */ if (rc != NO_ERROR) /* check for errors */ ToolsErrorDos(rc); /* display error message */ dSeconds = tsEnd.fSeconds - tsStart.fSeconds; /* calculate duration */ if (dSeconds == 0.0) /* prevent divison by zero */ dSeconds = 0.001; /* assume this minimum value */ /* @@@PH */ if (Options.fQuiet != TRUE) /* check if output is OK ? */ printf ("\n%10u files processed. (%12.3f per second)" "\n%10u lines processed. (%12.3f per second)" "\n%10u bytes processed. (%12.3f per second)", Globals.ulProcessedFiles, Globals.ulProcessedFiles / dSeconds, Globals.ulProcessedLines, Globals.ulProcessedLines / dSeconds, Globals.ulProcessedBytes, Globals.ulProcessedBytes / dSeconds); if (Globals.pBufferHeader != NULL) /* check if memory was allocated */ free (Globals.pBufferHeader); /* free that memory */ if (Globals.pBufferFooter != NULL) /* check if memory was allocated */ free (Globals.pBufferFooter); /* free that memory */ } free (Globals.piobufInput); /* free allocated I/O buffering */ free (Globals.piobufOutput); return (rc); /* deliver return code to the operating system */ }