parseOpts.h

Go to the documentation of this file.
00001 
00002 #ifndef __PARSEOPTS_H__
00003 #define __PARSEOPTS_H__
00004 
00005 /* Copyright (c) 2007, Forkbeard team
00006 
00007  All rights reserved.
00008 
00009  Licensed under BSD license. See License.txt
00010 */
00011 
00091 /* Includes */ 
00092 #include <stdio.h>
00093 #include <stdlib.h>
00094 #include <string.h>
00095 
00096 
00097 /* Option argument type constants */
00098 #define OPTION_HAS_ARGS 1 
00099 #define OPTION_NO_ARGS  0 
00101 /* getOpts return error constants */
00102 #define OPTION_ERR_NO_ARGS            -1 
00103 #define OPTION_ERR_ALLOC              -2 
00104 #define OPTION_ERR_UNKNOWN_OPTION     -3 
00105 #define OPTION_ERR_NOT_APPLICABLE     -4 
00106 #define OPTION_ERR_MISSING_ARGUMENT   -5 
00108 /* Option identification constants */
00109 #define OPTION_VERBOSE      1     
00110 #define OPTION_XML          2     
00111 #define OPTION_HELP         3     
00112 #define OPTION_SCAN         4     
00113 #define OPTION_PUSH         5     
00114 #define OPTION_PULL         6     
00115 #define OPTION_PULL_STD     7     
00116 #define OPTION_PULL_ALL     8     
00117 #define OPTION_FORCE        9     
00118 #define OPTION_FTP         10     
00119 #define OPTION_SYNC        11     
00120 #define OPTION_FBS         12     
00121 #define OPTION_PIN         127    
00122 #define OPTION_FILES       128    
00123 #define OPTION_CHANNEL     129    
00124 #define OPTION_RFCOMM_FILE 130    
00125 #define OPTION_OUT_DIR     131    
00126 #define OPTION_IN_DIR      132    
00128 /* Tool identification bitmasks */
00129 #define TOOL_NONE     0x00 
00130 #define TOOL_SCANNER  0x01 
00131 #define TOOL_SDPTOOL  0x02 
00132 #define TOOL_OPPTOOL  0x04 
00133 #define TOOL_RFCOMM   0x08 
00134 #define TOOL_ALL      TOOL_SCANNER |TOOL_SDPTOOL | TOOL_OPPTOOL | TOOL_RFCOMM 
00136 /* parseOpts return codes */
00137 #define PARSEOPTS_RETURN_SUCCESS           1   
00138 #define PARSEOPTS_RETURN_ERROR            -1   
00139 #define PARSEOPTS_RETURN_INAPPLICABLE     -2   
00140 #define PARSEOPTS_RETURN_UNKNOWN          -3   
00141 #define PARSEOPTS_RETURN_MISSING_ARGUMENT -4   
00153 typedef struct parseoptsOptionStruct
00154   {
00155     int verboseFlag;      
00156     int xmlFlag;          
00157     int helpFlag;         
00158     int scanFlag;         
00159     int pushFlag;         
00160     int pullFlag;         
00161     int pullStdFlag;      
00162     int pullAllFlag;      
00163     int forceFlag;        
00164     int ftpFlag;          
00165     int syncFlag;         
00166     int fbsFlag;          
00168     int pinFlag;          
00169     char* pinValue;       
00170     int filesFlag;        
00171     char* filesValue;     
00173     int channelFlag;      
00174     char* channelValue;   
00175     int rfcommfileFlag;   
00176     char* rfcommfileValue;
00177     int outdirFlag;       
00178     char* outdirValue;    
00179     int indirFlag;        
00180     char* indirValue;     
00182     int deviceFlag;       
00183     char* deviceValue;    
00184   };
00185 
00186 
00187 
00193 typedef struct parseoptsDefinition
00194   {
00195     int number;         
00196     char *name;         
00197     char *description;  
00198     char *shortName;    
00199     int hasArgs;        
00200     int toolMask;       
00201   };
00202 
00203 
00204 
00205 
00222 int getopts( int argc, char **argv, char **pArgs, int tool );
00223 
00224 
00225 
00226 
00242 int parseOpts( int argc, char **argv, struct parseoptsOptionStruct *pOpts, int tool );
00243 
00244 
00245 
00246 
00254 char* optionSetValue( const char* pNewValue, char* pChangeValue );
00255 
00256 
00257 
00258 
00264 void freeOpts( struct parseoptsOptionStruct *pOpts );
00265 
00266 
00267 /*\@}*/
00268 
00269 #endif /* __PARSEOPTS_H__  */
00270 
00271 // End of file
00272 
footer
 SourceForge.net Logo