source: trunk/third/ORBit/popt/test2.c @ 15271

Revision 15271, 5.1 KB checked in by ghudson, 24 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r15270, which included commits to RCS files with non-trunk default branches.
Line 
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
14char *PathnameOfKeyFile         = NULL;
15char *PathnameOfOfferFile       = NULL;
16
17char *txHost                    = NULL;
18int   txSslPort                 = 443;
19int   txStoreId                 = 0;
20
21char *contentProtocol           = NULL;
22char *contentHost               = NULL;
23int   contentPort               = 80;
24char *contentPath               = NULL;
25
26char *dbPassword                = NULL;
27char *dbUserName                = NULL;
28
29char *rcfile = "createuser-defaults";
30char *username=NULL;
31
32char *password                  = NULL;
33char *firstname                 = NULL;
34char *lastname                  = NULL;
35char *addr1                     = NULL;
36char *addr2                     = NULL;
37char *city                      = NULL;
38char *state                     = NULL;
39char *postal                    = NULL;
40char *country                   = NULL;
41
42char *email                     = NULL;
43
44char *dayphone                  = NULL;
45char *fax                       = NULL;
46
47
48int
49main(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,  transactOptionsTable, 0,
113            "Transact Options (not all will apply)", NULL },
114        { NULL, '\0', POPT_ARG_INCLUDE_TABLE,  databaseOptionsTable, 0,
115            "Transact Database Names", NULL },
116        { NULL, '\0', POPT_ARG_INCLUDE_TABLE,  userOptionsTable, 0,
117            "User Fields", NULL },
118        POPT_AUTOHELP
119        { NULL, 0, 0, NULL, 0, NULL, NULL }
120    };
121
122#if HAVE_MCHECK_H && HAVE_MTRACE
123    mtrace();   /* Trace malloc only if MALLOC_TRACE=mtrace-output-file. */
124#endif
125
126    optCon = poptGetContext("createuser", argc, argv, optionsTable, 0);
127    poptReadConfigFile(optCon, rcfile );
128
129    /* although there are no options to be parsed, check for --help */
130    poptGetNextOpt(optCon);
131
132    poptFreeContext(optCon);
133
134    printf( "dbusername %s\tdbpassword %s\n"
135            "txhost %s\ttxsslport %d\ttxstoreid %d\tpathofkeyfile %s\n"
136            "username %s\tpassword %s\tfirstname %s\tlastname %s\n"
137            "addr1 %s\taddr2 %s\tcity %s\tstate %s\tpostal %s\n"
138            "country %s\temail %s\tdayphone %s\tfax %s\n",
139        dbUserName, dbPassword,
140        txHost, txSslPort, txStoreId, PathnameOfKeyFile,
141        username, password, firstname, lastname,
142        addr1,addr2, city, state, postal,
143        country, email, dayphone, fax);
144    return 0;
145}
Note: See TracBrowser for help on using the repository browser.