コード例 #1
0
ファイル: mbd.jarray.c プロジェクト: mrcuongnv/openlava
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);
    }
}
コード例 #2
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);
}