test2.c 5.2 KB

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