#ifdef ournix #include "ournix.h" #endif char sccsID[] = "@(#) date_ver.c V1.8 Copyright Julian H. Stacey, Munich, April 1988\n" ; /* manual exists generate C char string with revision date in either text string or long numeric */ #include #include #ifdef MSDOS /* { */ #include /* needed for ctime */ #endif /* } */ extern char *ctime() ; extern long time() ; extern long atol() ; char **ARGV ; int ARGC ; main(argc,argv) int argc ; char **argv ; { char dateline[50] ; char *strip_p ; long time_now = 0L ; typedef char FLAG ; FLAG numeric = 0 ; FLAG genesis = 0 ; /* 1 if beginning of time */ time_t later = (time_t)0 ; char *beginning = (char *)0 ; char *end = (char *)0 ; char *name = "time_stamp" ; char *loc_include = (char *)0 ; char *sys_include = (char *)0 ; char *out_name = (char *)0 ; FILE *out_file = stdout ; ARGC = argc ; ARGV = argv ; #ifdef VSL /* { */ #include "../../include/vsl.h" #endif /* } */ while (argc-- && (**++argv == '-')) switch ( *++*argv) { case 'i': loc_include = ++*argv ; break ; case 'I': sys_include = ++*argv ; break ; /* 'i' and 'I' exists because UCB make cant pass # character to this program */ case 'b': beginning = ++*argv ; break ; case 'e': end = ++*argv ; break ; case 'n': numeric = 1 ; break ; case 't': numeric = 0 ; break ; case 'v': name = ++*argv ; break ; case 'o': out_name = ++*argv ; break ; /* no check is made as to whether file is linked etc (ie the file is treated as a simple msdos file, with no Unix specialities allowed for). */ case 'd': /* days after now */ later = (time_t)24 * (time_t)60 * (time_t)60 * (time_t)atol(++*argv); break ; case '0': genesis = 1 ; break ; default : syntax() ; } if (argc > 1) syntax() ; if (argc == 1 ) name = *argv ; if (!genesis) (void)time(&time_now); time_now += later ; if ((out_name != (char *)0) && ((out_file = fopen(out_name,"w")) == (FILE *)0)) { fprintf(stderr,"%s: Aborting, couldnt open %s.\n", *ARGV, out_name) ; exit(1) ; } if (beginning != (char *)0) fprintf(out_file,"%s\n",beginning) ; if (sys_include != (char *)0) fprintf(out_file, "#include <%s>\n" ,sys_include) ; if (loc_include != (char *)0) fprintf(out_file, "#include \"%s\"\n" ,loc_include) ; /* later expand to multiple include possibly */ if (!numeric) { (void) strcpy(dateline,ctime(&time_now)); /* remove \n from end of line */ for (strip_p = dateline ; *strip_p++ ;); *(strip_p - 2) = '\0'; fprintf(out_file,"char %s[] = \"%s\"", name, dateline ); } else fprintf(out_file,"time_t %s = (time_t) %ldL",name, (long)time_now ); fprintf(out_file," ; %c%c from %s %c%c \n", '/','*',*ARGV,'*','/' ); if (end != (char *)0) fprintf(out_file,"%s\n",end) ; if (out_name != (char *)0) (void) fclose(out_file) ; exit(0) ; } syntax() { fprintf(stderr, "Error, Correct syntax is:\n\t%s [-0] [-n] [-t] [-iIncludeLocalName] [-IincludeSystemName]\n\t[-dDays] [-oOutput_file] [-bBeginText] [-eEndText] [-vVariableName]\n", *ARGV); exit(1) ; }