int getLogClass_ (char *lsp, char *tsp) { char *word; int class = 0; timinglevel = 0; logclass = 0; if (tsp != NULL && isint_(tsp)) timinglevel = atoi(tsp); while (lsp != NULL && (word = getNextWord_(&lsp))) { if (strcmp (word, "LC_SCHED") == 0) class |= LC_SCHED; if (strcmp (word, "LC_PEND") == 0) class |= LC_PEND; if (strcmp (word, "LC_JLIMIT") == 0) class |= LC_JLIMIT; if (strcmp (word, "LC_EXEC") == 0) class |= LC_EXEC; if (strcmp (word, "LC_TRACE") == 0) class |= LC_TRACE; if (strcmp (word, "LC_COMM") == 0) class |= LC_COMM; if (strcmp (word, "LC_XDR") == 0) class |= LC_XDR; if (strcmp (word, "LC_CHKPNT") == 0) class |= LC_CHKPNT; if (strcmp (word, "LC_FILE") == 0) class |= LC_FILE; if (strcmp (word, "LC_AUTH") == 0) class |= LC_AUTH; if (strcmp (word, "LC_HANG") == 0) class |= LC_HANG; if (strcmp (word, "LC_SIGNAL") == 0) class |= LC_SIGNAL; if (strcmp (word, "LC_PIM") == 0) class |= LC_PIM; if (strcmp (word, "LC_SYS") == 0) class |= LC_SYS; if (strcmp (word, "LC_LOADINDX") == 0) class |= LC_LOADINDX; if (strcmp (word, "LC_JGRP") == 0) class |= LC_JGRP; if (strcmp (word, "LC_JARRAY") == 0) class |= LC_JARRAY; if (strcmp (word, "LC_MPI") == 0) class |= LC_MPI; if (strcmp (word, "LC_ELIM") == 0) class |= LC_ELIM; if (strcmp (word, "LC_M_LOG") == 0) class |= LC_M_LOG; if (strcmp (word, "LC_PERFM") == 0) class |= LC_PERFM; } logclass = class; return 0; }
int getJobIdIndexList (char *jobIdStr, int *outJobId, struct idxList **idxListP) { int jobId = 0; char *startP; int errCode; int maxJLimit = 0; *idxListP = NULL; if ((startP = strchr (jobIdStr, '[')) == NULL) { if (!isint_ (jobIdStr) || ((jobId = atoi (jobIdStr)) < 0)) { return (LSBE_BAD_JOBID); } *outJobId = jobId; return (LSBE_NO_ERROR); } *startP = '\0'; if (!isint_ (jobIdStr) || ((jobId = atoi (jobIdStr)) <= 0) || (jobId > LSB_MAX_ARRAY_JOBID)) { return (LSBE_BAD_JOBID); } *outJobId = jobId; *startP = '['; if ((*idxListP = parseJobArrayIndex (jobIdStr, &errCode, &maxJLimit)) == NULL) { return (errCode); } return (LSBE_NO_ERROR); }
int getValPair(char **resReq, int *val1, int *val2) { char *token, *cp, *wd1 = NULL, *wd2 = NULL; int len; *val1 = INFINIT_INT; *val2 = INFINIT_INT; token = getNextToken (resReq); if (!token) return 0; len = strlen (token); if (len == 0) return 0; cp = token; while (*cp != '\0' && *cp != ',' && *cp != '/') cp++; if (*cp != '\0') { *cp = '\0'; if (cp - token > 0) wd1 = token; if (cp - token < len - 1) wd2 = ++cp; } else wd1 = token; if (wd1 && !isint_(wd1)) return -1; if (wd2 && !isint_(wd2)) return -1; if (!wd1 && !wd2) return -1; if (wd1) *val1 = atoi(wd1); if (wd2) *val2 = atoi(wd2); return 0; }
int limLock(int argc, char **argv) { int duration; char *optName; duration = 0; while ((optName = myGetOpt(argc, argv, "l:")) != NULL) { switch(optName[0]) { case 'l': duration = atoi(optarg); if (!isint_(optarg) || atoi(optarg) <= 0) { fprintf(stderr, "\ The host locking duration <%s> should be a positive integer\n", optarg); return -2; } break; default: return -2; } }
int limLock(int argc, char **argv) { u_long duration = 0; extern int optind; extern char *optarg; char *optName; while ((optName = myGetOpt(argc, argv, "l:")) != NULL) { switch(optName[0]) { case 'l': duration = atoi(optarg); if (!isint_(optarg) || atoi(optarg) <= 0) { fprintf(stderr, I18N(258, "The host locking duration <%s> should be a positive integer\n"), optarg); /* catgets 258 */ return -2; } break; default: return -2; } } if (argc > optind) return -2; if (ls_lockhost(duration) < 0) { ls_perror("failed"); return(-1); } if (duration) printf(I18N(259, "Host is locked for %lu seconds\n") /* catgets 259 */, (unsigned long)duration); else printf(I18N(260, "Host is locked\n")); /* catgets 260 */ fflush(stdout); return(0); }
int requeueEParse (struct requeueEStruct **rquest, char *reqstr, int *error) { int numStruct, exitV; char mode, *word; numAlloc =16; *error =0; mode = RQE_NORMAL; if (!(*rquest=(struct requeueEStruct *) malloc(numAlloc*sizeof (struct requeueEStruct)))) return 0; (*rquest)[0].type = RQE_END; for (numStruct = 0;;) { if (!(word = a_getNextWord_(&reqstr))) break; if (isint_(word)) { if ((exitV=my_atoi(word,256,-1))!=INFINIT_INT) { if (!fill_struct (rquest, numStruct, exitV, mode)) numStruct ++; else *error =1; } else *error =1; } else if (strncasecmp(word,"EXCLUDE(",8)==0) mode = RQE_EXCLUDE; else if (*word==')') mode = RQE_NORMAL; } if (numStruct) *rquest=(struct requeueEStruct *) realloc(*rquest, (numStruct+1)*sizeof (struct requeueEStruct)); return numStruct; }
void bmove (int argc, char **argv, int opCode) { int position, reqPos; LS_LONG_INT jobId = 0; int achar; if (lsb_init(argv[0]) < 0) { lsb_perror("lsb_init"); exit(-1); } opterr = 0; while((achar = getopt(argc, argv, "hV")) != EOF) { switch(achar) { case 'V': fputs(_LS_VERSION_, stderr); exit(0); case 'h': default: usage(argv[0]); } } if (argc == optind) { fprintf(stderr, "%s.\n", (_i18n_msg_get(ls_catd,NL_SETN,852, "Job ID must be specified"))); /* catgets 852 */ usage(argv[0]); } if (optind < argc-2) { fprintf(stderr, "%s.\n", (_i18n_msg_get(ls_catd,NL_SETN,853, "Command syntax error: too many arguments"))); /* catgets 853 */ usage(argv[0]); } if (getOneJobId (argv[optind], &jobId, 0)) { usage(argv[0]); } position = 1; if (optind == argc - 2) { if (!isint_(argv[++optind]) || atoi(argv[optind]) <= 0) { fprintf(stderr, "%s: %s.\n", argv[optind], I18N(854, "Position value must be a positive integer")); /* catgets854*/ usage(argv[0]); } position = atoi(argv[optind]); } reqPos = position; if (lsb_movejob(jobId, &position, opCode) <0) { lsb_perror(lsb_jobid2str (jobId)); exit(-1); } if (position != reqPos) fprintf(stderr, (_i18n_msg_get(ls_catd,NL_SETN,855, "Warning: position value <%d> is beyond movable range.\n")), /* catgets 855 */ reqPos); if (opCode == TO_TOP) fprintf(stderr, (_i18n_msg_get(ls_catd,NL_SETN,856, "Job <%s> has been moved to position %d from top.\n")), /* catgets 856 */ lsb_jobid2str (jobId), position); else fprintf(stderr, (_i18n_msg_get(ls_catd,NL_SETN,857, "Job <%s> has been moved to position %d from bottom.\n")), /* catgets 857 */ lsb_jobid2str (jobId), position); exit(0); }
static int do_options (int argc, char **argv, LS_LONG_INT **jobIds, int signalValue) { int cc; int kflg=0; int sflg=0; int sigflg=0; int forceflg=0; int newOptions = 0; sigJobId = 0; sigUser = NULL; sigQueue = NULL; sigHost = NULL; sigJobName = NULL; chkOptions = 0; sigValue = signalValue; while ((cc = getopt(argc, argv, "VhkSlq:u:m:p:rfs:J:n:ad")) != EOF) { switch (cc) { case 'u': if (sigUser) usage(argv[0], signalValue); if (strcmp(optarg, "all") == 0) sigUser = ALL_USERS; else sigUser = optarg; break; case 'q': sigQueue = optarg; break; case 'm': sigHost = optarg; break; case 'l': if (signalValue != SIGKILL) { fprintf (stderr, "%s: %s %s\n", argv[0], _i18n_msg_get(ls_catd,NL_SETN,459, "Illegal option --"), /* catgets 459 */ "l"); usage (argv[0], signalValue); } puts (getSigSymbolList()); exit (-1); case 's': if (signalValue != SIGKILL) { fprintf (stderr, "%s: %s %s\n", argv[0], _i18n_msg_get(ls_catd,NL_SETN,459, "Illegal option --"), "s"); usage (argv[0], signalValue); } if (forceflg) { usage (argv[0], signalValue); exit(-1); } else { if ((sigValue = getSigVal(optarg)) < 0) { fprintf(stderr, (_i18n_msg_get(ls_catd,NL_SETN,461, "%s: Illegal signal value\n")), optarg); /* catgets 461 */ exit (-1); } sigflg = TRUE; } break; case 'a': if (signalValue != SIGDEL && signalValue != SIGSTOP) { fprintf (stderr, "%s: %s %s\n", argv[0], _i18n_msg_get(ls_catd,NL_SETN,459, "Illegal option --"), "a"); usage (argv[0], signalValue); } newOptions |= ALL_JOB; break; case 'd': if (signalValue != SIGDEL && signalValue != SIGSTOP) { fprintf (stderr, "%s: %s %s\n", argv[0], _i18n_msg_get(ls_catd,NL_SETN,459, "Illegal option --"), "d"); usage (argv[0], signalValue); } newOptions |= DONE_JOB; break; case 'n': if (signalValue != SIGDEL) { fprintf (stderr, "%s: %s %s\n", argv[0], _i18n_msg_get(ls_catd,NL_SETN,459, "Illegal option --"), "n"); usage (argv[0], signalValue); } if (isint_(optarg) && ((runCount = atoi(optarg)) >= 0)) break; fprintf(stderr, (_i18n_msg_get(ls_catd,NL_SETN,465, "%s: Illegal times value\n")), optarg); /* catgets 465 */ exit(-1); case 'J': if ( supportJobNamePattern(optarg) != 0) { fprintf(stderr, (_i18n_msg_get(ls_catd, NL_SETN, 491, "%s: Job or Job Group name is not valid.\n")), optarg); /* catgets 491*/ exit (-1); } sigJobName = optarg; break; case 'f': if (signalValue == SIGCHK) { chkOptions |= LSB_CHKPNT_FORCE; } else { usage(argv[0], signalValue); exit(-1); } break; case 'r': if ( (signalValue == SIGKILL) && (!sigflg) ) { sigValue = SIGFORCE; newOptions |= ZOMBIE_JOB; forceflg=TRUE; } else { usage(argv[0], signalValue); exit(-1); } break; case 'p': if (signalValue != SIGCHK) { usage(argv[0], signalValue); exit(-1); } if (isint_(optarg) && ((chkPeriod = atoi(optarg) * 60) >= 0)) break; fprintf(stderr, (_i18n_msg_get(ls_catd,NL_SETN,466, "%s: Illegal checkpoint period value\n")), optarg); /* catgets 466 */ exit(-1); case 'k': if (sflg) { usage(argv[0], signalValue); exit(-1); } else { kflg++; if (signalValue != SIGCHK) { usage(argv[0], signalValue); exit(-1); } chkOptions |= LSB_CHKPNT_KILL; } break; case 'S': if (kflg) { usage(argv[0], signalValue); exit(-1); } else { sflg++; if (signalValue != SIGCHK) { usage(argv[0], signalValue); exit(-1); } chkOptions |= LSB_CHKPNT_STOP; } break; case 'V': fputs(_LS_VERSION_, stderr); exit(0); case 'h': default: usage(argv[0], signalValue); } } if ((argc == optind) && (sigUser == NULL) && (sigQueue == NULL) && (sigHost == NULL) && (sigJobName == NULL) ) { fprintf(stderr, "%s.\n", (_i18n_msg_get(ls_catd,NL_SETN,467, "Job ID or one of '-m', '-u' '-q' and '-J' must be specified"))); /* catgets 467 */ usage(argv[0], signalValue); } return (getJobIds (argc, argv, sigJobName, sigUser, sigQueue, sigHost, jobIds, newOptions)); }
int get_ports(void) { static char fname[] = "get_ports"; struct servent *sv; if (daemonParams[LSB_MBD_PORT].paramValue != NULL) { if (!isint_(daemonParams[LSB_MBD_PORT].paramValue) || (mbd_port = atoi(daemonParams[LSB_MBD_PORT].paramValue)) <= 0) ls_syslog(LOG_ERR, _i18n_msg_get(ls_catd , NL_SETN, 8226, "%s: LSB_MBD_PORT <%s> in lsf.conf must be a positive number"), /* catgets 8226 */ fname, daemonParams[LSB_MBD_PORT].paramValue); else mbd_port = htons(mbd_port); } else if (debug) mbd_port = htons(BATCH_MASTER_PORT); else { sv = getservbyname(MBATCHD_SERV, "tcp"); if (!sv) { ls_syslog(LOG_ERR, _i18n_msg_get(ls_catd , NL_SETN, 8227, "%s: %s service not registered"), fname, MBATCHD_SERV); lsb_merr(_i18n_printf(_i18n_msg_get(ls_catd , NL_SETN, 3208, "%s: %s service not registered"), fname, MBATCHD_SERV)); return -1; } mbd_port = sv->s_port; } if (daemonParams[LSB_SBD_PORT].paramValue != NULL) { if (!isint_(daemonParams[LSB_SBD_PORT].paramValue) || (sbd_port = atoi(daemonParams[LSB_SBD_PORT].paramValue)) <= 0) ls_syslog(LOG_ERR, _i18n_msg_get(ls_catd , NL_SETN, 8229, "%s: LSB_SBD_PORT <%s> in lsf.conf must be a positive number"), /* catgets 8229 */ fname, daemonParams[LSB_SBD_PORT].paramValue); else sbd_port = htons(sbd_port); } else if (debug) sbd_port = htons(BATCH_SLAVE_PORT); else { sv = getservbyname(SBATCHD_SERV, "tcp"); if (!sv) { lsb_merr(_i18n_printf(_i18n_msg_get(ls_catd , NL_SETN, 3208, "%s: %s service not registered"), fname, SBATCHD_SERV)); ls_syslog(LOG_ERR, _i18n_msg_get(ls_catd , NL_SETN, 8231, "%s: %s service not registered"), /* catgets 8231 */ fname, SBATCHD_SERV); return -1; } sbd_port = sv->s_port; } return 0; }
static int getJobIdIndexList (char *string, int *outJobId, struct idxList **idxListP, int options) { int jobId = 0; char *startP; static char jobIdStr[16]; int jobIdLen; char inJobIdStr[MAXLINELEN]; *idxListP = NULL; strcpy (inJobIdStr, string); if ((startP = strchr (string, '[')) == NULL) { if (!isint_ (string)) { if (isdigitstr_ (string) && islongint_ (string)) { LS_LONG_INT interJobId = 0; if ((interJobId = atoi64_ (string)) > 0) { strcpy (inJobIdStr, lsb_jobid2str (interJobId)); } } } } if ((startP = strchr (inJobIdStr, '[')) == NULL) { if (!isint_ (inJobIdStr)) { fprintf (stderr, (_i18n_msg_get (ls_catd, NL_SETN, 1008, "%s: Illegal job ID.\n")), string); /* catgets 1008 */ return (-1); } if ((jobId = atoi (inJobIdStr)) < 0) { fprintf (stderr, (_i18n_msg_get (ls_catd, NL_SETN, 1008, "%s: Illegal job ID.\n")), string); return (-1); } *outJobId = jobId; return (0); } if ((jobIdLen = (int) (startP - inJobIdStr)) >= 16) { fprintf (stderr, (_i18n_msg_get (ls_catd, NL_SETN, 1010, "Job Id (%s) is too long.\n")), string); /* catgets 1010 */ return (-1); } STRNCPY (jobIdStr, inJobIdStr, jobIdLen + 1); if (!isint_ (jobIdStr)) { fprintf (stderr, (_i18n_msg_get (ls_catd, NL_SETN, 1008, "%s: Illegal job ID.\n")), string); return (-1); } jobId = atoi (jobIdStr); if ((jobId <= 0) || (jobId > LSB_MAX_ARRAY_JOBID)) { fprintf (stderr, (_i18n_msg_get (ls_catd, NL_SETN, 1012, "%s: Job ID out of valid range.\n")), string); /* catgets 1012 */ return (-1); } *outJobId = jobId; if ((*idxListP = parseJobArrayIndex (inJobIdStr)) == NULL) { return (-1); } return (0); }