2 Routines to simplify argument handling
4 Part of the swftools package.
6 Copyright (c) 2001 Matthias Kramm <kramm@quiss.org>
8 This file is distributed under the GPL, see file COPYING for details */
13 extern int args_callback_option(char*,char*);
14 extern int args_callback_longoption(char*,char*);
15 extern int args_callback_command(char*,char*);
16 extern void args_callback_usage(char*name);
21 void processargs(int argn2,char**argv2)
26 args_callback_usage(argv2[0]);
32 if(t<argn2-1) next=argv2[t+1];
39 if(!strcmp(&argv2[t][2],"help"))
41 args_callback_usage(argv2[0]);
44 t+=args_callback_longoption(&argv2[t][2],next);
48 if(strchr("?h",argv2[t][1]))
50 args_callback_usage(argv2[0]);
53 t+=args_callback_option(&argv2[t][1],next);
58 t+=args_callback_command(argv2[t],next);
69 int args_long2shortoption(struct options_t*options, char*name, char*val)
71 char*equal = strchr(name,'=');
76 while(options->shortoption) {
77 if(!strcmp(options->longoption, name)) {
78 char*tmp = (char*)malloc(strlen(options->shortoption)
79 +(equal?strlen(equal)+2:2));
80 strcpy(tmp, options->shortoption);
82 //strcpy(&tmp[strlen(tmp)], equal);
83 int ret = args_callback_option(tmp, equal);
86 return args_callback_option(tmp,val);
90 fprintf(stderr, "Unknown option: --%s\n", name);