/******************************************************************************* * rfaxusers.cpp * Retrieve the list of user-IDs (in-box names) from a RightFax server. * * Compile: * CL -I "-DVERS=\"R.L\"" rfaxusers.cpp rfaxprogram.obj \rfwin32.lib * where * 'R.L' is the program version number; * '' is the directory containing "rfapi.h" and "rfwin32.lib". * *------------------------------------------------------------------------------ * @version $Revision: 1.1 $ $Date: 2008/04/08 20:20:57 $ * @since 2008-04-07 * @author David R. Tribble (david@tribble.com) * * Copyright ©2008 by David R. Tribble, all rights reserved. * Permission is granted to any person or entity except those designated * by the United States Department of State as a terrorist, or terrorist * government or agency, to use and distribute this source code provided * that the original copyright notice remains present and unaltered. */ // Identification static char REV[] = "@(#)drt/rightfax/src/rfaxusers.cpp $Revision: 1.1 $ $Date: 2008/04/08 20:20:57 $"; static char PROG[] = "rfaxusers"; static char TITLE[] = "RFaxUsers - List users on a RightFax server"; #ifndef VERS #error Please define macro "VERS" as a string in the format "R.L" #endif static char VERSION[] = VERS; static char VERSION_W[] = "@(#)" "Release: " VERS; static char BUILT[] = "@(#)" "Built: " __DATE__; // System includes #ifndef _WIN32 #error Compile this file for Win32 only #endif #include #include #include #include #include #include #include #define WIN32 #define WIN32_LEAN_AND_MEAN 1 #include #include // Local includes #define rfaxprogram_cpp #include "rfaxprogram.hpp" //------------------------------------------------------------------------------ // Local classes //------------------------------------------------------------------------------ /******************************************************************************* * class RFaxUserLister * Retrieve the list of user-IDs (in-box names) from a RightFax server. * * @since 1.1, 2008-04-07 */ #define RFaxUserLister_VS 100 // Class version, 1.0 class RFaxUserLister: public RFaxProgram { // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Constants public: // Program exit status enum ExitCode { RC_OKAY = 0, // Success RC_CONNECT = 1, // Can't connect to server RC_INFO = 2, // Can't retrieve server info RC_OUT = 3, // Can't write to output file RC_USAGE = 255, // Improper usage }; // Listing types enum ListType { LIST_NORMAL = 0, // Normal listing LIST_SHORT = 1, // Short listing, user names only LIST_LONG = 2, // Long (verbose) listing LIST_CSV = 3, // CSV formatted listing }; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Static functions public: /*************************************************************************** * Retrieve the list of user-IDs (in-box names) from a RightFax server. * * Usage * rfaxusers [-option...] [-s] host [userID...] * * @param argc * Argument count, i.e., the number of elements in 'argv[]'. * * @param argv * Command line arguments. * * @return * Exit status code, which is one of the RC_XXX constants. * * @since 1.1, 2008-04-07 */ static int main(int argc, const char *const *argv); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Static functions protected: /*************************************************************************** * Compare two user-ID list elements. * The elements are compared user-ID. * * @param e1 * A user list element (of type USERLISTELEMENT1). * * @param e2 * Another user list element (of type USERLISTELEMENT1). * * @return * A signed result x, where * x < 0 if e1 < e2 (by name), or * x = 0 if e1 = e2 (by name), or * x > 0 if e1 > e2 (by name). * * @since 1.1, 2008-04-11 */ static int sortCmp1(const void *e1, const void *e2); /*************************************************************************** * Compare two user-ID list elements. * The elements are compared first by group-ID and then by user-ID. * * @param e1 * A user list element (of type USERLISTELEMENT1). * * @param e2 * Another user list element (of type USERLISTELEMENT1). * * @return * A signed result x, where * x < 0 if e1 < e2 (by name), or * x = 0 if e1 = e2 (by name), or * x > 0 if e1 > e2 (by name). * * @since 1.1, 2008-04-11 */ static int sortCmp2(const void *e1, const void *e2); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Variables protected: FILE * m_out; // Output stream const char * m_group; // Specific group name short m_listType; // Listing type (LIST_XXX) bool m_sorted; // Listing is sorted // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Functions protected: /*************************************************************************** * Destructor. * * @since 1.1, 2008-04-07 */ virtual ~RFaxUserLister(); /*************************************************************************** * Default constructor. * * @since 1.1, 2008-04-07 */ RFaxUserLister(); /*************************************************************************** * Retrieve the list of user-IDs (in-box names) from a RightFax server. * This function is called by main(). * * @param argc * Argument count, i.e., the number of elements in 'argv[]'. * * @param argv * Command line arguments. * * @since 1.1, 2008-04-11 */ int run(int argc, const char *const argv[]); /*************************************************************************** * Retrieve and print information about RightFax user-IDs to an output file. * * @param names * Array of user-IDs, terminated by a null pointer. * * @return * True if successful, otherwise false. * * @since 1.1, 2008-04-07 */ bool printUsers(const char *const names[]); /*************************************************************************** * Print the full information for a fax user-ID in CSV format. * * @param user * RightFax full user information. * If this is null, a heading is printed instead. * * @return * True if successful, otherwise false. * * @since 1.1, 2008-04-07 */ void printUserCSV(const USERINFO_11 *user); /*************************************************************************** * Print the full information for a fax user-ID. * * @param user * RightFax full user information. * If this is null, a heading is printed instead. * * @return * True if successful, otherwise false. * * @since 1.1, 2008-04-11 */ void printUserInfo(const USERINFO_11 *user); private: // Not implemented RFaxUserLister(const RFaxUserLister &o); // Not implemented const RFaxUserLister & operator =(const RFaxUserLister &o); }; //------------------------------------------------------------------------------ // Static class functions //------------------------------------------------------------------------------ /******************************************************************************* * RFaxUserLister::main() * Retrieve the list of user-IDs (in-box names) from a RightFax server. * * @param argc * Argument count, i.e., the number of elements in 'argv[]'. * * @param argv * Command line arguments. * * @see run() * * @since 1.1, 2008-04-07 */ /*static*/ int RFaxUserLister::main(int argc, const char *const argv[]) { #if RFaxUserLister_VS/100 != 1 #error class RFaxUserLister has changed #endif RFaxUserLister * srv = NULL; int rc; // Establish a RightFax server connection srv = new RFaxUserLister(); srv->m_out = stdout; rc = srv->run(argc, argv); // Clean up if (srv->m_hdl != NULL) srv->disconnect(); delete srv; return rc; } /******************************************************************************* * RFaxUserLister::sortCmp1() * Compare two user-ID list elements. * The elements are compared by user-ID. * * @param e1 * A user list element (of type USERLISTELEMENT1). * * @param e2 * Another user list element (of type USERLISTELEMENT1). * * @return * A signed result x, where * x < 0 if e1 < e2 (by name), or * x = 0 if e1 = e2 (by name), or * x > 0 if e1 > e2 (by name). * * @since 1.1, 2008-04-11 */ /*static*/ int RFaxUserLister::sortCmp1(const void *e1, const void *e2) { #if RFaxUserLister_VS/100 != 1 #error class RFaxUserLister has changed #endif const USERLISTELEMENT1 * user1; const USERLISTELEMENT1 * user2; int cmp = 0; // Compare the user-ID list elements user1 = (const USERLISTELEMENT1 *) e1; user2 = (const USERLISTELEMENT1 *) e2; cmp = ::stricmp(user1->userid, user2->userid); return cmp; } /******************************************************************************* * RFaxUserLister::sortCmp2() * Compare two user-ID list elements. * The elements are compared first by group-ID and then by user-ID. * * @param e1 * A user list element (of type USERLISTELEMENT1). * * @param e2 * Another user list element (of type USERLISTELEMENT1). * * @return * A signed result x, where * x < 0 if e1 < e2 (by name), or * x = 0 if e1 = e2 (by name), or * x > 0 if e1 > e2 (by name). * * @since 1.1, 2008-04-11 */ /*static*/ int RFaxUserLister::sortCmp2(const void *e1, const void *e2) { #if RFaxUserLister_VS/100 != 1 #error class RFaxUserLister has changed #endif const USERLISTELEMENT1 * user1; const USERLISTELEMENT1 * user2; int cmp = 0; // Compare the user-ID list elements user1 = (const USERLISTELEMENT1 *) e1; user2 = (const USERLISTELEMENT1 *) e2; cmp = ::stricmp(user1->groupid, user2->groupid); if (cmp != 0) return cmp; cmp = ::stricmp(user1->userid, user2->userid); return cmp; } //------------------------------------------------------------------------------ // Class functions //------------------------------------------------------------------------------ /******************************************************************************* * RFaxUserLister::run() * Retrieve the list of user-IDs (in-box names) from a RightFax server. * This function is called by main(). * * Usage * rfaxusers [-option...] [-s] host [userID...] * * Options * -g name List users within a specific group. * -l Long (verbose) format. * -lc Long CSV format. * -ls Short format (user names only). * -o file Output file (default is standard output). * -s host RightFax server name or IP address (required). * -t Sort the user list. * * If no user-IDs or groups are specified, a list of all users is printed. * Group and user names may contain '?' and '*' wildcard characters. * *------------------------------------------------------------------------------- * @param argc * Argument count, i.e., the number of elements in 'argv[]'. * * @param argv * Command line arguments. * * @since 1.1, 2008-04-11 */ int RFaxUserLister::run(int argc, const char *const argv[]) { int rc = RC_OKAY; const char * addr; const char * optServer = NULL; const char * optGroup = NULL; const char * optOutfile = "-"; short optListType = LIST_NORMAL; bool optSorted = false; int i; // Parse command line options if (argc < 2) goto usage; for (i = 1; i < argc and argv[i][0] == '-'; i++) { if (::strcmp(argv[i], "-?") == 0 or ::strcmp(argv[i], "/?") == 0) goto usage; //else if (::strcmp(argv[i], "-c") == 0) // optCounted = true; else if (::strcmp(argv[i], "-g") == 0 and i+1 < argc) optGroup = argv[++i]; else if (::strcmp(argv[i], "-l") == 0) optListType = LIST_LONG; else if (::strcmp(argv[i], "-lc") == 0) optListType = LIST_CSV; else if (::strcmp(argv[i], "-ls") == 0) optListType = LIST_SHORT; else if (::strcmp(argv[i], "-o") == 0 and i+1 < argc) optOutfile = argv[++i]; else if (::strcmp(argv[i], "-s") == 0 and i+1 < argc) optServer = argv[++i]; else if (::strcmp(argv[i], "-t") == 0) optSorted = true; else goto usage; } // Check args if (optServer == NULL and i < argc) optServer = argv[i++]; if (optServer == NULL) { usage: // Display program version info ::printf("%s\n", TITLE); ::printf("Version %s [%s]\n", VERSION, BUILT+4); ::printf("\n"); ::fflush(stdout); // Improper command usage ::printf("List the users on a RightFax server.\n"); ::printf("\n"); ::printf("usage: %s [-option...] host [userID...]\n", PROG); ::printf("\n"); ::printf("Options:\n"); //::printf(" -c " // "Count users and groups, do not list.\n"); ::printf(" -g name " "Show users within a specific group.\n"); ::printf(" -l " "Long (verbose) format.\n"); ::printf(" -lc " "Long CSV format.\n"); ::printf(" -ls " "Short format (user names only).\n"); ::printf(" -o file " "Output file (default is standard output).\n"); ::printf(" -s host " "RightFax server name or IP address (required).\n"); ::printf(" -t " "Sort the user list.\n"); ::printf("\n"); ::printf("If no user-IDs or groups are specified, a list of all users " "is printed.\n"); ::printf("Group and user names may contain '?' and '*' wildcard " "characters.\n"); ::fflush(stdout); return RC_USAGE; } // Open the output file m_out = stdout; if (::strcmp(optOutfile, "-") != 0) { m_out = ::fopen(optOutfile, "w"); if (m_out == NULL) { ::printf("*** Can't open/write: %s: %s\n", optOutfile, ::strerror(errno)); return RC_OUT; } } // Establish a connection to the RightFax server m_group = optGroup; m_listType = optListType; m_sorted = optSorted; ::printf("Server: %s\n", optServer); ::fflush(stdout); if (not connect(optServer)) return RC_CONNECT; ::printf("\n"); ::fflush(stdout); // Retrieve and display the list of user-IDs printUsers(argv+i); ::fflush(m_out); ::printf("\n"); ::fflush(stdout); done: // Done, disconnect from server if (m_out != stdout) ::fclose(m_out); disconnect(); return rc; } /******************************************************************************* * RFaxUserLister::~RFaxUserLister() * Destructor. * * @since 1.1, 2008-04-07 */ RFaxUserLister::~RFaxUserLister() { #if RFaxUserLister_VS != 100 #error class RFaxUserLister has changed #endif // Deallocate } /******************************************************************************* * RFaxUserLister::RFaxUserLister() * Default constructor. * * @since 1.1, 2008-04-07 */ RFaxUserLister::RFaxUserLister(): RFaxProgram(), m_group(NULL), m_listType(LIST_NORMAL) { #if RFaxUserLister_VS != 100 #error class RFaxUserLister has changed #endif // Initialize } /******************************************************************************* * RFaxUserLister::printUsers() * Retrieve and display the list of user-IDs from the fax server. * * @param names * Array of user-IDs, terminated by a null pointer. * * @return * True if successful, otherwise false. * * @since 1.1, 2008-04-07 */ bool RFaxUserLister::printUsers(const char *const names[]) { #if RFaxUserLister_VS/100 != 1 #error class RFaxUserLister has changed #endif RFAXSERVERHANDLE hdl; RFAXLISTHANDLE list; USERLISTELEMENT1 * user; int count; int rc; // Retrieve the list of user-IDs if (m_listType != LIST_SHORT) { ::printf("Retrieving user list...\n"); ::fflush(stdout); } hdl = (RFAXSERVERHANDLE) m_hdl; rc = ::RFaxGetUserList(hdl, 1, &list); if (rc != RFAX_SUCCESS) return false; // Sort the user list if (m_sorted) { if (m_listType == LIST_SHORT) rc = ::RFaxListSort(list, &sortCmp1); else rc = ::RFaxListSort(list, &sortCmp2); if (rc != RFAX_SUCCESS) { ::printf("*** Can't sort the user-ID list\n"); ::fflush(stdout); } } // Print a heading line switch (m_listType) { case LIST_LONG: printUserInfo(NULL); break; case LIST_CSV: printUserCSV(NULL); break; } // Display the user-ID list count = 0; rc = ::RFaxListGetFirstElementPtr(list, (void **)&user); userLoop: while (rc == RFAX_SUCCESS) { USERINFO_11 info; // Check the user's group-ID against the specified group if (m_group != NULL and m_group[0] != '\0') { if (not matchesPattern(user->groupid, m_group)) goto nextLoop; } // Check the user-ID against the specified user list if (names != NULL and names[0] != NULL) { int u; // Note: Brute-force O(n**2) search algorithm for (u = 0; names[u] != NULL; u++) if (matchesPattern(user->userid, names[u])) break; if (names[u] == NULL) goto nextLoop; } count++; // Print the user info switch (m_listType) { case LIST_LONG: case LIST_CSV: // Retrieve full user info from the fax server ::memset(&info, 0, sizeof(info)); #if use_new_struct // For API 7.x+ rc = ::RFaxLoadUser3(hdl, 1, NULL, user->userid, NULL, NULL, 0L, 0L, 11, &info); #else rc = ::RFaxLoadUser(hdl, 0L, user->userid, "", "", (USERINFO_10 *) &info); #endif // Print the full user info if (rc == RFAX_SUCCESS) { if (m_listType == LIST_LONG) printUserInfo(&info); else //if (m_listType == LIST_CSV) printUserCSV(&info); } else { // Can't retrieve the full user info ::fprintf(m_out, "\"%s\\%s\",\"%s\",", user->groupid, user->userid, user->username); ::printf("*** Cannot retrieve info for user\n"); } break; case LIST_SHORT: // Print short user info (user name only) ::fprintf(m_out, "%s\n", user->userid); break; case LIST_NORMAL: default: // Print normal user info ::fprintf(m_out, "%d %s\\%s \"%s\"\n", count, user->groupid, user->userid, user->username); } nextLoop: // Retrieve the next user in the list (for the next iteration) rc = ::RFaxListGetNextElementPtr(list, (void **)&user); } ::fflush(m_out); ::fflush(stdout); // Close the list handle ::RFaxCloseListHandle(list); list = NULL; // Success if (m_listType != LIST_SHORT) ::printf("Users: %d\n", count); ::fflush(stdout); return true; } /******************************************************************************* * RFaxUserLister::printUserCSV() * Print the full information for a fax user-ID in CSV format. * * @param info * RightFax full user information. * If this is null, a heading is printed instead. * * @return * True if successful, otherwise false. * * @since 1.1, 2008-04-07 */ void RFaxUserLister::printUserCSV(const USERINFO_11 *info) { #if RFaxUserLister_VS/100 != 1 #error class RFaxUserLister has changed #endif // Sanity check if (m_out == NULL) return; if (info == NULL) { time_t t; struct tm ts; char tbuf[80+1]; int i; // Print a heading with the current date and time ::time(&t); ts = *::gmtime(&t); ::strftime(tbuf, sizeof(tbuf), "%Y-%m-%d %H:%M:%S Z", &ts); ::fprintf(m_out, "\"%s\",", "format=1"); ::fprintf(m_out, "\"%s\",", tbuf); ::fprintf(m_out, "\"%s\"", m_serverIP); ::fprintf(m_out, "\n"); // Print a heading with column titles ::fprintf(m_out, "%s,", "groupid"); ::fprintf(m_out, "%s,", "userid"); ::fprintf(m_out, "%s,", "username"); ::fprintf(m_out, "%s,", "usNumFaxesOwned"); ::fprintf(m_out, "%s,", "userflags"); //::fprintf(m_out, "%s,", "password"); ::fprintf(m_out, "%s,", "userdidnumber"); ::fprintf(m_out, "%s,", "fcsmodelname"); ::fprintf(m_out, "%s,", "notify_type"); ::fprintf(m_out, "%s,", "st_didnum"); ::fprintf(m_out, "%s,", "st_genfaxnum"); ::fprintf(m_out, "%s,", "st_callback"); ::fprintf(m_out, "%s,", "st_opernum"); ::fprintf(m_out, "%s,", "st_fromname"); ::fprintf(m_out, "%s,", "st_fromphone"); ::fprintf(m_out, "%s,", "st_to_faxnum"); ::fprintf(m_out, "%s,", "st_to_contactnum"); ::fprintf(m_out, "%s,", "st_to_name"); ::fprintf(m_out, "%s,", "st_to_company"); ::fprintf(m_out, "%s,", "st_to_citystate"); ::fprintf(m_out, "%s,", "autoprint_netprint_id"); ::fprintf(m_out, "%s,", "default_printer"); ::fprintf(m_out, "%s,", "ucWebImageFormat"); ::fprintf(m_out, "%s,", "szAutoSentPrinter"); ::fprintf(m_out, "%s,", "usAutoPrintFlags"); ::fprintf(m_out, "%s,", "ulSubscriberID"); ::fprintf(m_out, "%s,", "ulUserFlags2"); ::fprintf(m_out, "%s,", "ucHighestPriority"); ::fprintf(m_out, "%s,", "ucDefaultPriority"); ::fprintf(m_out, "%s,", "newfax_notify_user"); ::fprintf(m_out, "%s,", "routetype"); ::fprintf(m_out, "%s,", "routefmt"); ::fprintf(m_out, "%s,", "af_phone"); ::fprintf(m_out, "%s,", "send_notify"); ::fprintf(m_out, "%s,", "receive_notify"); ::fprintf(m_out, "%s,", "update_interval"); ::fprintf(m_out, "%s,", "auto_delete"); ::fprintf(m_out, "%s,", "default_view_scale"); ::fprintf(m_out, "%s,", "autoocr_flags"); ::fprintf(m_out, "%s,", "autoocr_layout"); ::fprintf(m_out, "%s,", "autoocr_format"); ::fprintf(m_out, "%s,", "autoocr_ext"); ::fprintf(m_out, "%s,", "af_user"); ::fprintf(m_out, "%s,", "route_deleteafter"); ::fprintf(m_out, "%s,", "ulChangeTag"); ::fprintf(m_out, "%s,", "routeinfo"); ::fprintf(m_out, "%s,", "nwdsname"); //::fprintf(m_out, "%s,", "folders"); for (i = 0; i < 4; i++) { ::fprintf(m_out, "%s_%d,", "szOtherPBID", i+1); //::fprintf(m_out, "%s_%d,", "szOtherPBPass", i+1); } ::fprintf(m_out, "%s,", "sRPO_StartPage"); ::fprintf(m_out, "%s,", "sRPO_EndPage"); ::fprintf(m_out, "%s,", "ucRPO_Flags"); ::fprintf(m_out, "%s,", "ucRPO_Res"); ::fprintf(m_out, "%s,", "ucRPO_Size"); ::fprintf(m_out, "%s,", "ucRPO_Source"); ::fprintf(m_out, "%s,", "ucRPO_OutputBin"); ::fprintf(m_out, "%s,", "ucRPO_Duplex"); ::fprintf(m_out, "%s,", "usRPO_SecurityCode"); ::fprintf(m_out, "%s,", "ucRPO_Copies"); ::fprintf(m_out, "%s,", "ucEmailRouteForm"); ::fprintf(m_out, "%s,", "aucRPO_AcctCode"); ::fprintf(m_out, "%s,", "ucRPO_Priority"); ::fprintf(m_out, "%s,", "ucRPO_Other"); ::fprintf(m_out, "%s,", "szDefaultBI1"); ::fprintf(m_out, "%s,", "szDefaultBI2"); ::fprintf(m_out, "%s", "sid"); #if is_not_supported_yet__ ::fprintf(m_out, "%s", "emailaddr"); #endif ::fprintf(m_out, "\n"); ::fflush(m_out); } else { int i; // Print full user info ::fprintf(m_out, "\"%s\",", info->groupid); ::fprintf(m_out, "\"%s\",", info->userid); ::fprintf(m_out, "\"%s\",", info->username); ::fprintf(m_out, "%u,", info->usNumFaxesOwned); ::fprintf(m_out, "%08lX,", info->userflags); //::fprintf(m_out, "\"%s\",", info->password); ::fprintf(m_out, "%lu,", info->userdidnumber); ::fprintf(m_out, "\"%s\",", info->fcsmodelname); ::fprintf(m_out, "%u,", info->notify_type); ::fprintf(m_out, "\"%s\",", info->st_didnum); ::fprintf(m_out, "\"%s\",", info->st_genfaxnum); ::fprintf(m_out, "%d,", info->st_callback); ::fprintf(m_out, "\"%s\",", info->st_opernum); ::fprintf(m_out, "\"%s\",", info->st_fromname); ::fprintf(m_out, "\"%s\",", info->st_fromphone); ::fprintf(m_out, "\"%s\",", info->st_to_faxnum); ::fprintf(m_out, "\"%s\",", info->st_to_contactnum); ::fprintf(m_out, "\"%s\",", info->st_to_name); ::fprintf(m_out, "\"%s\",", info->st_to_company); ::fprintf(m_out, "\"%s\",", info->st_to_citystate); ::fprintf(m_out, "\"%s\",", info->autoprint_netprint_id); ::fprintf(m_out, "\"%s\",", info->default_printer); ::fprintf(m_out, "%u,", info->ucWebImageFormat); ::fprintf(m_out, "\"%s\",", info->szAutoSentPrinter); ::fprintf(m_out, "%04X,", info->usAutoPrintFlags); ::fprintf(m_out, "%lu,", info->ulSubscriberID); ::fprintf(m_out, "%08lX,", info->ulUserFlags2); ::fprintf(m_out, "%u,", info->ucHighestPriority); ::fprintf(m_out, "%u,", info->ucDefaultPriority); ::fprintf(m_out, "\"%s\",", info->newfax_notify_user); ::fprintf(m_out, "%u,", info->routetype); ::fprintf(m_out, "%u,", info->routefmt); ::fprintf(m_out, "\"%s\",", info->af_phone); ::fprintf(m_out, "%u,", info->send_notify); ::fprintf(m_out, "%u,", info->receive_notify); ::fprintf(m_out, "%u,", info->update_interval); ::fprintf(m_out, "%u,", info->auto_delete); ::fprintf(m_out, "%u,", info->default_view_scale); ::fprintf(m_out, "%u,", info->autoocr_flags); ::fprintf(m_out, "%u,", info->autoocr_layout); ::fprintf(m_out, "%u,", info->autoocr_format); ::fprintf(m_out, "\"%s\",", info->autoocr_ext); ::fprintf(m_out, "%u,", info->af_user); ::fprintf(m_out, "%u,", info->route_deleteafter); ::fprintf(m_out, "%lu,", info->ulChangeTag); ::fprintf(m_out, "\"%s\",", info->routeinfo); ::fprintf(m_out, "\"%s\",", info->nwdsname); //::fprintf(m_out, "%s...,", info->folders); for (i = 0; i < 4; i++) { ::fprintf(m_out, "\"%s\",", info->szOtherPBID[i]); //::fprintf(m_out, "\"%s\",", info->szOtherPBPass[i]); } ::fprintf(m_out, "%d,", info->sRPO_StartPage); ::fprintf(m_out, "%d,", info->sRPO_EndPage); ::fprintf(m_out, "%u,", info->ucRPO_Flags); ::fprintf(m_out, "%u,", info->ucRPO_Res); ::fprintf(m_out, "%u,", info->ucRPO_Size); ::fprintf(m_out, "%u,", info->ucRPO_Source); ::fprintf(m_out, "%u,", info->ucRPO_OutputBin); ::fprintf(m_out, "%u,", info->ucRPO_Duplex); ::fprintf(m_out, "%u,", info->usRPO_SecurityCode); ::fprintf(m_out, "%u,", info->ucRPO_Copies); ::fprintf(m_out, "%u,", info->ucEmailRouteForm); ::fprintf(m_out, "%u,", info->aucRPO_AcctCode); ::fprintf(m_out, "%u,", info->ucRPO_Priority); ::fprintf(m_out, "%u,", info->ucRPO_Other); ::fprintf(m_out, "\"%s\",", info->szDefaultBI1); ::fprintf(m_out, "\"%s\",", info->szDefaultBI2); ::fprintf(m_out, "\""); for (i = 0; info->sid[i] != '\0'; i++) ::fprintf(m_out, "%s%02X", (i > 0 ? " " : ""), (unsigned char) info->sid[i]); ::fprintf(m_out, "\""); #if is_not_supported_yet__ ::fprintf(m_out, ",\"%s\"", info->emailaddr); #endif ::fprintf(m_out, "\n"); ::fflush(m_out); } } /******************************************************************************* * RFaxUserLister::printUserInfo() * Print the full information for a fax user-ID. * * @param info * RightFax full user information. * If this is null, a heading is printed instead. * * @return * True if successful, otherwise false. * * @since 1.1, 2008-04-11 */ void RFaxUserLister::printUserInfo(const USERINFO_11 *info) { #if RFaxUserLister_VS/100 != 1 #error class RFaxUserLister has changed #endif // Sanity check if (m_out == NULL) return; if (info == NULL) { time_t t; struct tm ts; char tbuf[80+1]; // Print a heading with the current date and time ::time(&t); ts = *::gmtime(&t); ::strftime(tbuf, sizeof(tbuf), "%Y-%m-%d %H:%M:%S Z", &ts); ::fprintf(m_out, "[List]\n"); ::fprintf(m_out, "Format=%s\n", "1"); ::fprintf(m_out, "Server=%s\n", m_serverIP); ::fprintf(m_out, "Date=%s\n", tbuf); ::fprintf(m_out, "\n"); ::fflush(m_out); } else { time_t t; struct tm ts; char tbuf[80+1]; int i; // Print full user info ::fprintf(m_out, "[%s\\%s]\n", info->groupid, info->userid); ::fprintf(m_out, "%s=%s\n", "GroupID", info->groupid); ::fprintf(m_out, "%s=%s\n", "UserID", info->userid); ::fprintf(m_out, "%s=%s\n", "UserName", info->username); ::fprintf(m_out, "%s=%u\n", "NumFaxesOwned", info->usNumFaxesOwned); ::fprintf(m_out, "%s=%08lX\n", "UserFlags", info->userflags); //::fprintf(m_out, "%s=%s\n", // "Password", info->password); ::fprintf(m_out, "%s=%lu\n", "UserDID", info->userdidnumber); ::fprintf(m_out, "%s=%s\n", "FcsModelName", info->fcsmodelname); ::fprintf(m_out, "%s=%u\n", "NotifyType", info->notify_type); ::fprintf(m_out, "%s=%s\n", "StDID", info->st_didnum); ::fprintf(m_out, "%s=%s\n", "StGenFaxNum", info->st_genfaxnum); ::fprintf(m_out, "%s=%d\n", "StCallBack", info->st_callback); ::fprintf(m_out, "%s=%s\n", "StOperNum", info->st_opernum); ::fprintf(m_out, "%s=%s\n", "StFromName", info->st_fromname); ::fprintf(m_out, "%s=%s\n", "StFromPhone", info->st_fromphone); ::fprintf(m_out, "%s=%s\n", "StToFaxNum", info->st_to_faxnum); ::fprintf(m_out, "%s=%s\n", "StToContactNum", info->st_to_contactnum); ::fprintf(m_out, "%s=%s\n", "StToName", info->st_to_name); ::fprintf(m_out, "%s=%s\n", "StToCompany", info->st_to_company); ::fprintf(m_out, "%s=%s\n", "StToCityState", info->st_to_citystate); ::fprintf(m_out, "%s=%s\n", "AutoPrintNetPrintID", info->autoprint_netprint_id); ::fprintf(m_out, "%s=%s\n", "DefaultPrinter", info->default_printer); ::fprintf(m_out, "%s=%u\n", "WebImageFormat", info->ucWebImageFormat); ::fprintf(m_out, "%s=%s\n", "AutoSentPrinter", info->szAutoSentPrinter); ::fprintf(m_out, "%s=%04X\n", "AutoPrintFlags", info->usAutoPrintFlags); ::fprintf(m_out, "%s=%lu\n", "SubscriberID", info->ulSubscriberID); ::fprintf(m_out, "%s=%08lX\n", "UserFlags2", info->ulUserFlags2); ::fprintf(m_out, "%s=%u\n", "HighestPriority", info->ucHighestPriority); ::fprintf(m_out, "%s=%u\n", "DefaultPriority", info->ucDefaultPriority); ::fprintf(m_out, "%s=%s\n", "NewFaxNotifyUser", info->newfax_notify_user); ::fprintf(m_out, "%s=%u\n", "RouteType", info->routetype); ::fprintf(m_out, "%s=%u\n", "RouteFmt", info->routefmt); ::fprintf(m_out, "%s=%s\n", "AfPhone", info->af_phone); ::fprintf(m_out, "%s=%u\n", "SendNotify", info->send_notify); ::fprintf(m_out, "%s=%u\n", "ReceiveNotify", info->receive_notify); ::fprintf(m_out, "%s=%u\n", "UpdateInterval", info->update_interval); ::fprintf(m_out, "%s=%u\n", "AutoDelete", info->auto_delete); ::fprintf(m_out, "%s=%u\n", "DefaultViewScale", info->default_view_scale); ::fprintf(m_out, "%s=%u\n", "AutooCrFlags", info->autoocr_flags); ::fprintf(m_out, "%s=%u\n", "AutoOcrLayout", info->autoocr_layout); ::fprintf(m_out, "%s=%u\n", "AutoOcrFormat", info->autoocr_format); ::fprintf(m_out, "%s=%s\n", "AutoOcrExt", info->autoocr_ext); ::fprintf(m_out, "%s=%u\n", "AfUser", info->af_user); ::fprintf(m_out, "%s=%u\n", "RouteDeleteafter", info->route_deleteafter); t = (time_t) info->ulChangeTag; ts = *::gmtime(&t); ::strftime(tbuf, sizeof(tbuf), ", %m/%d/%Y %H:%M:%S Z", &ts); ::fprintf(m_out, "%s=%lu%s\n", "ChangeTag", info->ulChangeTag, (t != 0 ? tbuf : "")); ::fprintf(m_out, "%s=%s\n", "RouteInfo", info->routeinfo); ::fprintf(m_out, "%s=%s\n", "NwDsName", info->nwdsname); //::fprintf(m_out, "%s=%s...\n", // "folders", info->folders); for (i = 0; i < 4; i++) { ::fprintf(m_out, "%s_%d=%s\n", "OtherPBID", i+1, info->szOtherPBID[i]); //::fprintf(m_out, "%s_%d=%s\n", // "OtherPBPass", i+1, info->szOtherPBPass[i]); } ::fprintf(m_out, "%s=%d\n", "RpoStartPage", info->sRPO_StartPage); ::fprintf(m_out, "%s=%d\n", "RpoEndPage", info->sRPO_EndPage); ::fprintf(m_out, "%s=%u\n", "RpoFlags", info->ucRPO_Flags); ::fprintf(m_out, "%s=%u\n", "RpoRes", info->ucRPO_Res); ::fprintf(m_out, "%s=%u\n", "RpoSize", info->ucRPO_Size); ::fprintf(m_out, "%s=%u\n", "RpoSource", info->ucRPO_Source); ::fprintf(m_out, "%s=%u\n", "RpoOutputBin", info->ucRPO_OutputBin); ::fprintf(m_out, "%s=%u\n", "RpoDuplex", info->ucRPO_Duplex); ::fprintf(m_out, "%s=%u\n", "RpoSecurityCode", info->usRPO_SecurityCode); ::fprintf(m_out, "%s=%u\n", "RpoCopies", info->ucRPO_Copies); ::fprintf(m_out, "%s=%u\n", "EmailRouteForm", info->ucEmailRouteForm); ::fprintf(m_out, "%s=%u\n", "AucRpoAcctCode", info->aucRPO_AcctCode); ::fprintf(m_out, "%s=%u\n", "RpoPriority", info->ucRPO_Priority); ::fprintf(m_out, "%s=%u\n", "RpoOther", info->ucRPO_Other); ::fprintf(m_out, "%s=%s\n", "DefaultBI1", info->szDefaultBI1); ::fprintf(m_out, "%s=%s\n", "DefaultBI2", info->szDefaultBI2); ::fprintf(m_out, "%s=", "SecurityID"); for (i = 0; info->sid[i] != '\0'; i++) ::fprintf(m_out, "%s%02X", (i > 0 ? " " : ""), (unsigned char) info->sid[i]); ::fprintf(m_out, "\n"); #if is_not_supported_yet__ ::fprintf(m_out, "%s=%s\n", "EmailAddr", info->emailaddr); #endif ::fprintf(m_out, "\n"); ::fflush(m_out); } } //------------------------------------------------------------------------------ // Public (non-class) functions //------------------------------------------------------------------------------ /******************************************************************************* * ::main() * Retrieve the list of user-IDs (in-box names) from a RightFax server. * * Usage * rfaxusers [-option...] [-s] host [userID...] * *------------------------------------------------------------------------------- * @param argc * Argument count, i.e., the number of elements in 'argv[]'. * * @param argv * Command line arguments. * * @since 1.1, 2008-04-07 */ int main(int argc, char *argv[]) { // Execute this program return RFaxUserLister::main(argc, (const char *const *)argv); } // End rfaxusers.cpp