added better '-' support
[swftools.git] / lib / args.h
index f8cda88..f5f0351 100644 (file)
@@ -4,12 +4,26 @@
    Part of the swftools package.
 
    Copyright (c) 2001 Matthias Kramm <kramm@quiss.org> 
+   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<argn2-1) next=argv2[t+1];
         else        next=0;
 
-        if(argv2[t][0]=='-')
+        if(argv2[t][0]=='-' && argv2[t][1])
         {
             if(argv2[t][1]=='-')
             {
@@ -68,10 +82,6 @@ void processargs(int argn2,char**argv2)
                         s++;
                     } while(!ret);
                 }
-                else // - usually means "read stdout"
-                {
-                    t+=args_callback_option(&argv2[t][1],next);
-                }
             }
         }
         else
@@ -87,7 +97,7 @@ struct options_t
     char*longoption;
 };
 
-int args_long2shortoption(struct options_t*options, char*name, char*val)
+static int args_long2shortoption(struct options_t*options, char*name, char*val)
 {
     char*equal = strchr(name,'=');
     if (equal) {
@@ -115,12 +125,14 @@ int args_long2shortoption(struct options_t*options, char*name, char*val)
     exit(1);
 }
 
+#endif
+
 /* check whether the value t is in a given range.
   examples: 3 is in range 1-10: true
             7 is in range 2-4,6,8-10: false
            9 is in range 1,2,3-12: true
 */
-char is_in_range(int t, char*irange)
+static char is_in_range(int t, char*irange)
 {
     char*pos = irange;
     char*digits;