blob: 3523fbe6c6d5d722fe271add4c1f8b9cc9cc1362 [file] [log] [blame]
Dave Barach52642c32016-02-11 19:28:19 -05001/*
2 *------------------------------------------------------------------
3 * Copyright (c) 1997-2016 Cisco and/or its affiliates.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at:
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include <stdio.h>
18#include <time.h>
19#include <string.h>
20
21int main (int argc, char **argv)
22{
23 time_t now;
24 FILE *ofp;
25 char *dateval;
26 char *username;
27 char *userstr;
28 char *datestr;
29 int i;
30 char propname[32];
31 char *propvalue;
32 char timestr[64];
33 char *cp;
34
35 if (argc < 4) {
36 printf ("usage: mkversion ostype version outputfile\n");
37 exit (1);
38 }
39
40 ofp = fopen (argv[3], "w");
41 if (ofp == NULL) {
42 printf ("Couldn't create %s\n", argv[3]);
43 exit (1);
44 }
45
46 now = time (0);
47
48 fprintf (ofp, "/*\n");
49 fprintf (ofp, " * G2 Version Stamp, %s",
50 ctime (&now));
51 fprintf (ofp, " * Automatically generated, hand edits are pointless.\n");
52 fprintf (ofp, " */\n\n");
53
54 fprintf (ofp,
55 "const char *version_string = \"G2 (%s) major version %s\";\n",
56 argv[1], argv[2]);
57
58 username = (char *) cuserid (0);
59
60 strcpy(timestr, ctime(&now));
61
62 cp = timestr;
63
64 while (*cp) {
65 cp++;
66 }
67 if (*--cp == '\n')
68 *cp = 0;
69
70 fprintf (ofp,
71 "const char *minor_v_string = \"Built by %s at %s\";\n",
72 username, timestr);
73
74 exit (0);
75}
76
77