]> git.saurik.com Git - wxWidgets.git/blob - src/tiff/mkversion.c
don't reset the selection after event was vetoed if there is no old selection
[wxWidgets.git] / src / tiff / mkversion.c
1 /* "$Header$ */
2
3 /*
4 * Copyright (c) 1995-1997 Sam Leffler
5 * Copyright (c) 1995-1997 Silicon Graphics, Inc.
6 *
7 * Permission to use, copy, modify, distribute, and sell this software and
8 * its documentation for any purpose is hereby granted without fee, provided
9 * that (i) the above copyright notices and this permission notice appear in
10 * all copies of the software and related documentation, and (ii) the names of
11 * Sam Leffler and Silicon Graphics may not be used in any advertising or
12 * publicity relating to the software without the specific, prior written
13 * permission of Sam Leffler and Silicon Graphics.
14 *
15 * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
16 * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
17 * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
18 *
19 * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
20 * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
21 * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
22 * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
23 * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
24 * OF THIS SOFTWARE.
25 */
26
27 /*
28 * Generate a library version string for systems that
29 * do not have a shell (by default this is done with
30 * awk and echo from the Makefile).
31 *
32 * This was written by Peter Greenham for Acorn systems.
33 *
34 * Syntax: mkversion [-v version-file] [<outfile>]
35 */
36 #include <stdio.h>
37 #include <stdlib.h>
38 #include <string.h>
39
40 static void
41 usage(void)
42 {
43 fprintf(stderr,
44 "usage: mkversion [-v version-file]\n"
45 " [-r releasedate-file] [outfile]\n");
46 exit(-1);
47 }
48
49 static FILE*
50 openFile(char* filename)
51 {
52 FILE* fd = fopen(filename, "r");
53 if (fd == NULL) {
54 fprintf(stderr, "mkversion: %s: Could not open for reading.\n",
55 filename);
56 exit(-1);
57 }
58 return (fd);
59 }
60
61 int
62 main(int argc, char* argv[])
63 {
64 char* versionFile = "../VERSION";
65 char* releaseDateFile = "../RELEASE-DATE";
66 char version[128];
67 char rawReleaseDate[128];
68 char tiffLibVersion[128];
69 FILE* fd;
70 char* cp;
71
72 argc--, argv++;
73 while (argc > 0 && argv[0][0] == '-') {
74 if (strcmp(argv[0], "-v") == 0) {
75 if (argc < 1)
76 usage();
77 argc--, argv++;
78 versionFile = argv[0];
79 } else if (strcmp(argv[0], "-r") == 0) {
80 if (argc < 1)
81 usage();
82 argc--, argv++;
83 releaseDateFile = argv[0];
84 } else
85 usage();
86 argc--, argv++;
87 }
88
89 /*
90 * Read the VERSION file.
91 */
92 fd = openFile(versionFile);
93 if (fgets(version, sizeof (version)-1, fd) == NULL) {
94 fprintf(stderr, "mkversion: No version information in %s.\n",
95 versionFile);
96 exit(-1);
97 }
98 cp = strchr(version, '\n');
99 if (cp)
100 *cp = '\0';
101 fclose(fd);
102
103 /*
104 * Read the RELEASE-DATE, and translate format to emit TIFFLIB_VERSION.
105 */
106 fd = openFile(releaseDateFile);
107 if (fgets(rawReleaseDate, sizeof (rawReleaseDate)-1, fd) == NULL) {
108 fprintf(stderr, "mkversion: No release date information in %s.\n",
109 releaseDateFile);
110 exit(-1);
111 }
112 fclose(fd);
113
114 sprintf( tiffLibVersion, "#define TIFFLIB_VERSION %4.4s%2.2s%2.2s",
115 rawReleaseDate+6,
116 rawReleaseDate+0,
117 rawReleaseDate+3 );
118
119 /*
120 * Emit the tiffvers.h file.
121 */
122 if (argc > 0) {
123 fd = fopen(argv[0], "w");
124 if (fd == NULL) {
125 fprintf(stderr, "mkversion: %s: Could not open for writing.\n",
126 argv[0]);
127 exit(-1);
128 }
129 } else
130 fd = stdout;
131 fprintf(fd, "#define TIFFLIB_VERSION_STR \"LIBTIFF, Version %s\\n", version);
132 fprintf(fd, "Copyright (c) 1988-1996 Sam Leffler\\n");
133 fprintf(fd, "Copyright (c) 1991-1996 Silicon Graphics, Inc.\"\n");
134
135 fprintf( fd,
136 "/*\n"
137 " * This define can be used in code that requires\n"
138 " * compilation-related definitions specific to a\n"
139 " * version or versions of the library. Runtime\n"
140 " * version checking should be done based on the\n"
141 " * string returned by TIFFGetVersion.\n"
142 " */\n" );
143 fprintf(fd, "%s\n", tiffLibVersion );
144
145 if (fd != stdout)
146 fclose(fd);
147 return (0);
148 }