Ejemplo n.º 1
0
static struct idxList *
parseJobArrayIndex (char *jobName)
{
  struct idxList *idxList = NULL, *idx;
  char *index;
  int maxJLimit;
  static char fName[] = "parseJobArrayIndex";

  index = strchr (jobName, '[');
  if (!index)
    return (NULL);
  yybuff = index;
  if (idxparse (&idxList, &maxJLimit))
    {
      freeIdxList (idxList);
      if (idxerrno == IDX_MEM)
	fprintf (stderr, I18N_FUNC_FAIL, fName, "malloc");
      else
	fprintf (stderr, (_i18n_msg_get (ls_catd, NL_SETN, 1014, "%s: Bad job array index list.\n")), jobName);	/* catgets  1014  */
      return (NULL);
    }


  for (idx = idxList; idx; idx = idx->next)
    {
      if (idx->end == INFINIT_INT)
	idx->end = LSB_MAX_ARRAY_IDX;

      if (idx->start > idx->end)
	{
	  fprintf (stderr, "%d-%d: %s.\n", idx->start, idx->end, I18N (1015, "Job Array index invalid range"));	/* catgets 1015 */
	  freeIdxList (idxList);
	  return (NULL);
	}
      if ((idx->start <= 0) || (idx->start > LSB_MAX_ARRAY_IDX))
	{
	  fprintf (stderr, "%d: %s.\n", idx->start, I18N (1016, "Job Array index out of valid range"));	/* catgets  1016  */
	  freeIdxList (idxList);
	  return (NULL);
	}
      if ((idx->end <= 0) || (idx->end > LSB_MAX_ARRAY_IDX))
	{
	  fprintf (stderr, "%d: %s.\n",
		   idx->end,
		   I18N (1016, "Job Array index out of valid range"));
	  freeIdxList (idxList);
	  return (NULL);
	}
      if ((idx->step <= 0) || (idx->step > LSB_MAX_ARRAY_IDX))
	{
	  fprintf (stderr, "%d: %s.\n", idx->step, I18N (1018, "Job Array index step out of valid range"));	/* catgets  1018  */
	  freeIdxList (idxList);
	  return (NULL);
	}

    }
  return (idxList);
}
Ejemplo n.º 2
0
struct idxList *
parseJobArrayIndex(char *job_name, int *error, int *maxJLimit)
{

    struct idxList *idxList = NULL, *idx;
    char   *index;
    int    arraySize = 0;

    index = strchr(job_name, '[');
    *error = LSBE_NO_ERROR;
    if (!index)
        return(NULL);
    yybuff = index;

    *maxJLimit = INFINIT_INT;

    if (idxparse(&idxList, maxJLimit)) {
        freeIdxList(idxList);
        if (idxerrno == IDX_MEM)
            *error = LSBE_NO_MEM;
        else
            *error = LSBE_BAD_JOB;
        return(NULL);
    }

    for (idx = idxList; idx; idx = idx->next) {


        if (idx->start < 1 || idx->step < 1) {
            *error = LSBE_BAD_IDX;
        }
        if (idx->end == INFINIT_INT) {
            idx->end  = idx->start + (maxJobArraySize - 1)*idx->step;
        }

        if (idx->start > idx->end) {
            *error = LSBE_BAD_IDX;
        }

        if ((mSchedStage != M_STAGE_REPLAY)
            && (idx->end >= LSB_MAX_ARRAY_IDX)) {
            *error = LSBE_BIG_IDX;
        }

        arraySize += (idx->end - idx->start)/idx->step + 1;
    }

    if ((mSchedStage != M_STAGE_REPLAY) && (arraySize > maxJobArraySize)) {
        *error = LSBE_BIG_IDX;
    }

    if (*error == LSBE_NO_ERROR)
        return(idxList);
    else {
        freeIdxList(idxList);
        return(NULL);
    }
}
Ejemplo n.º 3
0
void
freeIdxListContext(void)
{
    freeIdxList(arrayIdxList);
    arrayIdxList = NULL;

}
Ejemplo n.º 4
0
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);

}
Ejemplo n.º 5
0
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);
}
Ejemplo n.º 6
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);

}
Ejemplo n.º 7
0
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);

}