char islongint_(char *word) { long long int number; if (!word || *word == '\0') return FALSE; if(!isdigitstr_(word)) return FALSE; if (errno == ERANGE) errno = 0; sscanf(word, "%lld", &number); if (errno != ERANGE) { if (number <= INFINIT_LONG_INT && number > -INFINIT_LONG_INT) return TRUE; } return FALSE; }
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); }