2
Popt Library Test Program Number Too
4
--> "a real world test of popt bugs" <--
6
Copyright (C) 1999 US Interactive, Inc.
8
This program can be used under the GPL or LGPL at your
9
whim as long as this Copyright remains attached.
14
char *PathnameOfKeyFile = NULL;
15
char *PathnameOfOfferFile = NULL;
21
char *contentProtocol = NULL;
22
char *contentHost = NULL;
24
char *contentPath = NULL;
26
char *dbPassword = NULL;
27
char *dbUserName = NULL;
29
char *rcfile = "createuser-defaults";
32
char *password = NULL;
33
char *firstname = NULL;
34
char *lastname = NULL;
44
char *dayphone = NULL;
49
main(int argc, const char ** argv) {
51
poptContext optCon; /* context for parsing command-line options */
52
struct poptOption userOptionsTable[] = {
53
{ "first", 'f', POPT_ARG_STRING, &firstname, 0,
54
"user's first name", "first" },
55
{ "last", 'l', POPT_ARG_STRING, &lastname, 0,
56
"user's last name", "last" },
57
{ "username", 'u', POPT_ARG_STRING, &username, 0,
58
"system user name", "user" },
59
{ "password", 'p', POPT_ARG_STRING, &password, 0,
60
"system password name", "password" },
61
{ "addr1", '1', POPT_ARG_STRING, &addr1, 0,
62
"line 1 of address", "addr1" },
63
{ "addr2", '2', POPT_ARG_STRING, &addr2, 0,
64
"line 2 of address", "addr2" },
65
{ "city", 'c', POPT_ARG_STRING, &city, 0,
67
{ "state", 's', POPT_ARG_STRING, &state, 0,
68
"state or province", "state" },
69
{ "postal", 'P', POPT_ARG_STRING, &postal, 0,
70
"postal or zip code", "postal" },
71
{ "zip", 'z', POPT_ARG_STRING, &postal, 0,
72
"postal or zip code", "postal" },
73
{ "country", 'C', POPT_ARG_STRING, &country, 0,
74
"two letter ISO country code", "country" },
75
{ "email", 'e', POPT_ARG_STRING, &email, 0,
76
"user's email address", "email" },
77
{ "dayphone", 'd', POPT_ARG_STRING, &dayphone, 0,
78
"day time phone number", "dayphone" },
79
{ "fax", 'F', POPT_ARG_STRING, &fax, 0,
80
"fax number", "fax" },
81
{ NULL, 0, 0, NULL, 0, NULL, NULL }
83
struct poptOption transactOptionsTable[] = {
84
{ "keyfile", '\0', POPT_ARG_STRING, &PathnameOfKeyFile, 0,
85
"transact offer key file (flat_O.kf)", "key-file" },
86
{ "offerfile", '\0', POPT_ARG_STRING, &PathnameOfOfferFile, 0,
87
"offer template file (osl.ofr)", "offer-file" },
88
{ "storeid", '\0', POPT_ARG_INT, &txStoreId, 0,
89
"store id", "store-id" },
90
{ "rcfile", '\0', POPT_ARG_STRING, &rcfile, 0,
91
"default command line options (in popt format)", "rcfile" },
92
{ "txhost", '\0', POPT_ARG_STRING, &txHost, 0,
93
"transact host", "transact-host" },
94
{ "txsslport", '\0', POPT_ARG_INT, &txSslPort, 0,
95
"transact server ssl port ", "transact ssl port" },
96
{ "cnhost", '\0', POPT_ARG_STRING, &contentHost, 0,
97
"content host", "content-host" },
98
{ "cnpath", '\0', POPT_ARG_STRING, &contentPath, 0,
99
"content url path", "content-path" },
100
{ NULL, 0, 0, NULL, 0, NULL, NULL }
103
struct poptOption databaseOptionsTable[] = {
104
{ "dbpassword", '\0', POPT_ARG_STRING, &dbPassword, 0,
105
"Database password", "DB password" },
106
{ "dbusername", '\0', POPT_ARG_STRING, &dbUserName, 0,
107
"Database user name", "DB UserName" },
108
{ NULL, 0, 0, NULL, 0, NULL, NULL }
111
struct poptOption optionsTable[] = {
112
{ NULL, '\0', POPT_ARG_INCLUDE_TABLE, NULL, 0,
113
"Transact Options (not all will apply)", NULL },
114
{ NULL, '\0', POPT_ARG_INCLUDE_TABLE, NULL, 0,
115
"Transact Database Names", NULL },
116
{ NULL, '\0', POPT_ARG_INCLUDE_TABLE, NULL, 0,
117
"User Fields", NULL },
119
{ NULL, 0, 0, NULL, 0, NULL, NULL }
122
optionsTable[0].arg = transactOptionsTable;
123
optionsTable[1].arg = databaseOptionsTable;
124
optionsTable[2].arg = userOptionsTable;
126
#if HAVE_MCHECK_H && HAVE_MTRACE
127
mtrace(); /* Trace malloc only if MALLOC_TRACE=mtrace-output-file. */
130
optCon = poptGetContext("createuser", argc, argv, optionsTable, 0);
131
poptReadConfigFile(optCon, rcfile );
133
/* although there are no options to be parsed, check for --help */
134
poptGetNextOpt(optCon);
136
optCon = poptFreeContext(optCon);
138
printf( "dbusername %s\tdbpassword %s\n"
139
"txhost %s\ttxsslport %d\ttxstoreid %d\tpathofkeyfile %s\n"
140
"username %s\tpassword %s\tfirstname %s\tlastname %s\n"
141
"addr1 %s\taddr2 %s\tcity %s\tstate %s\tpostal %s\n"
142
"country %s\temail %s\tdayphone %s\tfax %s\n",
143
dbUserName, dbPassword,
144
txHost, txSslPort, txStoreId, PathnameOfKeyFile,
145
username, password, firstname, lastname,
146
addr1,addr2, city, state, postal,
147
country, email, dayphone, fax);