Annotation of embedaddon/coova-chilli/src/cmdline.c, revision 1.1.1.1

1.1       misho       1: /*
                      2:   File autogenerated by gengetopt version 2.22
                      3:   generated with the following command:
                      4:   gengetopt -C --no-handle-help --no-handle-version
                      5: 
                      6:   The developers of gengetopt consider the fixed text that goes in all
                      7:   gengetopt output files to be in the public domain:
                      8:   we make no copyright claims on it.
                      9: */
                     10: 
                     11: /* If we use autoconf.  */
                     12: #ifdef HAVE_CONFIG_H
                     13: #include "config.h"
                     14: #endif
                     15: 
                     16: #include <stdio.h>
                     17: #include <stdlib.h>
                     18: #include <string.h>
                     19: 
                     20: #include "getopt.h"
                     21: 
                     22: #include "cmdline.h"
                     23: 
                     24: const char *gengetopt_args_info_purpose = "";
                     25: 
                     26: const char *gengetopt_args_info_usage = "Usage: " CMDLINE_PARSER_PACKAGE " [OPTIONS]...";
                     27: 
                     28: const char *gengetopt_args_info_description = "";
                     29: 
                     30: const char *gengetopt_args_info_help[] = {
                     31:   "  -h, --help                    Print help and exit",
                     32:   "  -V, --version                 Print version and exit",
                     33:   "  -f, --fg                      Run in foreground  (default=off)",
                     34:   "  -d, --debug                   Run in debug mode  (default=off)",
                     35:   "      --debugfacility=INT       Which modules to print debug messages for  \n                                  (default=`1')",
                     36:   "      --logfacility=INT         Syslog facility to be used for logging  \n                                  (default=`-1')",
                     37:   "  -c, --conf=STRING             Read configuration file",
                     38:   "      --interval=INT            Re-read configuration file at this interval  \n                                  (default=`3600')",
                     39:   "      --pidfile=STRING          Filename of process id file",
                     40:   "      --statedir=STRING         Directory of nonvolatile data",
                     41:   "  -n, --net=STRING              Network  (default=`192.168.182.0/24')",
                     42:   "      --dhcpstart=INT           Network DHCP Starting IP  (default=`0')",
                     43:   "      --dhcpend=INT             Network DHCP Ending IP  (default=`0')",
                     44:   "      --dynip=STRING            Dynamic IP address pool",
                     45:   "      --nodynip                 No Dynamic IP assignment  (default=off)",
                     46:   "      --statip=STRING           Static IP address pool",
                     47:   "      --dns1=STRING             Primary DNS server IP address",
                     48:   "      --dns2=STRING             Secondary DNS server IP address",
                     49:   "      --domain=STRING           Domain to use for DNS lookups  \n                                  (default=`coova.org')",
                     50:   "      --ipup=STRING             Script to run after link-up",
                     51:   "      --ipdown=STRING           Script to run after link-down",
                     52:   "      --conup=STRING            Script to run after user logon",
                     53:   "      --condown=STRING          Script to run after user logoff",
                     54:   "      --txqlen=INT              TX Queue length for tun interface (linux only)  \n                                  (default=`100')",
                     55:   "      --tundev=STRING           TUN/TAP Device, as in tun0 or tap1",
                     56:   "      --radiuslisten=STRING     IP address to send from",
                     57:   "      --radiusserver1=STRING    IP address of radius server 1  \n                                  (default=`rad01.coova.org')",
                     58:   "      --radiusserver2=STRING    IP address of radius server 2  \n                                  (default=`rad01.coova.org')",
                     59:   "      --radiusauthport=INT      Authentication UDP port of radius server  \n                                  (default=`1812')",
                     60:   "      --radiusacctport=INT      Accounting UDP port of radius server  \n                                  (default=`1813')",
                     61:   "      --radiussecret=STRING     Radius shared secret  \n                                  (default=`coova-anonymous')",
                     62:   "      --radiustimeout=INT       Retry timeout in seconds  (default=`30')",
                     63:   "      --radiusretry=INT         Total number of retries  (default=`6')",
                     64:   "      --radiusretrysec=INT      Number of retries before using secondary  \n                                  (default=`3')",
                     65:   "      --radiusnasid=STRING      Radius NAS-Identifier  (default=`nas01')",
                     66:   "      --radiuslocationid=STRING WISPr Location ID",
                     67:   "      --radiuslocationname=STRING\n                                WISPr Location Name",
                     68:   "      --locationname=STRING     Location Name",
                     69:   "      --radiusnasporttype=INT   Radius NAS-Port-Type  (default=`19')",
                     70:   "      --coaport=INT             Radius disconnect port to listen to  \n                                  (default=`0')",
                     71:   "      --coanoipcheck            Allow radius disconnect from any IP  \n                                  (default=off)",
                     72:   "      --proxylisten=STRING      IP address to listen to",
                     73:   "      --proxyport=INT           UDP port to listen to  (default=`0')",
                     74:   "      --proxyclient=STRING      IP address of proxy client(s)",
                     75:   "      --proxysecret=STRING      Radius proxy shared secret",
                     76:   "      --dhcpif=STRING           Local Ethernet interface",
                     77:   "      --dhcpmac=STRING          Interface MAC address",
                     78:   "      --dhcpradius              Map certain DHCP options to RADIUS attributes  \n                                  (default=off)",
                     79:   "      --dhcpgateway=STRING      DHCP gateway addresss for relay",
                     80:   "      --dhcpgatewayport=INT     DHCP gateway port for relay  (default=`67')",
                     81:   "      --dhcprelayagent=STRING   DHCP relay agent IP addresss (default \n                                  uamlisten)",
                     82:   "      --lease=INT               Lease time to allocate to clients  \n                                  (default=`600')",
                     83:   "      --eapolenable             Enable IEEE 802.1x authentication  \n                                  (default=off)",
                     84:   "      --uamserver=STRING        URL of authentication web server",
                     85:   "      --uamhomepage=STRING      URL of homepage to redirect unauthenticated \n                                  users to",
                     86:   "      --uamsecret=STRING        Shared secret between uamserver and chilli",
                     87:   "      --uamlisten=STRING        IP address to listen to for authentication \n                                  requests",
                     88:   "      --uamport=INT             TCP port to bind to for authentication requests \n                                   (default=`3990')",
                     89:   "      --uamuiport=INT           TCP port to bind to for UAM UI requests  \n                                  (default=`3991')",
                     90:   "      --uamallowed=STRING       Domain names exempt from access check ",
                     91:   "      --uamdomain=STRING        Domain name allowed (active dns filtering; one \n                                  per line!) ",
                     92:   "      --uamanydns               Allow client to use any DNS server  \n                                  (default=off)",
                     93:   "      --uamanyip                Allow client to use any IP Address  \n                                  (default=off)",
                     94:   "      --wisprlogin=STRING       A specific WISPr login url to be used",
                     95:   "      --nouamsuccess            Do not return to the UAM server on success, \n                                  original url instead  (default=off)",
                     96:   "      --nouamwispr              Do not send WISPr XML from ChilliSpot, assume \n                                  back-end does  (default=off)",
                     97:   "      --uamlogoutip=STRING      HTTP Auto-Logout IP Address  \n                                  (default=`1.1.1.1')",
                     98:   "      --defsessiontimeout=LONG  Default session-timeout if not returned by \n                                  RADIUS  (default=`0')",
                     99:   "      --defidletimeout=INT      Default idle-timeout if not returned by RADIUS  \n                                  (default=`0')",
                    100:   "      --defbandwidthmaxdown=LONG\n                                Default WISPr-Bandwidth-Max-Down if not \n                                  returned by RADIUS  (default=`0')",
                    101:   "      --defbandwidthmaxup=LONG  Default WISPr-Bandwidth-Max-Up if not returned \n                                  by RADIUS  (default=`0')",
                    102:   "      --definteriminterval=INT  Default interim-interval for accounting if not \n                                  returned by RADIUS  (default=`300')",
                    103:   "      --macauth                 Authenticate based on MAC address  \n                                  (default=off)",
                    104:   "      --macauthdeny             Deny access (even UAM) to MAC addresses given \n                                  Access-Reject  (default=off)",
                    105:   "      --macallowed=STRING       List of allowed MAC addresses",
                    106:   "      --macsuffix=STRING        Suffix to add to the MAC address",
                    107:   "      --macpasswd=STRING        Password used when performing MAC \n                                  authentication",
                    108:   "      --macallowlocal           Do not use RADIUS for authenticating the \n                                  macallowed  (default=off)",
                    109:   "      --wwwdir=STRING           Local content served by chilli (for splash \n                                  page, etc)",
                    110:   "      --wwwbin=STRING           Script binary (such as haserl) for simple web \n                                  programming",
                    111:   "      --uamui=STRING            Program in inetd style to handle all uam \n                                  requests",
                    112:   "      --adminuser=STRING        RADIUS administrative user login username  \n                                  (default=`chillispot')",
                    113:   "      --adminpasswd=STRING      RADIUS administrative user login password  \n                                  (default=`chillispot')",
                    114:   "      --nasmac=STRING           Unique MAC address of the NAS \n                                  (called-station-id)",
                    115:   "      --nasip=STRING            Unique IP address of the NAS (nas-ip-address)",
                    116:   "      --ssid=STRING             SSID of the session",
                    117:   "      --vlan=STRING             VLAN of the session",
                    118:   "      --cmdsocket=STRING        path to the command unix socket",
                    119:   "      --radiusoriginalurl       Turn on the sending of ChilliSpot-OriginalURL \n                                  in Access-Request  (default=off)",
                    120:   "      --swapoctets              Swap the meaning of input/output octets/packets \n                                   (default=off)",
                    121:   "      --usestatusfile           Use the status file to keep track of sessions  \n                                  (default=off)",
                    122:   "      --localusers=STRING       File keep 'Local' usernames and passwords",
                    123:   "      --postauthproxy=STRING    IP of an upstream transparent proxy",
                    124:   "      --postauthproxyport=INT   Port of an upstream transparent proxy  \n                                  (default=`0')",
                    125:   "      --wpaguests               Allow WPA 'Guest' access  (default=off)",
                    126:   "      --openidauth              Allow OpenID authentication  (default=off)",
                    127:   "      --papalwaysok             Always allow 'PAP' authentication (depreciated; \n                                  always on)  (default=off)",
                    128:   "      --chillixml               Use ChilliSpot XML in WISPr blocks  \n                                  (default=off)",
                    129:   "      --acctupdate              Allow updating of session attributes in \n                                  Accounting-Response  (default=off)",
                    130:   "      --dnsparanoia             Inspect DNS packets and drop responses with any \n                                  non- A, CNAME, SOA, or MX records (to prevent \n                                  dns tunnels)  (default=off)",
                    131:   "      --usetap                  Use a TAP instead of TUN (linux only)  \n                                  (default=off)",
                    132:   "      --routeif=STRING          Interface to use as default route; turns on \n                                  'manual' routing",
                    133:     0
                    134: };
                    135: 
                    136: typedef enum {ARG_NO
                    137:   , ARG_FLAG
                    138:   , ARG_STRING
                    139:   , ARG_INT
                    140:   , ARG_LONG
                    141: } cmdline_parser_arg_type;
                    142: 
                    143: static
                    144: void clear_given (struct gengetopt_args_info *args_info);
                    145: static
                    146: void clear_args (struct gengetopt_args_info *args_info);
                    147: 
                    148: static int
                    149: cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_info *args_info,
                    150:                         struct cmdline_parser_params *params, const char *additional_error);
                    151: 
                    152: static int
                    153: cmdline_parser_required2 (struct gengetopt_args_info *args_info, const char *prog_name, const char *additional_error);
                    154: struct line_list
                    155: {
                    156:   char * string_arg;
                    157:   struct line_list * next;
                    158: };
                    159: 
                    160: static struct line_list *cmd_line_list = 0;
                    161: static struct line_list *cmd_line_list_tmp = 0;
                    162: 
                    163: static void
                    164: free_cmd_list(void)
                    165: {
                    166:   /* free the list of a previous call */
                    167:   if (cmd_line_list)
                    168:     {
                    169:       while (cmd_line_list) {
                    170:         cmd_line_list_tmp = cmd_line_list;
                    171:         cmd_line_list = cmd_line_list->next;
                    172:         free (cmd_line_list_tmp->string_arg);
                    173:         free (cmd_line_list_tmp);
                    174:       }
                    175:     }
                    176: }
                    177: 
                    178: 
                    179: static char *
                    180: gengetopt_strdup (const char *s);
                    181: 
                    182: static
                    183: void clear_given (struct gengetopt_args_info *args_info)
                    184: {
                    185:   args_info->help_given = 0 ;
                    186:   args_info->version_given = 0 ;
                    187:   args_info->fg_given = 0 ;
                    188:   args_info->debug_given = 0 ;
                    189:   args_info->debugfacility_given = 0 ;
                    190:   args_info->logfacility_given = 0 ;
                    191:   args_info->conf_given = 0 ;
                    192:   args_info->interval_given = 0 ;
                    193:   args_info->pidfile_given = 0 ;
                    194:   args_info->statedir_given = 0 ;
                    195:   args_info->net_given = 0 ;
                    196:   args_info->dhcpstart_given = 0 ;
                    197:   args_info->dhcpend_given = 0 ;
                    198:   args_info->dynip_given = 0 ;
                    199:   args_info->nodynip_given = 0 ;
                    200:   args_info->statip_given = 0 ;
                    201:   args_info->dns1_given = 0 ;
                    202:   args_info->dns2_given = 0 ;
                    203:   args_info->domain_given = 0 ;
                    204:   args_info->ipup_given = 0 ;
                    205:   args_info->ipdown_given = 0 ;
                    206:   args_info->conup_given = 0 ;
                    207:   args_info->condown_given = 0 ;
                    208:   args_info->txqlen_given = 0 ;
                    209:   args_info->tundev_given = 0 ;
                    210:   args_info->radiuslisten_given = 0 ;
                    211:   args_info->radiusserver1_given = 0 ;
                    212:   args_info->radiusserver2_given = 0 ;
                    213:   args_info->radiusauthport_given = 0 ;
                    214:   args_info->radiusacctport_given = 0 ;
                    215:   args_info->radiussecret_given = 0 ;
                    216:   args_info->radiustimeout_given = 0 ;
                    217:   args_info->radiusretry_given = 0 ;
                    218:   args_info->radiusretrysec_given = 0 ;
                    219:   args_info->radiusnasid_given = 0 ;
                    220:   args_info->radiuslocationid_given = 0 ;
                    221:   args_info->radiuslocationname_given = 0 ;
                    222:   args_info->locationname_given = 0 ;
                    223:   args_info->radiusnasporttype_given = 0 ;
                    224:   args_info->coaport_given = 0 ;
                    225:   args_info->coanoipcheck_given = 0 ;
                    226:   args_info->proxylisten_given = 0 ;
                    227:   args_info->proxyport_given = 0 ;
                    228:   args_info->proxyclient_given = 0 ;
                    229:   args_info->proxysecret_given = 0 ;
                    230:   args_info->dhcpif_given = 0 ;
                    231:   args_info->dhcpmac_given = 0 ;
                    232:   args_info->dhcpradius_given = 0 ;
                    233:   args_info->dhcpgateway_given = 0 ;
                    234:   args_info->dhcpgatewayport_given = 0 ;
                    235:   args_info->dhcprelayagent_given = 0 ;
                    236:   args_info->lease_given = 0 ;
                    237:   args_info->eapolenable_given = 0 ;
                    238:   args_info->uamserver_given = 0 ;
                    239:   args_info->uamhomepage_given = 0 ;
                    240:   args_info->uamsecret_given = 0 ;
                    241:   args_info->uamlisten_given = 0 ;
                    242:   args_info->uamport_given = 0 ;
                    243:   args_info->uamuiport_given = 0 ;
                    244:   args_info->uamallowed_given = 0 ;
                    245:   args_info->uamdomain_given = 0 ;
                    246:   args_info->uamanydns_given = 0 ;
                    247:   args_info->uamanyip_given = 0 ;
                    248:   args_info->wisprlogin_given = 0 ;
                    249:   args_info->nouamsuccess_given = 0 ;
                    250:   args_info->nouamwispr_given = 0 ;
                    251:   args_info->uamlogoutip_given = 0 ;
                    252:   args_info->defsessiontimeout_given = 0 ;
                    253:   args_info->defidletimeout_given = 0 ;
                    254:   args_info->defbandwidthmaxdown_given = 0 ;
                    255:   args_info->defbandwidthmaxup_given = 0 ;
                    256:   args_info->definteriminterval_given = 0 ;
                    257:   args_info->macauth_given = 0 ;
                    258:   args_info->macauthdeny_given = 0 ;
                    259:   args_info->macallowed_given = 0 ;
                    260:   args_info->macsuffix_given = 0 ;
                    261:   args_info->macpasswd_given = 0 ;
                    262:   args_info->macallowlocal_given = 0 ;
                    263:   args_info->wwwdir_given = 0 ;
                    264:   args_info->wwwbin_given = 0 ;
                    265:   args_info->uamui_given = 0 ;
                    266:   args_info->adminuser_given = 0 ;
                    267:   args_info->adminpasswd_given = 0 ;
                    268:   args_info->nasmac_given = 0 ;
                    269:   args_info->nasip_given = 0 ;
                    270:   args_info->ssid_given = 0 ;
                    271:   args_info->vlan_given = 0 ;
                    272:   args_info->cmdsocket_given = 0 ;
                    273:   args_info->radiusoriginalurl_given = 0 ;
                    274:   args_info->swapoctets_given = 0 ;
                    275:   args_info->usestatusfile_given = 0 ;
                    276:   args_info->localusers_given = 0 ;
                    277:   args_info->postauthproxy_given = 0 ;
                    278:   args_info->postauthproxyport_given = 0 ;
                    279:   args_info->wpaguests_given = 0 ;
                    280:   args_info->openidauth_given = 0 ;
                    281:   args_info->papalwaysok_given = 0 ;
                    282:   args_info->chillixml_given = 0 ;
                    283:   args_info->acctupdate_given = 0 ;
                    284:   args_info->dnsparanoia_given = 0 ;
                    285:   args_info->usetap_given = 0 ;
                    286:   args_info->routeif_given = 0 ;
                    287: }
                    288: 
                    289: static
                    290: void clear_args (struct gengetopt_args_info *args_info)
                    291: {
                    292:   args_info->fg_flag = 0;
                    293:   args_info->debug_flag = 0;
                    294:   args_info->debugfacility_arg = 1;
                    295:   args_info->debugfacility_orig = NULL;
                    296:   args_info->logfacility_arg = -1;
                    297:   args_info->logfacility_orig = NULL;
                    298:   args_info->conf_arg = NULL;
                    299:   args_info->conf_orig = NULL;
                    300:   args_info->interval_arg = 3600;
                    301:   args_info->interval_orig = NULL;
                    302:   args_info->pidfile_arg = NULL;
                    303:   args_info->pidfile_orig = NULL;
                    304:   args_info->statedir_arg = NULL;
                    305:   args_info->statedir_orig = NULL;
                    306:   args_info->net_arg = gengetopt_strdup ("192.168.182.0/24");
                    307:   args_info->net_orig = NULL;
                    308:   args_info->dhcpstart_arg = 0;
                    309:   args_info->dhcpstart_orig = NULL;
                    310:   args_info->dhcpend_arg = 0;
                    311:   args_info->dhcpend_orig = NULL;
                    312:   args_info->dynip_arg = NULL;
                    313:   args_info->dynip_orig = NULL;
                    314:   args_info->nodynip_flag = 0;
                    315:   args_info->statip_arg = NULL;
                    316:   args_info->statip_orig = NULL;
                    317:   args_info->dns1_arg = NULL;
                    318:   args_info->dns1_orig = NULL;
                    319:   args_info->dns2_arg = NULL;
                    320:   args_info->dns2_orig = NULL;
                    321:   args_info->domain_arg = gengetopt_strdup ("coova.org");
                    322:   args_info->domain_orig = NULL;
                    323:   args_info->ipup_arg = NULL;
                    324:   args_info->ipup_orig = NULL;
                    325:   args_info->ipdown_arg = NULL;
                    326:   args_info->ipdown_orig = NULL;
                    327:   args_info->conup_arg = NULL;
                    328:   args_info->conup_orig = NULL;
                    329:   args_info->condown_arg = NULL;
                    330:   args_info->condown_orig = NULL;
                    331:   args_info->txqlen_arg = 100;
                    332:   args_info->txqlen_orig = NULL;
                    333:   args_info->tundev_arg = NULL;
                    334:   args_info->tundev_orig = NULL;
                    335:   args_info->radiuslisten_arg = NULL;
                    336:   args_info->radiuslisten_orig = NULL;
                    337:   args_info->radiusserver1_arg = gengetopt_strdup ("rad01.coova.org");
                    338:   args_info->radiusserver1_orig = NULL;
                    339:   args_info->radiusserver2_arg = gengetopt_strdup ("rad01.coova.org");
                    340:   args_info->radiusserver2_orig = NULL;
                    341:   args_info->radiusauthport_arg = 1812;
                    342:   args_info->radiusauthport_orig = NULL;
                    343:   args_info->radiusacctport_arg = 1813;
                    344:   args_info->radiusacctport_orig = NULL;
                    345:   args_info->radiussecret_arg = gengetopt_strdup ("coova-anonymous");
                    346:   args_info->radiussecret_orig = NULL;
                    347:   args_info->radiustimeout_arg = 30;
                    348:   args_info->radiustimeout_orig = NULL;
                    349:   args_info->radiusretry_arg = 6;
                    350:   args_info->radiusretry_orig = NULL;
                    351:   args_info->radiusretrysec_arg = 3;
                    352:   args_info->radiusretrysec_orig = NULL;
                    353:   args_info->radiusnasid_arg = gengetopt_strdup ("nas01");
                    354:   args_info->radiusnasid_orig = NULL;
                    355:   args_info->radiuslocationid_arg = NULL;
                    356:   args_info->radiuslocationid_orig = NULL;
                    357:   args_info->radiuslocationname_arg = NULL;
                    358:   args_info->radiuslocationname_orig = NULL;
                    359:   args_info->locationname_arg = NULL;
                    360:   args_info->locationname_orig = NULL;
                    361:   args_info->radiusnasporttype_arg = 19;
                    362:   args_info->radiusnasporttype_orig = NULL;
                    363:   args_info->coaport_arg = 0;
                    364:   args_info->coaport_orig = NULL;
                    365:   args_info->coanoipcheck_flag = 0;
                    366:   args_info->proxylisten_arg = NULL;
                    367:   args_info->proxylisten_orig = NULL;
                    368:   args_info->proxyport_arg = 0;
                    369:   args_info->proxyport_orig = NULL;
                    370:   args_info->proxyclient_arg = NULL;
                    371:   args_info->proxyclient_orig = NULL;
                    372:   args_info->proxysecret_arg = NULL;
                    373:   args_info->proxysecret_orig = NULL;
                    374:   args_info->dhcpif_arg = NULL;
                    375:   args_info->dhcpif_orig = NULL;
                    376:   args_info->dhcpmac_arg = NULL;
                    377:   args_info->dhcpmac_orig = NULL;
                    378:   args_info->dhcpradius_flag = 0;
                    379:   args_info->dhcpgateway_arg = NULL;
                    380:   args_info->dhcpgateway_orig = NULL;
                    381:   args_info->dhcpgatewayport_arg = 67;
                    382:   args_info->dhcpgatewayport_orig = NULL;
                    383:   args_info->dhcprelayagent_arg = NULL;
                    384:   args_info->dhcprelayagent_orig = NULL;
                    385:   args_info->lease_arg = 600;
                    386:   args_info->lease_orig = NULL;
                    387:   args_info->eapolenable_flag = 0;
                    388:   args_info->uamserver_arg = NULL;
                    389:   args_info->uamserver_orig = NULL;
                    390:   args_info->uamhomepage_arg = NULL;
                    391:   args_info->uamhomepage_orig = NULL;
                    392:   args_info->uamsecret_arg = NULL;
                    393:   args_info->uamsecret_orig = NULL;
                    394:   args_info->uamlisten_arg = NULL;
                    395:   args_info->uamlisten_orig = NULL;
                    396:   args_info->uamport_arg = 3990;
                    397:   args_info->uamport_orig = NULL;
                    398:   args_info->uamuiport_arg = 3991;
                    399:   args_info->uamuiport_orig = NULL;
                    400:   args_info->uamallowed_arg = NULL;
                    401:   args_info->uamallowed_orig = NULL;
                    402:   args_info->uamdomain_arg = NULL;
                    403:   args_info->uamdomain_orig = NULL;
                    404:   args_info->uamanydns_flag = 0;
                    405:   args_info->uamanyip_flag = 0;
                    406:   args_info->wisprlogin_arg = NULL;
                    407:   args_info->wisprlogin_orig = NULL;
                    408:   args_info->nouamsuccess_flag = 0;
                    409:   args_info->nouamwispr_flag = 0;
                    410:   args_info->uamlogoutip_arg = gengetopt_strdup ("1.1.1.1");
                    411:   args_info->uamlogoutip_orig = NULL;
                    412:   args_info->defsessiontimeout_arg = 0;
                    413:   args_info->defsessiontimeout_orig = NULL;
                    414:   args_info->defidletimeout_arg = 0;
                    415:   args_info->defidletimeout_orig = NULL;
                    416:   args_info->defbandwidthmaxdown_arg = 0;
                    417:   args_info->defbandwidthmaxdown_orig = NULL;
                    418:   args_info->defbandwidthmaxup_arg = 0;
                    419:   args_info->defbandwidthmaxup_orig = NULL;
                    420:   args_info->definteriminterval_arg = 300;
                    421:   args_info->definteriminterval_orig = NULL;
                    422:   args_info->macauth_flag = 0;
                    423:   args_info->macauthdeny_flag = 0;
                    424:   args_info->macallowed_arg = NULL;
                    425:   args_info->macallowed_orig = NULL;
                    426:   args_info->macsuffix_arg = NULL;
                    427:   args_info->macsuffix_orig = NULL;
                    428:   args_info->macpasswd_arg = NULL;
                    429:   args_info->macpasswd_orig = NULL;
                    430:   args_info->macallowlocal_flag = 0;
                    431:   args_info->wwwdir_arg = NULL;
                    432:   args_info->wwwdir_orig = NULL;
                    433:   args_info->wwwbin_arg = NULL;
                    434:   args_info->wwwbin_orig = NULL;
                    435:   args_info->uamui_arg = NULL;
                    436:   args_info->uamui_orig = NULL;
                    437:   args_info->adminuser_arg = gengetopt_strdup ("chillispot");
                    438:   args_info->adminuser_orig = NULL;
                    439:   args_info->adminpasswd_arg = gengetopt_strdup ("chillispot");
                    440:   args_info->adminpasswd_orig = NULL;
                    441:   args_info->nasmac_arg = NULL;
                    442:   args_info->nasmac_orig = NULL;
                    443:   args_info->nasip_arg = NULL;
                    444:   args_info->nasip_orig = NULL;
                    445:   args_info->ssid_arg = NULL;
                    446:   args_info->ssid_orig = NULL;
                    447:   args_info->vlan_arg = NULL;
                    448:   args_info->vlan_orig = NULL;
                    449:   args_info->cmdsocket_arg = NULL;
                    450:   args_info->cmdsocket_orig = NULL;
                    451:   args_info->radiusoriginalurl_flag = 0;
                    452:   args_info->swapoctets_flag = 0;
                    453:   args_info->usestatusfile_flag = 0;
                    454:   args_info->localusers_arg = NULL;
                    455:   args_info->localusers_orig = NULL;
                    456:   args_info->postauthproxy_arg = NULL;
                    457:   args_info->postauthproxy_orig = NULL;
                    458:   args_info->postauthproxyport_arg = 0;
                    459:   args_info->postauthproxyport_orig = NULL;
                    460:   args_info->wpaguests_flag = 0;
                    461:   args_info->openidauth_flag = 0;
                    462:   args_info->papalwaysok_flag = 0;
                    463:   args_info->chillixml_flag = 0;
                    464:   args_info->acctupdate_flag = 0;
                    465:   args_info->dnsparanoia_flag = 0;
                    466:   args_info->usetap_flag = 0;
                    467:   args_info->routeif_arg = NULL;
                    468:   args_info->routeif_orig = NULL;
                    469:   
                    470: }
                    471: 
                    472: static
                    473: void init_args_info(struct gengetopt_args_info *args_info)
                    474: {
                    475: 
                    476: 
                    477:   args_info->help_help = gengetopt_args_info_help[0] ;
                    478:   args_info->version_help = gengetopt_args_info_help[1] ;
                    479:   args_info->fg_help = gengetopt_args_info_help[2] ;
                    480:   args_info->debug_help = gengetopt_args_info_help[3] ;
                    481:   args_info->debugfacility_help = gengetopt_args_info_help[4] ;
                    482:   args_info->logfacility_help = gengetopt_args_info_help[5] ;
                    483:   args_info->conf_help = gengetopt_args_info_help[6] ;
                    484:   args_info->interval_help = gengetopt_args_info_help[7] ;
                    485:   args_info->pidfile_help = gengetopt_args_info_help[8] ;
                    486:   args_info->statedir_help = gengetopt_args_info_help[9] ;
                    487:   args_info->net_help = gengetopt_args_info_help[10] ;
                    488:   args_info->dhcpstart_help = gengetopt_args_info_help[11] ;
                    489:   args_info->dhcpend_help = gengetopt_args_info_help[12] ;
                    490:   args_info->dynip_help = gengetopt_args_info_help[13] ;
                    491:   args_info->nodynip_help = gengetopt_args_info_help[14] ;
                    492:   args_info->statip_help = gengetopt_args_info_help[15] ;
                    493:   args_info->dns1_help = gengetopt_args_info_help[16] ;
                    494:   args_info->dns2_help = gengetopt_args_info_help[17] ;
                    495:   args_info->domain_help = gengetopt_args_info_help[18] ;
                    496:   args_info->ipup_help = gengetopt_args_info_help[19] ;
                    497:   args_info->ipdown_help = gengetopt_args_info_help[20] ;
                    498:   args_info->conup_help = gengetopt_args_info_help[21] ;
                    499:   args_info->condown_help = gengetopt_args_info_help[22] ;
                    500:   args_info->txqlen_help = gengetopt_args_info_help[23] ;
                    501:   args_info->tundev_help = gengetopt_args_info_help[24] ;
                    502:   args_info->radiuslisten_help = gengetopt_args_info_help[25] ;
                    503:   args_info->radiusserver1_help = gengetopt_args_info_help[26] ;
                    504:   args_info->radiusserver2_help = gengetopt_args_info_help[27] ;
                    505:   args_info->radiusauthport_help = gengetopt_args_info_help[28] ;
                    506:   args_info->radiusacctport_help = gengetopt_args_info_help[29] ;
                    507:   args_info->radiussecret_help = gengetopt_args_info_help[30] ;
                    508:   args_info->radiustimeout_help = gengetopt_args_info_help[31] ;
                    509:   args_info->radiusretry_help = gengetopt_args_info_help[32] ;
                    510:   args_info->radiusretrysec_help = gengetopt_args_info_help[33] ;
                    511:   args_info->radiusnasid_help = gengetopt_args_info_help[34] ;
                    512:   args_info->radiuslocationid_help = gengetopt_args_info_help[35] ;
                    513:   args_info->radiuslocationname_help = gengetopt_args_info_help[36] ;
                    514:   args_info->locationname_help = gengetopt_args_info_help[37] ;
                    515:   args_info->radiusnasporttype_help = gengetopt_args_info_help[38] ;
                    516:   args_info->coaport_help = gengetopt_args_info_help[39] ;
                    517:   args_info->coanoipcheck_help = gengetopt_args_info_help[40] ;
                    518:   args_info->proxylisten_help = gengetopt_args_info_help[41] ;
                    519:   args_info->proxyport_help = gengetopt_args_info_help[42] ;
                    520:   args_info->proxyclient_help = gengetopt_args_info_help[43] ;
                    521:   args_info->proxysecret_help = gengetopt_args_info_help[44] ;
                    522:   args_info->dhcpif_help = gengetopt_args_info_help[45] ;
                    523:   args_info->dhcpmac_help = gengetopt_args_info_help[46] ;
                    524:   args_info->dhcpradius_help = gengetopt_args_info_help[47] ;
                    525:   args_info->dhcpgateway_help = gengetopt_args_info_help[48] ;
                    526:   args_info->dhcpgatewayport_help = gengetopt_args_info_help[49] ;
                    527:   args_info->dhcprelayagent_help = gengetopt_args_info_help[50] ;
                    528:   args_info->lease_help = gengetopt_args_info_help[51] ;
                    529:   args_info->eapolenable_help = gengetopt_args_info_help[52] ;
                    530:   args_info->uamserver_help = gengetopt_args_info_help[53] ;
                    531:   args_info->uamhomepage_help = gengetopt_args_info_help[54] ;
                    532:   args_info->uamsecret_help = gengetopt_args_info_help[55] ;
                    533:   args_info->uamlisten_help = gengetopt_args_info_help[56] ;
                    534:   args_info->uamport_help = gengetopt_args_info_help[57] ;
                    535:   args_info->uamuiport_help = gengetopt_args_info_help[58] ;
                    536:   args_info->uamallowed_help = gengetopt_args_info_help[59] ;
                    537:   args_info->uamallowed_min = -1;
                    538:   args_info->uamallowed_max = -1;
                    539:   args_info->uamdomain_help = gengetopt_args_info_help[60] ;
                    540:   args_info->uamdomain_min = -1;
                    541:   args_info->uamdomain_max = -1;
                    542:   args_info->uamanydns_help = gengetopt_args_info_help[61] ;
                    543:   args_info->uamanyip_help = gengetopt_args_info_help[62] ;
                    544:   args_info->wisprlogin_help = gengetopt_args_info_help[63] ;
                    545:   args_info->nouamsuccess_help = gengetopt_args_info_help[64] ;
                    546:   args_info->nouamwispr_help = gengetopt_args_info_help[65] ;
                    547:   args_info->uamlogoutip_help = gengetopt_args_info_help[66] ;
                    548:   args_info->defsessiontimeout_help = gengetopt_args_info_help[67] ;
                    549:   args_info->defidletimeout_help = gengetopt_args_info_help[68] ;
                    550:   args_info->defbandwidthmaxdown_help = gengetopt_args_info_help[69] ;
                    551:   args_info->defbandwidthmaxup_help = gengetopt_args_info_help[70] ;
                    552:   args_info->definteriminterval_help = gengetopt_args_info_help[71] ;
                    553:   args_info->macauth_help = gengetopt_args_info_help[72] ;
                    554:   args_info->macauthdeny_help = gengetopt_args_info_help[73] ;
                    555:   args_info->macallowed_help = gengetopt_args_info_help[74] ;
                    556:   args_info->macallowed_min = -1;
                    557:   args_info->macallowed_max = -1;
                    558:   args_info->macsuffix_help = gengetopt_args_info_help[75] ;
                    559:   args_info->macpasswd_help = gengetopt_args_info_help[76] ;
                    560:   args_info->macallowlocal_help = gengetopt_args_info_help[77] ;
                    561:   args_info->wwwdir_help = gengetopt_args_info_help[78] ;
                    562:   args_info->wwwbin_help = gengetopt_args_info_help[79] ;
                    563:   args_info->uamui_help = gengetopt_args_info_help[80] ;
                    564:   args_info->adminuser_help = gengetopt_args_info_help[81] ;
                    565:   args_info->adminpasswd_help = gengetopt_args_info_help[82] ;
                    566:   args_info->nasmac_help = gengetopt_args_info_help[83] ;
                    567:   args_info->nasip_help = gengetopt_args_info_help[84] ;
                    568:   args_info->ssid_help = gengetopt_args_info_help[85] ;
                    569:   args_info->vlan_help = gengetopt_args_info_help[86] ;
                    570:   args_info->cmdsocket_help = gengetopt_args_info_help[87] ;
                    571:   args_info->radiusoriginalurl_help = gengetopt_args_info_help[88] ;
                    572:   args_info->swapoctets_help = gengetopt_args_info_help[89] ;
                    573:   args_info->usestatusfile_help = gengetopt_args_info_help[90] ;
                    574:   args_info->localusers_help = gengetopt_args_info_help[91] ;
                    575:   args_info->postauthproxy_help = gengetopt_args_info_help[92] ;
                    576:   args_info->postauthproxyport_help = gengetopt_args_info_help[93] ;
                    577:   args_info->wpaguests_help = gengetopt_args_info_help[94] ;
                    578:   args_info->openidauth_help = gengetopt_args_info_help[95] ;
                    579:   args_info->papalwaysok_help = gengetopt_args_info_help[96] ;
                    580:   args_info->chillixml_help = gengetopt_args_info_help[97] ;
                    581:   args_info->acctupdate_help = gengetopt_args_info_help[98] ;
                    582:   args_info->dnsparanoia_help = gengetopt_args_info_help[99] ;
                    583:   args_info->usetap_help = gengetopt_args_info_help[100] ;
                    584:   args_info->routeif_help = gengetopt_args_info_help[101] ;
                    585:   
                    586: }
                    587: 
                    588: void
                    589: cmdline_parser_print_version (void)
                    590: {
                    591:   printf ("%s %s\n", CMDLINE_PARSER_PACKAGE, CMDLINE_PARSER_VERSION);
                    592: }
                    593: 
                    594: static void print_help_common(void) {
                    595:   cmdline_parser_print_version ();
                    596: 
                    597:   if (strlen(gengetopt_args_info_purpose) > 0)
                    598:     printf("\n%s\n", gengetopt_args_info_purpose);
                    599: 
                    600:   if (strlen(gengetopt_args_info_usage) > 0)
                    601:     printf("\n%s\n", gengetopt_args_info_usage);
                    602: 
                    603:   printf("\n");
                    604: 
                    605:   if (strlen(gengetopt_args_info_description) > 0)
                    606:     printf("%s\n", gengetopt_args_info_description);
                    607: }
                    608: 
                    609: void
                    610: cmdline_parser_print_help (void)
                    611: {
                    612:   int i = 0;
                    613:   print_help_common();
                    614:   while (gengetopt_args_info_help[i])
                    615:     printf("%s\n", gengetopt_args_info_help[i++]);
                    616: }
                    617: 
                    618: void
                    619: cmdline_parser_init (struct gengetopt_args_info *args_info)
                    620: {
                    621:   clear_given (args_info);
                    622:   clear_args (args_info);
                    623:   init_args_info (args_info);
                    624: }
                    625: 
                    626: void
                    627: cmdline_parser_params_init(struct cmdline_parser_params *params)
                    628: {
                    629:   if (params)
                    630:     { 
                    631:       params->override = 0;
                    632:       params->initialize = 1;
                    633:       params->check_required = 1;
                    634:       params->check_ambiguity = 0;
                    635:       params->print_errors = 1;
                    636:     }
                    637: }
                    638: 
                    639: struct cmdline_parser_params *
                    640: cmdline_parser_params_create(void)
                    641: {
                    642:   struct cmdline_parser_params *params = 
                    643:     (struct cmdline_parser_params *)malloc(sizeof(struct cmdline_parser_params));
                    644:   cmdline_parser_params_init(params);  
                    645:   return params;
                    646: }
                    647: 
                    648: static void
                    649: free_string_field (char **s)
                    650: {
                    651:   if (*s)
                    652:     {
                    653:       free (*s);
                    654:       *s = 0;
                    655:     }
                    656: }
                    657: 
                    658: /** @brief generic value variable */
                    659: union generic_value {
                    660:     int int_arg;
                    661:     long long_arg;
                    662:     char *string_arg;
                    663: };
                    664: 
                    665: /** @brief holds temporary values for multiple options */
                    666: struct generic_list
                    667: {
                    668:   union generic_value arg;
                    669:   char *orig;
                    670:   struct generic_list *next;
                    671: };
                    672: 
                    673: /**
                    674:  * @brief add a node at the head of the list 
                    675:  */
                    676: static void add_node(struct generic_list **list) {
                    677:   struct generic_list *new_node = (struct generic_list *) malloc (sizeof (struct generic_list));
                    678:   new_node->next = *list;
                    679:   *list = new_node;
                    680:   new_node->arg.string_arg = NULL;
                    681:   new_node->orig = NULL;
                    682: }
                    683: 
                    684: 
                    685: static void
                    686: free_multiple_string_field(unsigned int len, char ***arg, char ***orig)
                    687: {
                    688:   unsigned int i;
                    689:   if (*arg) {
                    690:     for (i = 0; i < len; ++i)
                    691:       {
                    692:         free_string_field(&((*arg)[i]));
                    693:         free_string_field(&((*orig)[i]));
                    694:       }
                    695:     free_string_field(&((*arg)[0])); /* free default string */
                    696: 
                    697:     free (*arg);
                    698:     *arg = 0;
                    699:     free (*orig);
                    700:     *orig = 0;
                    701:   }
                    702: }
                    703: 
                    704: static void
                    705: cmdline_parser_release (struct gengetopt_args_info *args_info)
                    706: {
                    707: 
                    708:   free_string_field (&(args_info->debugfacility_orig));
                    709:   free_string_field (&(args_info->logfacility_orig));
                    710:   free_string_field (&(args_info->conf_arg));
                    711:   free_string_field (&(args_info->conf_orig));
                    712:   free_string_field (&(args_info->interval_orig));
                    713:   free_string_field (&(args_info->pidfile_arg));
                    714:   free_string_field (&(args_info->pidfile_orig));
                    715:   free_string_field (&(args_info->statedir_arg));
                    716:   free_string_field (&(args_info->statedir_orig));
                    717:   free_string_field (&(args_info->net_arg));
                    718:   free_string_field (&(args_info->net_orig));
                    719:   free_string_field (&(args_info->dhcpstart_orig));
                    720:   free_string_field (&(args_info->dhcpend_orig));
                    721:   free_string_field (&(args_info->dynip_arg));
                    722:   free_string_field (&(args_info->dynip_orig));
                    723:   free_string_field (&(args_info->statip_arg));
                    724:   free_string_field (&(args_info->statip_orig));
                    725:   free_string_field (&(args_info->dns1_arg));
                    726:   free_string_field (&(args_info->dns1_orig));
                    727:   free_string_field (&(args_info->dns2_arg));
                    728:   free_string_field (&(args_info->dns2_orig));
                    729:   free_string_field (&(args_info->domain_arg));
                    730:   free_string_field (&(args_info->domain_orig));
                    731:   free_string_field (&(args_info->ipup_arg));
                    732:   free_string_field (&(args_info->ipup_orig));
                    733:   free_string_field (&(args_info->ipdown_arg));
                    734:   free_string_field (&(args_info->ipdown_orig));
                    735:   free_string_field (&(args_info->conup_arg));
                    736:   free_string_field (&(args_info->conup_orig));
                    737:   free_string_field (&(args_info->condown_arg));
                    738:   free_string_field (&(args_info->condown_orig));
                    739:   free_string_field (&(args_info->txqlen_orig));
                    740:   free_string_field (&(args_info->tundev_arg));
                    741:   free_string_field (&(args_info->tundev_orig));
                    742:   free_string_field (&(args_info->radiuslisten_arg));
                    743:   free_string_field (&(args_info->radiuslisten_orig));
                    744:   free_string_field (&(args_info->radiusserver1_arg));
                    745:   free_string_field (&(args_info->radiusserver1_orig));
                    746:   free_string_field (&(args_info->radiusserver2_arg));
                    747:   free_string_field (&(args_info->radiusserver2_orig));
                    748:   free_string_field (&(args_info->radiusauthport_orig));
                    749:   free_string_field (&(args_info->radiusacctport_orig));
                    750:   free_string_field (&(args_info->radiussecret_arg));
                    751:   free_string_field (&(args_info->radiussecret_orig));
                    752:   free_string_field (&(args_info->radiustimeout_orig));
                    753:   free_string_field (&(args_info->radiusretry_orig));
                    754:   free_string_field (&(args_info->radiusretrysec_orig));
                    755:   free_string_field (&(args_info->radiusnasid_arg));
                    756:   free_string_field (&(args_info->radiusnasid_orig));
                    757:   free_string_field (&(args_info->radiuslocationid_arg));
                    758:   free_string_field (&(args_info->radiuslocationid_orig));
                    759:   free_string_field (&(args_info->radiuslocationname_arg));
                    760:   free_string_field (&(args_info->radiuslocationname_orig));
                    761:   free_string_field (&(args_info->locationname_arg));
                    762:   free_string_field (&(args_info->locationname_orig));
                    763:   free_string_field (&(args_info->radiusnasporttype_orig));
                    764:   free_string_field (&(args_info->coaport_orig));
                    765:   free_string_field (&(args_info->proxylisten_arg));
                    766:   free_string_field (&(args_info->proxylisten_orig));
                    767:   free_string_field (&(args_info->proxyport_orig));
                    768:   free_string_field (&(args_info->proxyclient_arg));
                    769:   free_string_field (&(args_info->proxyclient_orig));
                    770:   free_string_field (&(args_info->proxysecret_arg));
                    771:   free_string_field (&(args_info->proxysecret_orig));
                    772:   free_string_field (&(args_info->dhcpif_arg));
                    773:   free_string_field (&(args_info->dhcpif_orig));
                    774:   free_string_field (&(args_info->dhcpmac_arg));
                    775:   free_string_field (&(args_info->dhcpmac_orig));
                    776:   free_string_field (&(args_info->dhcpgateway_arg));
                    777:   free_string_field (&(args_info->dhcpgateway_orig));
                    778:   free_string_field (&(args_info->dhcpgatewayport_orig));
                    779:   free_string_field (&(args_info->dhcprelayagent_arg));
                    780:   free_string_field (&(args_info->dhcprelayagent_orig));
                    781:   free_string_field (&(args_info->lease_orig));
                    782:   free_string_field (&(args_info->uamserver_arg));
                    783:   free_string_field (&(args_info->uamserver_orig));
                    784:   free_string_field (&(args_info->uamhomepage_arg));
                    785:   free_string_field (&(args_info->uamhomepage_orig));
                    786:   free_string_field (&(args_info->uamsecret_arg));
                    787:   free_string_field (&(args_info->uamsecret_orig));
                    788:   free_string_field (&(args_info->uamlisten_arg));
                    789:   free_string_field (&(args_info->uamlisten_orig));
                    790:   free_string_field (&(args_info->uamport_orig));
                    791:   free_string_field (&(args_info->uamuiport_orig));
                    792:   free_multiple_string_field (args_info->uamallowed_given, &(args_info->uamallowed_arg), &(args_info->uamallowed_orig));
                    793:   free_multiple_string_field (args_info->uamdomain_given, &(args_info->uamdomain_arg), &(args_info->uamdomain_orig));
                    794:   free_string_field (&(args_info->wisprlogin_arg));
                    795:   free_string_field (&(args_info->wisprlogin_orig));
                    796:   free_string_field (&(args_info->uamlogoutip_arg));
                    797:   free_string_field (&(args_info->uamlogoutip_orig));
                    798:   free_string_field (&(args_info->defsessiontimeout_orig));
                    799:   free_string_field (&(args_info->defidletimeout_orig));
                    800:   free_string_field (&(args_info->defbandwidthmaxdown_orig));
                    801:   free_string_field (&(args_info->defbandwidthmaxup_orig));
                    802:   free_string_field (&(args_info->definteriminterval_orig));
                    803:   free_multiple_string_field (args_info->macallowed_given, &(args_info->macallowed_arg), &(args_info->macallowed_orig));
                    804:   free_string_field (&(args_info->macsuffix_arg));
                    805:   free_string_field (&(args_info->macsuffix_orig));
                    806:   free_string_field (&(args_info->macpasswd_arg));
                    807:   free_string_field (&(args_info->macpasswd_orig));
                    808:   free_string_field (&(args_info->wwwdir_arg));
                    809:   free_string_field (&(args_info->wwwdir_orig));
                    810:   free_string_field (&(args_info->wwwbin_arg));
                    811:   free_string_field (&(args_info->wwwbin_orig));
                    812:   free_string_field (&(args_info->uamui_arg));
                    813:   free_string_field (&(args_info->uamui_orig));
                    814:   free_string_field (&(args_info->adminuser_arg));
                    815:   free_string_field (&(args_info->adminuser_orig));
                    816:   free_string_field (&(args_info->adminpasswd_arg));
                    817:   free_string_field (&(args_info->adminpasswd_orig));
                    818:   free_string_field (&(args_info->nasmac_arg));
                    819:   free_string_field (&(args_info->nasmac_orig));
                    820:   free_string_field (&(args_info->nasip_arg));
                    821:   free_string_field (&(args_info->nasip_orig));
                    822:   free_string_field (&(args_info->ssid_arg));
                    823:   free_string_field (&(args_info->ssid_orig));
                    824:   free_string_field (&(args_info->vlan_arg));
                    825:   free_string_field (&(args_info->vlan_orig));
                    826:   free_string_field (&(args_info->cmdsocket_arg));
                    827:   free_string_field (&(args_info->cmdsocket_orig));
                    828:   free_string_field (&(args_info->localusers_arg));
                    829:   free_string_field (&(args_info->localusers_orig));
                    830:   free_string_field (&(args_info->postauthproxy_arg));
                    831:   free_string_field (&(args_info->postauthproxy_orig));
                    832:   free_string_field (&(args_info->postauthproxyport_orig));
                    833:   free_string_field (&(args_info->routeif_arg));
                    834:   free_string_field (&(args_info->routeif_orig));
                    835:   
                    836:   
                    837: 
                    838:   clear_given (args_info);
                    839: }
                    840: 
                    841: 
                    842: static void
                    843: write_into_file(FILE *outfile, const char *opt, const char *arg, char *values[])
                    844: {
                    845:   if (arg) {
                    846:     fprintf(outfile, "%s=\"%s\"\n", opt, arg);
                    847:   } else {
                    848:     fprintf(outfile, "%s\n", opt);
                    849:   }
                    850: }
                    851: 
                    852: static void
                    853: write_multiple_into_file(FILE *outfile, int len, const char *opt, char **arg, char *values[])
                    854: {
                    855:   int i;
                    856:   
                    857:   for (i = 0; i < len; ++i)
                    858:     write_into_file(outfile, opt, (arg ? arg[i] : 0), values);
                    859: }
                    860: 
                    861: int
                    862: cmdline_parser_dump(FILE *outfile, struct gengetopt_args_info *args_info)
                    863: {
                    864:   int i = 0;
                    865: 
                    866:   if (!outfile)
                    867:     {
                    868:       fprintf (stderr, "%s: cannot dump options to stream\n", CMDLINE_PARSER_PACKAGE);
                    869:       return EXIT_FAILURE;
                    870:     }
                    871: 
                    872:   if (args_info->help_given)
                    873:     write_into_file(outfile, "help", 0, 0 );
                    874:   if (args_info->version_given)
                    875:     write_into_file(outfile, "version", 0, 0 );
                    876:   if (args_info->fg_given)
                    877:     write_into_file(outfile, "fg", 0, 0 );
                    878:   if (args_info->debug_given)
                    879:     write_into_file(outfile, "debug", 0, 0 );
                    880:   if (args_info->debugfacility_given)
                    881:     write_into_file(outfile, "debugfacility", args_info->debugfacility_orig, 0);
                    882:   if (args_info->logfacility_given)
                    883:     write_into_file(outfile, "logfacility", args_info->logfacility_orig, 0);
                    884:   if (args_info->conf_given)
                    885:     write_into_file(outfile, "conf", args_info->conf_orig, 0);
                    886:   if (args_info->interval_given)
                    887:     write_into_file(outfile, "interval", args_info->interval_orig, 0);
                    888:   if (args_info->pidfile_given)
                    889:     write_into_file(outfile, "pidfile", args_info->pidfile_orig, 0);
                    890:   if (args_info->statedir_given)
                    891:     write_into_file(outfile, "statedir", args_info->statedir_orig, 0);
                    892:   if (args_info->net_given)
                    893:     write_into_file(outfile, "net", args_info->net_orig, 0);
                    894:   if (args_info->dhcpstart_given)
                    895:     write_into_file(outfile, "dhcpstart", args_info->dhcpstart_orig, 0);
                    896:   if (args_info->dhcpend_given)
                    897:     write_into_file(outfile, "dhcpend", args_info->dhcpend_orig, 0);
                    898:   if (args_info->dynip_given)
                    899:     write_into_file(outfile, "dynip", args_info->dynip_orig, 0);
                    900:   if (args_info->nodynip_given)
                    901:     write_into_file(outfile, "nodynip", 0, 0 );
                    902:   if (args_info->statip_given)
                    903:     write_into_file(outfile, "statip", args_info->statip_orig, 0);
                    904:   if (args_info->dns1_given)
                    905:     write_into_file(outfile, "dns1", args_info->dns1_orig, 0);
                    906:   if (args_info->dns2_given)
                    907:     write_into_file(outfile, "dns2", args_info->dns2_orig, 0);
                    908:   if (args_info->domain_given)
                    909:     write_into_file(outfile, "domain", args_info->domain_orig, 0);
                    910:   if (args_info->ipup_given)
                    911:     write_into_file(outfile, "ipup", args_info->ipup_orig, 0);
                    912:   if (args_info->ipdown_given)
                    913:     write_into_file(outfile, "ipdown", args_info->ipdown_orig, 0);
                    914:   if (args_info->conup_given)
                    915:     write_into_file(outfile, "conup", args_info->conup_orig, 0);
                    916:   if (args_info->condown_given)
                    917:     write_into_file(outfile, "condown", args_info->condown_orig, 0);
                    918:   if (args_info->txqlen_given)
                    919:     write_into_file(outfile, "txqlen", args_info->txqlen_orig, 0);
                    920:   if (args_info->tundev_given)
                    921:     write_into_file(outfile, "tundev", args_info->tundev_orig, 0);
                    922:   if (args_info->radiuslisten_given)
                    923:     write_into_file(outfile, "radiuslisten", args_info->radiuslisten_orig, 0);
                    924:   if (args_info->radiusserver1_given)
                    925:     write_into_file(outfile, "radiusserver1", args_info->radiusserver1_orig, 0);
                    926:   if (args_info->radiusserver2_given)
                    927:     write_into_file(outfile, "radiusserver2", args_info->radiusserver2_orig, 0);
                    928:   if (args_info->radiusauthport_given)
                    929:     write_into_file(outfile, "radiusauthport", args_info->radiusauthport_orig, 0);
                    930:   if (args_info->radiusacctport_given)
                    931:     write_into_file(outfile, "radiusacctport", args_info->radiusacctport_orig, 0);
                    932:   if (args_info->radiussecret_given)
                    933:     write_into_file(outfile, "radiussecret", args_info->radiussecret_orig, 0);
                    934:   if (args_info->radiustimeout_given)
                    935:     write_into_file(outfile, "radiustimeout", args_info->radiustimeout_orig, 0);
                    936:   if (args_info->radiusretry_given)
                    937:     write_into_file(outfile, "radiusretry", args_info->radiusretry_orig, 0);
                    938:   if (args_info->radiusretrysec_given)
                    939:     write_into_file(outfile, "radiusretrysec", args_info->radiusretrysec_orig, 0);
                    940:   if (args_info->radiusnasid_given)
                    941:     write_into_file(outfile, "radiusnasid", args_info->radiusnasid_orig, 0);
                    942:   if (args_info->radiuslocationid_given)
                    943:     write_into_file(outfile, "radiuslocationid", args_info->radiuslocationid_orig, 0);
                    944:   if (args_info->radiuslocationname_given)
                    945:     write_into_file(outfile, "radiuslocationname", args_info->radiuslocationname_orig, 0);
                    946:   if (args_info->locationname_given)
                    947:     write_into_file(outfile, "locationname", args_info->locationname_orig, 0);
                    948:   if (args_info->radiusnasporttype_given)
                    949:     write_into_file(outfile, "radiusnasporttype", args_info->radiusnasporttype_orig, 0);
                    950:   if (args_info->coaport_given)
                    951:     write_into_file(outfile, "coaport", args_info->coaport_orig, 0);
                    952:   if (args_info->coanoipcheck_given)
                    953:     write_into_file(outfile, "coanoipcheck", 0, 0 );
                    954:   if (args_info->proxylisten_given)
                    955:     write_into_file(outfile, "proxylisten", args_info->proxylisten_orig, 0);
                    956:   if (args_info->proxyport_given)
                    957:     write_into_file(outfile, "proxyport", args_info->proxyport_orig, 0);
                    958:   if (args_info->proxyclient_given)
                    959:     write_into_file(outfile, "proxyclient", args_info->proxyclient_orig, 0);
                    960:   if (args_info->proxysecret_given)
                    961:     write_into_file(outfile, "proxysecret", args_info->proxysecret_orig, 0);
                    962:   if (args_info->dhcpif_given)
                    963:     write_into_file(outfile, "dhcpif", args_info->dhcpif_orig, 0);
                    964:   if (args_info->dhcpmac_given)
                    965:     write_into_file(outfile, "dhcpmac", args_info->dhcpmac_orig, 0);
                    966:   if (args_info->dhcpradius_given)
                    967:     write_into_file(outfile, "dhcpradius", 0, 0 );
                    968:   if (args_info->dhcpgateway_given)
                    969:     write_into_file(outfile, "dhcpgateway", args_info->dhcpgateway_orig, 0);
                    970:   if (args_info->dhcpgatewayport_given)
                    971:     write_into_file(outfile, "dhcpgatewayport", args_info->dhcpgatewayport_orig, 0);
                    972:   if (args_info->dhcprelayagent_given)
                    973:     write_into_file(outfile, "dhcprelayagent", args_info->dhcprelayagent_orig, 0);
                    974:   if (args_info->lease_given)
                    975:     write_into_file(outfile, "lease", args_info->lease_orig, 0);
                    976:   if (args_info->eapolenable_given)
                    977:     write_into_file(outfile, "eapolenable", 0, 0 );
                    978:   if (args_info->uamserver_given)
                    979:     write_into_file(outfile, "uamserver", args_info->uamserver_orig, 0);
                    980:   if (args_info->uamhomepage_given)
                    981:     write_into_file(outfile, "uamhomepage", args_info->uamhomepage_orig, 0);
                    982:   if (args_info->uamsecret_given)
                    983:     write_into_file(outfile, "uamsecret", args_info->uamsecret_orig, 0);
                    984:   if (args_info->uamlisten_given)
                    985:     write_into_file(outfile, "uamlisten", args_info->uamlisten_orig, 0);
                    986:   if (args_info->uamport_given)
                    987:     write_into_file(outfile, "uamport", args_info->uamport_orig, 0);
                    988:   if (args_info->uamuiport_given)
                    989:     write_into_file(outfile, "uamuiport", args_info->uamuiport_orig, 0);
                    990:   write_multiple_into_file(outfile, args_info->uamallowed_given, "uamallowed", args_info->uamallowed_orig, 0);
                    991:   write_multiple_into_file(outfile, args_info->uamdomain_given, "uamdomain", args_info->uamdomain_orig, 0);
                    992:   if (args_info->uamanydns_given)
                    993:     write_into_file(outfile, "uamanydns", 0, 0 );
                    994:   if (args_info->uamanyip_given)
                    995:     write_into_file(outfile, "uamanyip", 0, 0 );
                    996:   if (args_info->wisprlogin_given)
                    997:     write_into_file(outfile, "wisprlogin", args_info->wisprlogin_orig, 0);
                    998:   if (args_info->nouamsuccess_given)
                    999:     write_into_file(outfile, "nouamsuccess", 0, 0 );
                   1000:   if (args_info->nouamwispr_given)
                   1001:     write_into_file(outfile, "nouamwispr", 0, 0 );
                   1002:   if (args_info->uamlogoutip_given)
                   1003:     write_into_file(outfile, "uamlogoutip", args_info->uamlogoutip_orig, 0);
                   1004:   if (args_info->defsessiontimeout_given)
                   1005:     write_into_file(outfile, "defsessiontimeout", args_info->defsessiontimeout_orig, 0);
                   1006:   if (args_info->defidletimeout_given)
                   1007:     write_into_file(outfile, "defidletimeout", args_info->defidletimeout_orig, 0);
                   1008:   if (args_info->defbandwidthmaxdown_given)
                   1009:     write_into_file(outfile, "defbandwidthmaxdown", args_info->defbandwidthmaxdown_orig, 0);
                   1010:   if (args_info->defbandwidthmaxup_given)
                   1011:     write_into_file(outfile, "defbandwidthmaxup", args_info->defbandwidthmaxup_orig, 0);
                   1012:   if (args_info->definteriminterval_given)
                   1013:     write_into_file(outfile, "definteriminterval", args_info->definteriminterval_orig, 0);
                   1014:   if (args_info->macauth_given)
                   1015:     write_into_file(outfile, "macauth", 0, 0 );
                   1016:   if (args_info->macauthdeny_given)
                   1017:     write_into_file(outfile, "macauthdeny", 0, 0 );
                   1018:   write_multiple_into_file(outfile, args_info->macallowed_given, "macallowed", args_info->macallowed_orig, 0);
                   1019:   if (args_info->macsuffix_given)
                   1020:     write_into_file(outfile, "macsuffix", args_info->macsuffix_orig, 0);
                   1021:   if (args_info->macpasswd_given)
                   1022:     write_into_file(outfile, "macpasswd", args_info->macpasswd_orig, 0);
                   1023:   if (args_info->macallowlocal_given)
                   1024:     write_into_file(outfile, "macallowlocal", 0, 0 );
                   1025:   if (args_info->wwwdir_given)
                   1026:     write_into_file(outfile, "wwwdir", args_info->wwwdir_orig, 0);
                   1027:   if (args_info->wwwbin_given)
                   1028:     write_into_file(outfile, "wwwbin", args_info->wwwbin_orig, 0);
                   1029:   if (args_info->uamui_given)
                   1030:     write_into_file(outfile, "uamui", args_info->uamui_orig, 0);
                   1031:   if (args_info->adminuser_given)
                   1032:     write_into_file(outfile, "adminuser", args_info->adminuser_orig, 0);
                   1033:   if (args_info->adminpasswd_given)
                   1034:     write_into_file(outfile, "adminpasswd", args_info->adminpasswd_orig, 0);
                   1035:   if (args_info->nasmac_given)
                   1036:     write_into_file(outfile, "nasmac", args_info->nasmac_orig, 0);
                   1037:   if (args_info->nasip_given)
                   1038:     write_into_file(outfile, "nasip", args_info->nasip_orig, 0);
                   1039:   if (args_info->ssid_given)
                   1040:     write_into_file(outfile, "ssid", args_info->ssid_orig, 0);
                   1041:   if (args_info->vlan_given)
                   1042:     write_into_file(outfile, "vlan", args_info->vlan_orig, 0);
                   1043:   if (args_info->cmdsocket_given)
                   1044:     write_into_file(outfile, "cmdsocket", args_info->cmdsocket_orig, 0);
                   1045:   if (args_info->radiusoriginalurl_given)
                   1046:     write_into_file(outfile, "radiusoriginalurl", 0, 0 );
                   1047:   if (args_info->swapoctets_given)
                   1048:     write_into_file(outfile, "swapoctets", 0, 0 );
                   1049:   if (args_info->usestatusfile_given)
                   1050:     write_into_file(outfile, "usestatusfile", 0, 0 );
                   1051:   if (args_info->localusers_given)
                   1052:     write_into_file(outfile, "localusers", args_info->localusers_orig, 0);
                   1053:   if (args_info->postauthproxy_given)
                   1054:     write_into_file(outfile, "postauthproxy", args_info->postauthproxy_orig, 0);
                   1055:   if (args_info->postauthproxyport_given)
                   1056:     write_into_file(outfile, "postauthproxyport", args_info->postauthproxyport_orig, 0);
                   1057:   if (args_info->wpaguests_given)
                   1058:     write_into_file(outfile, "wpaguests", 0, 0 );
                   1059:   if (args_info->openidauth_given)
                   1060:     write_into_file(outfile, "openidauth", 0, 0 );
                   1061:   if (args_info->papalwaysok_given)
                   1062:     write_into_file(outfile, "papalwaysok", 0, 0 );
                   1063:   if (args_info->chillixml_given)
                   1064:     write_into_file(outfile, "chillixml", 0, 0 );
                   1065:   if (args_info->acctupdate_given)
                   1066:     write_into_file(outfile, "acctupdate", 0, 0 );
                   1067:   if (args_info->dnsparanoia_given)
                   1068:     write_into_file(outfile, "dnsparanoia", 0, 0 );
                   1069:   if (args_info->usetap_given)
                   1070:     write_into_file(outfile, "usetap", 0, 0 );
                   1071:   if (args_info->routeif_given)
                   1072:     write_into_file(outfile, "routeif", args_info->routeif_orig, 0);
                   1073:   
                   1074: 
                   1075:   i = EXIT_SUCCESS;
                   1076:   return i;
                   1077: }
                   1078: 
                   1079: int
                   1080: cmdline_parser_file_save(const char *filename, struct gengetopt_args_info *args_info)
                   1081: {
                   1082:   FILE *outfile;
                   1083:   int i = 0;
                   1084: 
                   1085:   outfile = fopen(filename, "w");
                   1086: 
                   1087:   if (!outfile)
                   1088:     {
                   1089:       fprintf (stderr, "%s: cannot open file for writing: %s\n", CMDLINE_PARSER_PACKAGE, filename);
                   1090:       return EXIT_FAILURE;
                   1091:     }
                   1092: 
                   1093:   i = cmdline_parser_dump(outfile, args_info);
                   1094:   fclose (outfile);
                   1095: 
                   1096:   return i;
                   1097: }
                   1098: 
                   1099: void
                   1100: cmdline_parser_free (struct gengetopt_args_info *args_info)
                   1101: {
                   1102:   cmdline_parser_release (args_info);
                   1103: }
                   1104: 
                   1105: /** @brief replacement of strdup, which is not standard */
                   1106: char *
                   1107: gengetopt_strdup (const char *s)
                   1108: {
                   1109:   char *result = NULL;
                   1110:   if (!s)
                   1111:     return result;
                   1112: 
                   1113:   result = (char*)malloc(strlen(s) + 1);
                   1114:   if (result == (char*)0)
                   1115:     return (char*)0;
                   1116:   strcpy(result, s);
                   1117:   return result;
                   1118: }
                   1119: 
                   1120: static char *
                   1121: get_multiple_arg_token(const char *arg)
                   1122: {
                   1123:   char *tok, *ret;
                   1124:   size_t len, num_of_escape, i, j;
                   1125: 
                   1126:   if (!arg)
                   1127:     return NULL;
                   1128: 
                   1129:   tok = strchr (arg, ',');
                   1130:   num_of_escape = 0;
                   1131: 
                   1132:   /* make sure it is not escaped */
                   1133:   while (tok)
                   1134:     {
                   1135:       if (*(tok-1) == '\\')
                   1136:         {
                   1137:           /* find the next one */
                   1138:           tok = strchr (tok+1, ',');
                   1139:           ++num_of_escape;
                   1140:         }
                   1141:       else
                   1142:         break;
                   1143:     }
                   1144: 
                   1145:   if (tok)
                   1146:     len = (size_t)(tok - arg + 1);
                   1147:   else
                   1148:     len = strlen (arg) + 1;
                   1149: 
                   1150:   len -= num_of_escape;
                   1151: 
                   1152:   ret = (char *) malloc (len);
                   1153: 
                   1154:   i = 0;
                   1155:   j = 0;
                   1156:   while (arg[i] && (j < len-1))
                   1157:     {
                   1158:       if (arg[i] == '\\' && 
                   1159:          arg[ i + 1 ] && 
                   1160:          arg[ i + 1 ] == ',')
                   1161:         ++i;
                   1162: 
                   1163:       ret[j++] = arg[i++];
                   1164:     }
                   1165: 
                   1166:   ret[len-1] = '\0';
                   1167: 
                   1168:   return ret;
                   1169: }
                   1170: 
                   1171: static char *
                   1172: get_multiple_arg_token_next(const char *arg)
                   1173: {
                   1174:   char *tok;
                   1175: 
                   1176:   if (!arg)
                   1177:     return NULL;
                   1178: 
                   1179:   tok = strchr (arg, ',');
                   1180: 
                   1181:   /* make sure it is not escaped */
                   1182:   while (tok)
                   1183:     {
                   1184:       if (*(tok-1) == '\\')
                   1185:         {
                   1186:           /* find the next one */
                   1187:           tok = strchr (tok+1, ',');
                   1188:         }
                   1189:       else
                   1190:         break;
                   1191:     }
                   1192: 
                   1193:   if (! tok || strlen(tok) == 1)
                   1194:     return 0;
                   1195: 
                   1196:   return tok+1;
                   1197: }
                   1198: 
                   1199: static int
                   1200: check_multiple_option_occurrences(const char *prog_name, unsigned int option_given, int min, int max, const char *option_desc);
                   1201: 
                   1202: int
                   1203: check_multiple_option_occurrences(const char *prog_name, unsigned int option_given, int min, int max, const char *option_desc)
                   1204: {
                   1205:   int error = 0;
                   1206: 
                   1207:   if (option_given && ! (min < 0 && max < 0))
                   1208:     {
                   1209:       if (min >= 0 && max >= 0)
                   1210:         {
                   1211:           if (min == max)
                   1212:             {
                   1213:               /* specific occurrences */
                   1214:               if (option_given != min)
                   1215:                 {
                   1216:                   fprintf (stderr, "%s: %s option occurrences must be %d\n",
                   1217:                     prog_name, option_desc, min);
                   1218:                   error = 1;
                   1219:                 }
                   1220:             }
                   1221:           else if (option_given < min
                   1222:               || option_given > max)
                   1223:             {
                   1224:               /* range occurrences */
                   1225:               fprintf (stderr, "%s: %s option occurrences must be between %d and %d\n",
                   1226:                 prog_name, option_desc, min, max);
                   1227:               error = 1;
                   1228:             }
                   1229:         }
                   1230:       else if (min >= 0)
                   1231:         {
                   1232:           /* at least check */
                   1233:           if (option_given < min)
                   1234:             {
                   1235:               fprintf (stderr, "%s: %s option occurrences must be at least %d\n",
                   1236:                 prog_name, option_desc, min);
                   1237:               error = 1;
                   1238:             }
                   1239:         }
                   1240:       else if (max >= 0)
                   1241:         {
                   1242:           /* at most check */
                   1243:           if (option_given > max)
                   1244:             {
                   1245:               fprintf (stderr, "%s: %s option occurrences must be at most %d\n",
                   1246:                 prog_name, option_desc, max);
                   1247:               error = 1;
                   1248:             }
                   1249:         }
                   1250:     }
                   1251:     
                   1252:   return error;
                   1253: }
                   1254: int
                   1255: cmdline_parser (int argc, char * const *argv, struct gengetopt_args_info *args_info)
                   1256: {
                   1257:   return cmdline_parser2 (argc, argv, args_info, 0, 1, 1);
                   1258: }
                   1259: 
                   1260: int
                   1261: cmdline_parser_ext (int argc, char * const *argv, struct gengetopt_args_info *args_info,
                   1262:                    struct cmdline_parser_params *params)
                   1263: {
                   1264:   int result;
                   1265:   result = cmdline_parser_internal (argc, argv, args_info, params, NULL);
                   1266: 
                   1267:   if (result == EXIT_FAILURE)
                   1268:     {
                   1269:       cmdline_parser_free (args_info);
                   1270:       exit (EXIT_FAILURE);
                   1271:     }
                   1272:   
                   1273:   return result;
                   1274: }
                   1275: 
                   1276: int
                   1277: cmdline_parser2 (int argc, char * const *argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required)
                   1278: {
                   1279:   int result;
                   1280:   struct cmdline_parser_params params;
                   1281:   
                   1282:   params.override = override;
                   1283:   params.initialize = initialize;
                   1284:   params.check_required = check_required;
                   1285:   params.check_ambiguity = 0;
                   1286:   params.print_errors = 1;
                   1287: 
                   1288:   result = cmdline_parser_internal (argc, argv, args_info, &params, NULL);
                   1289: 
                   1290:   if (result == EXIT_FAILURE)
                   1291:     {
                   1292:       cmdline_parser_free (args_info);
                   1293:       exit (EXIT_FAILURE);
                   1294:     }
                   1295:   
                   1296:   return result;
                   1297: }
                   1298: 
                   1299: int
                   1300: cmdline_parser_required (struct gengetopt_args_info *args_info, const char *prog_name)
                   1301: {
                   1302:   int result = EXIT_SUCCESS;
                   1303: 
                   1304:   if (cmdline_parser_required2(args_info, prog_name, NULL) > 0)
                   1305:     result = EXIT_FAILURE;
                   1306: 
                   1307:   if (result == EXIT_FAILURE)
                   1308:     {
                   1309:       cmdline_parser_free (args_info);
                   1310:       exit (EXIT_FAILURE);
                   1311:     }
                   1312:   
                   1313:   return result;
                   1314: }
                   1315: 
                   1316: int
                   1317: cmdline_parser_required2 (struct gengetopt_args_info *args_info, const char *prog_name, const char *additional_error)
                   1318: {
                   1319:   int error = 0;
                   1320: 
                   1321:   /* checks for required options */
                   1322:   if (check_multiple_option_occurrences(prog_name, args_info->uamallowed_given, args_info->uamallowed_min, args_info->uamallowed_max, "'--uamallowed'"))
                   1323:      error = 1;
                   1324:   
                   1325:   if (check_multiple_option_occurrences(prog_name, args_info->uamdomain_given, args_info->uamdomain_min, args_info->uamdomain_max, "'--uamdomain'"))
                   1326:      error = 1;
                   1327:   
                   1328:   if (check_multiple_option_occurrences(prog_name, args_info->macallowed_given, args_info->macallowed_min, args_info->macallowed_max, "'--macallowed'"))
                   1329:      error = 1;
                   1330:   
                   1331:   
                   1332:   /* checks for dependences among options */
                   1333: 
                   1334:   return error;
                   1335: }
                   1336: 
                   1337: 
                   1338: static char *package_name = 0;
                   1339: 
                   1340: /**
                   1341:  * @brief updates an option
                   1342:  * @param field the generic pointer to the field to update
                   1343:  * @param orig_field the pointer to the orig field
                   1344:  * @param field_given the pointer to the number of occurrence of this option
                   1345:  * @param prev_given the pointer to the number of occurrence already seen
                   1346:  * @param value the argument for this option (if null no arg was specified)
                   1347:  * @param possible_values the possible values for this option (if specified)
                   1348:  * @param default_value the default value (in case the option only accepts fixed values)
                   1349:  * @param arg_type the type of this option
                   1350:  * @param check_ambiguity @see cmdline_parser_params.check_ambiguity
                   1351:  * @param override @see cmdline_parser_params.override
                   1352:  * @param no_free whether to free a possible previous value
                   1353:  * @param multiple_option whether this is a multiple option
                   1354:  * @param long_opt the corresponding long option
                   1355:  * @param short_opt the corresponding short option (or '-' if none)
                   1356:  * @param additional_error possible further error specification
                   1357:  */
                   1358: static
                   1359: int update_arg(void *field, char **orig_field,
                   1360:                unsigned int *field_given, unsigned int *prev_given, 
                   1361:                char *value, char *possible_values[], const char *default_value,
                   1362:                cmdline_parser_arg_type arg_type,
                   1363:                int check_ambiguity, int override,
                   1364:                int no_free, int multiple_option,
                   1365:                const char *long_opt, char short_opt,
                   1366:                const char *additional_error)
                   1367: {
                   1368:   char *stop_char = 0;
                   1369:   const char *val = value;
                   1370:   int found;
                   1371:   char **string_field;
                   1372: 
                   1373:   stop_char = 0;
                   1374:   found = 0;
                   1375: 
                   1376:   if (!multiple_option && prev_given && (*prev_given || (check_ambiguity && *field_given)))
                   1377:     {
                   1378:       if (short_opt != '-')
                   1379:         fprintf (stderr, "%s: `--%s' (`-%c') option given more than once%s\n", 
                   1380:                package_name, long_opt, short_opt,
                   1381:                (additional_error ? additional_error : ""));
                   1382:       else
                   1383:         fprintf (stderr, "%s: `--%s' option given more than once%s\n", 
                   1384:                package_name, long_opt,
                   1385:                (additional_error ? additional_error : ""));
                   1386:       return 1; /* failure */
                   1387:     }
                   1388: 
                   1389:     
                   1390:   if (field_given && *field_given && ! override)
                   1391:     return 0;
                   1392:   if (prev_given)
                   1393:     (*prev_given)++;
                   1394:   if (field_given)
                   1395:     (*field_given)++;
                   1396:   if (possible_values)
                   1397:     val = possible_values[found];
                   1398: 
                   1399:   switch(arg_type) {
                   1400:   case ARG_FLAG:
                   1401:     *((int *)field) = !*((int *)field);
                   1402:     break;
                   1403:   case ARG_INT:
                   1404:     if (val) *((int *)field) = strtol (val, &stop_char, 0);
                   1405:     break;
                   1406:   case ARG_LONG:
                   1407:     if (val) *((long *)field) = (long)strtol (val, &stop_char, 0);
                   1408:     break;
                   1409:   case ARG_STRING:
                   1410:     if (val) {
                   1411:       string_field = (char **)field;
                   1412:       if (!no_free && *string_field)
                   1413:         free (*string_field); /* free previous string */
                   1414:       *string_field = gengetopt_strdup (val);
                   1415:     }
                   1416:     break;
                   1417:   default:
                   1418:     break;
                   1419:   };
                   1420: 
                   1421:   /* check numeric conversion */
                   1422:   switch(arg_type) {
                   1423:   case ARG_INT:
                   1424:   case ARG_LONG:
                   1425:     if (val && !(stop_char && *stop_char == '\0')) {
                   1426:       fprintf(stderr, "%s: invalid numeric value: %s\n", package_name, val);
                   1427:       return 1; /* failure */
                   1428:     }
                   1429:     break;
                   1430:   default:
                   1431:     ;
                   1432:   };
                   1433: 
                   1434:   /* store the original value */
                   1435:   switch(arg_type) {
                   1436:   case ARG_NO:
                   1437:   case ARG_FLAG:
                   1438:     break;
                   1439:   default:
                   1440:     if (value && orig_field) {
                   1441:       if (no_free) {
                   1442:         *orig_field = value;
                   1443:       } else {
                   1444:         if (*orig_field)
                   1445:           free (*orig_field); /* free previous string */
                   1446:         *orig_field = gengetopt_strdup (value);
                   1447:       }
                   1448:     }
                   1449:   };
                   1450: 
                   1451:   return 0; /* OK */
                   1452: }
                   1453: 
                   1454: /**
                   1455:  * @brief store information about a multiple option in a temporary list
                   1456:  * @param list where to (temporarily) store multiple options
                   1457:  */
                   1458: static
                   1459: int update_multiple_arg_temp(struct generic_list **list,
                   1460:                unsigned int *prev_given, const char *val,
                   1461:                char *possible_values[], const char *default_value,
                   1462:                cmdline_parser_arg_type arg_type,
                   1463:                const char *long_opt, char short_opt,
                   1464:                const char *additional_error)
                   1465: {
                   1466:   char *multi_token, *multi_next; /* store single arguments */
                   1467: 
                   1468:   if (arg_type == ARG_NO) {
                   1469:     (*prev_given)++;
                   1470:     return 0; /* OK */
                   1471:   }
                   1472: 
                   1473:   multi_token = get_multiple_arg_token(val);
                   1474:   multi_next = get_multiple_arg_token_next (val);
                   1475: 
                   1476:   while (1)
                   1477:     {
                   1478:       add_node (list);
                   1479:       if (update_arg((void *)&((*list)->arg), &((*list)->orig), 0,
                   1480:           prev_given, multi_token, possible_values, default_value, 
                   1481:           arg_type, 0, 1, 1, 1, long_opt, short_opt, additional_error)) {
                   1482:         if (multi_token) free(multi_token);
                   1483:         return 1; /* failure */
                   1484:       }
                   1485: 
                   1486:       if (multi_next)
                   1487:         {
                   1488:           multi_token = get_multiple_arg_token(multi_next);
                   1489:           multi_next = get_multiple_arg_token_next (multi_next);
                   1490:         }
                   1491:       else
                   1492:         break;
                   1493:     }
                   1494: 
                   1495:   return 0; /* OK */
                   1496: }
                   1497: 
                   1498: /**
                   1499:  * @brief free the passed list (including possible string argument)
                   1500:  */
                   1501: static
                   1502: void free_list(struct generic_list *list, short string_arg)
                   1503: {
                   1504:   if (list) {
                   1505:     struct generic_list *tmp;
                   1506:     while (list)
                   1507:       {
                   1508:         tmp = list;
                   1509:         if (string_arg && list->arg.string_arg)
                   1510:           free (list->arg.string_arg);
                   1511:         if (list->orig)
                   1512:           free (list->orig);
                   1513:         list = list->next;
                   1514:         free (tmp);
                   1515:       }
                   1516:   }
                   1517: }
                   1518: 
                   1519: /**
                   1520:  * @brief updates a multiple option starting from the passed list
                   1521:  */
                   1522: static
                   1523: void update_multiple_arg(void *field, char ***orig_field,
                   1524:                unsigned int field_given, unsigned int prev_given, union generic_value *default_value,
                   1525:                cmdline_parser_arg_type arg_type,
                   1526:                struct generic_list *list)
                   1527: {
                   1528:   int i;
                   1529:   struct generic_list *tmp;
                   1530: 
                   1531:   if (prev_given && list) {
                   1532:     *orig_field = (char **) realloc (*orig_field, (field_given + prev_given) * sizeof (char *));
                   1533: 
                   1534:     switch(arg_type) {
                   1535:     case ARG_INT:
                   1536:       *((int **)field) = (int *)realloc (*((int **)field), (field_given + prev_given) * sizeof (int)); break;
                   1537:     case ARG_LONG:
                   1538:       *((long **)field) = (long *)realloc (*((long **)field), (field_given + prev_given) * sizeof (long)); break;
                   1539:     case ARG_STRING:
                   1540:       *((char ***)field) = (char **)realloc (*((char ***)field), (field_given + prev_given) * sizeof (char *)); break;
                   1541:     default:
                   1542:       break;
                   1543:     };
                   1544:     
                   1545:     for (i = (prev_given - 1); i >= 0; --i)
                   1546:       {
                   1547:         tmp = list;
                   1548:         
                   1549:         switch(arg_type) {
                   1550:         case ARG_INT:
                   1551:           (*((int **)field))[i + field_given] = tmp->arg.int_arg; break;
                   1552:         case ARG_LONG:
                   1553:           (*((long **)field))[i + field_given] = tmp->arg.long_arg; break;
                   1554:         case ARG_STRING:
                   1555:           (*((char ***)field))[i + field_given] = tmp->arg.string_arg; break;
                   1556:         default:
                   1557:           break;
                   1558:         }        
                   1559:         (*orig_field) [i + field_given] = list->orig;
                   1560:         list = list->next;
                   1561:         free (tmp);
                   1562:       }
                   1563:   } else { /* set the default value */
                   1564:     if (default_value && ! field_given) {
                   1565:       switch(arg_type) {
                   1566:       case ARG_INT:
                   1567:         if (! *((int **)field)) {
                   1568:           *((int **)field) = (int *)malloc (sizeof (int));
                   1569:           (*((int **)field))[0] = default_value->int_arg; 
                   1570:         }
                   1571:         break;
                   1572:       case ARG_LONG:
                   1573:         if (! *((long **)field)) {
                   1574:           *((long **)field) = (long *)malloc (sizeof (long));
                   1575:           (*((long **)field))[0] = default_value->long_arg;
                   1576:         }
                   1577:         break;
                   1578:       case ARG_STRING:
                   1579:         if (! *((char ***)field)) {
                   1580:           *((char ***)field) = (char **)malloc (sizeof (char *));
                   1581:           (*((char ***)field))[0] = gengetopt_strdup(default_value->string_arg);
                   1582:         }
                   1583:         break;
                   1584:       default: break;
                   1585:       }
                   1586:       if (!(*orig_field)) {
                   1587:         *orig_field = (char **) malloc (sizeof (char *));
                   1588:         (*orig_field)[0] = NULL;
                   1589:       }
                   1590:     }
                   1591:   }
                   1592: }
                   1593: 
                   1594: int
                   1595: cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_info *args_info,
                   1596:                         struct cmdline_parser_params *params, const char *additional_error)
                   1597: {
                   1598:   int c;       /* Character of the parsed option.  */
                   1599: 
                   1600:   struct generic_list * uamallowed_list = NULL;
                   1601:   struct generic_list * uamdomain_list = NULL;
                   1602:   struct generic_list * macallowed_list = NULL;
                   1603:   int error = 0;
                   1604:   struct gengetopt_args_info local_args_info;
                   1605:   
                   1606:   int override;
                   1607:   int initialize;
                   1608:   int check_required;
                   1609:   int check_ambiguity;
                   1610:   
                   1611:   package_name = argv[0];
                   1612:   
                   1613:   override = params->override;
                   1614:   initialize = params->initialize;
                   1615:   check_required = params->check_required;
                   1616:   check_ambiguity = params->check_ambiguity;
                   1617: 
                   1618:   if (initialize)
                   1619:     cmdline_parser_init (args_info);
                   1620: 
                   1621:   cmdline_parser_init (&local_args_info);
                   1622: 
                   1623:   optarg = 0;
                   1624:   optind = 0;
                   1625:   opterr = params->print_errors;
                   1626:   optopt = '?';
                   1627: 
                   1628:   while (1)
                   1629:     {
                   1630:       int option_index = 0;
                   1631: 
                   1632:       static struct option long_options[] = {
                   1633:         { "help",      0, NULL, 'h' },
                   1634:         { "version",   0, NULL, 'V' },
                   1635:         { "fg",        0, NULL, 'f' },
                   1636:         { "debug",     0, NULL, 'd' },
                   1637:         { "debugfacility",     1, NULL, 0 },
                   1638:         { "logfacility",       1, NULL, 0 },
                   1639:         { "conf",      1, NULL, 'c' },
                   1640:         { "interval",  1, NULL, 0 },
                   1641:         { "pidfile",   1, NULL, 0 },
                   1642:         { "statedir",  1, NULL, 0 },
                   1643:         { "net",       1, NULL, 'n' },
                   1644:         { "dhcpstart", 1, NULL, 0 },
                   1645:         { "dhcpend",   1, NULL, 0 },
                   1646:         { "dynip",     1, NULL, 0 },
                   1647:         { "nodynip",   0, NULL, 0 },
                   1648:         { "statip",    1, NULL, 0 },
                   1649:         { "dns1",      1, NULL, 0 },
                   1650:         { "dns2",      1, NULL, 0 },
                   1651:         { "domain",    1, NULL, 0 },
                   1652:         { "ipup",      1, NULL, 0 },
                   1653:         { "ipdown",    1, NULL, 0 },
                   1654:         { "conup",     1, NULL, 0 },
                   1655:         { "condown",   1, NULL, 0 },
                   1656:         { "txqlen",    1, NULL, 0 },
                   1657:         { "tundev",    1, NULL, 0 },
                   1658:         { "radiuslisten",      1, NULL, 0 },
                   1659:         { "radiusserver1",     1, NULL, 0 },
                   1660:         { "radiusserver2",     1, NULL, 0 },
                   1661:         { "radiusauthport",    1, NULL, 0 },
                   1662:         { "radiusacctport",    1, NULL, 0 },
                   1663:         { "radiussecret",      1, NULL, 0 },
                   1664:         { "radiustimeout",     1, NULL, 0 },
                   1665:         { "radiusretry",       1, NULL, 0 },
                   1666:         { "radiusretrysec",    1, NULL, 0 },
                   1667:         { "radiusnasid",       1, NULL, 0 },
                   1668:         { "radiuslocationid",  1, NULL, 0 },
                   1669:         { "radiuslocationname",        1, NULL, 0 },
                   1670:         { "locationname",      1, NULL, 0 },
                   1671:         { "radiusnasporttype", 1, NULL, 0 },
                   1672:         { "coaport",   1, NULL, 0 },
                   1673:         { "coanoipcheck",      0, NULL, 0 },
                   1674:         { "proxylisten",       1, NULL, 0 },
                   1675:         { "proxyport", 1, NULL, 0 },
                   1676:         { "proxyclient",       1, NULL, 0 },
                   1677:         { "proxysecret",       1, NULL, 0 },
                   1678:         { "dhcpif",    1, NULL, 0 },
                   1679:         { "dhcpmac",   1, NULL, 0 },
                   1680:         { "dhcpradius",        0, NULL, 0 },
                   1681:         { "dhcpgateway",       1, NULL, 0 },
                   1682:         { "dhcpgatewayport",   1, NULL, 0 },
                   1683:         { "dhcprelayagent",    1, NULL, 0 },
                   1684:         { "lease",     1, NULL, 0 },
                   1685:         { "eapolenable",       0, NULL, 0 },
                   1686:         { "uamserver", 1, NULL, 0 },
                   1687:         { "uamhomepage",       1, NULL, 0 },
                   1688:         { "uamsecret", 1, NULL, 0 },
                   1689:         { "uamlisten", 1, NULL, 0 },
                   1690:         { "uamport",   1, NULL, 0 },
                   1691:         { "uamuiport", 1, NULL, 0 },
                   1692:         { "uamallowed",        1, NULL, 0 },
                   1693:         { "uamdomain", 1, NULL, 0 },
                   1694:         { "uamanydns", 0, NULL, 0 },
                   1695:         { "uamanyip",  0, NULL, 0 },
                   1696:         { "wisprlogin",        1, NULL, 0 },
                   1697:         { "nouamsuccess",      0, NULL, 0 },
                   1698:         { "nouamwispr",        0, NULL, 0 },
                   1699:         { "uamlogoutip",       1, NULL, 0 },
                   1700:         { "defsessiontimeout", 1, NULL, 0 },
                   1701:         { "defidletimeout",    1, NULL, 0 },
                   1702:         { "defbandwidthmaxdown",       1, NULL, 0 },
                   1703:         { "defbandwidthmaxup", 1, NULL, 0 },
                   1704:         { "definteriminterval",        1, NULL, 0 },
                   1705:         { "macauth",   0, NULL, 0 },
                   1706:         { "macauthdeny",       0, NULL, 0 },
                   1707:         { "macallowed",        1, NULL, 0 },
                   1708:         { "macsuffix", 1, NULL, 0 },
                   1709:         { "macpasswd", 1, NULL, 0 },
                   1710:         { "macallowlocal",     0, NULL, 0 },
                   1711:         { "wwwdir",    1, NULL, 0 },
                   1712:         { "wwwbin",    1, NULL, 0 },
                   1713:         { "uamui",     1, NULL, 0 },
                   1714:         { "adminuser", 1, NULL, 0 },
                   1715:         { "adminpasswd",       1, NULL, 0 },
                   1716:         { "nasmac",    1, NULL, 0 },
                   1717:         { "nasip",     1, NULL, 0 },
                   1718:         { "ssid",      1, NULL, 0 },
                   1719:         { "vlan",      1, NULL, 0 },
                   1720:         { "cmdsocket", 1, NULL, 0 },
                   1721:         { "radiusoriginalurl", 0, NULL, 0 },
                   1722:         { "swapoctets",        0, NULL, 0 },
                   1723:         { "usestatusfile",     0, NULL, 0 },
                   1724:         { "localusers",        1, NULL, 0 },
                   1725:         { "postauthproxy",     1, NULL, 0 },
                   1726:         { "postauthproxyport", 1, NULL, 0 },
                   1727:         { "wpaguests", 0, NULL, 0 },
                   1728:         { "openidauth",        0, NULL, 0 },
                   1729:         { "papalwaysok",       0, NULL, 0 },
                   1730:         { "chillixml", 0, NULL, 0 },
                   1731:         { "acctupdate",        0, NULL, 0 },
                   1732:         { "dnsparanoia",       0, NULL, 0 },
                   1733:         { "usetap",    0, NULL, 0 },
                   1734:         { "routeif",   1, NULL, 0 },
                   1735:         { NULL,        0, NULL, 0 }
                   1736:       };
                   1737: 
                   1738:       c = getopt_long (argc, argv, "hVfdc:n:", long_options, &option_index);
                   1739: 
                   1740:       if (c == -1) break;      /* Exit from `while (1)' loop.  */
                   1741: 
                   1742:       switch (c)
                   1743:         {
                   1744:         case 'h':      /* Print help and exit.  */
                   1745:         
                   1746:         
                   1747:           if (update_arg( 0 , 
                   1748:                0 , &(args_info->help_given),
                   1749:               &(local_args_info.help_given), optarg, 0, 0, ARG_NO,
                   1750:               check_ambiguity, override, 0, 0,
                   1751:               "help", 'h',
                   1752:               additional_error))
                   1753:             goto failure;
                   1754:           cmdline_parser_free (&local_args_info);
                   1755:           return 0;
                   1756:         
                   1757:           break;
                   1758:         case 'V':      /* Print version and exit.  */
                   1759:         
                   1760:         
                   1761:           if (update_arg( 0 , 
                   1762:                0 , &(args_info->version_given),
                   1763:               &(local_args_info.version_given), optarg, 0, 0, ARG_NO,
                   1764:               check_ambiguity, override, 0, 0,
                   1765:               "version", 'V',
                   1766:               additional_error))
                   1767:             goto failure;
                   1768:           cmdline_parser_free (&local_args_info);
                   1769:           return 0;
                   1770:         
                   1771:           break;
                   1772:         case 'f':      /* Run in foreground.  */
                   1773:         
                   1774:         
                   1775:           if (update_arg((void *)&(args_info->fg_flag), 0, &(args_info->fg_given),
                   1776:               &(local_args_info.fg_given), optarg, 0, 0, ARG_FLAG,
                   1777:               check_ambiguity, override, 1, 0, "fg", 'f',
                   1778:               additional_error))
                   1779:             goto failure;
                   1780:         
                   1781:           break;
                   1782:         case 'd':      /* Run in debug mode.  */
                   1783:         
                   1784:         
                   1785:           if (update_arg((void *)&(args_info->debug_flag), 0, &(args_info->debug_given),
                   1786:               &(local_args_info.debug_given), optarg, 0, 0, ARG_FLAG,
                   1787:               check_ambiguity, override, 1, 0, "debug", 'd',
                   1788:               additional_error))
                   1789:             goto failure;
                   1790:         
                   1791:           break;
                   1792:         case 'c':      /* Read configuration file.  */
                   1793:         
                   1794:         
                   1795:           if (update_arg( (void *)&(args_info->conf_arg), 
                   1796:                &(args_info->conf_orig), &(args_info->conf_given),
                   1797:               &(local_args_info.conf_given), optarg, 0, 0, ARG_STRING,
                   1798:               check_ambiguity, override, 0, 0,
                   1799:               "conf", 'c',
                   1800:               additional_error))
                   1801:             goto failure;
                   1802:         
                   1803:           break;
                   1804:         case 'n':      /* Network.  */
                   1805:         
                   1806:         
                   1807:           if (update_arg( (void *)&(args_info->net_arg), 
                   1808:                &(args_info->net_orig), &(args_info->net_given),
                   1809:               &(local_args_info.net_given), optarg, 0, "192.168.182.0/24", ARG_STRING,
                   1810:               check_ambiguity, override, 0, 0,
                   1811:               "net", 'n',
                   1812:               additional_error))
                   1813:             goto failure;
                   1814:         
                   1815:           break;
                   1816: 
                   1817:         case 0:        /* Long option with no short option */
                   1818:           /* Which modules to print debug messages for.  */
                   1819:           if (strcmp (long_options[option_index].name, "debugfacility") == 0)
                   1820:           {
                   1821:           
                   1822:           
                   1823:             if (update_arg( (void *)&(args_info->debugfacility_arg), 
                   1824:                  &(args_info->debugfacility_orig), &(args_info->debugfacility_given),
                   1825:                 &(local_args_info.debugfacility_given), optarg, 0, "1", ARG_INT,
                   1826:                 check_ambiguity, override, 0, 0,
                   1827:                 "debugfacility", '-',
                   1828:                 additional_error))
                   1829:               goto failure;
                   1830:           
                   1831:           }
                   1832:           /* Syslog facility to be used for logging.  */
                   1833:           else if (strcmp (long_options[option_index].name, "logfacility") == 0)
                   1834:           {
                   1835:           
                   1836:           
                   1837:             if (update_arg( (void *)&(args_info->logfacility_arg), 
                   1838:                  &(args_info->logfacility_orig), &(args_info->logfacility_given),
                   1839:                 &(local_args_info.logfacility_given), optarg, 0, "-1", ARG_INT,
                   1840:                 check_ambiguity, override, 0, 0,
                   1841:                 "logfacility", '-',
                   1842:                 additional_error))
                   1843:               goto failure;
                   1844:           
                   1845:           }
                   1846:           /* Re-read configuration file at this interval.  */
                   1847:           else if (strcmp (long_options[option_index].name, "interval") == 0)
                   1848:           {
                   1849:           
                   1850:           
                   1851:             if (update_arg( (void *)&(args_info->interval_arg), 
                   1852:                  &(args_info->interval_orig), &(args_info->interval_given),
                   1853:                 &(local_args_info.interval_given), optarg, 0, "3600", ARG_INT,
                   1854:                 check_ambiguity, override, 0, 0,
                   1855:                 "interval", '-',
                   1856:                 additional_error))
                   1857:               goto failure;
                   1858:           
                   1859:           }
                   1860:           /* Filename of process id file.  */
                   1861:           else if (strcmp (long_options[option_index].name, "pidfile") == 0)
                   1862:           {
                   1863:           
                   1864:           
                   1865:             if (update_arg( (void *)&(args_info->pidfile_arg), 
                   1866:                  &(args_info->pidfile_orig), &(args_info->pidfile_given),
                   1867:                 &(local_args_info.pidfile_given), optarg, 0, 0, ARG_STRING,
                   1868:                 check_ambiguity, override, 0, 0,
                   1869:                 "pidfile", '-',
                   1870:                 additional_error))
                   1871:               goto failure;
                   1872:           
                   1873:           }
                   1874:           /* Directory of nonvolatile data.  */
                   1875:           else if (strcmp (long_options[option_index].name, "statedir") == 0)
                   1876:           {
                   1877:           
                   1878:           
                   1879:             if (update_arg( (void *)&(args_info->statedir_arg), 
                   1880:                  &(args_info->statedir_orig), &(args_info->statedir_given),
                   1881:                 &(local_args_info.statedir_given), optarg, 0, 0, ARG_STRING,
                   1882:                 check_ambiguity, override, 0, 0,
                   1883:                 "statedir", '-',
                   1884:                 additional_error))
                   1885:               goto failure;
                   1886:           
                   1887:           }
                   1888:           /* Network DHCP Starting IP.  */
                   1889:           else if (strcmp (long_options[option_index].name, "dhcpstart") == 0)
                   1890:           {
                   1891:           
                   1892:           
                   1893:             if (update_arg( (void *)&(args_info->dhcpstart_arg), 
                   1894:                  &(args_info->dhcpstart_orig), &(args_info->dhcpstart_given),
                   1895:                 &(local_args_info.dhcpstart_given), optarg, 0, "0", ARG_INT,
                   1896:                 check_ambiguity, override, 0, 0,
                   1897:                 "dhcpstart", '-',
                   1898:                 additional_error))
                   1899:               goto failure;
                   1900:           
                   1901:           }
                   1902:           /* Network DHCP Ending IP.  */
                   1903:           else if (strcmp (long_options[option_index].name, "dhcpend") == 0)
                   1904:           {
                   1905:           
                   1906:           
                   1907:             if (update_arg( (void *)&(args_info->dhcpend_arg), 
                   1908:                  &(args_info->dhcpend_orig), &(args_info->dhcpend_given),
                   1909:                 &(local_args_info.dhcpend_given), optarg, 0, "0", ARG_INT,
                   1910:                 check_ambiguity, override, 0, 0,
                   1911:                 "dhcpend", '-',
                   1912:                 additional_error))
                   1913:               goto failure;
                   1914:           
                   1915:           }
                   1916:           /* Dynamic IP address pool.  */
                   1917:           else if (strcmp (long_options[option_index].name, "dynip") == 0)
                   1918:           {
                   1919:           
                   1920:           
                   1921:             if (update_arg( (void *)&(args_info->dynip_arg), 
                   1922:                  &(args_info->dynip_orig), &(args_info->dynip_given),
                   1923:                 &(local_args_info.dynip_given), optarg, 0, 0, ARG_STRING,
                   1924:                 check_ambiguity, override, 0, 0,
                   1925:                 "dynip", '-',
                   1926:                 additional_error))
                   1927:               goto failure;
                   1928:           
                   1929:           }
                   1930:           /* No Dynamic IP assignment.  */
                   1931:           else if (strcmp (long_options[option_index].name, "nodynip") == 0)
                   1932:           {
                   1933:           
                   1934:           
                   1935:             if (update_arg((void *)&(args_info->nodynip_flag), 0, &(args_info->nodynip_given),
                   1936:                 &(local_args_info.nodynip_given), optarg, 0, 0, ARG_FLAG,
                   1937:                 check_ambiguity, override, 1, 0, "nodynip", '-',
                   1938:                 additional_error))
                   1939:               goto failure;
                   1940:           
                   1941:           }
                   1942:           /* Static IP address pool.  */
                   1943:           else if (strcmp (long_options[option_index].name, "statip") == 0)
                   1944:           {
                   1945:           
                   1946:           
                   1947:             if (update_arg( (void *)&(args_info->statip_arg), 
                   1948:                  &(args_info->statip_orig), &(args_info->statip_given),
                   1949:                 &(local_args_info.statip_given), optarg, 0, 0, ARG_STRING,
                   1950:                 check_ambiguity, override, 0, 0,
                   1951:                 "statip", '-',
                   1952:                 additional_error))
                   1953:               goto failure;
                   1954:           
                   1955:           }
                   1956:           /* Primary DNS server IP address.  */
                   1957:           else if (strcmp (long_options[option_index].name, "dns1") == 0)
                   1958:           {
                   1959:           
                   1960:           
                   1961:             if (update_arg( (void *)&(args_info->dns1_arg), 
                   1962:                  &(args_info->dns1_orig), &(args_info->dns1_given),
                   1963:                 &(local_args_info.dns1_given), optarg, 0, 0, ARG_STRING,
                   1964:                 check_ambiguity, override, 0, 0,
                   1965:                 "dns1", '-',
                   1966:                 additional_error))
                   1967:               goto failure;
                   1968:           
                   1969:           }
                   1970:           /* Secondary DNS server IP address.  */
                   1971:           else if (strcmp (long_options[option_index].name, "dns2") == 0)
                   1972:           {
                   1973:           
                   1974:           
                   1975:             if (update_arg( (void *)&(args_info->dns2_arg), 
                   1976:                  &(args_info->dns2_orig), &(args_info->dns2_given),
                   1977:                 &(local_args_info.dns2_given), optarg, 0, 0, ARG_STRING,
                   1978:                 check_ambiguity, override, 0, 0,
                   1979:                 "dns2", '-',
                   1980:                 additional_error))
                   1981:               goto failure;
                   1982:           
                   1983:           }
                   1984:           /* Domain to use for DNS lookups.  */
                   1985:           else if (strcmp (long_options[option_index].name, "domain") == 0)
                   1986:           {
                   1987:           
                   1988:           
                   1989:             if (update_arg( (void *)&(args_info->domain_arg), 
                   1990:                  &(args_info->domain_orig), &(args_info->domain_given),
                   1991:                 &(local_args_info.domain_given), optarg, 0, "coova.org", ARG_STRING,
                   1992:                 check_ambiguity, override, 0, 0,
                   1993:                 "domain", '-',
                   1994:                 additional_error))
                   1995:               goto failure;
                   1996:           
                   1997:           }
                   1998:           /* Script to run after link-up.  */
                   1999:           else if (strcmp (long_options[option_index].name, "ipup") == 0)
                   2000:           {
                   2001:           
                   2002:           
                   2003:             if (update_arg( (void *)&(args_info->ipup_arg), 
                   2004:                  &(args_info->ipup_orig), &(args_info->ipup_given),
                   2005:                 &(local_args_info.ipup_given), optarg, 0, 0, ARG_STRING,
                   2006:                 check_ambiguity, override, 0, 0,
                   2007:                 "ipup", '-',
                   2008:                 additional_error))
                   2009:               goto failure;
                   2010:           
                   2011:           }
                   2012:           /* Script to run after link-down.  */
                   2013:           else if (strcmp (long_options[option_index].name, "ipdown") == 0)
                   2014:           {
                   2015:           
                   2016:           
                   2017:             if (update_arg( (void *)&(args_info->ipdown_arg), 
                   2018:                  &(args_info->ipdown_orig), &(args_info->ipdown_given),
                   2019:                 &(local_args_info.ipdown_given), optarg, 0, 0, ARG_STRING,
                   2020:                 check_ambiguity, override, 0, 0,
                   2021:                 "ipdown", '-',
                   2022:                 additional_error))
                   2023:               goto failure;
                   2024:           
                   2025:           }
                   2026:           /* Script to run after user logon.  */
                   2027:           else if (strcmp (long_options[option_index].name, "conup") == 0)
                   2028:           {
                   2029:           
                   2030:           
                   2031:             if (update_arg( (void *)&(args_info->conup_arg), 
                   2032:                  &(args_info->conup_orig), &(args_info->conup_given),
                   2033:                 &(local_args_info.conup_given), optarg, 0, 0, ARG_STRING,
                   2034:                 check_ambiguity, override, 0, 0,
                   2035:                 "conup", '-',
                   2036:                 additional_error))
                   2037:               goto failure;
                   2038:           
                   2039:           }
                   2040:           /* Script to run after user logoff.  */
                   2041:           else if (strcmp (long_options[option_index].name, "condown") == 0)
                   2042:           {
                   2043:           
                   2044:           
                   2045:             if (update_arg( (void *)&(args_info->condown_arg), 
                   2046:                  &(args_info->condown_orig), &(args_info->condown_given),
                   2047:                 &(local_args_info.condown_given), optarg, 0, 0, ARG_STRING,
                   2048:                 check_ambiguity, override, 0, 0,
                   2049:                 "condown", '-',
                   2050:                 additional_error))
                   2051:               goto failure;
                   2052:           
                   2053:           }
                   2054:           /* TX Queue length for tun interface (linux only).  */
                   2055:           else if (strcmp (long_options[option_index].name, "txqlen") == 0)
                   2056:           {
                   2057:           
                   2058:           
                   2059:             if (update_arg( (void *)&(args_info->txqlen_arg), 
                   2060:                  &(args_info->txqlen_orig), &(args_info->txqlen_given),
                   2061:                 &(local_args_info.txqlen_given), optarg, 0, "100", ARG_INT,
                   2062:                 check_ambiguity, override, 0, 0,
                   2063:                 "txqlen", '-',
                   2064:                 additional_error))
                   2065:               goto failure;
                   2066:           
                   2067:           }
                   2068:           /* TUN/TAP Device, as in tun0 or tap1.  */
                   2069:           else if (strcmp (long_options[option_index].name, "tundev") == 0)
                   2070:           {
                   2071:           
                   2072:           
                   2073:             if (update_arg( (void *)&(args_info->tundev_arg), 
                   2074:                  &(args_info->tundev_orig), &(args_info->tundev_given),
                   2075:                 &(local_args_info.tundev_given), optarg, 0, 0, ARG_STRING,
                   2076:                 check_ambiguity, override, 0, 0,
                   2077:                 "tundev", '-',
                   2078:                 additional_error))
                   2079:               goto failure;
                   2080:           
                   2081:           }
                   2082:           /* IP address to send from.  */
                   2083:           else if (strcmp (long_options[option_index].name, "radiuslisten") == 0)
                   2084:           {
                   2085:           
                   2086:           
                   2087:             if (update_arg( (void *)&(args_info->radiuslisten_arg), 
                   2088:                  &(args_info->radiuslisten_orig), &(args_info->radiuslisten_given),
                   2089:                 &(local_args_info.radiuslisten_given), optarg, 0, 0, ARG_STRING,
                   2090:                 check_ambiguity, override, 0, 0,
                   2091:                 "radiuslisten", '-',
                   2092:                 additional_error))
                   2093:               goto failure;
                   2094:           
                   2095:           }
                   2096:           /* IP address of radius server 1.  */
                   2097:           else if (strcmp (long_options[option_index].name, "radiusserver1") == 0)
                   2098:           {
                   2099:           
                   2100:           
                   2101:             if (update_arg( (void *)&(args_info->radiusserver1_arg), 
                   2102:                  &(args_info->radiusserver1_orig), &(args_info->radiusserver1_given),
                   2103:                 &(local_args_info.radiusserver1_given), optarg, 0, "rad01.coova.org", ARG_STRING,
                   2104:                 check_ambiguity, override, 0, 0,
                   2105:                 "radiusserver1", '-',
                   2106:                 additional_error))
                   2107:               goto failure;
                   2108:           
                   2109:           }
                   2110:           /* IP address of radius server 2.  */
                   2111:           else if (strcmp (long_options[option_index].name, "radiusserver2") == 0)
                   2112:           {
                   2113:           
                   2114:           
                   2115:             if (update_arg( (void *)&(args_info->radiusserver2_arg), 
                   2116:                  &(args_info->radiusserver2_orig), &(args_info->radiusserver2_given),
                   2117:                 &(local_args_info.radiusserver2_given), optarg, 0, "rad01.coova.org", ARG_STRING,
                   2118:                 check_ambiguity, override, 0, 0,
                   2119:                 "radiusserver2", '-',
                   2120:                 additional_error))
                   2121:               goto failure;
                   2122:           
                   2123:           }
                   2124:           /* Authentication UDP port of radius server.  */
                   2125:           else if (strcmp (long_options[option_index].name, "radiusauthport") == 0)
                   2126:           {
                   2127:           
                   2128:           
                   2129:             if (update_arg( (void *)&(args_info->radiusauthport_arg), 
                   2130:                  &(args_info->radiusauthport_orig), &(args_info->radiusauthport_given),
                   2131:                 &(local_args_info.radiusauthport_given), optarg, 0, "1812", ARG_INT,
                   2132:                 check_ambiguity, override, 0, 0,
                   2133:                 "radiusauthport", '-',
                   2134:                 additional_error))
                   2135:               goto failure;
                   2136:           
                   2137:           }
                   2138:           /* Accounting UDP port of radius server.  */
                   2139:           else if (strcmp (long_options[option_index].name, "radiusacctport") == 0)
                   2140:           {
                   2141:           
                   2142:           
                   2143:             if (update_arg( (void *)&(args_info->radiusacctport_arg), 
                   2144:                  &(args_info->radiusacctport_orig), &(args_info->radiusacctport_given),
                   2145:                 &(local_args_info.radiusacctport_given), optarg, 0, "1813", ARG_INT,
                   2146:                 check_ambiguity, override, 0, 0,
                   2147:                 "radiusacctport", '-',
                   2148:                 additional_error))
                   2149:               goto failure;
                   2150:           
                   2151:           }
                   2152:           /* Radius shared secret.  */
                   2153:           else if (strcmp (long_options[option_index].name, "radiussecret") == 0)
                   2154:           {
                   2155:           
                   2156:           
                   2157:             if (update_arg( (void *)&(args_info->radiussecret_arg), 
                   2158:                  &(args_info->radiussecret_orig), &(args_info->radiussecret_given),
                   2159:                 &(local_args_info.radiussecret_given), optarg, 0, "coova-anonymous", ARG_STRING,
                   2160:                 check_ambiguity, override, 0, 0,
                   2161:                 "radiussecret", '-',
                   2162:                 additional_error))
                   2163:               goto failure;
                   2164:           
                   2165:           }
                   2166:           /* Retry timeout in seconds.  */
                   2167:           else if (strcmp (long_options[option_index].name, "radiustimeout") == 0)
                   2168:           {
                   2169:           
                   2170:           
                   2171:             if (update_arg( (void *)&(args_info->radiustimeout_arg), 
                   2172:                  &(args_info->radiustimeout_orig), &(args_info->radiustimeout_given),
                   2173:                 &(local_args_info.radiustimeout_given), optarg, 0, "30", ARG_INT,
                   2174:                 check_ambiguity, override, 0, 0,
                   2175:                 "radiustimeout", '-',
                   2176:                 additional_error))
                   2177:               goto failure;
                   2178:           
                   2179:           }
                   2180:           /* Total number of retries.  */
                   2181:           else if (strcmp (long_options[option_index].name, "radiusretry") == 0)
                   2182:           {
                   2183:           
                   2184:           
                   2185:             if (update_arg( (void *)&(args_info->radiusretry_arg), 
                   2186:                  &(args_info->radiusretry_orig), &(args_info->radiusretry_given),
                   2187:                 &(local_args_info.radiusretry_given), optarg, 0, "6", ARG_INT,
                   2188:                 check_ambiguity, override, 0, 0,
                   2189:                 "radiusretry", '-',
                   2190:                 additional_error))
                   2191:               goto failure;
                   2192:           
                   2193:           }
                   2194:           /* Number of retries before using secondary.  */
                   2195:           else if (strcmp (long_options[option_index].name, "radiusretrysec") == 0)
                   2196:           {
                   2197:           
                   2198:           
                   2199:             if (update_arg( (void *)&(args_info->radiusretrysec_arg), 
                   2200:                  &(args_info->radiusretrysec_orig), &(args_info->radiusretrysec_given),
                   2201:                 &(local_args_info.radiusretrysec_given), optarg, 0, "3", ARG_INT,
                   2202:                 check_ambiguity, override, 0, 0,
                   2203:                 "radiusretrysec", '-',
                   2204:                 additional_error))
                   2205:               goto failure;
                   2206:           
                   2207:           }
                   2208:           /* Radius NAS-Identifier.  */
                   2209:           else if (strcmp (long_options[option_index].name, "radiusnasid") == 0)
                   2210:           {
                   2211:           
                   2212:           
                   2213:             if (update_arg( (void *)&(args_info->radiusnasid_arg), 
                   2214:                  &(args_info->radiusnasid_orig), &(args_info->radiusnasid_given),
                   2215:                 &(local_args_info.radiusnasid_given), optarg, 0, "nas01", ARG_STRING,
                   2216:                 check_ambiguity, override, 0, 0,
                   2217:                 "radiusnasid", '-',
                   2218:                 additional_error))
                   2219:               goto failure;
                   2220:           
                   2221:           }
                   2222:           /* WISPr Location ID.  */
                   2223:           else if (strcmp (long_options[option_index].name, "radiuslocationid") == 0)
                   2224:           {
                   2225:           
                   2226:           
                   2227:             if (update_arg( (void *)&(args_info->radiuslocationid_arg), 
                   2228:                  &(args_info->radiuslocationid_orig), &(args_info->radiuslocationid_given),
                   2229:                 &(local_args_info.radiuslocationid_given), optarg, 0, 0, ARG_STRING,
                   2230:                 check_ambiguity, override, 0, 0,
                   2231:                 "radiuslocationid", '-',
                   2232:                 additional_error))
                   2233:               goto failure;
                   2234:           
                   2235:           }
                   2236:           /* WISPr Location Name.  */
                   2237:           else if (strcmp (long_options[option_index].name, "radiuslocationname") == 0)
                   2238:           {
                   2239:           
                   2240:           
                   2241:             if (update_arg( (void *)&(args_info->radiuslocationname_arg), 
                   2242:                  &(args_info->radiuslocationname_orig), &(args_info->radiuslocationname_given),
                   2243:                 &(local_args_info.radiuslocationname_given), optarg, 0, 0, ARG_STRING,
                   2244:                 check_ambiguity, override, 0, 0,
                   2245:                 "radiuslocationname", '-',
                   2246:                 additional_error))
                   2247:               goto failure;
                   2248:           
                   2249:           }
                   2250:           /* Location Name.  */
                   2251:           else if (strcmp (long_options[option_index].name, "locationname") == 0)
                   2252:           {
                   2253:           
                   2254:           
                   2255:             if (update_arg( (void *)&(args_info->locationname_arg), 
                   2256:                  &(args_info->locationname_orig), &(args_info->locationname_given),
                   2257:                 &(local_args_info.locationname_given), optarg, 0, 0, ARG_STRING,
                   2258:                 check_ambiguity, override, 0, 0,
                   2259:                 "locationname", '-',
                   2260:                 additional_error))
                   2261:               goto failure;
                   2262:           
                   2263:           }
                   2264:           /* Radius NAS-Port-Type.  */
                   2265:           else if (strcmp (long_options[option_index].name, "radiusnasporttype") == 0)
                   2266:           {
                   2267:           
                   2268:           
                   2269:             if (update_arg( (void *)&(args_info->radiusnasporttype_arg), 
                   2270:                  &(args_info->radiusnasporttype_orig), &(args_info->radiusnasporttype_given),
                   2271:                 &(local_args_info.radiusnasporttype_given), optarg, 0, "19", ARG_INT,
                   2272:                 check_ambiguity, override, 0, 0,
                   2273:                 "radiusnasporttype", '-',
                   2274:                 additional_error))
                   2275:               goto failure;
                   2276:           
                   2277:           }
                   2278:           /* Radius disconnect port to listen to.  */
                   2279:           else if (strcmp (long_options[option_index].name, "coaport") == 0)
                   2280:           {
                   2281:           
                   2282:           
                   2283:             if (update_arg( (void *)&(args_info->coaport_arg), 
                   2284:                  &(args_info->coaport_orig), &(args_info->coaport_given),
                   2285:                 &(local_args_info.coaport_given), optarg, 0, "0", ARG_INT,
                   2286:                 check_ambiguity, override, 0, 0,
                   2287:                 "coaport", '-',
                   2288:                 additional_error))
                   2289:               goto failure;
                   2290:           
                   2291:           }
                   2292:           /* Allow radius disconnect from any IP.  */
                   2293:           else if (strcmp (long_options[option_index].name, "coanoipcheck") == 0)
                   2294:           {
                   2295:           
                   2296:           
                   2297:             if (update_arg((void *)&(args_info->coanoipcheck_flag), 0, &(args_info->coanoipcheck_given),
                   2298:                 &(local_args_info.coanoipcheck_given), optarg, 0, 0, ARG_FLAG,
                   2299:                 check_ambiguity, override, 1, 0, "coanoipcheck", '-',
                   2300:                 additional_error))
                   2301:               goto failure;
                   2302:           
                   2303:           }
                   2304:           /* IP address to listen to.  */
                   2305:           else if (strcmp (long_options[option_index].name, "proxylisten") == 0)
                   2306:           {
                   2307:           
                   2308:           
                   2309:             if (update_arg( (void *)&(args_info->proxylisten_arg), 
                   2310:                  &(args_info->proxylisten_orig), &(args_info->proxylisten_given),
                   2311:                 &(local_args_info.proxylisten_given), optarg, 0, 0, ARG_STRING,
                   2312:                 check_ambiguity, override, 0, 0,
                   2313:                 "proxylisten", '-',
                   2314:                 additional_error))
                   2315:               goto failure;
                   2316:           
                   2317:           }
                   2318:           /* UDP port to listen to.  */
                   2319:           else if (strcmp (long_options[option_index].name, "proxyport") == 0)
                   2320:           {
                   2321:           
                   2322:           
                   2323:             if (update_arg( (void *)&(args_info->proxyport_arg), 
                   2324:                  &(args_info->proxyport_orig), &(args_info->proxyport_given),
                   2325:                 &(local_args_info.proxyport_given), optarg, 0, "0", ARG_INT,
                   2326:                 check_ambiguity, override, 0, 0,
                   2327:                 "proxyport", '-',
                   2328:                 additional_error))
                   2329:               goto failure;
                   2330:           
                   2331:           }
                   2332:           /* IP address of proxy client(s).  */
                   2333:           else if (strcmp (long_options[option_index].name, "proxyclient") == 0)
                   2334:           {
                   2335:           
                   2336:           
                   2337:             if (update_arg( (void *)&(args_info->proxyclient_arg), 
                   2338:                  &(args_info->proxyclient_orig), &(args_info->proxyclient_given),
                   2339:                 &(local_args_info.proxyclient_given), optarg, 0, 0, ARG_STRING,
                   2340:                 check_ambiguity, override, 0, 0,
                   2341:                 "proxyclient", '-',
                   2342:                 additional_error))
                   2343:               goto failure;
                   2344:           
                   2345:           }
                   2346:           /* Radius proxy shared secret.  */
                   2347:           else if (strcmp (long_options[option_index].name, "proxysecret") == 0)
                   2348:           {
                   2349:           
                   2350:           
                   2351:             if (update_arg( (void *)&(args_info->proxysecret_arg), 
                   2352:                  &(args_info->proxysecret_orig), &(args_info->proxysecret_given),
                   2353:                 &(local_args_info.proxysecret_given), optarg, 0, 0, ARG_STRING,
                   2354:                 check_ambiguity, override, 0, 0,
                   2355:                 "proxysecret", '-',
                   2356:                 additional_error))
                   2357:               goto failure;
                   2358:           
                   2359:           }
                   2360:           /* Local Ethernet interface.  */
                   2361:           else if (strcmp (long_options[option_index].name, "dhcpif") == 0)
                   2362:           {
                   2363:           
                   2364:           
                   2365:             if (update_arg( (void *)&(args_info->dhcpif_arg), 
                   2366:                  &(args_info->dhcpif_orig), &(args_info->dhcpif_given),
                   2367:                 &(local_args_info.dhcpif_given), optarg, 0, 0, ARG_STRING,
                   2368:                 check_ambiguity, override, 0, 0,
                   2369:                 "dhcpif", '-',
                   2370:                 additional_error))
                   2371:               goto failure;
                   2372:           
                   2373:           }
                   2374:           /* Interface MAC address.  */
                   2375:           else if (strcmp (long_options[option_index].name, "dhcpmac") == 0)
                   2376:           {
                   2377:           
                   2378:           
                   2379:             if (update_arg( (void *)&(args_info->dhcpmac_arg), 
                   2380:                  &(args_info->dhcpmac_orig), &(args_info->dhcpmac_given),
                   2381:                 &(local_args_info.dhcpmac_given), optarg, 0, 0, ARG_STRING,
                   2382:                 check_ambiguity, override, 0, 0,
                   2383:                 "dhcpmac", '-',
                   2384:                 additional_error))
                   2385:               goto failure;
                   2386:           
                   2387:           }
                   2388:           /* Map certain DHCP options to RADIUS attributes.  */
                   2389:           else if (strcmp (long_options[option_index].name, "dhcpradius") == 0)
                   2390:           {
                   2391:           
                   2392:           
                   2393:             if (update_arg((void *)&(args_info->dhcpradius_flag), 0, &(args_info->dhcpradius_given),
                   2394:                 &(local_args_info.dhcpradius_given), optarg, 0, 0, ARG_FLAG,
                   2395:                 check_ambiguity, override, 1, 0, "dhcpradius", '-',
                   2396:                 additional_error))
                   2397:               goto failure;
                   2398:           
                   2399:           }
                   2400:           /* DHCP gateway addresss for relay.  */
                   2401:           else if (strcmp (long_options[option_index].name, "dhcpgateway") == 0)
                   2402:           {
                   2403:           
                   2404:           
                   2405:             if (update_arg( (void *)&(args_info->dhcpgateway_arg), 
                   2406:                  &(args_info->dhcpgateway_orig), &(args_info->dhcpgateway_given),
                   2407:                 &(local_args_info.dhcpgateway_given), optarg, 0, 0, ARG_STRING,
                   2408:                 check_ambiguity, override, 0, 0,
                   2409:                 "dhcpgateway", '-',
                   2410:                 additional_error))
                   2411:               goto failure;
                   2412:           
                   2413:           }
                   2414:           /* DHCP gateway port for relay.  */
                   2415:           else if (strcmp (long_options[option_index].name, "dhcpgatewayport") == 0)
                   2416:           {
                   2417:           
                   2418:           
                   2419:             if (update_arg( (void *)&(args_info->dhcpgatewayport_arg), 
                   2420:                  &(args_info->dhcpgatewayport_orig), &(args_info->dhcpgatewayport_given),
                   2421:                 &(local_args_info.dhcpgatewayport_given), optarg, 0, "67", ARG_INT,
                   2422:                 check_ambiguity, override, 0, 0,
                   2423:                 "dhcpgatewayport", '-',
                   2424:                 additional_error))
                   2425:               goto failure;
                   2426:           
                   2427:           }
                   2428:           /* DHCP relay agent IP addresss (default uamlisten).  */
                   2429:           else if (strcmp (long_options[option_index].name, "dhcprelayagent") == 0)
                   2430:           {
                   2431:           
                   2432:           
                   2433:             if (update_arg( (void *)&(args_info->dhcprelayagent_arg), 
                   2434:                  &(args_info->dhcprelayagent_orig), &(args_info->dhcprelayagent_given),
                   2435:                 &(local_args_info.dhcprelayagent_given), optarg, 0, 0, ARG_STRING,
                   2436:                 check_ambiguity, override, 0, 0,
                   2437:                 "dhcprelayagent", '-',
                   2438:                 additional_error))
                   2439:               goto failure;
                   2440:           
                   2441:           }
                   2442:           /* Lease time to allocate to clients.  */
                   2443:           else if (strcmp (long_options[option_index].name, "lease") == 0)
                   2444:           {
                   2445:           
                   2446:           
                   2447:             if (update_arg( (void *)&(args_info->lease_arg), 
                   2448:                  &(args_info->lease_orig), &(args_info->lease_given),
                   2449:                 &(local_args_info.lease_given), optarg, 0, "600", ARG_INT,
                   2450:                 check_ambiguity, override, 0, 0,
                   2451:                 "lease", '-',
                   2452:                 additional_error))
                   2453:               goto failure;
                   2454:           
                   2455:           }
                   2456:           /* Enable IEEE 802.1x authentication.  */
                   2457:           else if (strcmp (long_options[option_index].name, "eapolenable") == 0)
                   2458:           {
                   2459:           
                   2460:           
                   2461:             if (update_arg((void *)&(args_info->eapolenable_flag), 0, &(args_info->eapolenable_given),
                   2462:                 &(local_args_info.eapolenable_given), optarg, 0, 0, ARG_FLAG,
                   2463:                 check_ambiguity, override, 1, 0, "eapolenable", '-',
                   2464:                 additional_error))
                   2465:               goto failure;
                   2466:           
                   2467:           }
                   2468:           /* URL of authentication web server.  */
                   2469:           else if (strcmp (long_options[option_index].name, "uamserver") == 0)
                   2470:           {
                   2471:           
                   2472:           
                   2473:             if (update_arg( (void *)&(args_info->uamserver_arg), 
                   2474:                  &(args_info->uamserver_orig), &(args_info->uamserver_given),
                   2475:                 &(local_args_info.uamserver_given), optarg, 0, 0, ARG_STRING,
                   2476:                 check_ambiguity, override, 0, 0,
                   2477:                 "uamserver", '-',
                   2478:                 additional_error))
                   2479:               goto failure;
                   2480:           
                   2481:           }
                   2482:           /* URL of homepage to redirect unauthenticated users to.  */
                   2483:           else if (strcmp (long_options[option_index].name, "uamhomepage") == 0)
                   2484:           {
                   2485:           
                   2486:           
                   2487:             if (update_arg( (void *)&(args_info->uamhomepage_arg), 
                   2488:                  &(args_info->uamhomepage_orig), &(args_info->uamhomepage_given),
                   2489:                 &(local_args_info.uamhomepage_given), optarg, 0, 0, ARG_STRING,
                   2490:                 check_ambiguity, override, 0, 0,
                   2491:                 "uamhomepage", '-',
                   2492:                 additional_error))
                   2493:               goto failure;
                   2494:           
                   2495:           }
                   2496:           /* Shared secret between uamserver and chilli.  */
                   2497:           else if (strcmp (long_options[option_index].name, "uamsecret") == 0)
                   2498:           {
                   2499:           
                   2500:           
                   2501:             if (update_arg( (void *)&(args_info->uamsecret_arg), 
                   2502:                  &(args_info->uamsecret_orig), &(args_info->uamsecret_given),
                   2503:                 &(local_args_info.uamsecret_given), optarg, 0, 0, ARG_STRING,
                   2504:                 check_ambiguity, override, 0, 0,
                   2505:                 "uamsecret", '-',
                   2506:                 additional_error))
                   2507:               goto failure;
                   2508:           
                   2509:           }
                   2510:           /* IP address to listen to for authentication requests.  */
                   2511:           else if (strcmp (long_options[option_index].name, "uamlisten") == 0)
                   2512:           {
                   2513:           
                   2514:           
                   2515:             if (update_arg( (void *)&(args_info->uamlisten_arg), 
                   2516:                  &(args_info->uamlisten_orig), &(args_info->uamlisten_given),
                   2517:                 &(local_args_info.uamlisten_given), optarg, 0, 0, ARG_STRING,
                   2518:                 check_ambiguity, override, 0, 0,
                   2519:                 "uamlisten", '-',
                   2520:                 additional_error))
                   2521:               goto failure;
                   2522:           
                   2523:           }
                   2524:           /* TCP port to bind to for authentication requests.  */
                   2525:           else if (strcmp (long_options[option_index].name, "uamport") == 0)
                   2526:           {
                   2527:           
                   2528:           
                   2529:             if (update_arg( (void *)&(args_info->uamport_arg), 
                   2530:                  &(args_info->uamport_orig), &(args_info->uamport_given),
                   2531:                 &(local_args_info.uamport_given), optarg, 0, "3990", ARG_INT,
                   2532:                 check_ambiguity, override, 0, 0,
                   2533:                 "uamport", '-',
                   2534:                 additional_error))
                   2535:               goto failure;
                   2536:           
                   2537:           }
                   2538:           /* TCP port to bind to for UAM UI requests.  */
                   2539:           else if (strcmp (long_options[option_index].name, "uamuiport") == 0)
                   2540:           {
                   2541:           
                   2542:           
                   2543:             if (update_arg( (void *)&(args_info->uamuiport_arg), 
                   2544:                  &(args_info->uamuiport_orig), &(args_info->uamuiport_given),
                   2545:                 &(local_args_info.uamuiport_given), optarg, 0, "3991", ARG_INT,
                   2546:                 check_ambiguity, override, 0, 0,
                   2547:                 "uamuiport", '-',
                   2548:                 additional_error))
                   2549:               goto failure;
                   2550:           
                   2551:           }
                   2552:           /* Domain names exempt from access check .  */
                   2553:           else if (strcmp (long_options[option_index].name, "uamallowed") == 0)
                   2554:           {
                   2555:           
                   2556:             if (update_multiple_arg_temp(&uamallowed_list, 
                   2557:                 &(local_args_info.uamallowed_given), optarg, 0, 0, ARG_STRING,
                   2558:                 "uamallowed", '-',
                   2559:                 additional_error))
                   2560:               goto failure;
                   2561:           
                   2562:           }
                   2563:           /* Domain name allowed (active dns filtering; one per line!) .  */
                   2564:           else if (strcmp (long_options[option_index].name, "uamdomain") == 0)
                   2565:           {
                   2566:           
                   2567:             if (update_multiple_arg_temp(&uamdomain_list, 
                   2568:                 &(local_args_info.uamdomain_given), optarg, 0, 0, ARG_STRING,
                   2569:                 "uamdomain", '-',
                   2570:                 additional_error))
                   2571:               goto failure;
                   2572:           
                   2573:           }
                   2574:           /* Allow client to use any DNS server.  */
                   2575:           else if (strcmp (long_options[option_index].name, "uamanydns") == 0)
                   2576:           {
                   2577:           
                   2578:           
                   2579:             if (update_arg((void *)&(args_info->uamanydns_flag), 0, &(args_info->uamanydns_given),
                   2580:                 &(local_args_info.uamanydns_given), optarg, 0, 0, ARG_FLAG,
                   2581:                 check_ambiguity, override, 1, 0, "uamanydns", '-',
                   2582:                 additional_error))
                   2583:               goto failure;
                   2584:           
                   2585:           }
                   2586:           /* Allow client to use any IP Address.  */
                   2587:           else if (strcmp (long_options[option_index].name, "uamanyip") == 0)
                   2588:           {
                   2589:           
                   2590:           
                   2591:             if (update_arg((void *)&(args_info->uamanyip_flag), 0, &(args_info->uamanyip_given),
                   2592:                 &(local_args_info.uamanyip_given), optarg, 0, 0, ARG_FLAG,
                   2593:                 check_ambiguity, override, 1, 0, "uamanyip", '-',
                   2594:                 additional_error))
                   2595:               goto failure;
                   2596:           
                   2597:           }
                   2598:           /* A specific WISPr login url to be used.  */
                   2599:           else if (strcmp (long_options[option_index].name, "wisprlogin") == 0)
                   2600:           {
                   2601:           
                   2602:           
                   2603:             if (update_arg( (void *)&(args_info->wisprlogin_arg), 
                   2604:                  &(args_info->wisprlogin_orig), &(args_info->wisprlogin_given),
                   2605:                 &(local_args_info.wisprlogin_given), optarg, 0, 0, ARG_STRING,
                   2606:                 check_ambiguity, override, 0, 0,
                   2607:                 "wisprlogin", '-',
                   2608:                 additional_error))
                   2609:               goto failure;
                   2610:           
                   2611:           }
                   2612:           /* Do not return to the UAM server on success, original url instead.  */
                   2613:           else if (strcmp (long_options[option_index].name, "nouamsuccess") == 0)
                   2614:           {
                   2615:           
                   2616:           
                   2617:             if (update_arg((void *)&(args_info->nouamsuccess_flag), 0, &(args_info->nouamsuccess_given),
                   2618:                 &(local_args_info.nouamsuccess_given), optarg, 0, 0, ARG_FLAG,
                   2619:                 check_ambiguity, override, 1, 0, "nouamsuccess", '-',
                   2620:                 additional_error))
                   2621:               goto failure;
                   2622:           
                   2623:           }
                   2624:           /* Do not send WISPr XML from ChilliSpot, assume back-end does.  */
                   2625:           else if (strcmp (long_options[option_index].name, "nouamwispr") == 0)
                   2626:           {
                   2627:           
                   2628:           
                   2629:             if (update_arg((void *)&(args_info->nouamwispr_flag), 0, &(args_info->nouamwispr_given),
                   2630:                 &(local_args_info.nouamwispr_given), optarg, 0, 0, ARG_FLAG,
                   2631:                 check_ambiguity, override, 1, 0, "nouamwispr", '-',
                   2632:                 additional_error))
                   2633:               goto failure;
                   2634:           
                   2635:           }
                   2636:           /* HTTP Auto-Logout IP Address.  */
                   2637:           else if (strcmp (long_options[option_index].name, "uamlogoutip") == 0)
                   2638:           {
                   2639:           
                   2640:           
                   2641:             if (update_arg( (void *)&(args_info->uamlogoutip_arg), 
                   2642:                  &(args_info->uamlogoutip_orig), &(args_info->uamlogoutip_given),
                   2643:                 &(local_args_info.uamlogoutip_given), optarg, 0, "1.1.1.1", ARG_STRING,
                   2644:                 check_ambiguity, override, 0, 0,
                   2645:                 "uamlogoutip", '-',
                   2646:                 additional_error))
                   2647:               goto failure;
                   2648:           
                   2649:           }
                   2650:           /* Default session-timeout if not returned by RADIUS.  */
                   2651:           else if (strcmp (long_options[option_index].name, "defsessiontimeout") == 0)
                   2652:           {
                   2653:           
                   2654:           
                   2655:             if (update_arg( (void *)&(args_info->defsessiontimeout_arg), 
                   2656:                  &(args_info->defsessiontimeout_orig), &(args_info->defsessiontimeout_given),
                   2657:                 &(local_args_info.defsessiontimeout_given), optarg, 0, "0", ARG_LONG,
                   2658:                 check_ambiguity, override, 0, 0,
                   2659:                 "defsessiontimeout", '-',
                   2660:                 additional_error))
                   2661:               goto failure;
                   2662:           
                   2663:           }
                   2664:           /* Default idle-timeout if not returned by RADIUS.  */
                   2665:           else if (strcmp (long_options[option_index].name, "defidletimeout") == 0)
                   2666:           {
                   2667:           
                   2668:           
                   2669:             if (update_arg( (void *)&(args_info->defidletimeout_arg), 
                   2670:                  &(args_info->defidletimeout_orig), &(args_info->defidletimeout_given),
                   2671:                 &(local_args_info.defidletimeout_given), optarg, 0, "0", ARG_INT,
                   2672:                 check_ambiguity, override, 0, 0,
                   2673:                 "defidletimeout", '-',
                   2674:                 additional_error))
                   2675:               goto failure;
                   2676:           
                   2677:           }
                   2678:           /* Default WISPr-Bandwidth-Max-Down if not returned by RADIUS.  */
                   2679:           else if (strcmp (long_options[option_index].name, "defbandwidthmaxdown") == 0)
                   2680:           {
                   2681:           
                   2682:           
                   2683:             if (update_arg( (void *)&(args_info->defbandwidthmaxdown_arg), 
                   2684:                  &(args_info->defbandwidthmaxdown_orig), &(args_info->defbandwidthmaxdown_given),
                   2685:                 &(local_args_info.defbandwidthmaxdown_given), optarg, 0, "0", ARG_LONG,
                   2686:                 check_ambiguity, override, 0, 0,
                   2687:                 "defbandwidthmaxdown", '-',
                   2688:                 additional_error))
                   2689:               goto failure;
                   2690:           
                   2691:           }
                   2692:           /* Default WISPr-Bandwidth-Max-Up if not returned by RADIUS.  */
                   2693:           else if (strcmp (long_options[option_index].name, "defbandwidthmaxup") == 0)
                   2694:           {
                   2695:           
                   2696:           
                   2697:             if (update_arg( (void *)&(args_info->defbandwidthmaxup_arg), 
                   2698:                  &(args_info->defbandwidthmaxup_orig), &(args_info->defbandwidthmaxup_given),
                   2699:                 &(local_args_info.defbandwidthmaxup_given), optarg, 0, "0", ARG_LONG,
                   2700:                 check_ambiguity, override, 0, 0,
                   2701:                 "defbandwidthmaxup", '-',
                   2702:                 additional_error))
                   2703:               goto failure;
                   2704:           
                   2705:           }
                   2706:           /* Default interim-interval for accounting if not returned by RADIUS.  */
                   2707:           else if (strcmp (long_options[option_index].name, "definteriminterval") == 0)
                   2708:           {
                   2709:           
                   2710:           
                   2711:             if (update_arg( (void *)&(args_info->definteriminterval_arg), 
                   2712:                  &(args_info->definteriminterval_orig), &(args_info->definteriminterval_given),
                   2713:                 &(local_args_info.definteriminterval_given), optarg, 0, "300", ARG_INT,
                   2714:                 check_ambiguity, override, 0, 0,
                   2715:                 "definteriminterval", '-',
                   2716:                 additional_error))
                   2717:               goto failure;
                   2718:           
                   2719:           }
                   2720:           /* Authenticate based on MAC address.  */
                   2721:           else if (strcmp (long_options[option_index].name, "macauth") == 0)
                   2722:           {
                   2723:           
                   2724:           
                   2725:             if (update_arg((void *)&(args_info->macauth_flag), 0, &(args_info->macauth_given),
                   2726:                 &(local_args_info.macauth_given), optarg, 0, 0, ARG_FLAG,
                   2727:                 check_ambiguity, override, 1, 0, "macauth", '-',
                   2728:                 additional_error))
                   2729:               goto failure;
                   2730:           
                   2731:           }
                   2732:           /* Deny access (even UAM) to MAC addresses given Access-Reject.  */
                   2733:           else if (strcmp (long_options[option_index].name, "macauthdeny") == 0)
                   2734:           {
                   2735:           
                   2736:           
                   2737:             if (update_arg((void *)&(args_info->macauthdeny_flag), 0, &(args_info->macauthdeny_given),
                   2738:                 &(local_args_info.macauthdeny_given), optarg, 0, 0, ARG_FLAG,
                   2739:                 check_ambiguity, override, 1, 0, "macauthdeny", '-',
                   2740:                 additional_error))
                   2741:               goto failure;
                   2742:           
                   2743:           }
                   2744:           /* List of allowed MAC addresses.  */
                   2745:           else if (strcmp (long_options[option_index].name, "macallowed") == 0)
                   2746:           {
                   2747:           
                   2748:             if (update_multiple_arg_temp(&macallowed_list, 
                   2749:                 &(local_args_info.macallowed_given), optarg, 0, 0, ARG_STRING,
                   2750:                 "macallowed", '-',
                   2751:                 additional_error))
                   2752:               goto failure;
                   2753:           
                   2754:           }
                   2755:           /* Suffix to add to the MAC address.  */
                   2756:           else if (strcmp (long_options[option_index].name, "macsuffix") == 0)
                   2757:           {
                   2758:           
                   2759:           
                   2760:             if (update_arg( (void *)&(args_info->macsuffix_arg), 
                   2761:                  &(args_info->macsuffix_orig), &(args_info->macsuffix_given),
                   2762:                 &(local_args_info.macsuffix_given), optarg, 0, 0, ARG_STRING,
                   2763:                 check_ambiguity, override, 0, 0,
                   2764:                 "macsuffix", '-',
                   2765:                 additional_error))
                   2766:               goto failure;
                   2767:           
                   2768:           }
                   2769:           /* Password used when performing MAC authentication.  */
                   2770:           else if (strcmp (long_options[option_index].name, "macpasswd") == 0)
                   2771:           {
                   2772:           
                   2773:           
                   2774:             if (update_arg( (void *)&(args_info->macpasswd_arg), 
                   2775:                  &(args_info->macpasswd_orig), &(args_info->macpasswd_given),
                   2776:                 &(local_args_info.macpasswd_given), optarg, 0, 0, ARG_STRING,
                   2777:                 check_ambiguity, override, 0, 0,
                   2778:                 "macpasswd", '-',
                   2779:                 additional_error))
                   2780:               goto failure;
                   2781:           
                   2782:           }
                   2783:           /* Do not use RADIUS for authenticating the macallowed.  */
                   2784:           else if (strcmp (long_options[option_index].name, "macallowlocal") == 0)
                   2785:           {
                   2786:           
                   2787:           
                   2788:             if (update_arg((void *)&(args_info->macallowlocal_flag), 0, &(args_info->macallowlocal_given),
                   2789:                 &(local_args_info.macallowlocal_given), optarg, 0, 0, ARG_FLAG,
                   2790:                 check_ambiguity, override, 1, 0, "macallowlocal", '-',
                   2791:                 additional_error))
                   2792:               goto failure;
                   2793:           
                   2794:           }
                   2795:           /* Local content served by chilli (for splash page, etc).  */
                   2796:           else if (strcmp (long_options[option_index].name, "wwwdir") == 0)
                   2797:           {
                   2798:           
                   2799:           
                   2800:             if (update_arg( (void *)&(args_info->wwwdir_arg), 
                   2801:                  &(args_info->wwwdir_orig), &(args_info->wwwdir_given),
                   2802:                 &(local_args_info.wwwdir_given), optarg, 0, 0, ARG_STRING,
                   2803:                 check_ambiguity, override, 0, 0,
                   2804:                 "wwwdir", '-',
                   2805:                 additional_error))
                   2806:               goto failure;
                   2807:           
                   2808:           }
                   2809:           /* Script binary (such as haserl) for simple web programming.  */
                   2810:           else if (strcmp (long_options[option_index].name, "wwwbin") == 0)
                   2811:           {
                   2812:           
                   2813:           
                   2814:             if (update_arg( (void *)&(args_info->wwwbin_arg), 
                   2815:                  &(args_info->wwwbin_orig), &(args_info->wwwbin_given),
                   2816:                 &(local_args_info.wwwbin_given), optarg, 0, 0, ARG_STRING,
                   2817:                 check_ambiguity, override, 0, 0,
                   2818:                 "wwwbin", '-',
                   2819:                 additional_error))
                   2820:               goto failure;
                   2821:           
                   2822:           }
                   2823:           /* Program in inetd style to handle all uam requests.  */
                   2824:           else if (strcmp (long_options[option_index].name, "uamui") == 0)
                   2825:           {
                   2826:           
                   2827:           
                   2828:             if (update_arg( (void *)&(args_info->uamui_arg), 
                   2829:                  &(args_info->uamui_orig), &(args_info->uamui_given),
                   2830:                 &(local_args_info.uamui_given), optarg, 0, 0, ARG_STRING,
                   2831:                 check_ambiguity, override, 0, 0,
                   2832:                 "uamui", '-',
                   2833:                 additional_error))
                   2834:               goto failure;
                   2835:           
                   2836:           }
                   2837:           /* RADIUS administrative user login username.  */
                   2838:           else if (strcmp (long_options[option_index].name, "adminuser") == 0)
                   2839:           {
                   2840:           
                   2841:           
                   2842:             if (update_arg( (void *)&(args_info->adminuser_arg), 
                   2843:                  &(args_info->adminuser_orig), &(args_info->adminuser_given),
                   2844:                 &(local_args_info.adminuser_given), optarg, 0, "chillispot", ARG_STRING,
                   2845:                 check_ambiguity, override, 0, 0,
                   2846:                 "adminuser", '-',
                   2847:                 additional_error))
                   2848:               goto failure;
                   2849:           
                   2850:           }
                   2851:           /* RADIUS administrative user login password.  */
                   2852:           else if (strcmp (long_options[option_index].name, "adminpasswd") == 0)
                   2853:           {
                   2854:           
                   2855:           
                   2856:             if (update_arg( (void *)&(args_info->adminpasswd_arg), 
                   2857:                  &(args_info->adminpasswd_orig), &(args_info->adminpasswd_given),
                   2858:                 &(local_args_info.adminpasswd_given), optarg, 0, "chillispot", ARG_STRING,
                   2859:                 check_ambiguity, override, 0, 0,
                   2860:                 "adminpasswd", '-',
                   2861:                 additional_error))
                   2862:               goto failure;
                   2863:           
                   2864:           }
                   2865:           /* Unique MAC address of the NAS (called-station-id).  */
                   2866:           else if (strcmp (long_options[option_index].name, "nasmac") == 0)
                   2867:           {
                   2868:           
                   2869:           
                   2870:             if (update_arg( (void *)&(args_info->nasmac_arg), 
                   2871:                  &(args_info->nasmac_orig), &(args_info->nasmac_given),
                   2872:                 &(local_args_info.nasmac_given), optarg, 0, 0, ARG_STRING,
                   2873:                 check_ambiguity, override, 0, 0,
                   2874:                 "nasmac", '-',
                   2875:                 additional_error))
                   2876:               goto failure;
                   2877:           
                   2878:           }
                   2879:           /* Unique IP address of the NAS (nas-ip-address).  */
                   2880:           else if (strcmp (long_options[option_index].name, "nasip") == 0)
                   2881:           {
                   2882:           
                   2883:           
                   2884:             if (update_arg( (void *)&(args_info->nasip_arg), 
                   2885:                  &(args_info->nasip_orig), &(args_info->nasip_given),
                   2886:                 &(local_args_info.nasip_given), optarg, 0, 0, ARG_STRING,
                   2887:                 check_ambiguity, override, 0, 0,
                   2888:                 "nasip", '-',
                   2889:                 additional_error))
                   2890:               goto failure;
                   2891:           
                   2892:           }
                   2893:           /* SSID of the session.  */
                   2894:           else if (strcmp (long_options[option_index].name, "ssid") == 0)
                   2895:           {
                   2896:           
                   2897:           
                   2898:             if (update_arg( (void *)&(args_info->ssid_arg), 
                   2899:                  &(args_info->ssid_orig), &(args_info->ssid_given),
                   2900:                 &(local_args_info.ssid_given), optarg, 0, 0, ARG_STRING,
                   2901:                 check_ambiguity, override, 0, 0,
                   2902:                 "ssid", '-',
                   2903:                 additional_error))
                   2904:               goto failure;
                   2905:           
                   2906:           }
                   2907:           /* VLAN of the session.  */
                   2908:           else if (strcmp (long_options[option_index].name, "vlan") == 0)
                   2909:           {
                   2910:           
                   2911:           
                   2912:             if (update_arg( (void *)&(args_info->vlan_arg), 
                   2913:                  &(args_info->vlan_orig), &(args_info->vlan_given),
                   2914:                 &(local_args_info.vlan_given), optarg, 0, 0, ARG_STRING,
                   2915:                 check_ambiguity, override, 0, 0,
                   2916:                 "vlan", '-',
                   2917:                 additional_error))
                   2918:               goto failure;
                   2919:           
                   2920:           }
                   2921:           /* path to the command unix socket.  */
                   2922:           else if (strcmp (long_options[option_index].name, "cmdsocket") == 0)
                   2923:           {
                   2924:           
                   2925:           
                   2926:             if (update_arg( (void *)&(args_info->cmdsocket_arg), 
                   2927:                  &(args_info->cmdsocket_orig), &(args_info->cmdsocket_given),
                   2928:                 &(local_args_info.cmdsocket_given), optarg, 0, 0, ARG_STRING,
                   2929:                 check_ambiguity, override, 0, 0,
                   2930:                 "cmdsocket", '-',
                   2931:                 additional_error))
                   2932:               goto failure;
                   2933:           
                   2934:           }
                   2935:           /* Turn on the sending of ChilliSpot-OriginalURL in Access-Request.  */
                   2936:           else if (strcmp (long_options[option_index].name, "radiusoriginalurl") == 0)
                   2937:           {
                   2938:           
                   2939:           
                   2940:             if (update_arg((void *)&(args_info->radiusoriginalurl_flag), 0, &(args_info->radiusoriginalurl_given),
                   2941:                 &(local_args_info.radiusoriginalurl_given), optarg, 0, 0, ARG_FLAG,
                   2942:                 check_ambiguity, override, 1, 0, "radiusoriginalurl", '-',
                   2943:                 additional_error))
                   2944:               goto failure;
                   2945:           
                   2946:           }
                   2947:           /* Swap the meaning of input/output octets/packets.  */
                   2948:           else if (strcmp (long_options[option_index].name, "swapoctets") == 0)
                   2949:           {
                   2950:           
                   2951:           
                   2952:             if (update_arg((void *)&(args_info->swapoctets_flag), 0, &(args_info->swapoctets_given),
                   2953:                 &(local_args_info.swapoctets_given), optarg, 0, 0, ARG_FLAG,
                   2954:                 check_ambiguity, override, 1, 0, "swapoctets", '-',
                   2955:                 additional_error))
                   2956:               goto failure;
                   2957:           
                   2958:           }
                   2959:           /* Use the status file to keep track of sessions.  */
                   2960:           else if (strcmp (long_options[option_index].name, "usestatusfile") == 0)
                   2961:           {
                   2962:           
                   2963:           
                   2964:             if (update_arg((void *)&(args_info->usestatusfile_flag), 0, &(args_info->usestatusfile_given),
                   2965:                 &(local_args_info.usestatusfile_given), optarg, 0, 0, ARG_FLAG,
                   2966:                 check_ambiguity, override, 1, 0, "usestatusfile", '-',
                   2967:                 additional_error))
                   2968:               goto failure;
                   2969:           
                   2970:           }
                   2971:           /* File keep 'Local' usernames and passwords.  */
                   2972:           else if (strcmp (long_options[option_index].name, "localusers") == 0)
                   2973:           {
                   2974:           
                   2975:           
                   2976:             if (update_arg( (void *)&(args_info->localusers_arg), 
                   2977:                  &(args_info->localusers_orig), &(args_info->localusers_given),
                   2978:                 &(local_args_info.localusers_given), optarg, 0, 0, ARG_STRING,
                   2979:                 check_ambiguity, override, 0, 0,
                   2980:                 "localusers", '-',
                   2981:                 additional_error))
                   2982:               goto failure;
                   2983:           
                   2984:           }
                   2985:           /* IP of an upstream transparent proxy.  */
                   2986:           else if (strcmp (long_options[option_index].name, "postauthproxy") == 0)
                   2987:           {
                   2988:           
                   2989:           
                   2990:             if (update_arg( (void *)&(args_info->postauthproxy_arg), 
                   2991:                  &(args_info->postauthproxy_orig), &(args_info->postauthproxy_given),
                   2992:                 &(local_args_info.postauthproxy_given), optarg, 0, 0, ARG_STRING,
                   2993:                 check_ambiguity, override, 0, 0,
                   2994:                 "postauthproxy", '-',
                   2995:                 additional_error))
                   2996:               goto failure;
                   2997:           
                   2998:           }
                   2999:           /* Port of an upstream transparent proxy.  */
                   3000:           else if (strcmp (long_options[option_index].name, "postauthproxyport") == 0)
                   3001:           {
                   3002:           
                   3003:           
                   3004:             if (update_arg( (void *)&(args_info->postauthproxyport_arg), 
                   3005:                  &(args_info->postauthproxyport_orig), &(args_info->postauthproxyport_given),
                   3006:                 &(local_args_info.postauthproxyport_given), optarg, 0, "0", ARG_INT,
                   3007:                 check_ambiguity, override, 0, 0,
                   3008:                 "postauthproxyport", '-',
                   3009:                 additional_error))
                   3010:               goto failure;
                   3011:           
                   3012:           }
                   3013:           /* Allow WPA 'Guest' access.  */
                   3014:           else if (strcmp (long_options[option_index].name, "wpaguests") == 0)
                   3015:           {
                   3016:           
                   3017:           
                   3018:             if (update_arg((void *)&(args_info->wpaguests_flag), 0, &(args_info->wpaguests_given),
                   3019:                 &(local_args_info.wpaguests_given), optarg, 0, 0, ARG_FLAG,
                   3020:                 check_ambiguity, override, 1, 0, "wpaguests", '-',
                   3021:                 additional_error))
                   3022:               goto failure;
                   3023:           
                   3024:           }
                   3025:           /* Allow OpenID authentication.  */
                   3026:           else if (strcmp (long_options[option_index].name, "openidauth") == 0)
                   3027:           {
                   3028:           
                   3029:           
                   3030:             if (update_arg((void *)&(args_info->openidauth_flag), 0, &(args_info->openidauth_given),
                   3031:                 &(local_args_info.openidauth_given), optarg, 0, 0, ARG_FLAG,
                   3032:                 check_ambiguity, override, 1, 0, "openidauth", '-',
                   3033:                 additional_error))
                   3034:               goto failure;
                   3035:           
                   3036:           }
                   3037:           /* Always allow 'PAP' authentication (depreciated; always on).  */
                   3038:           else if (strcmp (long_options[option_index].name, "papalwaysok") == 0)
                   3039:           {
                   3040:           
                   3041:           
                   3042:             if (update_arg((void *)&(args_info->papalwaysok_flag), 0, &(args_info->papalwaysok_given),
                   3043:                 &(local_args_info.papalwaysok_given), optarg, 0, 0, ARG_FLAG,
                   3044:                 check_ambiguity, override, 1, 0, "papalwaysok", '-',
                   3045:                 additional_error))
                   3046:               goto failure;
                   3047:           
                   3048:           }
                   3049:           /* Use ChilliSpot XML in WISPr blocks.  */
                   3050:           else if (strcmp (long_options[option_index].name, "chillixml") == 0)
                   3051:           {
                   3052:           
                   3053:           
                   3054:             if (update_arg((void *)&(args_info->chillixml_flag), 0, &(args_info->chillixml_given),
                   3055:                 &(local_args_info.chillixml_given), optarg, 0, 0, ARG_FLAG,
                   3056:                 check_ambiguity, override, 1, 0, "chillixml", '-',
                   3057:                 additional_error))
                   3058:               goto failure;
                   3059:           
                   3060:           }
                   3061:           /* Allow updating of session attributes in Accounting-Response.  */
                   3062:           else if (strcmp (long_options[option_index].name, "acctupdate") == 0)
                   3063:           {
                   3064:           
                   3065:           
                   3066:             if (update_arg((void *)&(args_info->acctupdate_flag), 0, &(args_info->acctupdate_given),
                   3067:                 &(local_args_info.acctupdate_given), optarg, 0, 0, ARG_FLAG,
                   3068:                 check_ambiguity, override, 1, 0, "acctupdate", '-',
                   3069:                 additional_error))
                   3070:               goto failure;
                   3071:           
                   3072:           }
                   3073:           /* Inspect DNS packets and drop responses with any non- A, CNAME, SOA, or MX records (to prevent dns tunnels).  */
                   3074:           else if (strcmp (long_options[option_index].name, "dnsparanoia") == 0)
                   3075:           {
                   3076:           
                   3077:           
                   3078:             if (update_arg((void *)&(args_info->dnsparanoia_flag), 0, &(args_info->dnsparanoia_given),
                   3079:                 &(local_args_info.dnsparanoia_given), optarg, 0, 0, ARG_FLAG,
                   3080:                 check_ambiguity, override, 1, 0, "dnsparanoia", '-',
                   3081:                 additional_error))
                   3082:               goto failure;
                   3083:           
                   3084:           }
                   3085:           /* Use a TAP instead of TUN (linux only).  */
                   3086:           else if (strcmp (long_options[option_index].name, "usetap") == 0)
                   3087:           {
                   3088:           
                   3089:           
                   3090:             if (update_arg((void *)&(args_info->usetap_flag), 0, &(args_info->usetap_given),
                   3091:                 &(local_args_info.usetap_given), optarg, 0, 0, ARG_FLAG,
                   3092:                 check_ambiguity, override, 1, 0, "usetap", '-',
                   3093:                 additional_error))
                   3094:               goto failure;
                   3095:           
                   3096:           }
                   3097:           /* Interface to use as default route; turns on 'manual' routing.  */
                   3098:           else if (strcmp (long_options[option_index].name, "routeif") == 0)
                   3099:           {
                   3100:           
                   3101:           
                   3102:             if (update_arg( (void *)&(args_info->routeif_arg), 
                   3103:                  &(args_info->routeif_orig), &(args_info->routeif_given),
                   3104:                 &(local_args_info.routeif_given), optarg, 0, 0, ARG_STRING,
                   3105:                 check_ambiguity, override, 0, 0,
                   3106:                 "routeif", '-',
                   3107:                 additional_error))
                   3108:               goto failure;
                   3109:           
                   3110:           }
                   3111:           
                   3112:           break;
                   3113:         case '?':      /* Invalid option.  */
                   3114:           /* `getopt_long' already printed an error message.  */
                   3115:           goto failure;
                   3116: 
                   3117:         default:       /* bug: option not considered.  */
                   3118:           fprintf (stderr, "%s: option unknown: %c%s\n", CMDLINE_PARSER_PACKAGE, c, (additional_error ? additional_error : ""));
                   3119:           abort ();
                   3120:         } /* switch */
                   3121:     } /* while */
                   3122: 
                   3123: 
                   3124:   update_multiple_arg((void *)&(args_info->uamallowed_arg),
                   3125:     &(args_info->uamallowed_orig), args_info->uamallowed_given,
                   3126:     local_args_info.uamallowed_given, 0 , 
                   3127:     ARG_STRING, uamallowed_list);
                   3128:   update_multiple_arg((void *)&(args_info->uamdomain_arg),
                   3129:     &(args_info->uamdomain_orig), args_info->uamdomain_given,
                   3130:     local_args_info.uamdomain_given, 0 , 
                   3131:     ARG_STRING, uamdomain_list);
                   3132:   update_multiple_arg((void *)&(args_info->macallowed_arg),
                   3133:     &(args_info->macallowed_orig), args_info->macallowed_given,
                   3134:     local_args_info.macallowed_given, 0 , 
                   3135:     ARG_STRING, macallowed_list);
                   3136: 
                   3137:   args_info->uamallowed_given += local_args_info.uamallowed_given;
                   3138:   local_args_info.uamallowed_given = 0;
                   3139:   args_info->uamdomain_given += local_args_info.uamdomain_given;
                   3140:   local_args_info.uamdomain_given = 0;
                   3141:   args_info->macallowed_given += local_args_info.macallowed_given;
                   3142:   local_args_info.macallowed_given = 0;
                   3143:   
                   3144:   if (check_required)
                   3145:     {
                   3146:       error += cmdline_parser_required2 (args_info, argv[0], additional_error);
                   3147:     }
                   3148: 
                   3149:   cmdline_parser_release (&local_args_info);
                   3150: 
                   3151:   if ( error )
                   3152:     return (EXIT_FAILURE);
                   3153: 
                   3154:   return 0;
                   3155: 
                   3156: failure:
                   3157:   free_list (uamallowed_list, 1 );
                   3158:   free_list (uamdomain_list, 1 );
                   3159:   free_list (macallowed_list, 1 );
                   3160:   
                   3161:   cmdline_parser_release (&local_args_info);
                   3162:   return (EXIT_FAILURE);
                   3163: }
                   3164: 
                   3165: #ifndef CONFIG_FILE_LINE_SIZE
                   3166: #define CONFIG_FILE_LINE_SIZE 2048
                   3167: #endif
                   3168: #define ADDITIONAL_ERROR " in configuration file "
                   3169: 
                   3170: #define CONFIG_FILE_LINE_BUFFER_SIZE (CONFIG_FILE_LINE_SIZE+3)
                   3171: /* 3 is for "--" and "=" */
                   3172: 
                   3173: static int
                   3174: _cmdline_parser_configfile (char * const filename, int *my_argc)
                   3175: {
                   3176:   FILE* file;
                   3177:   char my_argv[CONFIG_FILE_LINE_BUFFER_SIZE+1];
                   3178:   char linebuf[CONFIG_FILE_LINE_SIZE];
                   3179:   int line_num = 0;
                   3180:   int result = 0, equal;
                   3181:   char *fopt, *farg;
                   3182:   char *str_index;
                   3183:   size_t len, next_token;
                   3184:   char delimiter;
                   3185: 
                   3186:   if ((file = fopen(filename, "r")) == NULL)
                   3187:     {
                   3188:       fprintf (stderr, "%s: Error opening configuration file '%s'\n",
                   3189:                CMDLINE_PARSER_PACKAGE, filename);
                   3190:       return EXIT_FAILURE;
                   3191:     }
                   3192: 
                   3193:   while ((fgets(linebuf, CONFIG_FILE_LINE_SIZE, file)) != NULL)
                   3194:     {
                   3195:       ++line_num;
                   3196:       my_argv[0] = '\0';
                   3197:       len = strlen(linebuf);
                   3198:       if (len > (CONFIG_FILE_LINE_BUFFER_SIZE-1))
                   3199:         {
                   3200:           fprintf (stderr, "%s:%s:%d: Line too long in configuration file\n",
                   3201:                    CMDLINE_PARSER_PACKAGE, filename, line_num);
                   3202:           result = EXIT_FAILURE;
                   3203:           break;
                   3204:         }
                   3205: 
                   3206:       /* find first non-whitespace character in the line */
                   3207:       next_token = strspn (linebuf, " \t\r\n");
                   3208:       str_index  = linebuf + next_token;
                   3209: 
                   3210:       if ( str_index[0] == '\0' || str_index[0] == '#')
                   3211:         continue; /* empty line or comment line is skipped */
                   3212: 
                   3213:       fopt = str_index;
                   3214: 
                   3215:       /* truncate fopt at the end of the first non-valid character */
                   3216:       next_token = strcspn (fopt, " \t\r\n=");
                   3217: 
                   3218:       if (fopt[next_token] == '\0') /* the line is over */
                   3219:         {
                   3220:           farg  = NULL;
                   3221:           equal = 0;
                   3222:           goto noarg;
                   3223:         }
                   3224: 
                   3225:       /* remember if equal sign is present */
                   3226:       equal = (fopt[next_token] == '=');
                   3227:       fopt[next_token++] = '\0';
                   3228: 
                   3229:       /* advance pointers to the next token after the end of fopt */
                   3230:       next_token += strspn (fopt + next_token, " \t\r\n");
                   3231: 
                   3232:       /* check for the presence of equal sign, and if so, skip it */
                   3233:       if ( !equal )
                   3234:         if ((equal = (fopt[next_token] == '=')))
                   3235:           {
                   3236:             next_token++;
                   3237:             next_token += strspn (fopt + next_token, " \t\r\n");
                   3238:           }
                   3239:       str_index  += next_token;
                   3240: 
                   3241:       /* find argument */
                   3242:       farg = str_index;
                   3243:       if ( farg[0] == '\"' || farg[0] == '\'' )
                   3244:         { /* quoted argument */
                   3245:           str_index = strchr (++farg, str_index[0] ); /* skip opening quote */
                   3246:           if (! str_index)
                   3247:             {
                   3248:               fprintf
                   3249:                 (stderr,
                   3250:                  "%s:%s:%d: unterminated string in configuration file\n",
                   3251:                  CMDLINE_PARSER_PACKAGE, filename, line_num);
                   3252:               result = EXIT_FAILURE;
                   3253:               break;
                   3254:             }
                   3255:         }
                   3256:       else
                   3257:         { /* read up the remaining part up to a delimiter */
                   3258:           next_token = strcspn (farg, " \t\r\n#\'\"");
                   3259:           str_index += next_token;
                   3260:         }
                   3261: 
                   3262:       /* truncate farg at the delimiter and store it for further check */
                   3263:       delimiter = *str_index, *str_index++ = '\0';
                   3264: 
                   3265:       /* everything but comment is illegal at the end of line */
                   3266:       if (delimiter != '\0' && delimiter != '#')
                   3267:         {
                   3268:           str_index += strspn(str_index, " \t\r\n");
                   3269:           if (*str_index != '\0' && *str_index != '#')
                   3270:             {
                   3271:               fprintf
                   3272:                 (stderr,
                   3273:                  "%s:%s:%d: malformed string in configuration file\n",
                   3274:                  CMDLINE_PARSER_PACKAGE, filename, line_num);
                   3275:               result = EXIT_FAILURE;
                   3276:               break;
                   3277:             }
                   3278:         }
                   3279: 
                   3280:     noarg:
                   3281:       if (!strcmp(fopt,"include")) {
                   3282:         if (farg && *farg) {
                   3283:           result = _cmdline_parser_configfile(farg, my_argc);
                   3284:         } else {
                   3285:           fprintf(stderr, "%s:%s:%d: include requires a filename argument.\n",
                   3286:                   CMDLINE_PARSER_PACKAGE, filename, line_num);
                   3287:         }
                   3288:         continue;
                   3289:       }
                   3290:       len = strlen(fopt);
                   3291:       strcat (my_argv, len > 1 ? "--" : "-");
                   3292:       strcat (my_argv, fopt);
                   3293:       if (len > 1 && ((farg && *farg) || equal))
                   3294:         strcat (my_argv, "=");
                   3295:       if (farg && *farg)
                   3296:         strcat (my_argv, farg);
                   3297:       ++(*my_argc);
                   3298: 
                   3299:       cmd_line_list_tmp = (struct line_list *) malloc (sizeof (struct line_list));
                   3300:       cmd_line_list_tmp->next = cmd_line_list;
                   3301:       cmd_line_list = cmd_line_list_tmp;
                   3302:       cmd_line_list->string_arg = gengetopt_strdup(my_argv);
                   3303:     } /* while */
                   3304: 
                   3305:   if (file)
                   3306:     fclose(file);
                   3307:   return result;
                   3308: }
                   3309: 
                   3310: int
                   3311: cmdline_parser_configfile (char * const filename,
                   3312:                            struct gengetopt_args_info *args_info,
                   3313:                            int override, int initialize, int check_required)
                   3314: {
                   3315:   struct cmdline_parser_params params;
                   3316: 
                   3317:   params.override = override;
                   3318:   params.initialize = initialize;
                   3319:   params.check_required = check_required;
                   3320:   params.check_ambiguity = 0;
                   3321:   params.print_errors = 1;
                   3322:   
                   3323:   return cmdline_parser_config_file (filename, args_info, &params);
                   3324: }
                   3325: 
                   3326: int
                   3327: cmdline_parser_config_file (char * const filename,
                   3328:                            struct gengetopt_args_info *args_info,
                   3329:                            struct cmdline_parser_params *params)
                   3330: {
                   3331:   int i, result;
                   3332:   int my_argc = 1;
                   3333:   char **my_argv_arg;
                   3334:   char *additional_error;
                   3335: 
                   3336:   /* store the program name */
                   3337:   cmd_line_list_tmp = (struct line_list *) malloc (sizeof (struct line_list));
                   3338:   cmd_line_list_tmp->next = cmd_line_list;
                   3339:   cmd_line_list = cmd_line_list_tmp;
                   3340:   cmd_line_list->string_arg = gengetopt_strdup (CMDLINE_PARSER_PACKAGE);
                   3341: 
                   3342:   result = _cmdline_parser_configfile(filename, &my_argc);
                   3343: 
                   3344:   if (result != EXIT_FAILURE) {
                   3345:     my_argv_arg = (char **) malloc((my_argc+1) * sizeof(char *));
                   3346:     cmd_line_list_tmp = cmd_line_list;
                   3347: 
                   3348:     for (i = my_argc - 1; i >= 0; --i) {
                   3349:       my_argv_arg[i] = cmd_line_list_tmp->string_arg;
                   3350:       cmd_line_list_tmp = cmd_line_list_tmp->next;
                   3351:     }
                   3352: 
                   3353:     my_argv_arg[my_argc] = 0;
                   3354: 
                   3355:     additional_error = (char *)malloc(strlen(filename) + strlen(ADDITIONAL_ERROR) + 1);
                   3356:     strcpy (additional_error, ADDITIONAL_ERROR);
                   3357:     strcat (additional_error, filename);
                   3358:     result =
                   3359:       cmdline_parser_internal (my_argc, my_argv_arg, args_info,
                   3360:                               params,
                   3361:                               additional_error);
                   3362: 
                   3363:     free (additional_error);
                   3364:     free (my_argv_arg);
                   3365:   }
                   3366: 
                   3367:   free_cmd_list();
                   3368:   if (result == EXIT_FAILURE)
                   3369:     {
                   3370:       cmdline_parser_free (args_info);
                   3371:       exit (EXIT_FAILURE);
                   3372:     }
                   3373:   
                   3374:   return result;
                   3375: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>