]> git.ipfire.org Git - thirdparty/libbsd.git/commitdiff
Add bsd_getopt
authorRobert Millan <rmh@aybabtu.com>
Mon, 13 Feb 2006 20:56:47 +0000 (20:56 +0000)
committerGuillem Jover <guillem@hadrons.org>
Tue, 6 May 2008 05:50:26 +0000 (08:50 +0300)
ChangeLog
Makefile
Versions
bsd_getopt.c [new file with mode: 0644]
include/bsd/getopt.h [new file with mode: 0644]

index f33a120d5a263e05da729e72a216e07484a347e7..bfb38ee1e472084a41612f5fc515f06cb1aec853 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2006-02-13  Robert Millan  <rmh@aybabtu.com>
+       
+       Add bsd_getopt.
+       * bsd_getopt.c: New.
+       * include/bsd/getopt.h: New.
+       * Versions: Add bsd_getopt and optreset.
+       * Makefile: Add bsd_getopt.c and include/bsd/getopt.h.
+
 2006-02-10  Robert Millan  <rmh@aybabtu.com>
        
        Add errc, warnc, verrc and vwarnc.
index 51908201977630114c97f65f7225450fd3c7f168..a028db0a7b4553340347bb0023ce040fad312a82 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -4,9 +4,9 @@
 # $Id$
 #
 
-LIB_SRCS = arc4random.c err.c fgetln.c inet_net_pton.c strlcat.c strlcpy.c md5c.c fmtcheck.c
+LIB_SRCS = arc4random.c bsd_getopt.c err.c fgetln.c inet_net_pton.c strlcat.c strlcpy.c md5c.c fmtcheck.c
 
-LIB_INCLUDES = include/bsd/err.h include/bsd/ip_icmp.h include/bsd/random.h include/bsd/queue.h include/bsd/md5.h include/bsd/string.h include/bsd/bsd.h include/bsd/stdlib.h
+LIB_INCLUDES = include/bsd/err.h include/bsd/getopt.h include/bsd/ip_icmp.h include/bsd/random.h include/bsd/queue.h include/bsd/md5.h include/bsd/string.h include/bsd/bsd.h include/bsd/stdlib.h
 
 LIB_MANS = man/arc4random.3 man/strlcpy.3 man/fgetln.3 man/fmtcheck.3
 
index 49e068c3315e7c0b3770814abf796a8b71daeeba..318bbc3148f542bf1937f0e2a54b3fcd4b9417b6 100644 (file)
--- a/Versions
+++ b/Versions
@@ -1,6 +1,7 @@
 LIBBSD_0.0 {
   global:
     arc4random;
+    bsd_getopt; optreset;
     errc; warnc; verrc; vwarnc;
     fgetln;
     fgetwln;
diff --git a/bsd_getopt.c b/bsd_getopt.c
new file mode 100644 (file)
index 0000000..8245fc8
--- /dev/null
@@ -0,0 +1,15 @@
+#include <bsd/getopt.h>
+
+int optreset = 0;
+
+int
+bsd_getopt (int argc, char **argv, char *shortopts)
+{
+  if (optreset == 1)
+    {
+      optreset = 0;
+      optind = 0;
+    }
+
+  return getopt (argc, argv, shortopts);
+}
diff --git a/include/bsd/getopt.h b/include/bsd/getopt.h
new file mode 100644 (file)
index 0000000..bf78f01
--- /dev/null
@@ -0,0 +1,4 @@
+#include <getopt.h>
+extern int optreset;
+
+int bsd_getopt (int, char **, char *);