X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=lib%2Fargs.h;h=f5f03514fb6e6c21fcc4b6b5af9e00e422374187;hb=d54d036a50a094227ced110a9adbd5c53697ce37;hp=2d5c6615175ee0663968aa17fd3b5e067ebbd2dd;hpb=b4c1a60dc1d38ee55f2fc58cbfc3a9f5c613101c;p=swftools.git diff --git a/lib/args.h b/lib/args.h index 2d5c661..f5f0351 100644 --- a/lib/args.h +++ b/lib/args.h @@ -4,12 +4,26 @@ Part of the swftools package. Copyright (c) 2001 Matthias Kramm + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. - This file is distributed under the GPL, see file COPYING for details */ + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef __args_h__ #define __args_h__ +#ifndef NO_ARGPARSER + extern int args_callback_option(char*,char*); extern int args_callback_longoption(char*,char*); extern int args_callback_command(char*,char*); @@ -18,7 +32,7 @@ extern void args_callback_usage(char*name); //int argn; //char**argv; -void processargs(int argn2,char**argv2) +static void processargs(int argn2,char**argv2) { int t; if(argn2==1) @@ -32,7 +46,7 @@ void processargs(int argn2,char**argv2) if(t='0' && *digits<='9') + digits++; + if(digits == pos) { + fprintf(stderr, "Error: \"%s\" is not a valid format (digit expected)\n",irange); + exit(1); + } + + tmp=*digits;*digits=0; + num = atoi(pos); + *digits=tmp; + pos = digits; + + while(*pos == ' ' || *pos == '\r' || *pos == '\n' || *pos == '\t') + pos++; + + if(range && last<=t && num>=t) + return 1; + if(range) { + range = 0; + if(*pos) + pos ++; + continue; + } + + if(*pos=='-') + { + if(range) { + fprintf(stderr, "Error: \"%s\" is not a valid format (too many '-'s)\n",irange); + exit(1); + } + last = num; + range = 1; + if(*pos) + pos ++; + continue; + } + else + { + /* if it isn't a '-', we assume it is a seperator like + ',', ';', ':', whatever. */ + if(t == num) + return 1; + if(*pos) + pos ++; + continue; + } + } + if(range && last<=t) + return 1; + return 0; +} + #endif //__args_h__