"Fossies" - the Fresh Open Source Software Archive

Member "htmlrecode-1.3.1/argh/argh.h" (21 Jul 2009, 3565 Bytes) of package /linux/www/old/htmlrecode-1.3.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "argh.h" see the Fossies "Dox" file reference documentation.

    1 #ifndef optrar_argh_h
    2 #define optrar_argh_h
    3 
    4 /* Copyright (C) 1992,2004 Bisqwit (http://iki.fi/bisqwit/) */
    5 
    6 #ifdef __cplusplus
    7 extern "C" {
    8 #endif
    9 
   10 extern void argh_init(void);
   11 extern void argh_done(void);
   12 extern void argh_add_long(const char *longname, int alias);
   13 extern void argh_add_bool(int alias);
   14 extern void argh_add_int(int c, int min, int max);
   15 extern void argh_add_float(int c, double min, double max);
   16 extern void argh_add_string(int c, unsigned minlen, unsigned maxlen);
   17 extern void argh_add_desc(int c, const char *s, const char *optparam);
   18 extern void argh_start_parse(int argc, const char *const *argv);
   19 extern int argh_get_bool(void);
   20 extern int argh_get_int(void);
   21 extern double argh_get_float(void);
   22 extern int argh_ok(void);
   23 extern int argh_get_param(void);
   24 extern void argh_list_options(void);
   25 /* Note: This pointer is only valid until next argh_get_param() call */
   26 /* Attention: Do not try to free() it. */
   27 extern const char *argh_get_string(void);
   28 
   29 #ifdef __cplusplus
   30 }
   31 #endif
   32 
   33 /* C language usage example: 
   34 
   35 static int stereo=0;
   36 static int Rate  =43200;
   37 static char *host = NULL;
   38 
   39 static void PrintVersionInfo(void)
   40 {
   41     printf("erec - polydriving recording server v"VERSION" (C) 1992,2000 Bisqwit\n");
   42 }
   43 
   44 #include <argh.h>
   45 
   46 int main(int argc, const char *const *argv)
   47 {
   48     int Heelp = 0;
   49     
   50     argh_init();
   51     
   52     argh_add_long("stereo", '2'); argh_add_bool('2'); argh_add_desc('2', "Specifies stereo sound. Default is mono.", NULL);
   53     argh_add_long("mono",   'm'); argh_add_bool('m'); argh_add_desc('m', "Redundant. It's here for esd compatibility.", NULL);
   54     argh_add_long("rate",   'r'); argh_add_int('r',18,999999); argh_add_desc('r', "Specifies recording rate. 43200 is default.", "<num>");
   55     argh_add_long("device", 'd'); argh_add_string('d',1,1023); argh_add_desc('d', "Specify device.", "<file>");
   56     argh_add_long("help",   'h'); argh_add_bool('h'); argh_add_desc('h', "Help", NULL);
   57     argh_add_long("version",'V'); argh_add_bool('V'); argh_add_desc('V', "Version information", NULL);
   58     
   59     argh_start_parse(argc, argv);
   60     for(;;)
   61     {
   62         int c = argh_get_param();
   63         if(c == -1)break;
   64         switch(c)
   65         {
   66             case 'V':
   67                 PrintVersionInfo();
   68                 return 0;
   69             case 'h':
   70                 Heelp = 1;
   71                 break;
   72             case '2':
   73                 if(argh_get_bool())++stereo;else stereo=0;
   74                 break;
   75             case 'm':
   76                 if(argh_get_bool())stereo = 0;else ++stereo;
   77                 break;
   78             case 'r':
   79                 Rate = argh_get_int();
   80                 break;
   81             case 'd':
   82                 strncpy(Device, argh_get_string(), sizeof Device);
   83                 Device[sizeof(Device)-1] = 0;
   84                 break;
   85             default:
   86             {
   87                 const char *s = argh_get_string();
   88                 host = (char *)malloc(strlen(s)+1);
   89                 strcpy(host, s);
   90             }
   91         }
   92     }
   93     if(!host)host = (char *)"10.104.2.2";
   94     
   95     if(!argh_ok())return -1;
   96     
   97     if(Heelp)
   98     {
   99         PrintVersionInfo();
  100         printf(
  101             "\nAllows multiple applications request recorded data"
  102             "\nat the same time with different stream attributes.\n");
  103         printf(
  104             "Usage: erec [<options> [<...>]] [<host> | none]\n"
  105             "Options:\n");
  106         argh_list_options();
  107         printf("\n"
  108             "If <host> is other than none, the output will be sent with esdcat.\n");
  109         return 0;
  110     }
  111     
  112     ...
  113 }
  114 
  115 */
  116 
  117 #endif