Crossfire Server, Branches 1.12  R18729
devel.c
Go to the documentation of this file.
1 /*
2  CrossFire, A Multiplayer game for X-windows
3 
4  Copyright (C) 2001 Mark Wedel & Crossfire Development Team
5  Copyright (C) 1992 Frank Tore Johansen
6 
7  This program is free software; you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation; either version 2 of the License, or
10  (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 
21  The authors can be reached via e-mail to crossfire-devel@real-time.com
22 */
23 
24 /*
25  * Little program aimed at giving information to plugin about config of the crossfire server.
26  * Simply invoke with the config parameter to get. Only the most common parameters (those
27  * that could be needed by an independent configure script) are available. The rest is available
28  * in config.h andd should be included in any plugin needing it.
29  */
30 
31 #include "stdio.h"
32 #include "stdlib.h"
33 #include "string.h"
34 
35 typedef struct {
36  const char *name;
37  const char *value;
38 } cf_parameter;
39 
41  { "CONFDIR", CONFDIR },
42  { "DATADIR", DATADIR },
43  { "LIBDIR", LIBDIR },
44  { "LOCALDIR", LOCALDIR },
45  { "PLUGIN_SUFFIX", PLUGIN_SUFFIX },
46 };
47 
49 
50 int main(int argc, char **argv) {
51  int i;
52 
53  if (argc == 2) {
54  if (!strcmp(argv[1], "--parameter-list")) {
55  printf("parameter maybe one of:\n");
56  printf("\tPLUGININSTALLDIR\n");
57  for (i = 0; i < cf_parameter_list_size; i++)
58  printf("\t%s\n", cf_parameter_list[i].name);
59  return 0;
60  }
61  /*Special case, handle plugin installation dir, which is most likeley why
62  user wants to use crossfire-config in a configure script*/
63  if (!strcmp(argv[1], "PLUGININSTALLDIR")) {
64  printf("%s/plugins/\n", LIBDIR);
65  return 0;
66  }
67  if (!strcmp(argv[1], "--Dflags")) {
68  for (i = 0; i < cf_parameter_list_size; i++)
69  printf("-D%s=\\\"%s\\\" ", cf_parameter_list[i].name, cf_parameter_list[i].value);
70  /*printf ("-DDATADIR=\\\"%s\\\" -DLIBDIR=\\\"%s\\\" -DLOCALDIR=\\\"%s\\\"\n",
71  cf_parameter_list[0].value, cf_parameter_list[1].value, cf_parameter_list[2].value);*/
72  printf("\n");
73  return 0;
74  }
75  for (i = 0; i < cf_parameter_list_size; i++) {
76  if (!strcmp(argv[1], cf_parameter_list[i].name)) {
77  printf("%s\n", cf_parameter_list[i].value);
78  return 0;
79  }
80  }
81  }
82  /* Bad arguments count or invalid ones */
83  printf("usage: crossfire-config --Dflags");
84  printf(" (gives complete Dflags line for compiler invocation)\n");
85  printf("usage: crossfire-config --parameter-list");
86  printf(" (show the list of available parameters)\n");
87  printf("usage: crossfire-config <parameter name>");
88  printf(" (extract a compilation parameter)\n");
89  return -1;
90 }
#define PLUGIN_SUFFIX
Definition: win32.h:124
const char * name
Definition: devel.c:36
const cf_parameter cf_parameter_list[]
Definition: devel.c:40
#define LIBDIR
Definition: win32.h:110
#define LOCALDIR
Definition: win32.h:114
const int cf_parameter_list_size
Definition: devel.c:48
#define DATADIR
Definition: win32.h:109
const char * value
Definition: devel.c:37
int main(int argc, char **argv)
Definition: devel.c:50
#define CONFDIR
Definition: win32.h:111