blob: 0e22cfa86b5150d165fec923b3f5a33ce234ea33 [file] [log] [blame]
Dave Barach02500902020-04-04 18:34:41 -04001/*
Dave Barach52642c32016-02-11 19:28:19 -05002 *------------------------------------------------------------------
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);
Dave Barach02500902020-04-04 18:34:41 -040047
Dave Barach52642c32016-02-11 19:28:19 -050048 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
Dave Barach02500902020-04-04 18:34:41 -040054 fprintf (ofp,
Dave Barach52642c32016-02-11 19:28:19 -050055 "const char *version_string = \"G2 (%s) major version %s\";\n",
56 argv[1], argv[2]);
Dave Barach02500902020-04-04 18:34:41 -040057
Dave Barach52642c32016-02-11 19:28:19 -050058 username = (char *) cuserid (0);
59
Dave Barach02500902020-04-04 18:34:41 -040060 strncpy(timestr, ctime(&now), sizeof (timestr));
61
Dave Barach52642c32016-02-11 19:28:19 -050062 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);
Dave Barach02500902020-04-04 18:34:41 -040073
Dave Barach52642c32016-02-11 19:28:19 -050074 exit (0);
75}