home *** CD-ROM | disk | FTP | other *** search
/ hobbes.nmsu.edu 2008 / 2008-06-02_hobbes.nmsu.edu.zip / new / scummc-0.2.0-os2.zip / ScummC / src / scc_param.h < prev    next >
Encoding:
C/C++ Source or Header  |  2008-02-03  |  1.9 KB  |  75 lines

  1. /* ScummC
  2.  * Copyright (C) 2004-2006  Alban Bedel
  3.  *
  4.  * This program is free software; you can redistribute it and/or
  5.  * modify it under the terms of the GNU General Public License
  6.  * as published by the Free Software Foundation; either version 2
  7.  * of the License, or (at your option) any later version.
  8.  
  9.  * This program is distributed in the hope that it will be useful,
  10.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12.  * GNU General Public License for more details.
  13.  
  14.  * You should have received a copy of the GNU General Public License
  15.  * along with this program; if not, write to the Free Software
  16.  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  17.  *
  18.  */
  19.  
  20. /**
  21.  * @file scc_param.h
  22.  * @ingroup utils
  23.  * @brief Command line parser
  24.  */
  25.  
  26. #define SCC_PARAM_FLAG 1
  27. #define SCC_PARAM_INT  2
  28. #define SCC_PARAM_STR  3
  29. #define SCC_PARAM_DBL  4
  30. #define SCC_PARAM_STR_LIST 5
  31. #define SCC_PARAM_INT_LIST 6
  32. #define SCC_PARAM_HELP     7
  33.  
  34. #define SCC_PARAM_TYPE_NO_ARG 1
  35.  
  36. #define SCC_PARAM_UNKNOWN      -1
  37. #define SCC_PARAM_NEED_ARG     -2
  38. #define SCC_PARAM_INVALID      -3
  39. #define SCC_PARAM_OUT_OF_RANGE -4
  40. #define SCC_PARAM_INVALID_TYPE -5
  41.  
  42. typedef struct scc_param_st {
  43.   char* name;
  44.   int type;
  45.   int min,max;
  46.   void* ptr;
  47. } scc_param_t;
  48.  
  49. typedef struct scc_cl_arg_st scc_cl_arg_t;
  50. struct scc_cl_arg_st {
  51.   scc_cl_arg_t* next;
  52.   char* val;
  53. };
  54.  
  55. int scc_param_parse(scc_param_t* params,char* k,char* v);
  56.  
  57. scc_cl_arg_t* scc_param_parse_argv(scc_param_t* params,int argc,char** argv);
  58.  
  59. typedef struct scc_param_help_st scc_param_help_t;
  60. struct scc_param_help_st {
  61.   char* name;
  62.   char* arg;
  63.   char* dfault;
  64.   char* desc;
  65.   scc_param_help_t* group;
  66. };
  67.  
  68. typedef struct scc_help_st {
  69.   char* name;
  70.   char* usage;
  71.   scc_param_help_t* param_help;
  72. } scc_help_t;
  73.  
  74. void scc_print_help(scc_help_t* help,int exit_code);
  75.