19f07849eSopenharmony_ci/* 29f07849eSopenharmony_ci Popt Library Test Program Number Too 39f07849eSopenharmony_ci 49f07849eSopenharmony_ci --> "a real world test of popt bugs" <-- 59f07849eSopenharmony_ci 69f07849eSopenharmony_ci Copyright (C) 1999 US Interactive, Inc. 79f07849eSopenharmony_ci 89f07849eSopenharmony_ci This program can be used under the GPL or LGPL at your 99f07849eSopenharmony_ci whim as long as this Copyright remains attached. 109f07849eSopenharmony_ci*/ 119f07849eSopenharmony_ci 129f07849eSopenharmony_ci#include "system.h" 139f07849eSopenharmony_ci 149f07849eSopenharmony_cistatic char *PathnameOfKeyFile = NULL; 159f07849eSopenharmony_cistatic char *PathnameOfOfferFile = NULL; 169f07849eSopenharmony_ci 179f07849eSopenharmony_cistatic char *txHost = NULL; 189f07849eSopenharmony_cistatic int txSslPort = 443; 199f07849eSopenharmony_cistatic int txStoreId = 0; 209f07849eSopenharmony_ci 219f07849eSopenharmony_cistatic char *contentHost = NULL; 229f07849eSopenharmony_cistatic char *contentPath = NULL; 239f07849eSopenharmony_ci 249f07849eSopenharmony_cistatic char *dbPassword = NULL; 259f07849eSopenharmony_cistatic char *dbUserName = NULL; 269f07849eSopenharmony_ci 279f07849eSopenharmony_cistatic const char *rcfile = "createuser-defaults"; 289f07849eSopenharmony_cistatic char *username = NULL; 299f07849eSopenharmony_ci 309f07849eSopenharmony_cistatic char *password = NULL; 319f07849eSopenharmony_cistatic char *firstname = NULL; 329f07849eSopenharmony_cistatic char *lastname = NULL; 339f07849eSopenharmony_cistatic char *addr1 = NULL; 349f07849eSopenharmony_cistatic char *addr2 = NULL; 359f07849eSopenharmony_cistatic char *city = NULL; 369f07849eSopenharmony_cistatic char *state = NULL; 379f07849eSopenharmony_cistatic char *postal = NULL; 389f07849eSopenharmony_cistatic char *country = NULL; 399f07849eSopenharmony_ci 409f07849eSopenharmony_cistatic char *email = NULL; 419f07849eSopenharmony_ci 429f07849eSopenharmony_cistatic char *dayphone = NULL; 439f07849eSopenharmony_cistatic char *fax = NULL; 449f07849eSopenharmony_ci 459f07849eSopenharmony_ci 469f07849eSopenharmony_ciint 479f07849eSopenharmony_cimain(int argc, const char ** argv) { 489f07849eSopenharmony_ci 499f07849eSopenharmony_ci poptContext optCon; /* context for parsing command-line options */ 509f07849eSopenharmony_ci struct poptOption userOptionsTable[] = { 519f07849eSopenharmony_ci { "first", 'f', POPT_ARG_STRING, &firstname, 0, 529f07849eSopenharmony_ci "user's first name", "first" }, 539f07849eSopenharmony_ci { "last", 'l', POPT_ARG_STRING, &lastname, 0, 549f07849eSopenharmony_ci "user's last name", "last" }, 559f07849eSopenharmony_ci { "username", 'u', POPT_ARG_STRING, &username, 0, 569f07849eSopenharmony_ci "system user name", "user" }, 579f07849eSopenharmony_ci { "password", 'p', POPT_ARG_STRING, &password, 0, 589f07849eSopenharmony_ci "system password name", "password" }, 599f07849eSopenharmony_ci { "addr1", '1', POPT_ARG_STRING, &addr1, 0, 609f07849eSopenharmony_ci "line 1 of address", "addr1" }, 619f07849eSopenharmony_ci { "addr2", '2', POPT_ARG_STRING, &addr2, 0, 629f07849eSopenharmony_ci "line 2 of address", "addr2" }, 639f07849eSopenharmony_ci { "city", 'c', POPT_ARG_STRING, &city, 0, 649f07849eSopenharmony_ci "city", "city" }, 659f07849eSopenharmony_ci { "state", 's', POPT_ARG_STRING, &state, 0, 669f07849eSopenharmony_ci "state or province", "state" }, 679f07849eSopenharmony_ci { "postal", 'P', POPT_ARG_STRING, &postal, 0, 689f07849eSopenharmony_ci "postal or zip code", "postal" }, 699f07849eSopenharmony_ci { "zip", 'z', POPT_ARG_STRING, &postal, 0, 709f07849eSopenharmony_ci "postal or zip code", "postal" }, 719f07849eSopenharmony_ci { "country", 'C', POPT_ARG_STRING, &country, 0, 729f07849eSopenharmony_ci "two letter ISO country code", "country" }, 739f07849eSopenharmony_ci { "email", 'e', POPT_ARG_STRING, &email, 0, 749f07849eSopenharmony_ci "user's email address", "email" }, 759f07849eSopenharmony_ci { "dayphone", 'd', POPT_ARG_STRING, &dayphone, 0, 769f07849eSopenharmony_ci "day time phone number", "dayphone" }, 779f07849eSopenharmony_ci { "fax", 'F', POPT_ARG_STRING, &fax, 0, 789f07849eSopenharmony_ci "fax number", "fax" }, 799f07849eSopenharmony_ci { NULL, 0, 0, NULL, 0, NULL, NULL } 809f07849eSopenharmony_ci }; 819f07849eSopenharmony_ci struct poptOption transactOptionsTable[] = { 829f07849eSopenharmony_ci { "keyfile", '\0', POPT_ARG_STRING, &PathnameOfKeyFile, 0, 839f07849eSopenharmony_ci "transact offer key file (flat_O.kf)", "key-file" }, 849f07849eSopenharmony_ci { "offerfile", '\0', POPT_ARG_STRING, &PathnameOfOfferFile, 0, 859f07849eSopenharmony_ci "offer template file (osl.ofr)", "offer-file" }, 869f07849eSopenharmony_ci { "storeid", '\0', POPT_ARG_INT, &txStoreId, 0, 879f07849eSopenharmony_ci "store id", "store-id" }, 889f07849eSopenharmony_ci { "rcfile", '\0', POPT_ARG_STRING, &rcfile, 0, 899f07849eSopenharmony_ci "default command line options (in popt format)", "rcfile" }, 909f07849eSopenharmony_ci { "txhost", '\0', POPT_ARG_STRING, &txHost, 0, 919f07849eSopenharmony_ci "transact host", "transact-host" }, 929f07849eSopenharmony_ci { "txsslport", '\0', POPT_ARG_INT, &txSslPort, 0, 939f07849eSopenharmony_ci "transact server ssl port ", "transact ssl port" }, 949f07849eSopenharmony_ci { "cnhost", '\0', POPT_ARG_STRING, &contentHost, 0, 959f07849eSopenharmony_ci "content host", "content-host" }, 969f07849eSopenharmony_ci { "cnpath", '\0', POPT_ARG_STRING, &contentPath, 0, 979f07849eSopenharmony_ci "content url path", "content-path" }, 989f07849eSopenharmony_ci { NULL, 0, 0, NULL, 0, NULL, NULL } 999f07849eSopenharmony_ci }; 1009f07849eSopenharmony_ci 1019f07849eSopenharmony_ci struct poptOption databaseOptionsTable[] = { 1029f07849eSopenharmony_ci { "dbpassword", '\0', POPT_ARG_STRING, &dbPassword, 0, 1039f07849eSopenharmony_ci "Database password", "DB password" }, 1049f07849eSopenharmony_ci { "dbusername", '\0', POPT_ARG_STRING, &dbUserName, 0, 1059f07849eSopenharmony_ci "Database user name", "DB UserName" }, 1069f07849eSopenharmony_ci { NULL, 0, 0, NULL, 0, NULL, NULL } 1079f07849eSopenharmony_ci }; 1089f07849eSopenharmony_ci 1099f07849eSopenharmony_ci struct poptOption optionsTable[] = { 1109f07849eSopenharmony_ci { NULL, '\0', POPT_ARG_INCLUDE_TABLE, NULL, 0, 1119f07849eSopenharmony_ci "Transact Options (not all will apply)", NULL }, 1129f07849eSopenharmony_ci { NULL, '\0', POPT_ARG_INCLUDE_TABLE, NULL, 0, 1139f07849eSopenharmony_ci "Transact Database Names", NULL }, 1149f07849eSopenharmony_ci { NULL, '\0', POPT_ARG_INCLUDE_TABLE, NULL, 0, 1159f07849eSopenharmony_ci "User Fields", NULL }, 1169f07849eSopenharmony_ci POPT_AUTOHELP 1179f07849eSopenharmony_ci { NULL, 0, 0, NULL, 0, NULL, NULL } 1189f07849eSopenharmony_ci }; 1199f07849eSopenharmony_ci 1209f07849eSopenharmony_ci optionsTable[0].arg = transactOptionsTable; 1219f07849eSopenharmony_ci optionsTable[1].arg = databaseOptionsTable; 1229f07849eSopenharmony_ci optionsTable[2].arg = userOptionsTable; 1239f07849eSopenharmony_ci 1249f07849eSopenharmony_ci#if defined(HAVE_MCHECK_H) && defined(HAVE_MTRACE) 1259f07849eSopenharmony_ci mtrace(); /* Trace malloc only if MALLOC_TRACE=mtrace-output-file. */ 1269f07849eSopenharmony_ci#endif 1279f07849eSopenharmony_ci 1289f07849eSopenharmony_ci optCon = poptGetContext("createuser", argc, argv, optionsTable, 0); 1299f07849eSopenharmony_ci poptReadConfigFile(optCon, rcfile ); 1309f07849eSopenharmony_ci 1319f07849eSopenharmony_ci /* although there are no options to be parsed, check for --help */ 1329f07849eSopenharmony_ci poptGetNextOpt(optCon); 1339f07849eSopenharmony_ci 1349f07849eSopenharmony_ci optCon = poptFreeContext(optCon); 1359f07849eSopenharmony_ci 1369f07849eSopenharmony_ci printf( "dbusername %s\tdbpassword %s\n" 1379f07849eSopenharmony_ci "txhost %s\ttxsslport %d\ttxstoreid %d\tpathofkeyfile %s\n" 1389f07849eSopenharmony_ci "username %s\tpassword %s\tfirstname %s\tlastname %s\n" 1399f07849eSopenharmony_ci "addr1 %s\taddr2 %s\tcity %s\tstate %s\tpostal %s\n" 1409f07849eSopenharmony_ci "country %s\temail %s\tdayphone %s\tfax %s\n", 1419f07849eSopenharmony_ci dbUserName, dbPassword, 1429f07849eSopenharmony_ci txHost, txSslPort, txStoreId, PathnameOfKeyFile, 1439f07849eSopenharmony_ci username, password, firstname, lastname, 1449f07849eSopenharmony_ci addr1,addr2, city, state, postal, 1459f07849eSopenharmony_ci country, email, dayphone, fax); 1469f07849eSopenharmony_ci return 0; 1479f07849eSopenharmony_ci} 148