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 char *PathnameOfKeyFile = NULL;
15 char *PathnameOfOfferFile = NULL;
16
17 char *txHost = NULL;
18 int txSslPort = 443;
19 int txStoreId = 0;
20
21 char *contentProtocol = NULL;
22 char *contentHost = NULL;
23 int contentPort = 80;
24 char *contentPath = NULL;
25
26 char *dbPassword = NULL;
27 char *dbUserName = NULL;
28
29 char *rcfile = "createuser-defaults";
30 char *username=NULL;
31
32 char *password = NULL;
33 char *firstname = NULL;
34 char *lastname = NULL;
35 char *addr1 = NULL;
36 char *addr2 = NULL;
37 char *city = NULL;
38 char *state = NULL;
39 char *postal = NULL;
40 char *country = NULL;
41
42 char *email = NULL;
43
44 char *dayphone = NULL;
45 char *fax = NULL;
46
47
48 int
main(int argc,const char ** argv)49 main(int argc, const char ** argv) {
50
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,
66 "city", "city" },
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 }
82 };
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 }
101 };
102
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 }
109 };
110
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 },
118 POPT_AUTOHELP
119 { NULL, 0, 0, NULL, 0, NULL, NULL }
120 };
121
122 optionsTable[0].arg = transactOptionsTable;
123 optionsTable[1].arg = databaseOptionsTable;
124 optionsTable[2].arg = userOptionsTable;
125
126 #if defined(HAVE_MCHECK_H) && defined(HAVE_MTRACE)
127 mtrace(); /* Trace malloc only if MALLOC_TRACE=mtrace-output-file. */
128 #endif
129
130 optCon = poptGetContext("createuser", argc, argv, optionsTable, 0);
131 poptReadConfigFile(optCon, rcfile );
132
133 /* although there are no options to be parsed, check for --help */
134 poptGetNextOpt(optCon);
135
136 optCon = poptFreeContext(optCon);
137
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);
148 return 0;
149 }
150