/** * @brief * main - the entry point in pbsTclInit.c * * @param[in] argc - argument count. * @param[in] argv - argument variables. * * @return int * @retval 0 : success */ int main(int argc, char *argv[]) { char tcl_libpath[MAXPATHLEN+13]; /* 13 for "TCL_LIBRARY=" + \0 */ int rc; /*the real deal or just pbs_version and exit?*/ execution_mode(argc, argv); if(set_msgdaemonname("pbs_tclsh")) { fprintf(stderr, "Out of memory\n"); return 1; } set_logfile(stderr); #ifdef WIN32 winsock_init(); Tcl_FindExecutable(argv[0]); #endif /* load the pbs conf file */ if (pbs_loadconf(0) == 0) { fprintf(stderr, "%s: Configuration error\n", argv[0]); return (1); } if (!getenv("TCL_LIBRARY")) { if (pbs_conf.pbs_exec_path) { sprintf((char *)tcl_libpath, #ifdef WIN32 "TCL_LIBRARY=%s/lib/tcl%s", #else "TCL_LIBRARY=%s/tcltk/lib/tcl%s", #endif pbs_conf.pbs_exec_path, TCL_VERSION); putenv(tcl_libpath); } } if (pbs_conf.pbs_use_tcp == 1) { char *nodename; struct tpp_config tpp_conf; char my_hostname[PBS_MAXHOSTNAME+1]; fd_set selset; struct timeval tv; if (pbs_conf.pbs_leaf_name) nodename = pbs_conf.pbs_leaf_name; else { if (gethostname(my_hostname, (sizeof(my_hostname) - 1)) < 0) { fprintf(stderr, "Failed to get hostname\n"); return -1; } nodename = my_hostname; } /* We don't want to show logs related to connecting pbs_comm on console * this set this flag to ignore it */ log_mask = SHOW_NONE; /* set tpp function pointers */ set_tpp_funcs(log_tppmsg); /* call tpp_init */ rc = 0; #ifndef WIN32 if (pbs_conf.auth_method == AUTH_MUNGE) rc = set_tpp_config(&pbs_conf, &tpp_conf, nodename, -1, pbs_conf.pbs_leaf_routers, pbs_conf.pbs_use_compression, TPP_AUTH_EXTERNAL, get_ext_auth_data, validate_ext_auth_data); else #endif rc = set_tpp_config(&pbs_conf, &tpp_conf, nodename, -1, pbs_conf.pbs_leaf_routers, pbs_conf.pbs_use_compression, TPP_AUTH_RESV_PORT, NULL, NULL); if (rc == -1) { fprintf(stderr, "Error setting TPP config\n"); return -1; } if ((rpp_fd = tpp_init(&tpp_conf)) == -1) { fprintf(stderr, "rpp_init failed\n"); return -1; } /* * Wait for net to get restored, ie, app to connect to routers */ FD_ZERO(&selset); FD_SET(rpp_fd, &selset); tv.tv_sec = 5; tv.tv_usec = 0; select(FD_SETSIZE, &selset, (fd_set *) 0, (fd_set *) 0, &tv); rpp_poll(); /* to clear off the read notification */ /* Once the connection is established we can unset log_mask */ log_mask &= ~SHOW_NONE; } else { /* set rpp function pointers */ set_rpp_funcs(log_rppfail); } Tcl_Main(argc, argv, pbsTcl_Init); return 0; }
int main(int argc, char *argv[]) { int i; char mom_name[PBS_MAXHOSTNAME+1]; int mom_port = 0; int c, rc; int mom_sd; char *req; #ifdef WIN32 if (winsock_init()) { return 1; } #endif if (gethostname(mom_name, (sizeof(mom_name) - 1)) < 0 ) mom_name[0] = '\0'; while ((c = getopt(argc, argv, "m:p:")) != EOF) { switch (c) { case 'm': strcpy(mom_name, optarg); break; case 'p': mom_port = atoi(optarg); break; default: fprintf(stderr, "Bad option: %c\n", c); } } if (mom_name[0] == '\0' || optind == argc) { fprintf(stderr, "Error in usage: pbs_rmget [-m mom name] [-p mom port] <req1>...[reqN]\n"); return 1; } if(set_msgdaemonname("pbs_rmget")) { fprintf(stderr, "Out of memory\n"); return 1; } /* load the pbs conf file */ if (pbs_loadconf(0) == 0) { fprintf(stderr, "%s: Configuration error\n", argv[0]); return (1); } if (pbs_conf.pbs_use_tcp == 1) { struct tpp_config tpp_conf; fd_set selset; struct timeval tv; if (!pbs_conf.pbs_leaf_name) { char my_hostname[PBS_MAXHOSTNAME+1]; if (gethostname(my_hostname, (sizeof(my_hostname) - 1)) < 0) { fprintf(stderr, "Failed to get hostname\n"); return -1; } pbs_conf.pbs_leaf_name = get_all_ips(my_hostname, log_buffer, sizeof(log_buffer) - 1); if (!pbs_conf.pbs_leaf_name) { fprintf(stderr, "%s\n", log_buffer); fprintf(stderr, "%s\n", "Unable to determine TPP node name"); return -1; } } /* We don't want to show logs related to connecting pbs_comm on console * this set this flag to ignore it */ log_mask = SHOW_NONE; /* set tpp function pointers */ set_tpp_funcs(log_tppmsg); /* call tpp_init */ rc = 0; #ifndef WIN32 if (pbs_conf.auth_method == AUTH_MUNGE) rc = set_tpp_config(&pbs_conf, &tpp_conf, pbs_conf.pbs_leaf_name, -1, pbs_conf.pbs_leaf_routers, pbs_conf.pbs_use_compression, TPP_AUTH_EXTERNAL, get_ext_auth_data, validate_ext_auth_data); else #endif rc = set_tpp_config(&pbs_conf, &tpp_conf, pbs_conf.pbs_leaf_name, -1, pbs_conf.pbs_leaf_routers, pbs_conf.pbs_use_compression, TPP_AUTH_RESV_PORT, NULL, NULL); if (rc == -1) { fprintf(stderr, "Error setting TPP config\n"); return -1; } if ((rpp_fd = tpp_init(&tpp_conf)) == -1) { fprintf(stderr, "rpp_init failed\n"); return -1; } /* * Wait for net to get restored, ie, app to connect to routers */ FD_ZERO(&selset); FD_SET(rpp_fd, &selset); tv.tv_sec = 5; tv.tv_usec = 0; select(FD_SETSIZE, &selset, NULL, NULL, &tv); rpp_poll(); /* to clear off the read notification */ /* Once the connection is established we can unset log_mask */ log_mask &= ~SHOW_NONE; } else { /* set rpp function pointers */ set_rpp_funcs(log_rppfail); } /* get the FQDN of the mom */ c = get_fullhostname(mom_name, mom_name, (sizeof(mom_name) - 1)); if (c == -1) { fprintf(stderr, "Unable to get full hostname for mom %s\n", mom_name); return -1; } if ((mom_sd = openrm(mom_name, mom_port)) < 0) { fprintf(stderr, "Unable to open connection to mom: %s:%d\n", mom_name, mom_port); return 1; } for (i = optind; i < argc; i++) addreq(mom_sd, argv[i]); for (i = optind; i < argc; i++) { req = getreq(mom_sd); if (req == NULL) { fprintf(stderr, "Error getting response %d from mom.\n", i - optind); return 1; } printf("[%d] %s\n", i - optind, req); free(req); } closerm(mom_sd); return 0; }