home *** CD-ROM | disk | FTP | other *** search
- /* Utility to write "XBBS standard" logfile entries from batch files */
-
- #include "stdio.h"
- #include "stdlib.h"
- #include "time.h"
- #include "dos.h"
- #include "string.h"
-
- char * fidodate(void);
- char * addtolog(char *);
-
- char logfile[143];
-
-
- void main (argc,argv)
-
- int argc;
- char *argv[];
-
- {
-
- register unsigned int x;
- char logentry[143]="";
-
- if (argc<3) {
- fputs("\nERROR CALLING LOG! Usage: LOG Filename.EXT Text to add to logfile\n",stdout);
- exit(1);
- }
- strcpy(logfile,argv[1]);
- for (x=2;x<argc;x++) {
- strcat(logentry,argv[x]);
- strcat(logentry," ");
- }
- addtolog(logentry);
- }
-
-
-
- char * fidodate (void)
-
- {
-
- char months[12][4]={
- "Jan",
- "Feb",
- "Mar",
- "Apr",
- "May",
- "Jun",
- "Jul",
- "Aug",
- "Sep",
- "Oct",
- "Nov",
- "Dec"
- };
- static char fdate[20];
- struct date dos_date;
- struct time dos_time;
-
- /* 26 Jul 89 06:23:47 */
-
- getdate(&dos_date);
- gettime(&dos_time);
-
- sprintf(fdate,"%02hu %s %02d %02hu:%02hu:%02hu",dos_date.da_day,months[dos_date.da_mon-1],dos_date.da_year%100,dos_time.ti_hour,dos_time.ti_min,dos_time.ti_sec);
- return(fdate);
-
- }
-
-
-
- char * addtolog (text) /* WRITE LOGFILE ENTRIES */
-
- char *text;
-
- {
-
- FILE *pf;
- char p[133];
-
- pf = fopen(logfile,"a");
- if (pf == NULL) return text;
- fseek(pf,0,SEEK_END);
- if (text[0]!='*') {
- strcpy(p,fidodate());
- p[16]=0;
- strcat(p," ");
- strncat(p,text,132-strlen(p));
- p[132]=0;
- }
- else {
- strncpy(p,text,79);
- p[79]=0;
- }
- fputs(p,pf);
- fputs("\n",pf);
- fclose(pf);
- return text;
-
- }