00001 #ifndef __CLARGS_H 00002 #define __CLARGS_H 00003 00004 /**********************************************************/ 00005 /*/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\*/ 00006 /* 00007 Copyright: 1993 - Grupo de Voz (DAET) ETSII/IT-Bilbao 00008 00009 Nombre fuente................ CLARGS.H 00010 Nombre paquete............... - 00011 Lenguaje fuente.............. C (Borland C/C++ 3.1) 00012 Estado....................... Utilizable 00013 Dependencia Hard/OS.......... NO 00014 Codigo condicional........... NO 00015 00016 Codificacion................. Borja Etxebarria 00017 00018 Version dd/mm/aa Autor Comentario 00019 ------- -------- -------- ---------- 00020 1.1.0 20/05/97 Borja arg {allow_unknown} en clasw_getsw() 00021 1.0.0 11/01/93 Borja Codificacion inicial. 00022 00023 ======================== Contenido ======================== 00024 Fichero de cabecera de CLARGS.C 00025 00026 Gestion de argumentos de linea. 00027 =========================================================== 00028 */ 00029 /*/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\*/ 00030 /**********************************************************/ 00031 00032 #include <stdio.h> 00033 00034 /**********************************************************/ 00035 00036 #ifdef __cplusplus 00037 extern "C" { 00038 #endif 00039 00040 /**********************************************************/ 00041 00042 #define CLARGS_MAX_LEN 256 /* Maxima longitud de un argumento 00043 (incluido el 0 final) */ 00044 00045 #define CLARGS_CFGFILE "CfgFile" /* switch de fichero de configuracion */ 00046 #define CLARGS_ARGFILE "ArgFile" /* switch de fichero de argumentos */ 00047 00048 /**********************************************************/ 00049 /* 1 para mayusculas!=minusculas. 00050 0 no distingue (0 es el valor por defecto) */ 00051 00052 extern int _clargs_case_sensitive; 00053 00054 /**********************************************************/ 00055 00056 typedef struct { 00057 char args[CLARGS_MAX_LEN]; /* buffer para meter los argumentos */ 00058 int argc; /* argc-1 de main() */ 00059 char * * argv; /* argv+1[] de main() */ 00060 00061 int lastarg; /* ultimo argumento de linea procesado */ 00062 00063 char * cfgfn; /* nombre del fichero de configuracion a utilizar */ 00064 char * exefn; /* _cfgfn, pero en el directorio del .exe, o NULL 00065 si _cfgfn no es el indicado por defecto */ 00066 00067 FILE * cfgf; /* fichero de configuracion */ 00068 FILE * argf; /* fichero de argumentos */ 00069 } clargs; 00070 00071 typedef struct { 00072 clargs * c; 00073 const char * * switches; /* array de switches validos para getsw() */ 00074 int nswitches; /* numero de switches */ 00075 } clasw; 00076 00077 /**********************************************************/ 00078 00079 clargs * clargs_construct( int argc, char * argv[], const char * def_cfgfn ); 00080 void clargs_destruct( clargs * c ); 00081 void clargs_restart( clargs * c ); 00082 char * clargs_getarg( clargs * c ); 00083 char * clargs_getsarg( clargs * c ); 00084 char * clargs_getparg( clargs * c ); 00085 00086 /**********************************************************/ 00087 00088 clasw * clasw_construct( int argc, char * argv[], const char * sw[], 00089 const char * def_cfgfn ); 00090 void clasw_destruct( clasw * c ); 00091 int clasw_getsw( clasw * c, char ** value, int allow_unknown ); 00092 void clasw_restart( clasw * c ); 00093 char * clasw_getarg( clasw * c ); 00094 char * clasw_getsarg( clasw * c ); 00095 char * clasw_getparg( clasw * c ); 00096 00097 /**********************************************************/ 00098 00099 #ifdef __cplusplus 00100 } /* extern "C" */ 00101 #endif 00102 00103 /**********************************************************/ 00104 00105 #endif