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