Dave Barach | 0250090 | 2020-04-04 18:34:41 -0400 | [diff] [blame^] | 1 | /* |
Dave Barach | 52642c3 | 2016-02-11 19:28:19 -0500 | [diff] [blame] | 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 | |
| 21 | int 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 Barach | 0250090 | 2020-04-04 18:34:41 -0400 | [diff] [blame^] | 47 | |
Dave Barach | 52642c3 | 2016-02-11 19:28:19 -0500 | [diff] [blame] | 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 | |
Dave Barach | 0250090 | 2020-04-04 18:34:41 -0400 | [diff] [blame^] | 54 | fprintf (ofp, |
Dave Barach | 52642c3 | 2016-02-11 19:28:19 -0500 | [diff] [blame] | 55 | "const char *version_string = \"G2 (%s) major version %s\";\n", |
| 56 | argv[1], argv[2]); |
Dave Barach | 0250090 | 2020-04-04 18:34:41 -0400 | [diff] [blame^] | 57 | |
Dave Barach | 52642c3 | 2016-02-11 19:28:19 -0500 | [diff] [blame] | 58 | username = (char *) cuserid (0); |
| 59 | |
Dave Barach | 0250090 | 2020-04-04 18:34:41 -0400 | [diff] [blame^] | 60 | strncpy(timestr, ctime(&now), sizeof (timestr)); |
| 61 | |
Dave Barach | 52642c3 | 2016-02-11 19:28:19 -0500 | [diff] [blame] | 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); |
Dave Barach | 0250090 | 2020-04-04 18:34:41 -0400 | [diff] [blame^] | 73 | |
Dave Barach | 52642c3 | 2016-02-11 19:28:19 -0500 | [diff] [blame] | 74 | exit (0); |
| 75 | } |