1 |
root |
1.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 |
|
|
#include "stdio.h" |
31 |
|
|
#include "stdlib.h" |
32 |
|
|
#include "string.h" |
33 |
|
|
typedef struct |
34 |
|
|
{ |
35 |
|
|
char* name; |
36 |
|
|
char* value; |
37 |
|
|
} cf_parameter; |
38 |
|
|
cf_parameter cf_parameter_list[]= |
39 |
|
|
{ |
40 |
|
|
{"CONFDIR",CONFDIR}, |
41 |
|
|
{"DATADIR",DATADIR}, |
42 |
|
|
{"LIBDIR",LIBDIR}, |
43 |
|
|
{"LOCALDIR",LOCALDIR}, |
44 |
|
|
{"PLUGIN_SUFFIX",PLUGIN_SUFFIX}, |
45 |
|
|
}; |
46 |
|
|
int cf_parameter_list_size = sizeof (cf_parameter_list)/sizeof (cf_parameter); |
47 |
|
|
|
48 |
|
|
int main (int argc, char **argv) |
49 |
|
|
{ |
50 |
|
|
int i; |
51 |
|
|
if (argc==2){ |
52 |
|
|
if (!strcmp (argv[1],"--parameter-list")){ |
53 |
|
|
printf ("parameter maybe one of:\n"); |
54 |
|
|
printf ("\tPLUGININSTALLDIR\n"); |
55 |
|
|
for (i=0;i<cf_parameter_list_size;i++) |
56 |
|
|
printf("\t%s\n",cf_parameter_list[i].name); |
57 |
|
|
return 0; |
58 |
|
|
} |
59 |
|
|
/*Special case, handle plugin installation dir, which is most likeley why |
60 |
|
|
user wants to use crossfire-config in a configure script*/ |
61 |
|
|
if (!strcmp (argv[1],"PLUGININSTALLDIR")){ |
62 |
|
|
printf ("%s/plugins/\n",LIBDIR); |
63 |
|
|
return 0; |
64 |
|
|
} |
65 |
|
|
if (!strcmp (argv[1],"--Dflags")){ |
66 |
|
|
for (i=0;i<cf_parameter_list_size;i++) |
67 |
|
|
printf("-D%s=\\\"%s\\\" ",cf_parameter_list[i].name,cf_parameter_list[i].value); |
68 |
|
|
/*printf ("-DDATADIR=\\\"%s\\\" -DLIBDIR=\\\"%s\\\" -DLOCALDIR=\\\"%s\\\"\n", |
69 |
|
|
cf_parameter_list[0].value,cf_parameter_list[1].value,cf_parameter_list[2].value);*/ |
70 |
|
|
printf("\n"); |
71 |
|
|
return 0; |
72 |
|
|
} |
73 |
|
|
for (i=0;i<cf_parameter_list_size;i++){ |
74 |
|
|
if (!strcmp (argv[1],cf_parameter_list[i].name)){ |
75 |
|
|
printf ("%s\n",cf_parameter_list[i].value); |
76 |
|
|
return 0; |
77 |
|
|
} |
78 |
|
|
} |
79 |
|
|
} |
80 |
|
|
/* Bad arguments count of invalid ones*/ |
81 |
|
|
printf ("usage: crossfire-config --Dflags"); |
82 |
|
|
printf (" (gives complete Dflags line for compiler invocation)\n"); |
83 |
|
|
printf ("usage: crossfire-config --parameter-list"); |
84 |
|
|
printf (" (show the list of available parameters)\n"); |
85 |
|
|
printf ("usage: crossfire-config <parameter name>"); |
86 |
|
|
printf (" (extract a compilation parameter)\n"); |
87 |
|
|
return -1; |
88 |
|
|
} |
89 |
|
|
|