home *** CD-ROM | disk | FTP | other *** search
- /*
- * Log in BINKLEY.LOG
- * Written by P.J. Muller
- */
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <dos.h>
- #include <time.h>
- #include <string.h>
-
- #define EOS '\0'
-
- static char *mtext[]={ "Jan", "Feb", "Mar", "Apr", "May", "Jun",
- "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
-
- void status_line (FILE *status_log, char *error)
- {
- time_t ltime;
- struct tm *tp;
-
- (void)time (<ime);
- tp = localtime (<ime);
-
- fprintf (status_log, "%c %02i %03s %02i:%02i:%02i LOG %s\n", ' ',
- tp->tm_mday, mtext[tp->tm_mon], tp->tm_hour, tp->tm_min, tp->tm_sec,
- error);
- }
-
- int main(void)
- {
- char *binkpath;
- char binklog[100];
- char cmd[130], *d;
- char far *cmdline;
- FILE *log = NULL;
-
- if ((binkpath = getenv("BINKLEY")) == NULL)
- binkpath = "";
-
- sprintf(binklog, "%s%sBINKLEY.LOG", binkpath,
- (strlen(binkpath) > 3) && (binkpath[strlen(binkpath)-1] == '\\') ?
- "" : "\\");
-
- if ((log = fopen(binklog, "at")) == NULL) {
- fprintf(stderr, "Error opening %s\n", binklog);
- exit(255);
- }
-
- cmdline = MK_FP(_psp, 0x82);
- cmdline[127] = EOS;
- d = cmd;
- while ((*d++ = *cmdline++) != EOS)
- /* nothing */;
- if ((d = strchr(cmd, '\r')) != NULL)
- *d = EOS;
-
- (void)puts(cmd);
- status_line(log, cmd);
-
- (void)fclose(log);
-
- return 0;
- } /* main */
-