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 = "/*\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";
51 char *_ipglob_copyright_header = "/*\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";
55 rindex(char *path, char c)
73 index(char *path, char c)
99 if ((pathname = getcwd(NULL, 255)) == NULL) {
100 printf("Can't get current path!\n");
105 cp = (char *)rindex(pathname, '/');
107 cp = (char *)rindex(pathname, '/');
110 cp = (char *)rindex(pathname, '\\');
112 cp = (char *)rindex(pathname, '\\');
115 printf("Configuring...\n");
117 sprintf(buf, "%s/include/gamesdef.h", pathname);
119 sprintf(buf, "%s/src/client/ipglob.c", pathname);
123 printf("making directory %s\n", EP);
124 if (mkdir(EP, 493)) {
125 printf("mkdir failed on %s, exiting.\n", EP);
129 sprintf(buf, "%s/data", EP);
130 if (access(buf, 0)) {
131 printf("making directory %s\n", buf);
132 if (mkdir(buf, 493)) {
133 printf("mkdir failed on %s, exiting.\n", buf);
137 sprintf(buf, "%s/data/auth", EP);
143 wrmakesrc(char *pathname)
148 sprintf(buf, "%s/src/make.src", pathname);
149 if ((fp = fopen(buf, "w")) == NULL) {
150 printf("Cannot open %s for writing, exiting.\n", buf);
153 fprintf(fp, "# make.src - Wolfpack, 1996-2000\n");
154 fprintf(fp, "# Source tree absolute pathname - auto generated.\n\n");
155 fprintf(fp, "SRCDIR = %s\n", pathname);
160 wripglob(char *filename)
164 printf("Writing %s\n", filename);
165 if ((fp = fopen(filename, "w")) == NULL) {
166 printf("Cannot open %s for writing, exiting.\n", filename);
169 fprintf(fp, _ipglob_copyright_header);
170 fprintf(fp, "#include <stdio.h>\n");
171 fprintf(fp, "#include <setjmp.h>\n");
172 fprintf(fp, "#include \"misc.h\"\n");
173 fprintf(fp, "#include \"fnlist.h\"\n");
174 fprintf(fp, "#include \"proto.h\"\n\n");
175 fprintf(fp, "s_char empirehost[] = \"%s\";\n", HN);
176 fprintf(fp, "s_char empireport[] = \"%d\";\n", PN);
181 wrauth(char *filename)
185 printf("Writing %s\n", filename);
186 if ((fp = fopen(filename, "w")) == NULL) {
187 printf("Cannot open %s for writing, exiting.\n", filename);
191 fprintf(fp, "# Wolfpack, 1996-2000\n#\n");
192 fprintf(fp, "# Empire Authorization File - Users listed will be allowed to log in as deities.\n#\n");
193 fprintf(fp, "# Format is:\n");
194 fprintf(fp, "# hostname that authorized user uses on a line\n");
195 fprintf(fp, "# username that authorized user uses on a line\n#\n");
196 fprintf(fp, "# REMEMBER TO USE PAIRS OF LINES!\n#\n");
197 fprintf(fp, "# Example:\n#\n");
198 fprintf(fp, "nowhere.land.edu\nnowhereman\n");
199 fprintf(fp, "%s\n%s\n", HN, UN);
200 fprintf(fp, "%s\n%s\n", IP, UN);
201 fprintf(fp, "127.0.0.1\n%s\n", UN);
206 wrgamesdef(char *filename)
217 for (i = 0; i < strlen(EP); i++) {
226 c = buf[strlen(buf) - 1];
227 if (index("dhm", c) && strlen(buf) > 0) {
230 s_p_etu = (((double)s_p_etu * 60.0 * 60.0 * 24.0) / (double)ET);
232 s_p_etu = (((double)s_p_etu * 60.0 * 60.0) / (double)ET);
234 s_p_etu = (((double)s_p_etu * 60.0) / (double)ET);
236 printf("ETU frequency is bad - using 10 minutes.\n");
240 printf("Writing %s\n", filename);
241 if ((fp = fopen(filename, "w")) == NULL) {
242 printf("Cannot open %s for writing, exiting.\n", filename);
245 fprintf(fp, _c_copyright_header);
246 fprintf(fp, "/*\n * Wolfpack, 1996-2000\n *\n");
247 fprintf(fp, " * gamesdef.h - generated automatically by doconfig. Feel\n");
248 fprintf(fp, " * free to change these, but if you rebuild with overwrite on\n");
249 fprintf(fp, " * this file will be overwritten again.\n");
250 fprintf(fp, " */\n\n");
251 fprintf(fp, "#ifndef _GAMESDEF_H_\n");
252 fprintf(fp, "#define _GAMESDEF_H_\n\n");
253 fprintf(fp, "#if !defined(_WIN32)\n");
254 fprintf(fp, "#ifdef __STDC__\n");
255 fprintf(fp, "#define EMPPATH(xyz) \"%s/\" #xyz /* ANSI C */\n", EP);
256 fprintf(fp, "#else\n");
257 fprintf(fp, "#define EMPPATH(xyz) \"%s/xyz\" /* traditional */\n", EP);
258 fprintf(fp, "#endif /* __STDC__ */\n");
259 fprintf(fp, "#else\n");
260 fprintf(fp, "#define EMPPATH(xyz) \"%s\\\\\" #xyz /* ANSI C */\n", path);
261 fprintf(fp, "#endif /* _WIN32 */\n\n");
262 fprintf(fp, "#define PRVNAM \"%s\"\n", PV);
263 fprintf(fp, "#define PRVLOG \"%s\"\n", EM);
264 fprintf(fp, "#define GET_SOURCE \"using:\\n ftp://ftp.wolfpackempire.com/pub/empire/server or \\n http://www.wolfpackempire.com/\"\n");
265 fprintf(fp, "#define EMP_HOST \"%s\"\n", IP);
266 fprintf(fp, "#define EMP_PORT \"%d\"\n\n", PN);
267 fprintf(fp, "#define MAXNOC %d\n\n", MC);
268 fprintf(fp, "#define DEF_WORLD_X %d\n", WX);
269 fprintf(fp, "#define DEF_WORLD_Y %d\n\n", WY);
270 fprintf(fp, "#define DEF_S_P_ETU %d\n", s_p_etu);
271 fprintf(fp, "#define ETUS %d\n\n", ET);
273 fprintf(fp, "#define BLITZ 1\n\n");
274 fprintf(fp, "#endif /* _GAMESDEF_H_ */\n");