f08081f536cdbbe4d9862ae39ace4dad7dd3738c
[src/app-framework-binder.git] / src / afb-config.c
1 /*
2  * Copyright (C) 2015, 2016, 2017 "IoT.bzh"
3  * Author José Bollo <jose.bollo@iot.bzh>
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *   http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17
18 #define _GNU_SOURCE
19 #define AFB_BINDING_PRAGMA_NO_VERBOSE_MACRO
20
21 #include <stdlib.h>
22 #include <stdio.h>
23 #include <string.h>
24 #include <getopt.h>
25 #include <limits.h>
26 #include <unistd.h>
27
28 #include "verbose.h"
29 #include "afb-config.h"
30 #include "afb-hook.h"
31
32 #include <afb/afb-binding-v1.h>
33
34 #if !defined(BINDING_INSTALL_DIR)
35 #error "you should define BINDING_INSTALL_DIR"
36 #endif
37
38 #define AFB_VERSION    "0.6"
39
40 // default
41 #define DEFLT_CNTX_TIMEOUT  3600        // default Client Connection
42                                         // Timeout
43 #define DEFLT_API_TIMEOUT   20          // default Plugin API Timeout [0=NoLimit
44                                         // for Debug Only]
45 #define DEFLT_CACHE_TIMEOUT 100000      // default Static File Chache
46                                         // [Client Side Cache
47                                         // 100000~=1day]
48 #define CTX_NBCLIENTS       10          // allow a default of 10 authenticated
49                                         // clients
50
51
52 // Define command line option
53 #define SET_BACKGROUND     2
54 #define SET_FORGROUND      3
55
56 #define SET_ROOT_DIR       6
57 #define SET_ROOT_BASE      7
58 #define SET_ROOT_API       8
59 #define SET_ALIAS          9
60
61 #define SET_CACHE_TIMEOUT  10
62 #define SET_SESSION_DIR    11
63
64 #define SET_LDPATH         13
65 #define SET_APITIMEOUT     14
66 #define SET_CNTXTIMEOUT    15
67 #define SET_WEAK_LDPATH    16
68 #define NO_LDPATH          17
69
70 #define SET_MODE           18
71
72 #define DBUS_CLIENT        20
73 #define DBUS_SERVICE       21
74 #define SO_BINDING         22
75
76 #define SET_SESSIONMAX     23
77
78 #define WS_CLIENT          24
79 #define WS_SERVICE         25
80
81 #define SET_ROOT_HTTP      26
82
83 #define SET_NO_HTTPD       28
84
85 #define ADD_CALL           'c'
86 #define SET_TRACEDITF      'D'
87 #define SET_TRACEEVT       'E'
88 #define SET_EXEC           'e'
89 #define DISPLAY_HELP       'h'
90 #if defined(WITH_MONITORING_OTPION)
91 #define SET_MONITORING     'M'
92 #endif
93 #define SET_TCP_PORT       'p'
94 #define SET_QUIET          'q'
95 #define SET_RNDTOKEN       'r'
96 #define SET_TRACESVC       'S'
97 #define SET_TRACEREQ       'T'
98 #define SET_AUTH_TOKEN     't'
99 #define SET_UPLOAD_DIR     'u'
100 #define DISPLAY_VERSION    'V'
101 #define SET_VERBOSE        'v'
102 #define SET_WORK_DIR       'w'
103
104 const char shortopts[] =
105         "c:D:E:ehp:qrT:t:u:Vvw:"
106 #if defined(WITH_MONITORING_OTPION)
107         "M"
108 #endif
109 ;
110
111 // Command line structure hold cli --command + help text
112 typedef struct {
113         int val;                // command number within application
114         int has_arg;            // command number within application
115         char *name;             // command as used in --xxxx cli
116         char *help;             // help text
117 } AFB_options;
118
119 // Supported option
120 static AFB_options cliOptions[] = {
121 /* *INDENT-OFF* */
122         {SET_VERBOSE,       0, "verbose",     "Verbose Mode, repeat to increase verbosity"},
123         {SET_QUIET,         0, "quiet",       "Quiet Mode, repeat to decrease verbosity"},
124
125         {SET_FORGROUND,     0, "foreground",  "Get all in foreground mode"},
126         {SET_BACKGROUND,    0, "daemon",      "Get all in background mode"},
127
128         {SET_TCP_PORT,      1, "port",        "HTTP listening TCP port  [default 1234]"},
129         {SET_ROOT_HTTP,     1, "roothttp",    "HTTP Root Directory [default no root http (files not served but apis still available)]"},
130         {SET_ROOT_BASE,     1, "rootbase",    "Angular Base Root URL [default /opa]"},
131         {SET_ROOT_API,      1, "rootapi",     "HTML Root API URL [default /api]"},
132         {SET_ALIAS,         1, "alias",       "Multiple url map outside of rootdir [eg: --alias=/icons:/usr/share/icons]"},
133
134         {SET_APITIMEOUT,    1, "apitimeout",  "Binding API timeout in seconds [default 10]"},
135         {SET_CNTXTIMEOUT,   1, "cntxtimeout", "Client Session Context Timeout [default 900]"},
136         {SET_CACHE_TIMEOUT, 1, "cache-eol",   "Client cache end of live [default 3600]"},
137
138         {SET_WORK_DIR,      1, "workdir",     "Set the working directory [default: $PWD or current working directory]"},
139         {SET_UPLOAD_DIR,    1, "uploaddir",   "Directory for uploading files [default: workdir]"},
140         {SET_ROOT_DIR,      1, "rootdir",     "Root Directory of the application [default: workdir]"},
141         {SET_SESSION_DIR,   1, "sessiondir",  "OBSOLETE (was: Sessions file path)"},
142
143         {SET_LDPATH,        1, "ldpaths",     "Load bindings from dir1:dir2:... [default = " BINDING_INSTALL_DIR "]"},
144         {SO_BINDING,        1, "binding",     "Load the binding of path"},
145         {SET_WEAK_LDPATH,   1, "weak-ldpaths","Same as --ldpaths but ignore errors"},
146         {NO_LDPATH,         0, "no-ldpaths",  "Discard default ldpaths loading"},
147
148         {SET_AUTH_TOKEN,    1, "token",       "Initial Secret [default=no-session, --token= for session without authentication]"},
149         {SET_RNDTOKEN,      0, "random-token","Enforce a random token"},
150
151         {DISPLAY_VERSION,   0, "version",     "Display version and copyright"},
152         {DISPLAY_HELP,      0, "help",        "Display this help"},
153
154         {SET_MODE,          1, "mode",        "Set the mode: either local, remote or global"},
155
156         {DBUS_CLIENT,       1, "dbus-client", "Bind to an afb service through dbus"},
157         {DBUS_SERVICE,      1, "dbus-server", "Provides an afb service through dbus"},
158         {WS_CLIENT,         1, "ws-client",   "Bind to an afb service through websocket"},
159         {WS_SERVICE,        1, "ws-server",   "Provides an afb service through websockets"},
160
161         {SET_SESSIONMAX,    1, "session-max", "Max count of session simultaneously [default 10]"},
162
163         {SET_TRACEREQ,      1, "tracereq",    "Log the requests: no, common, extra, all"},
164         {SET_TRACEDITF,     1, "traceditf",   "Log the requests: no, common, extra, all"},
165         {SET_TRACESVC,      1, "tracesvc",    "Log the requests: no, all"},
166         {SET_TRACEEVT,      1, "traceevt",    "Log the requests: no, common, extra, all"},
167
168         {ADD_CALL,          1, "call",        "call at start format of val: API/VERB:json-args"},
169
170         {SET_NO_HTTPD,      0, "no-httpd",    "Forbids HTTP service"},
171         {SET_EXEC,          0, "exec",        "Execute the remaining arguments"},
172
173 #if defined(WITH_MONITORING_OTPION)
174         {SET_MONITORING,    0, "monitoring",  "enable HTTP monitoring at <ROOT>/monitoring/"},
175 #endif
176         {0, 0, NULL, NULL}
177 /* *INDENT-ON* */
178 };
179
180
181 struct enumdesc
182 {
183         const char *name;
184         int value;
185 };
186
187 static struct enumdesc tracereq_desc[] = {
188         { "no",     0 },
189         { "common", afb_hook_flags_req_common },
190         { "extra",  afb_hook_flags_req_extra },
191         { "all",    afb_hook_flags_req_all },
192         { NULL, 0 }
193 };
194
195 static struct enumdesc traceditf_desc[] = {
196         { "no",     0 },
197         { "common", afb_hook_flags_ditf_common },
198         { "extra",  afb_hook_flags_ditf_extra },
199         { "all",    afb_hook_flags_ditf_all },
200         { NULL, 0 }
201 };
202
203 static struct enumdesc tracesvc_desc[] = {
204         { "no",     0 },
205         { "all",    afb_hook_flags_svc_all },
206         { NULL, 0 }
207 };
208
209 static struct enumdesc traceevt_desc[] = {
210         { "no",     0 },
211         { "common", afb_hook_flags_evt_common },
212         { "extra",  afb_hook_flags_evt_extra },
213         { "all",    afb_hook_flags_evt_all },
214         { NULL, 0 }
215 };
216
217 static struct enumdesc mode_desc[] = {
218         { "local",  AFB_MODE_LOCAL },
219         { "remote", AFB_MODE_REMOTE },
220         { "global", AFB_MODE_GLOBAL },
221         { NULL, 0 }
222 };
223
224 /*----------------------------------------------------------
225  | printversion
226  |   print version and copyright
227  +--------------------------------------------------------- */
228 static void printVersion(FILE * file)
229 {
230         fprintf(file, "\n----------------------------------------- \n");
231         fprintf(file, "  AFB [Application Framework Binder] version=%s |\n",
232                 AFB_VERSION);
233         fprintf(file, " \n");
234         fprintf(file,
235                 "  Copyright (C) 2015, 2016, 2017 \"IoT.bzh\" [fulup -at- iot.bzh]\n");
236         fprintf(file, "  AFB comes with ABSOLUTELY NO WARRANTY.\n");
237         fprintf(file, "  Licence Apache 2\n\n");
238 }
239
240 /*----------------------------------------------------------
241  | printHelp
242  |   print information from long option array
243  +--------------------------------------------------------- */
244
245 static void printHelp(FILE * file, const char *name)
246 {
247         int ind;
248         char command[50];
249
250         fprintf(file, "%s:\nallowed options\n", name);
251         for (ind = 0; cliOptions[ind].name != NULL; ind++) {
252                 strcpy(command, cliOptions[ind].name);
253                 if (cliOptions[ind].has_arg)
254                         strcat(command, "=xxxx");
255                 fprintf(file, "  --%-15s %s\n", command, cliOptions[ind].help);
256         }
257         fprintf(file,
258                 "Example:\n  %s  --verbose --port=1234 --token='azerty' --ldpaths=build/bindings:/usr/lib64/agl/bindings\n",
259                 name);
260 }
261
262
263 /*----------------------------------------------------------
264  |   adds a string to the list
265  +--------------------------------------------------------- */
266 static void list_add(struct afb_config_list **head, char *value)
267 {
268         struct afb_config_list *item;
269
270         /*
271          * search tail
272          */
273         item = *head;
274         while (item != NULL) {
275                 head = &item->next;
276                 item = item->next;
277         }
278
279         /*
280          * alloc the item
281          */
282         item = malloc(sizeof *item);
283         if (item == NULL) {
284                 ERROR("out of memory");
285                 exit(1);
286         }
287
288         /*
289          * init the item
290          */
291         *head = item;
292         item->value = value;
293         item->next = NULL;
294 }
295
296 /*---------------------------------------------------------
297  |   helpers for argument scanning
298  +--------------------------------------------------------- */
299
300 static const char *name_of_option(int optc)
301 {
302         AFB_options *o = cliOptions;
303         while (o->name && o->val != optc)
304                 o++;
305         return o->name ? : "<unknown-option-name>";
306 }
307
308 static const char *current_argument(int optc)
309 {
310         if (optarg == 0) {
311                 ERROR("option [--%s] needs a value i.e. --%s=xxx",
312                       name_of_option(optc), name_of_option(optc));
313                 exit(1);
314         }
315         return optarg;
316 }
317
318 static char *argvalstr(int optc)
319 {
320         char *result = strdup(current_argument(optc));
321         if (result == NULL) {
322                 ERROR("can't alloc memory");
323                 exit(1);
324         }
325         return result;
326 }
327
328 static int argvalenum(int optc, struct enumdesc *desc)
329 {
330         int i;
331         size_t len;
332         char *list;
333         const char *name = current_argument(optc);
334
335         i = 0;
336         while(desc[i].name && strcmp(desc[i].name, name))
337                 i++;
338         if (!desc[i].name) {
339                 len = 0;
340                 i = 0;
341                 while(desc[i].name)
342                         len += strlen(desc[i++].name);
343                 list = malloc(len + i + i);
344                 if (!i || !list)
345                         ERROR("option [--%s] bad value (found %s)",
346                                 name_of_option(optc), name);
347                 else {
348                         i = 0;
349                         strcpy(list, desc[i].name ? : "");
350                         while(desc[++i].name)
351                                 strcat(strcat(list, ", "), desc[i].name);
352                         ERROR("option [--%s] bad value, only accepts values %s (found %s)",
353                                 name_of_option(optc), list, name);
354                 }
355                 free(list);
356                 exit(1);
357         }
358         return desc[i].value;
359 }
360
361 static int argvalint(int optc, int mini, int maxi, int base)
362 {
363         const char *beg, *end;
364         long int val;
365         beg = current_argument(optc);
366         val = strtol(beg, (char**)&end, base);
367         if (*end || end == beg) {
368                 ERROR("option [--%s] requires a valid integer (found %s)",
369                         name_of_option(optc), beg);
370                 exit(1);
371         }
372         if (val < (long int)mini || val > (long int)maxi) {
373                 ERROR("option [--%s] value out of bounds (not %d<=%ld<=%d)",
374                         name_of_option(optc), mini, val, maxi);
375                 exit(1);
376         }
377         return (int)val;
378 }
379
380 static int argvalintdec(int optc, int mini, int maxi)
381 {
382         return argvalint(optc, mini, maxi, 10);
383 }
384
385 static void noarg(int optc)
386 {
387         if (optarg != 0) {
388                 ERROR("option [--%s] need no value (found %s)", name_of_option(optc), optarg);
389                 exit(1);
390         }
391 }
392
393 /*---------------------------------------------------------
394  |   Parse option and launch action
395  +--------------------------------------------------------- */
396
397 static void parse_arguments(int argc, char **argv, struct afb_config *config)
398 {
399         char *programName = argv[0];
400         int optc, ind;
401         int nbcmd;
402         struct option *gnuOptions;
403
404         // ------------------ Process Command Line -----------------------
405
406         // build GNU getopt info from cliOptions
407         nbcmd = sizeof(cliOptions) / sizeof(AFB_options);
408         gnuOptions = malloc(sizeof(*gnuOptions) * (unsigned)nbcmd);
409         for (ind = 0; ind < nbcmd; ind++) {
410                 gnuOptions[ind].name = cliOptions[ind].name;
411                 gnuOptions[ind].has_arg = cliOptions[ind].has_arg;
412                 gnuOptions[ind].flag = 0;
413                 gnuOptions[ind].val = cliOptions[ind].val;
414         }
415
416         // get all options from command line
417         while ((optc = getopt_long(argc, argv, shortopts, gnuOptions, NULL)) != EOF) {
418                 switch (optc) {
419                 case SET_VERBOSE:
420                         verbosity++;
421                         break;
422
423                 case SET_QUIET:
424                         verbosity--;
425                         break;
426
427                 case SET_TCP_PORT:
428                         config->httpdPort = argvalintdec(optc, 1024, 32767);
429                         break;
430
431                 case SET_APITIMEOUT:
432                         config->apiTimeout = argvalintdec(optc, 0, INT_MAX);
433                         break;
434
435                 case SET_CNTXTIMEOUT:
436                         config->cntxTimeout = argvalintdec(optc, 0, INT_MAX);
437                         break;
438
439                 case SET_ROOT_DIR:
440                         config->rootdir = argvalstr(optc);
441                         INFO("Forcing Rootdir=%s", config->rootdir);
442                         break;
443
444                 case SET_ROOT_HTTP:
445                         config->roothttp = argvalstr(optc);
446                         INFO("Forcing Root HTTP=%s", config->roothttp);
447                         break;
448
449                 case SET_ROOT_BASE:
450                         config->rootbase = argvalstr(optc);
451                         INFO("Forcing Rootbase=%s", config->rootbase);
452                         break;
453
454                 case SET_ROOT_API:
455                         config->rootapi = argvalstr(optc);
456                         INFO("Forcing Rootapi=%s", config->rootapi);
457                         break;
458
459                 case SET_ALIAS:
460                         list_add(&config->aliases, argvalstr(optc));
461                         break;
462
463                 case SET_AUTH_TOKEN:
464                         config->token = argvalstr(optc);
465                         break;
466
467                 case SET_LDPATH:
468                         list_add(&config->ldpaths, argvalstr(optc));
469                         break;
470
471                 case SET_WEAK_LDPATH:
472                         list_add(&config->weak_ldpaths, argvalstr(optc));
473                         break;
474
475                 case NO_LDPATH:
476                         noarg(optc);
477                         config->no_ldpaths = 1;
478                         break;
479
480                 case ADD_CALL:
481                         list_add(&config->calls, argvalstr(optc));
482                         break;
483
484                 case SET_SESSION_DIR:
485                         /* config->sessiondir = argvalstr(optc); */
486                         WARNING("Obsolete otpion %s ignored", name_of_option(optc));
487                         break;
488
489                 case SET_UPLOAD_DIR:
490                         config->uploaddir = argvalstr(optc);
491                         break;
492
493                 case SET_WORK_DIR:
494                         config->workdir = argvalstr(optc);
495                         break;
496
497                 case SET_CACHE_TIMEOUT:
498                         config->cacheTimeout = argvalintdec(optc, 0, INT_MAX);
499                         break;
500
501                 case SET_SESSIONMAX:
502                         config->nbSessionMax = argvalintdec(optc, 1, INT_MAX);
503                         break;
504
505                 case SET_FORGROUND:
506                         noarg(optc);
507                         config->background = 0;
508                         break;
509
510                 case SET_BACKGROUND:
511                         noarg(optc);
512                         config->background = 1;
513                         break;
514
515                 case SET_MODE:
516                         config->mode = argvalenum(optc, mode_desc);
517                         break;
518
519                 case DBUS_CLIENT:
520                         list_add(&config->dbus_clients, argvalstr(optc));
521                         break;
522
523                 case DBUS_SERVICE:
524                         list_add(&config->dbus_servers, argvalstr(optc));
525                         break;
526
527                 case WS_CLIENT:
528                         list_add(&config->ws_clients, argvalstr(optc));
529                         break;
530
531                 case WS_SERVICE:
532                         list_add(&config->ws_servers, argvalstr(optc));
533                         break;
534
535                 case SO_BINDING:
536                         list_add(&config->so_bindings, argvalstr(optc));
537                         break;
538
539                 case SET_TRACEREQ:
540                         config->tracereq = argvalenum(optc, tracereq_desc);
541                         break;
542
543                 case SET_TRACEDITF:
544                         config->traceditf = argvalenum(optc, traceditf_desc);
545                         break;
546
547                 case SET_TRACESVC:
548                         config->tracesvc = argvalenum(optc, tracesvc_desc);
549                         break;
550
551                 case SET_TRACEEVT:
552                         config->traceevt = argvalenum(optc, traceevt_desc);
553                         break;
554
555                 case SET_NO_HTTPD:
556                         noarg(optc);
557                         config->noHttpd = 1;
558                         break;
559
560                 case SET_EXEC:
561                         config->exec = &argv[optind];
562                         optind = argc;
563                         break;
564
565                 case SET_RNDTOKEN:
566                         config->random_token = 1;
567                         break;
568
569 #if defined(WITH_MONITORING_OTPION)
570                 case SET_MONITORING:
571                         config->monitoring = 1;
572                         break;
573 #endif
574
575                 case DISPLAY_VERSION:
576                         noarg(optc);
577                         printVersion(stdout);
578                         exit(0);
579
580                 case DISPLAY_HELP:
581                         printHelp(stdout, programName);
582                         exit(0);
583
584                 default:
585                         exit(1);
586                 }
587         }
588         free(gnuOptions);
589 }
590
591 static void fulfill_config(struct afb_config *config)
592 {
593         // default HTTP port
594         if (config->httpdPort == 0)
595                 config->httpdPort = 1234;
596
597         // default binding API timeout
598         if (config->apiTimeout == 0)
599                 config->apiTimeout = DEFLT_API_TIMEOUT;
600
601         // default AUTH_TOKEN
602         if (config->random_token)
603                 config->token = NULL;
604
605         // cache timeout default one hour
606         if (config->cacheTimeout == 0)
607                 config->cacheTimeout = DEFLT_CACHE_TIMEOUT;
608
609         // cache timeout default one hour
610         if (config->cntxTimeout == 0)
611                 config->cntxTimeout = DEFLT_CNTX_TIMEOUT;
612
613         // max count of sessions
614         if (config->nbSessionMax == 0)
615                 config->nbSessionMax = CTX_NBCLIENTS;
616
617         /* set directories */
618         if (config->workdir == NULL)
619                 config->workdir = ".";
620
621         if (config->rootdir == NULL)
622                 config->rootdir = ".";
623
624         if (config->uploaddir == NULL)
625                 config->uploaddir = ".";
626
627         // if no Angular/HTML5 rootbase let's try '/' as default
628         if (config->rootbase == NULL)
629                 config->rootbase = "/opa";
630
631         if (config->rootapi == NULL)
632                 config->rootapi = "/api";
633
634         if (config->ldpaths == NULL && config->weak_ldpaths == NULL && !config->no_ldpaths)
635                 list_add(&config->ldpaths, BINDING_INSTALL_DIR);
636
637 #if defined(WITH_MONITORING_OTPION)
638         if (config->monitoring)
639                 list_add(&config->aliases, strdup("/monitoring:"BINDING_INSTALL_DIR"/monitoring"));
640 #endif
641
642         // if no config dir create a default path from uploaddir
643         if (config->console == NULL) {
644                 config->console = malloc(512);
645                 strncpy(config->console, config->uploaddir, 512);
646                 strncat(config->console, "/AFB-console.out", 512);
647         }
648 }
649
650 void afb_config_dump(struct afb_config *config)
651 {
652         struct afb_config_list *l;
653         struct enumdesc *e;
654         char **v;
655
656 #define NN(x)   (x)?:""
657 #define P(...)  fprintf(stderr, __VA_ARGS__)
658 #define PF(x)   P("-- %15s: ", #x)
659 #define PE      P("\n")
660 #define S(x)    PF(x);P("%s",NN(config->x));PE;
661 #define D(x)    PF(x);P("%d",config->x);PE;
662 #define H(x)    PF(x);P("%x",config->x);PE;
663 #define B(x)    PF(x);P("%s",config->x?"yes":"no");PE;
664 #define L(x)    PF(x);l=config->x;if(l){P("%s\n",NN(l->value));for(l=l->next;l;l=l->next)P("-- %15s  %s\n","",NN(l->value));}else PE;
665 #define E(x,d)  for(e=d;e->name&&e->value!=config->x;e++);if(e->name){PF(x);P("%s",e->name);PE;}else{D(x);}
666 #define V(x)    P("-- %15s:", #x);for(v=config->x;v&&*v;v++)P(" %s",*v); PE;
667
668         P("---BEGIN-OF-CONFIG---\n");
669         S(console)
670         S(rootdir)
671         S(roothttp)
672         S(rootbase)
673         S(rootapi)
674         S(workdir)
675         S(uploaddir)
676         S(token)
677
678         L(aliases)
679         L(dbus_clients)
680         L(dbus_servers)
681         L(ws_clients)
682         L(ws_servers)
683         L(so_bindings)
684         L(ldpaths)
685         L(calls)
686
687         V(exec)
688
689         D(httpdPort)
690         B(background)
691         D(cacheTimeout)
692         D(apiTimeout)
693         D(cntxTimeout)
694         D(nbSessionMax)
695         E(mode,mode_desc)
696         E(tracereq,tracereq_desc)
697         E(traceditf,traceditf_desc)
698         B(noHttpd)
699         P("---END-OF-CONFIG---\n");
700
701 #undef V
702 #undef E
703 #undef L
704 #undef B
705 #undef H
706 #undef D
707 #undef S
708 #undef PE
709 #undef PF
710 #undef P
711 #undef NN
712 }
713
714 struct afb_config *afb_config_parse_arguments(int argc, char **argv)
715 {
716         struct afb_config *result;
717
718         result = calloc(1, sizeof *result);
719
720         parse_arguments(argc, argv, result);
721         fulfill_config(result);
722         if (verbosity >= 3)
723                 afb_config_dump(result);
724         return result;
725 }
726