summaryrefslogtreecommitdiff
path: root/pico/blddate.c
blob: d3a9e720b91a50d3f33fed484cb3d090cd499c12 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <system.h>
#include <general.h>

/*
 * ========================================================================
 * Copyright 2006 University of Washington
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * ========================================================================
 */

main(argc, argv)
    int    argc;
    char **argv;
{
    struct tm *t;
    FILE      *outfile=stdout;
    time_t     ltime;

    if(argc > 1 && (outfile = fopen(argv[1], "w")) == NULL){
	/* TRANSLATORS: an error message when trying to create a file */
	fprintf(stderr, _("can't create '%s'\n"), argv[1]);
	exit(1);
    }

    time(&ltime);
    t = localtime(&ltime);
    fprintf(outfile,"char datestamp[]=\"%02d-%s-%d\";\n", t->tm_mday, 
	    (t->tm_mon == 0) ? "Jan" : 
	     (t->tm_mon == 1) ? "Feb" : 
	      (t->tm_mon == 2) ? "Mar" : 
	       (t->tm_mon == 3) ? "Apr" : 
		(t->tm_mon == 4) ? "May" : 
		 (t->tm_mon == 5) ? "Jun" : 
		  (t->tm_mon == 6) ? "Jul" : 
		   (t->tm_mon == 7) ? "Aug" : 
		    (t->tm_mon == 8) ? "Sep" : 
		     (t->tm_mon == 9) ? "Oct" : 
		      (t->tm_mon == 10) ? "Nov" : 
		       (t->tm_mon == 11) ? "Dec" : "UKN",
	    1900 + t->tm_year);

    fprintf(outfile, "char hoststamp[]=\"random-pc\";\n");
    fprintf(outfile, "char configoptions[] = \"\";\n");

    fclose(outfile);

    exit(0);
}