summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.am1
-rw-r--r--Makefile.in69
-rw-r--r--popt.334
-rw-r--r--popt.c6
-rw-r--r--popt.h1
-rw-r--r--popt.spec4
6 files changed, 89 insertions, 26 deletions
diff --git a/Makefile.am b/Makefile.am
index 4284910..9777e2e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -14,6 +14,7 @@ test1_LDADD = -lpopt
include_HEADERS = popt.h
lib_LIBRARIES = libpopt.a
libpopt_a_SOURCES = popt.c findme.c poptparse.c poptconfig.c popthelp.c
+man_MANS = popt.3
CVSTAG = $(PACKAGE)-$(subst .,_,$(VERSION))
diff --git a/Makefile.in b/Makefile.in
index 9fe78ed..3ab14d4 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -82,6 +82,7 @@ test1_LDADD = -lpopt
include_HEADERS = popt.h
lib_LIBRARIES = libpopt.a
libpopt_a_SOURCES = popt.c findme.c poptparse.c poptconfig.c popthelp.c
+man_MANS = popt.3
CVSTAG = $(PACKAGE)-$(subst .,_,$(VERSION))
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
@@ -105,11 +106,15 @@ test1_LDFLAGS =
CFLAGS = @CFLAGS@
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)
LINK = $(CC) $(CFLAGS) $(LDFLAGS) -o $@
+man3dir = $(mandir)/man3
+MANS = $(man_MANS)
+
+NROFF = nroff
HEADERS = $(include_HEADERS)
DIST_COMMON = README COPYING Makefile.am Makefile.in acconfig.h \
-aclocal.m4 config.h.in configure configure.in install-sh missing \
-mkinstalldirs stamp-h.in
+aclocal.m4 config.h.in configure.in install-sh missing mkinstalldirs \
+stamp-h.in
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
@@ -227,6 +232,45 @@ test1: $(test1_OBJECTS) $(test1_DEPENDENCIES)
@rm -f test1
$(LINK) $(test1_LDFLAGS) $(test1_OBJECTS) $(test1_LDADD) $(LIBS)
+install-man3:
+ $(mkinstalldirs) $(DESTDIR)$(man3dir)
+ @list='$(man3_MANS)'; \
+ l2='$(man_MANS)'; for i in $$l2; do \
+ case "$$i" in \
+ *.3*) list="$$list $$i" ;; \
+ esac; \
+ done; \
+ for i in $$list; do \
+ if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \
+ else file=$$i; fi; \
+ ext=`echo $$i | sed -e 's/^.*\\.//'`; \
+ inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
+ inst=`echo $$inst | sed '$(transform)'`.$$ext; \
+ echo " $(INSTALL_DATA) $$file $(DESTDIR)$(man3dir)/$$inst"; \
+ $(INSTALL_DATA) $$file $(DESTDIR)$(man3dir)/$$inst; \
+ done
+
+uninstall-man3:
+ @list='$(man3_MANS)'; \
+ l2='$(man_MANS)'; for i in $$l2; do \
+ case "$$i" in \
+ *.3*) list="$$list $$i" ;; \
+ esac; \
+ done; \
+ for i in $$list; do \
+ ext=`echo $$i | sed -e 's/^.*\\.//'`; \
+ inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
+ inst=`echo $$inst | sed '$(transform)'`.$$ext; \
+ echo " rm -f $(DESTDIR)$(man3dir)/$$inst"; \
+ rm -f $(DESTDIR)$(man3dir)/$$inst; \
+ done
+install-man: $(MANS)
+ @$(NORMAL_INSTALL)
+ $(MAKE) install-man3
+uninstall-man:
+ @$(NORMAL_UNINSTALL)
+ $(MAKE) uninstall-man3
+
install-includeHEADERS: $(include_HEADERS)
@$(NORMAL_INSTALL)
$(mkinstalldirs) $(DESTDIR)$(includedir)
@@ -394,13 +438,13 @@ installcheck: installcheck-recursive
all-recursive-am: config.h
$(MAKE) all-recursive
-all-am: Makefile $(LIBRARIES) $(PROGRAMS) $(HEADERS) config.h
+all-am: Makefile $(LIBRARIES) $(PROGRAMS) $(MANS) $(HEADERS) config.h
install-exec-am: install-libLIBRARIES
-install-data-am: install-includeHEADERS
+install-data-am: install-man install-includeHEADERS
-uninstall-am: uninstall-libLIBRARIES uninstall-includeHEADERS
+uninstall-am: uninstall-libLIBRARIES uninstall-man uninstall-includeHEADERS
install-exec: install-exec-recursive install-exec-am
@$(NORMAL_INSTALL)
@@ -416,7 +460,8 @@ uninstall: uninstall-recursive uninstall-am
install-strip:
$(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' INSTALL_SCRIPT='$(INSTALL_PROGRAM)' install
installdirs: installdirs-recursive
- $(mkinstalldirs) $(DATADIR)$(libdir) $(DATADIR)$(includedir)
+ $(mkinstalldirs) $(DATADIR)$(libdir) $(DESTDIR)$(mandir)/man3 \
+ $(DATADIR)$(includedir)
mostlyclean-generic:
@@ -469,12 +514,12 @@ maintainer-clean-libLIBRARIES uninstall-libLIBRARIES \
install-libLIBRARIES mostlyclean-compile distclean-compile \
clean-compile maintainer-clean-compile mostlyclean-noinstPROGRAMS \
distclean-noinstPROGRAMS clean-noinstPROGRAMS \
-maintainer-clean-noinstPROGRAMS uninstall-includeHEADERS \
-install-includeHEADERS install-data-recursive uninstall-data-recursive \
-install-exec-recursive uninstall-exec-recursive installdirs-recursive \
-uninstalldirs-recursive all-recursive check-recursive \
-installcheck-recursive info-recursive dvi-recursive \
-mostlyclean-recursive distclean-recursive clean-recursive \
+maintainer-clean-noinstPROGRAMS install-man3 uninstall-man3 install-man \
+uninstall-man uninstall-includeHEADERS install-includeHEADERS \
+install-data-recursive uninstall-data-recursive install-exec-recursive \
+uninstall-exec-recursive installdirs-recursive uninstalldirs-recursive \
+all-recursive check-recursive installcheck-recursive info-recursive \
+dvi-recursive mostlyclean-recursive distclean-recursive clean-recursive \
maintainer-clean-recursive tags tags-recursive mostlyclean-tags \
distclean-tags clean-tags maintainer-clean-tags distdir \
mostlyclean-depend distclean-depend clean-depend \
diff --git a/popt.3 b/popt.3
index eaf6c40..e299826 100644
--- a/popt.3
+++ b/popt.3
@@ -110,23 +110,23 @@ first two members,
the first is a long name, while the latter is a single character.
.sp
The
-.IR argInfo " member tell popt what type of argument is expected"
+.IR argInfo " member tells popt what type of argument is expected"
after the argument. If no option is expected,
-.BR POPT_ARG_NONE " should be used. (Connoisseurs of " getopt()
-.RI "will note that " argInfo " is the only required field of "
-.BR "struct poptOption" " that is not directly analogous to a field in "
-.RB "the " getopt_long() " argument table. The similarity between the "
-.RB "two allows for easy transitions from " getopt_long " to popt.) "
+.B POPT_ARG_NONE
+should be used.
The rest of the valid values are shown in the following table:
.sp
-.nf
-.B " Value Description arg Type"
-.BR POPT_ARG_NONE " No argument expected int"
-.BR POPT_ARG_STRING " No type checking to be performed char *"
-.BR POPT_ARG_INT " An integer argument is expected int"
-.BR POPT_ARG_LONG " A long integer is expected long"
+.TS
+lfB lfB lfB
+lfB lfR lfR.
+Value Description arg Type
+POPT_ARG_NONE No argument expected int
+POPT_ARG_STRING No type checking to be performed char *
+POPT_ARG_INT An integer argument is expected int
+POPT_ARG_LONG A long integer is expected long
+POPT_ARG_VAL Integer value taken from \f(CWval\fR int
+.TE
.sp
-.fi
If \fIargInfo\fR value is logically or'd with \fBPOPT_ARGFLAG_ONEDASH\fR,
the long argument may be given with a single - instead of two. For example,
if \fB--longopt\fR is an option with \fBPOPT_ARGFLAG_ONEDASH\fR, is
@@ -149,6 +149,14 @@ an argument, the variable that
.BR POPT_ARG_INT " and " POPT_ARG_LONG " are converted to the
appropriate type, and an error returned if the conversion fails.
.sp
+\fBPOPT_ARG_VAL\fR causes \fIarg\fP to be set to the (integer) value of
+\fIval\fP when the argument is found. This is most often useful for
+mutually-exclusive arguments in cases where it is not an error for
+multiple arguments to occur and where you want the last argument
+specified to win; for example, "rm -i -f". \fBPOPT_ARG_VAL\fP causes
+the parsing function not to return a value, since the value of \fIval\fP
+has already been used.
+.sp
.RI "The next option, " val ", is the value popt's parsing function
should return when the option is encountered. If it is 0, the parsing
function does not return a value, instead parsing the next
diff --git a/popt.c b/popt.c
index ca97e5d..f9e6153 100644
--- a/popt.c
+++ b/popt.c
@@ -392,6 +392,10 @@ int poptGetNextOpt(poptContext con) {
*((char **) opt->arg) = con->os->nextArg;
break;
+ case POPT_ARG_VAL:
+ *((int *) opt->arg) = opt->val;
+ break;
+
case POPT_ARG_INT:
case POPT_ARG_LONG:
aLong = strtol(con->os->nextArg, &end, 0);
@@ -419,7 +423,7 @@ int poptGetNextOpt(poptContext con) {
if (cb)
cb(con, POPT_CALLBACK_REASON_OPTION, opt, con->os->nextArg, cbData);
- else if (opt->val)
+ else if (opt->val && ((opt->argInfo & POPT_ARG_MASK) != POPT_ARG_VAL))
done = 1;
if ((con->finalArgvCount + 2) >= (con->finalArgvAlloced)) {
diff --git a/popt.h b/popt.h
index e216049..069cab1 100644
--- a/popt.h
+++ b/popt.h
@@ -22,6 +22,7 @@
for this table and any
included tables; arg points
to the domain string */
+#define POPT_ARG_VAL 7 /* arg should take value val */
#define POPT_ARG_MASK 0x0000FFFF
#define POPT_ARGFLAG_ONEDASH 0x80000000 /* allow -longoption */
#define POPT_ARGFLAG_DOC_HIDDEN 0x40000000 /* don't show in help/usage */
diff --git a/popt.spec b/popt.spec
index 718e75c..3a2ddc1 100644
--- a/popt.spec
+++ b/popt.spec
@@ -32,8 +32,12 @@ rm -rf $RPM_BUILD_ROOT
%files
%attr(0644, root, root) /usr/lib/libpopt.a
%attr(0644, root, root) /usr/include/popt.h
+%attr(0644, root, root) /usr/man/man3/popt.3
%changelog
+* Tue Nov 17 1998 Michael K. Johnson <johnsonm@redhat.com>
+- added man page to default install
+
* Thu Oct 22 1998 Erik Troan <ewt@redhat.com>
- see CHANGES file for 1.2