| 1 | #define SAM_D "Hello world sample for JvW-Fsys TXW OpenWatcom build environment." |
|---|
| 2 | |
|---|
| 3 | #define SAM_C "(c) 2005: Jan van Wijk" |
|---|
| 4 | |
|---|
| 5 | #define SAM_V "1.00 20-09-2005" // Initial version |
|---|
| 6 | |
|---|
| 7 | #include <txlib.h> // TX library interface |
|---|
| 8 | #if defined (WIN32) |
|---|
| 9 | #define SAM_N "SAM2 winNT" |
|---|
| 10 | #elif defined (DOS32) |
|---|
| 11 | #define SAM_N "SAM2 Dos32" |
|---|
| 12 | #elif defined (LINUX) |
|---|
| 13 | #define SAM_N "SAM2 Linux" |
|---|
| 14 | #else |
|---|
| 15 | #define SAM_N "SAM2 OS/2" |
|---|
| 16 | #endif |
|---|
| 17 | |
|---|
| 18 | |
|---|
| 19 | #define SAM_MANDATORY_PARAMS 1 // # of mandatory params to EXE |
|---|
| 20 | |
|---|
| 21 | char *usagetext[] = |
|---|
| 22 | { |
|---|
| 23 | " mandatory-params [optional-params]", |
|---|
| 24 | "", |
|---|
| 25 | " Switch character for EXE switches is '-' or '/'. All single letter", |
|---|
| 26 | " switches are case-sensitive, long switchnames like 'query' are not.", |
|---|
| 27 | "", |
|---|
| 28 | #if defined (DUMP) |
|---|
| 29 | " -123[t][s][l][r][dxx] = trace level 123, [t]stamp; [s]creen; No [l]ogging;" |
|---|
| 30 | " [r]e-open [d]elay xx ms per line", |
|---|
| 31 | #endif |
|---|
| 32 | "", |
|---|
| 33 | " -? = help on executable commandline switches (this text)", |
|---|
| 34 | " -7 = Use 7-bit ASCII only (no 'graphic' characters)", |
|---|
| 35 | " -a = switch off usage of ANSI escape characters for color", |
|---|
| 36 | " -l:logfile = start logging immediately to 'logfile.log'", |
|---|
| 37 | "", |
|---|
| 38 | NULL |
|---|
| 39 | }; |
|---|
| 40 | |
|---|
| 41 | |
|---|
| 42 | int main (int argc, char *argv[]); |
|---|
| 43 | |
|---|
| 44 | /*****************************************************************************/ |
|---|
| 45 | /* Main function of the program, handle commandline-arguments */ |
|---|
| 46 | /*****************************************************************************/ |
|---|
| 47 | int main (int argc, char *argv[]) |
|---|
| 48 | { |
|---|
| 49 | ULONG rc = NO_ERROR; // function return |
|---|
| 50 | |
|---|
| 51 | TxINITmain( "SAMTRACE", "SAM", FALSE, 0); |
|---|
| 52 | |
|---|
| 53 | if (TxaExeSwitch('l')) // start logfile now ? |
|---|
| 54 | { |
|---|
| 55 | TxAppendToLogFile( TxaExeSwitchStr( 'l', NULL, "sam"), TRUE); |
|---|
| 56 | } |
|---|
| 57 | if ((TxaExeSwitch('?')) || // switch help requested |
|---|
| 58 | (TxaExeArgc() <= SAM_MANDATORY_PARAMS)) // or not enough params |
|---|
| 59 | { |
|---|
| 60 | TxPrint( "\n%s %s %s\n%s\n\nUsage: %s", |
|---|
| 61 | SAM_N, SAM_V, SAM_C, SAM_D, TxaExeArgv(0)); |
|---|
| 62 | TxShowTxt( usagetext); |
|---|
| 63 | } |
|---|
| 64 | else |
|---|
| 65 | { |
|---|
| 66 | TxPrint( "\nHello from SAMPLE-2, parameter = '%s'\n\n", TxaExeArgv(1)); |
|---|
| 67 | } |
|---|
| 68 | TxEXITmain(rc); // TX Exit code, incl tracing |
|---|
| 69 | } // end 'main' |
|---|
| 70 | /*---------------------------------------------------------------------------*/ |
|---|