Exemplo n.º 1
0
void process_config_file(

  job_data_container *attr)

  {
  char torque_cfg_buf[MAX_LINE_LEN];      /* Buffer holds config file */
  char *param_val;
  if (load_config(torque_cfg_buf, sizeof(torque_cfg_buf)) == 0)
    {
    if ((param_val = get_trq_param("CLIENTRETRY", torque_cfg_buf)) != NULL)
      {
      hash_add_or_exit(attr, "PBS_CLIENTRETRY", param_val, CONFIG_DATA);
      }
    }
  } /* END process_config_file */
Exemplo n.º 2
0
/* trq_get_if_name:  This function parses the torque.cfg file
 * for the TRQ_IFNAME keyword and if set returns the value. 
 * The variable if_name is allocated space for the new 
 * interface name. It must be released by the called function. 
 */
char *trq_get_if_name()
  {
  struct stat filestruct;
  char home_dir[MAXPATHLEN];
  char *torque_cfg_buf;
  char *if_name, *ptr;
  int  length = strlen(PBS_SERVER_HOME) + strlen(TCONST_CFGFILE) + 1;
  int  file_size;
  int  rc;

  if(length > MAXPATHLEN)
    return(NULL); /* How are we going to return error information */

  home_dir[0] = '\0';

  strncat(home_dir, PBS_SERVER_HOME, MAXPATHLEN);
  strcat(home_dir, "/");
  strcat(home_dir, TCONST_CFGFILE);

  rc = stat(home_dir, &filestruct);
  if(rc < 0)
    return(NULL); /* this is not an error. torque.cfg file is optional */

  file_size = filestruct.st_size;

  /* we know the size of the torque.cfg file. Allocate some space for it */
  torque_cfg_buf = (char *)malloc(file_size+1);
  if(torque_cfg_buf == NULL)
    {
    fprintf(stderr, "failed to allocate memory in trq_get_if_name\n");
    return(NULL);
    }

  rc = load_config(torque_cfg_buf, file_size);
  if(rc)
    {
    fprintf(stderr, "load_config failed in trq_get_if_name: %d\n", rc);
	if(torque_cfg_buf)
      free(torque_cfg_buf);
    return(NULL);
	}

  ptr = get_trq_param(TRQ_IFNAME, torque_cfg_buf);
  if(ptr == NULL)
    {
    if(torque_cfg_buf)
	    free(torque_cfg_buf);
    return(NULL);
    }

  /* we have a name. We need to copy it to permanent storage */
  if_name = (char *)malloc(strlen(ptr)+1);
  if(if_name == NULL)
    {
	fprintf(stderr, "failed to allocate memory in trq_get_if_name for if_name\n");
	if(torque_cfg_buf)
	  free(torque_cfg_buf);
    return(NULL);
    }

  strcpy(if_name, ptr);

  if(torque_cfg_buf)
	free(torque_cfg_buf);

  return(if_name);
  }