summaryrefslogtreecommitdiff
path: root/popt
diff options
context:
space:
mode:
authorjbj <devnull@localhost>1999-10-25 20:10:00 +0000
committerjbj <devnull@localhost>1999-10-25 20:10:00 +0000
commit82c75cb6a261465700ca469793b54ad68bef99a8 (patch)
tree00f4aea283cfb8aef84d400c2d01ceebda4a0aec /popt
parentb074f1e2e712870d73613b4f8d848e963182b7e5 (diff)
downloadlibrpm-tizen-82c75cb6a261465700ca469793b54ad68bef99a8.tar.gz
librpm-tizen-82c75cb6a261465700ca469793b54ad68bef99a8.tar.bz2
librpm-tizen-82c75cb6a261465700ca469793b54ad68bef99a8.zip
Add poptDupArgv() and const's to popt.3 man page.
CVS patchset: 3401 CVS date: 1999/10/25 20:10:00
Diffstat (limited to 'popt')
-rw-r--r--popt/po/popt.pot2
-rw-r--r--popt/popt.358
-rw-r--r--popt/popt.c2
3 files changed, 35 insertions, 27 deletions
diff --git a/popt/po/popt.pot b/popt/po/popt.pot
index 78c2117ee..6793fcf01 100644
--- a/popt/po/popt.pot
+++ b/popt/po/popt.pot
@@ -6,7 +6,7 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
-"POT-Creation-Date: 1999-10-25 14:23-0400\n"
+"POT-Creation-Date: 1999-10-25 16:06-0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
diff --git a/popt/popt.3 b/popt/popt.3
index 582a27071..96848d339 100644
--- a/popt/popt.3
+++ b/popt/popt.3
@@ -5,9 +5,9 @@ popt \- Parse command line options
.nf
.B #include <popt.h>
.sp
-.BI "poptContext poptGetContext(char * " name ", int " argc ,
-.BI " char ** "argv ,
-.BI " struct poptOption * " options ,
+.BI "poptContext poptGetContext(const char * " name ", int " argc ,
+.BI " har ** "argv ,
+.BI " const struct poptOption * " options ,
.BI " int " flags );
.sp
.BI "void poptFreeContext(poptContext " con );
@@ -20,13 +20,13 @@ popt \- Parse command line options
.sp
.BI "char * poptGetArg(poptContext " con );
.sp
-.BI "char * poptPeekArg(poptContext " con );
+.BI "const char * poptPeekArg(poptContext " con );
.sp
-.BI "char ** poptGetArgs(poptContext " con );
+.BI "const char ** poptGetArgs(poptContext " con );
.sp
-.BI "const char * poptStrerror(const int " error );
+.BI "const char *const poptStrerror(const int " error );
.sp
-.BI "char * poptBadOption(poptContext " con ", int " flags );
+.BI "const char * poptBadOption(poptContext " con ", int " flags );
.sp
.BI "int poptReadDefaultConfig(poptContext " con ", int " flags );
.sp
@@ -36,9 +36,12 @@ popt \- Parse command line options
.BI " int " flags );
.sp
.BI "int poptParseArgvString(char * " s ", int * " argcPtr ,
-.BI " char *** " argvPtr );
+.BI " const char *** " argvPtr );
.sp
-.BI "int poptStuffArgs(poptContext " con ", char ** " argv );
+.BI "int poptDupArgv(int " argc ", const char ** " argv ", int * " argcPtr ",
+.BI " const char *** " argvPtr ");"
+.sp
+.BI "int poptStuffArgs(poptContext " con ", const char ** " argv );
.sp
.fi
.SH DESCRIPTION
@@ -242,9 +245,9 @@ modified outside the popt library.
.RB "New popt contexts are created by " poptGetContext() ":"
.sp
.nf
-.BI "poptContext poptGetContext(char * " name ", int "argc ",
+.BI "poptContext poptGetContext(const char * " name ", int "argc ",
.BI " char ** "argv ",
-.BI " struct poptOption * "options ",
+.BI " const struct poptOption * "options ",
.BI " int "flags ");"
.fi
.sp
@@ -351,7 +354,7 @@ processed.
.PP
.nf
.HP
-.BI "char * poptPeekArg(poptContext " con ");"
+.BI "const char * poptPeekArg(poptContext " con ");"
.fi
The next leftover argument is returned but not marked as processed.
This allows an application to look ahead into the argument list,
@@ -359,7 +362,7 @@ without modifying the list.
.PP
.nf
.HP
-.BI "char ** poptGetArgs(poptContext " con ");"
+.BI "const char ** poptGetArgs(poptContext " con ");"
.fi
All the leftover arguments are returned in a manner identical to
.IR argv ". The final element in the returned array points to "
@@ -457,14 +460,14 @@ Two functions are available to make it easy for applications to provide
good error messages.
.HP
.nf
-.BI "const char * poptStrerror(const int " error ");"
+.BI "const char *const poptStrerror(const int " error ");"
.fi
This function takes a popt error code and returns a string describing
.RB "the error, just as with the standard " strerror() " function."
.PP
.HP
.nf
-.BI "char * poptBadOption(poptContext " con ", int " flags ");"
+.BI "const char * poptBadOption(poptContext " con ", int " flags ");"
.fi
.RB "If an error occurred during " poptGetNextOpt() ", this function "
.RI "returns the option that caused the error. If the " flags " argument"
@@ -551,10 +554,10 @@ currently reserved for future expansion. The new alias is specified
.sp
.nf
struct poptAlias {
- char * longName; /* may be NULL */
+ const char * longName; /* may be NULL */
char shortName; /* may be '\\0' */
int argc;
- char ** argv; /* must be free()able */
+ const char ** argv; /* must be free()able */
};
.fi
.sp
@@ -571,20 +574,25 @@ using rules similiar to normal shell parsing.
.sp
.nf
.B "#include <popt.h>"
-.BI "int poptParseArgvString(char * " s ", int * "argcPtr ",
+.BI "int poptParseArgvString(char * " s ", int * " argcPtr ",
.BI " char *** " argvPtr ");"
+.BI "int poptDupArgv(int " argc ", const char ** " argv ", int * " argcPtr ",
+.BI " const char *** " argvPtr ");"
.fi
.sp
.RI "The string s is parsed into an " argv "-style array. The integer "
-.RI "pointed to by the second parameter, " argcPtr ", contains the number "
-of elements parsed, and the pointer pointed to by the final parameter is
-set to point to the newly created array. The array is dynamically
-.RB "allocated and should be " free() "ed when the application is finished "
-with it.
+.RI "pointed to by the " argcPtr " parameter contains the number of elements "
+.RI "parsed, and the final " argvPtr " parameter contains the address of the"
+newly created array.
+.RB "The routine " poptDupArgv() " can be used to make a copy of an existing "
+argument array.
.sp
.RI "The " argvPtr
-.RB "created by " poptParseArgvString() " is suitable to pass directly "
+.RB "created by " poptParseArgvString() " or " poptDupArgv() " is suitable to pass directly "
.RB "to " poptGetContext() .
+Both routines return a single dynamically allocated contiguous
+.RB "block of storage and should be " free() "ed when the application is"
+finished with the storage.
.SH "HANDLING EXTRA ARGUMENTS"
Some applications implement the equivalent of option aliasing but need
.RB "to do so through special logic. The " poptStuffArgs() " function "
@@ -593,7 +601,7 @@ allows an application to insert new arguments into the current
.sp
.nf
.B "#include <popt.h>"
-.BI "int poptStuffArgs(poptContext "con ", char ** " argv ");"
+.BI "int poptStuffArgs(poptContext "con ", const char ** " argv ");"
.fi
.sp
.RI "The passed " argv
diff --git a/popt/popt.c b/popt/popt.c
index 11eb18457..3fb54f7db 100644
--- a/popt/popt.c
+++ b/popt/popt.c
@@ -51,7 +51,7 @@ poptContext poptGetContext(const char * name, int argc, char ** argv,
con->os = con->optionStack;
con->os->argc = argc;
- con->os->argv = (const char **)argv; /* XXX don't change the API */
+ con->os->argv = (const char **) argv; /* XXX don't change the API */
con->os->argb = NULL;
if (!(flags & POPT_CONTEXT_KEEP_FIRST))