2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2000, Dave Pare, Jeff Bailey, Thomas Ruschak,
4 * Ken Stevens, Steve McClure
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * See the "LEGAL", "LICENSE", "CREDITS" and "README" files for all the
23 * related information and legal notices. It is expected that any future
24 * projects/authors will amend these files as needed.
28 * doconfig.c: Generates the gamesdef.h file used to build the game, and
29 * the various make include files needed to build correctly.
31 * Known contributors to this file:
32 * Steve McClure, 1996-2000
35 #include <sys/types.h>
44 void wrmakesrc(char *pathname);
45 void wripglob(char *filename);
46 void wrauth(char *filename);
47 void wrgamesdef(char *filename);
49 char *_c_copyright_header =
50 "/*\n * Empire - A multi-player, client/server Internet based war game.\n * Copyright (C) 1986-2000, Dave Pare, Jeff Bailey, Thomas Ruschak,\n * Ken Stevens, Steve McClure\n *\n * This program is free software; you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation; either version 2 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program; if not, write to the Free Software\n * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n *\n * ---\n *\n * See the \"LEGAL\", \"LICENSE\", \"CREDITS\" and \"README\" files for all the\n * related information and legal notices. It is expected that any future\n * projects/authors will amend these files as needed.\n *\n * ---\n *\n * gamesdef.h: This is an auto-generated file.\n * \n * Known contributors to this file:\n * Automatically generated by doconfig.c\n */\n\n";
52 char *_ipglob_copyright_header =
53 "/*\n * Empire - A multi-player, client/server Internet based war game.\n * Copyright (C) 1986-2000, Dave Pare, Jeff Bailey, Thomas Ruschak,\n * Ken Stevens, Steve McClure\n *\n * This program is free software; you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation; either version 2 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program; if not, write to the Free Software\n * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n *\n * ---\n *\n * See the \"LEGAL\", \"LICENSE\", \"CREDITS\" and \"README\" files for all the\n * related information and legal notices. It is expected that any future\n * projects/authors will amend these files as needed.\n *\n * ---\n *\n * ipglob.c: This is an auto-generated file.\n * \n * Known contributors to this file:\n * Automatically generated by doconfig.c\n */\n\n";
57 rindex(char *path, char c)
75 index(char *path, char c)
101 if ((pathname = getcwd(NULL, 255)) == NULL) {
102 printf("Can't get current path!\n");
106 cp = (char *)rindex(pathname, '/');
108 cp = (char *)rindex(pathname, '/');
111 cp = (char *)rindex(pathname, '\\');
113 cp = (char *)rindex(pathname, '\\');
116 printf("Configuring...\n");
118 sprintf(buf, "%s/include/gamesdef.h", pathname);
120 sprintf(buf, "%s/src/client/ipglob.c", pathname);
124 printf("making directory %s\n", EP);
125 if (mkdir(EP, 493)) {
126 printf("mkdir failed on %s, exiting.\n", EP);
130 sprintf(buf, "%s/data", EP);
131 if (access(buf, 0)) {
132 printf("making directory %s\n", buf);
133 if (mkdir(buf, 493)) {
134 printf("mkdir failed on %s, exiting.\n", buf);
138 sprintf(buf, "%s/data/auth", EP);
144 wrmakesrc(char *pathname)
149 sprintf(buf, "%s/src/make.src", pathname);
150 if ((fp = fopen(buf, "w")) == NULL) {
151 printf("Cannot open %s for writing, exiting.\n", buf);
154 fprintf(fp, "# make.src - Wolfpack, 1996-2000\n");
156 "# Source tree absolute pathname - auto generated.\n\n");
157 fprintf(fp, "SRCDIR = %s\n", pathname);
162 wripglob(char *filename)
166 printf("Writing %s\n", filename);
167 if ((fp = fopen(filename, "w")) == NULL) {
168 printf("Cannot open %s for writing, exiting.\n", filename);
171 fprintf(fp, _ipglob_copyright_header);
172 fprintf(fp, "#include <stdio.h>\n");
173 fprintf(fp, "#include <setjmp.h>\n");
174 fprintf(fp, "#include \"misc.h\"\n");
175 fprintf(fp, "#include \"fnlist.h\"\n");
176 fprintf(fp, "#include \"proto.h\"\n\n");
177 fprintf(fp, "s_char empirehost[] = \"%s\";\n", HN);
178 fprintf(fp, "s_char empireport[] = \"%d\";\n", PN);
183 wrauth(char *filename)
187 printf("Writing %s\n", filename);
188 if ((fp = fopen(filename, "w")) == NULL) {
189 printf("Cannot open %s for writing, exiting.\n", filename);
193 fprintf(fp, "# Wolfpack, 1996-2000\n#\n");
195 "# Empire Authorization File - Users listed will be allowed to log in as deities.\n#\n");
196 fprintf(fp, "# Format is:\n");
197 fprintf(fp, "# hostname that authorized user uses on a line\n");
198 fprintf(fp, "# username that authorized user uses on a line\n#\n");
199 fprintf(fp, "# REMEMBER TO USE PAIRS OF LINES!\n#\n");
200 fprintf(fp, "# Example:\n#\n");
201 fprintf(fp, "nowhere.land.edu\nnowhereman\n");
202 fprintf(fp, "%s\n%s\n", HN, UN);
203 fprintf(fp, "%s\n%s\n", IP, UN);
204 fprintf(fp, "127.0.0.1\n%s\n", UN);
209 wrgamesdef(char *filename)
220 for (i = 0; i < strlen(EP); i++) {
229 c = buf[strlen(buf) - 1];
230 if (index("dhm", c) && strlen(buf) > 0) {
234 (((double)s_p_etu * 60.0 * 60.0 * 24.0) / (double)ET);
236 s_p_etu = (((double)s_p_etu * 60.0 * 60.0) / (double)ET);
238 s_p_etu = (((double)s_p_etu * 60.0) / (double)ET);
240 printf("ETU frequency is bad - using 10 minutes.\n");
244 printf("Writing %s\n", filename);
245 if ((fp = fopen(filename, "w")) == NULL) {
246 printf("Cannot open %s for writing, exiting.\n", filename);
249 fprintf(fp, _c_copyright_header);
250 fprintf(fp, "/*\n * Wolfpack, 1996-2000\n *\n");
252 " * gamesdef.h - generated automatically by doconfig. Feel\n");
254 " * free to change these, but if you rebuild with overwrite on\n");
255 fprintf(fp, " * this file will be overwritten again.\n");
256 fprintf(fp, " */\n\n");
257 fprintf(fp, "#ifndef _GAMESDEF_H_\n");
258 fprintf(fp, "#define _GAMESDEF_H_\n\n");
259 fprintf(fp, "#if !defined(_WIN32)\n");
260 fprintf(fp, "#ifdef __STDC__\n");
261 fprintf(fp, "#define EMPPATH(xyz) \"%s/\" #xyz /* ANSI C */\n", EP);
262 fprintf(fp, "#else\n");
263 fprintf(fp, "#define EMPPATH(xyz) \"%s/xyz\" /* traditional */\n", EP);
264 fprintf(fp, "#endif /* __STDC__ */\n");
265 fprintf(fp, "#else\n");
266 fprintf(fp, "#define EMPPATH(xyz) \"%s\\\\\" #xyz /* ANSI C */\n",
268 fprintf(fp, "#endif /* _WIN32 */\n\n");
269 fprintf(fp, "#define PRVNAM \"%s\"\n", PV);
270 fprintf(fp, "#define PRVLOG \"%s\"\n", EM);
272 "#define GET_SOURCE \"using:\\n ftp://ftp.wolfpackempire.com/pub/empire/server or \\n http://www.wolfpackempire.com/\"\n");
273 fprintf(fp, "#define EMP_HOST \"%s\"\n", IP);
274 fprintf(fp, "#define EMP_PORT \"%d\"\n\n", PN);
275 fprintf(fp, "#define MAXNOC %d\n\n", MC);
276 fprintf(fp, "#define DEF_WORLD_X %d\n", WX);
277 fprintf(fp, "#define DEF_WORLD_Y %d\n\n", WY);
278 fprintf(fp, "#define DEF_S_P_ETU %d\n", s_p_etu);
279 fprintf(fp, "#define ETUS %d\n\n", ET);
281 fprintf(fp, "#define BLITZ 1\n\n");
282 fprintf(fp, "#endif /* _GAMESDEF_H_ */\n");