int getJobIdList (char *jobIdStr, int *numJobIds, LS_LONG_INT **jobIdList) { int jobId; LS_LONG_INT lsbJobId; LS_LONG_INT *temp, *jobIds; struct idxList *idxListP = NULL, *idx; int sizeOfJobIdArray = MAX_JOB_IDS; int i, j, errCode; *numJobIds = 0; if ((errCode = getJobIdIndexList (jobIdStr, &jobId, &idxListP)) != LSBE_NO_ERROR) { return(errCode); } if (jobId <= 0) return(LSBE_BAD_JOBID); if ((jobIds = (LS_LONG_INT *) calloc (MAX_JOB_IDS, sizeof (LS_LONG_INT))) == NULL) { mbdDie(MASTER_MEM); } if (idxListP == NULL) { jobIds[0] = jobId; *numJobIds = 1; *jobIdList = jobIds; return(LSBE_NO_ERROR); } for (idx = idxListP; idx; idx = idx->next) { for (j = idx->start; j <= idx->end; j+= idx->step) { lsbJobId = LSB_JOBID(jobId, j); if (*numJobIds >= sizeOfJobIdArray) { sizeOfJobIdArray += MAX_JOB_IDS; if ((temp = (LS_LONG_INT *) realloc(jobIds, sizeOfJobIdArray * sizeof(LS_LONG_INT))) == NULL) { mbdDie(MASTER_MEM); } jobIds = temp; } for (i = 0; i < *numJobIds; i++) if (lsbJobId == jobIds[i]) break; if (i == (*numJobIds)) { jobIds[(*numJobIds)++] = lsbJobId; } } } freeIdxList(idxListP); *jobIdList = jobIds; return (LSBE_NO_ERROR); }
int getOneJobId (char *string, LS_LONG_INT * outJobId, int options) { int jobId = 0; struct idxList *idxListP = NULL; if (getJobIdIndexList (string, &jobId, &idxListP, 0)) { return (-1); } if (jobId == 0) { fprintf (stderr, "%s.\n", (_i18n_msg_get (ls_catd, NL_SETN, 1006, "Job Id = 0 is out of valid range"))); /* catgets 1006 */ freeIdxList (idxListP); return (-1); } if (idxListP == NULL) { *outJobId = jobId; return (0); } if ((idxListP->next != NULL) | (idxListP->start != idxListP->end) | (idxListP->step != 1)) { fprintf (stderr, "%s: %s.\n", string, (_i18n_msg_get (ls_catd, NL_SETN, 1007, "Illegal job array index. One element only"))); /* catgets 1007 */ freeIdxList (idxListP); return (-1); } *outJobId = LSB_JOBID (jobId, idxListP->start); freeIdxList (idxListP); return (0); }
int getSpecJobIds (int argc, char **argv, LS_LONG_INT ** jobIds0, int *options) { int numJobIds = 0; static LS_LONG_INT *jobIds = NULL; int i; int j; LS_LONG_INT *temp; int jobId; LS_LONG_INT lsbJobId; int sizeOfJobIdArray = MAX_JOB_IDS; struct idxList *idxListP = NULL, *idx; static char fName[] = "getSpecJobIds"; if (jobIds) free (jobIds); if (argc < optind + 1) { *jobIds0 = NULL; return (0); } if ((jobIds = (LS_LONG_INT *) calloc (MAX_JOB_IDS, sizeof (LS_LONG_INT))) == NULL) { perror ("calloc"); exit (-1); } for (; argc > optind; optind++) { if (getJobIdIndexList (argv[optind], &jobId, &idxListP, 0)) { exit (-1); } if (idxListP == NULL) { if (numJobIds >= sizeOfJobIdArray) { sizeOfJobIdArray += MAX_JOB_IDS; if ((jobIds = realloc (jobIds, sizeOfJobIdArray * sizeof (LS_LONG_INT))) == NULL) { fprintf (stderr, I18N_FUNC_FAIL, fName, "malloc"); exit (-1); } } if (jobId == 0) { if (options) *options = CUR_JOB; numJobIds = 0; break; } for (i = 0; i < numJobIds; i++) if (jobId == jobIds[i]) break; if (i == numJobIds) { jobIds[numJobIds] = jobId; numJobIds++; } continue; } for (idx = idxListP; idx; idx = idx->next) { for (j = idx->start; j <= idx->end; j += idx->step) { lsbJobId = LSB_JOBID (jobId, j); if (numJobIds >= sizeOfJobIdArray) { sizeOfJobIdArray += MAX_JOB_IDS; if ((temp = (LS_LONG_INT *) realloc (jobIds, sizeOfJobIdArray * sizeof (LS_LONG_INT))) == NULL) { fprintf (stderr, I18N_FUNC_FAIL, fName, "malloc"); exit (-1); } jobIds = temp; } for (i = 0; i < numJobIds; i++) if (lsbJobId == jobIds[i]) break; if (i == numJobIds) { jobIds[numJobIds] = lsbJobId; numJobIds++; } } } freeIdxList (idxListP); } *jobIds0 = jobIds; return (numJobIds); }
int getJobIdList (char *jobIdStr, LS_LONG_INT ** jobIdList) { int numJobIds = 0; int jobId; LS_LONG_INT lsbJobId; LS_LONG_INT *temp, *jobIds; struct idxList *idxListP = NULL, *idx; int sizeOfJobIdArray = MAX_JOB_IDS; int i, j; if (getJobIdIndexList (jobIdStr, &jobId, &idxListP, 0)) { return (-1); } if (jobId <= 0) return (-1); if ((jobIds = (LS_LONG_INT *) calloc (MAX_JOB_IDS, sizeof (LS_LONG_INT))) == NULL) { return (-1); } if (idxListP == NULL) { jobIds[0] = jobId; numJobIds = 1; *jobIdList = jobIds; return (numJobIds); } for (idx = idxListP; idx; idx = idx->next) { for (j = idx->start; j <= idx->end; j += idx->step) { lsbJobId = LSB_JOBID (jobId, j); if (numJobIds >= sizeOfJobIdArray) { sizeOfJobIdArray += MAX_JOB_IDS; if ((temp = (LS_LONG_INT *) realloc (jobIds, sizeOfJobIdArray * sizeof (LS_LONG_INT))) == NULL) { return (-1); } jobIds = temp; } for (i = 0; i < numJobIds; i++) if (lsbJobId == jobIds[i]) break; if (i == numJobIds) { jobIds[numJobIds++] = lsbJobId; } } } freeIdxList (idxListP); *jobIdList = jobIds; return (numJobIds); }