Crossfire Server, Branch 1.12
R12190
|
00001 /* 00002 CrossFire, A Multiplayer game for X-windows 00003 00004 Copyright (C) 2001 Mark Wedel & Crossfire Development Team 00005 Copyright (C) 1992 Frank Tore Johansen 00006 00007 This program is free software; you can redistribute it and/or modify 00008 it under the terms of the GNU General Public License as published by 00009 the Free Software Foundation; either version 2 of the License, or 00010 (at your option) any later version. 00011 00012 This program is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 GNU General Public License for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with this program; if not, write to the Free Software 00019 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00020 00021 The authors can be reached via e-mail to crossfire-devel@real-time.com 00022 */ 00023 00024 /* 00025 * Little program aimed at giving information to plugin about config of the crossfire server. 00026 * Simply invoke with the config parameter to get. Only the most common parameters (those 00027 * that could be needed by an independent configure script) are available. The rest is available 00028 * in config.h andd should be included in any plugin needing it. 00029 */ 00030 00031 #include "stdio.h" 00032 #include "stdlib.h" 00033 #include "string.h" 00034 00035 typedef struct { 00036 const char *name; 00037 const char *value; 00038 } cf_parameter; 00039 00040 const cf_parameter cf_parameter_list[] = { 00041 { "CONFDIR", CONFDIR }, 00042 { "DATADIR", DATADIR }, 00043 { "LIBDIR", LIBDIR }, 00044 { "LOCALDIR", LOCALDIR }, 00045 { "PLUGIN_SUFFIX", PLUGIN_SUFFIX }, 00046 }; 00047 00048 const int cf_parameter_list_size = sizeof(cf_parameter_list)/sizeof(cf_parameter); 00049 00050 int main(int argc, char **argv) { 00051 int i; 00052 00053 if (argc == 2) { 00054 if (!strcmp(argv[1], "--parameter-list")) { 00055 printf("parameter maybe one of:\n"); 00056 printf("\tPLUGININSTALLDIR\n"); 00057 for (i = 0; i < cf_parameter_list_size; i++) 00058 printf("\t%s\n", cf_parameter_list[i].name); 00059 return 0; 00060 } 00061 /*Special case, handle plugin installation dir, which is most likeley why 00062 user wants to use crossfire-config in a configure script*/ 00063 if (!strcmp(argv[1], "PLUGININSTALLDIR")) { 00064 printf("%s/plugins/\n", LIBDIR); 00065 return 0; 00066 } 00067 if (!strcmp(argv[1], "--Dflags")) { 00068 for (i = 0; i < cf_parameter_list_size; i++) 00069 printf("-D%s=\\\"%s\\\" ", cf_parameter_list[i].name, cf_parameter_list[i].value); 00070 /*printf ("-DDATADIR=\\\"%s\\\" -DLIBDIR=\\\"%s\\\" -DLOCALDIR=\\\"%s\\\"\n", 00071 cf_parameter_list[0].value, cf_parameter_list[1].value, cf_parameter_list[2].value);*/ 00072 printf("\n"); 00073 return 0; 00074 } 00075 for (i = 0; i < cf_parameter_list_size; i++) { 00076 if (!strcmp(argv[1], cf_parameter_list[i].name)) { 00077 printf("%s\n", cf_parameter_list[i].value); 00078 return 0; 00079 } 00080 } 00081 } 00082 /* Bad arguments count or invalid ones */ 00083 printf("usage: crossfire-config --Dflags"); 00084 printf(" (gives complete Dflags line for compiler invocation)\n"); 00085 printf("usage: crossfire-config --parameter-list"); 00086 printf(" (show the list of available parameters)\n"); 00087 printf("usage: crossfire-config <parameter name>"); 00088 printf(" (extract a compilation parameter)\n"); 00089 return -1; 00090 }