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