예제 #1
0
  const std::string Options::toString() {
    std::stringstream ss;

    ss << "{" << std::endl;
    ss << "  commandArgs = {" << std::endl;
    for (auto arg : getCommandArgs()) {
      ss << "    \"" << arg << "\"" << std::endl;
    }
    ss << "  }" << std::endl;
    ss << "  verbosity = " << getVerbosity() << std::endl;
    ss << "}" << std::endl;

    return ss.str();
  }
예제 #2
0
int main(int argc, char** argv) {
    sgs_context *context;
    sgs_connection *connection;
    sgs_connection *session;

    /* Begin by initializing the read sets for reading,
     * writing, and exceptions; these sets are all sets
     * of file descriptors
     */
    FD_ZERO(&g_master_readset);
    FD_ZERO(&g_master_writeset);
    FD_ZERO(&g_master_exceptset);

    /* Now, initialize all of the flags that will be
     * used to keep track of which tests pass and which
     * tests fail
     */
    loginFailFail = loginDisconnectFail = loginFail = 1;
    channelJoinFail = channelLeaveFail = channelMessageFail = 1;
    sessionMessageFail = 1;

    /* Get any command line argumentss, and
     * set the appropriate (global) variables. Currently,
     * the command line can only specify the host and port
     * of the server, and ask for the usage message
     * to be printed
     */
    g_hostname = DEFAULT_HOST;
    g_port = DEFAULT_PORT;
    getCommandArgs(argc, argv);

    /* Create a context object, and load it up with the right set
     * of callbacks. The register_fd and unregister_fd callbacks
     * are loaded as part of the create call for historical purposes
     */
    context = sgs_ctx_create(g_hostname, g_port, register_fd_cb, unregister_fd_cb);
    if (context == NULL) {
        printf("error in context create\n");
        exit(1);
    }
    loadContext(context);
    /*Now, create a connection to the server; if this doesn't work things
     * are messed up enough to require simply printing an error message
     * and getting out
     */
    connection = sgs_connection_create(context);
    if (connection == NULL){
        printf ("error in creating a connection to the server\n");
        exit(1);
    }

    if (testLogin(connection) != 0) {
        printf ("Failed at least one login test\n");
        exit(1);
    }

    sgs_connection_login(connection, loginName, loginName);

    waitForInput(connection);

    return(printResults());
}