summaryrefslogtreecommitdiff
path: root/popt/test1.c
diff options
context:
space:
mode:
authorjbj <devnull@localhost>2000-12-31 20:30:37 +0000
committerjbj <devnull@localhost>2000-12-31 20:30:37 +0000
commit37a87e6f14cc9f4e81779c4777454e331934bb96 (patch)
treed9119b78799db87fc4cc916e39f75a453e05aef9 /popt/test1.c
parentb9145eabe09db09a56c9daf3006426b08182d848 (diff)
downloadlibrpm-tizen-37a87e6f14cc9f4e81779c4777454e331934bb96.tar.gz
librpm-tizen-37a87e6f14cc9f4e81779c4777454e331934bb96.tar.bz2
librpm-tizen-37a87e6f14cc9f4e81779c4777454e331934bb96.zip
- (popt): add POPT_ARGFLAG_OPTIONAL for long options with optional arg.
- (popt): diddle auto-help to include type of arg expected. CVS patchset: 4394 CVS date: 2000/12/31 20:30:37
Diffstat (limited to 'popt/test1.c')
-rw-r--r--popt/test1.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/popt/test1.c b/popt/test1.c
index 5b6aeb723..7b7f55fe0 100644
--- a/popt/test1.c
+++ b/popt/test1.c
@@ -19,6 +19,7 @@ int inc = 0;
int shortopt = 0;
float aFloat = 0.0;
double aDouble = 0.0;
+char * oStr = (char *)-1;
int singleDash = 0;
static struct poptOption moreCallbackArgs[] = {
@@ -54,6 +55,9 @@ static struct poptOption options[] = {
"A float argument", "FLOAT" },
{ "double", 'd', POPT_ARG_DOUBLE, &aDouble, 0,
"A double argument", "DOUBLE" },
+ { "ostr", '\0', POPT_ARG_STRING|POPT_ARGFLAG_OPTIONAL, &oStr, 0,
+ "An optional str", "ARG" },
+
{ NULL, '-', POPT_ARG_NONE | POPT_ARGFLAG_DOC_HIDDEN, &singleDash, 0 },
{ NULL, '\0', POPT_ARG_INCLUDE_TABLE, &moreArgs, 0, NULL },
{ NULL, '\0', POPT_ARG_INCLUDE_TABLE, &callbackArgs, 0, "Callback arguments" },
@@ -128,6 +132,8 @@ int main(int argc, const char ** argv) {
fprintf(stdout, " aFloat: %g", aFloat);
if (aDouble != 0.0)
fprintf(stdout, " aDouble: %g", aDouble);
+ if (oStr != (char *)-1)
+ fprintf(stdout, " oStr: %s", (oStr ? oStr : "(none)"));
if (singleDash)
fprintf(stdout, " -");