Ejemplo n.º 1
0
void
ini_ReadBootFile (
  pwr_tStatus	*status,
  ini_sContext	*cp
)
{
  char			day[80];
  char			time[80];
  char			buffer[256];
  char			*s;
  int			i;
  int			n;
  int			nvol;

  /*  pwr_tProjVersion	ver;*/
  FILE *f;

  pwr_dStatus(sts, status, INI__SUCCESS);

  f = ini_OpenFile(sts, cp, &cp->bootfile);

  if (f == NULL)
    return;

  errh_LogInfo(&cp->log, "Reading Boot file %s", cp->bootfile.name);

  for (
    i = 0, nvol = 0, s = fgets(buffer, sizeof(buffer) - 1, f);
    s != NULL;
    s = fgets(buffer, sizeof(buffer) - 1, f)
  ) {
    if (*s == '!') {
      s++;
      continue;
    }

    switch (i) {
    case 0:	/* Creation Date.  */
      i++;
      time[0] = day[0] = '\0';
      n = sscanf(s, "%s %s", day, time);
      break;
    case 1:
      i++;
      cp->proj[0] = '\0';
      n = sscanf(s, "%s", cp->proj);
      errh_LogInfo(&cp->log, "Created at %s %s for project: %s", day, time, cp->proj);
      break;
    case 2:
      i++;
      cp->group[0] = '\0';
      n = sscanf(s, "%s", cp->group);
      break;
    }
  }

  fclose(f);
}
Ejemplo n.º 2
0
pwr_tBoolean ini_ReadNodeFile (
  pwr_tStatus	*status,
  ini_sContext	*cp
)
{
  FILE *f;

  pwr_dStatus(sts, status, INI__SUCCESS);

  f = ini_OpenFile(sts, cp, &cp->nodefile);

  if (f == NULL)
    return NO;

  errh_LogInfo(&cp->log, "Reading Node file %s", cp->nodefile.name);

  qini_ParseFile(f, cp->nid_t, &cp->warnings, &cp->errors, &cp->fatals);
  fclose(f);

  return YES;
}
Ejemplo n.º 3
0
void ini_ProcTable(pwr_tStatus* status, ini_sContext* cp)
{
  FILE* f;
  ini_sProc* pp;
  char* s;
  char buffer[256];
  char sev_server_args[20] = "-n";

  pwr_dStatus(sts, status, INI__SUCCESS);

  pp = ini_ProcInsert(sts, cp, "pwr_qmon", "pwr_qmon_%d", 0, 1, "rt_qmon",
      cPrio_qmon, 0, 0, "-n", 0);
  pp->flags.b.qmon = 1;
  pp->proc.flags.b.system = 1;

  if (cp->flags.b.rootvolume)
    strcpy(sev_server_args, "");
  pp = ini_ProcInsert(sts, cp, "pwr_sev_server", "pwr_sev_server_%d", 0, 1,
      "sev_server", cPrio_sev_server, 0, 0, sev_server_args, 0);
  pp->proc.flags.b.system = 1;

  f = ini_OpenFile(sts, cp, &cp->applfile);
  if (f != NULL) {
    if (cp->flags.b.verbose)
      errh_LogInfo(
          &cp->log, "Reading Application file %s\n", cp->applfile.name);
    for (;;) {
      char* nl;

      s = fgets(buffer, sizeof(buffer) - 1, f);
      if (s == NULL)
        break;
      nl = strchr(s, '\n');
      if (nl != NULL)
        *nl = '\0';

      if (cp->flags.b.verbose)
        errh_LogInfo(&cp->log, "   %s", buffer);
      if (buffer[0] == '#')
        continue;

      do {
        int i_load = -1;
        int i_run = -1;
        int i_debug = -1;
        int i_prio = -1;
        char* id = NULL;
        char* name = NULL;
        char* load = NULL;
        char* run = NULL;
        char* file = NULL;
        char* prio = NULL;
        char* debug = NULL;
        char* arg = NULL;

        id = strtok(s, ",");
        if (id == NULL)
          break;
        name = strtok(NULL, ",");
        if (name == NULL)
          break;
        load = strtok(NULL, ",");
        if (load == NULL)
          break;
        run = strtok(NULL, ",");
        if (run == NULL)
          break;
        file = strtok(NULL, ",");
        if (file == NULL)
          break;
        prio = strtok(NULL, ",");
        if (prio == NULL)
          break;
        debug = strtok(NULL, ",");
        if (debug == NULL)
          break;
        arg = strtok(NULL, ",");
        if (arg == NULL)
          break;

        while (isspace(*id))
          id++;
        while (isspace(*name))
          name++;
        while (isspace(*load))
          load++;
        while (isspace(*run))
          run++;
        while (isspace(*file))
          file++;
        while (isspace(*prio))
          prio++;
        while (isspace(*debug))
          debug++;
        while (isspace(*arg))
          arg++;

        if (id[0] == '\0')
          break;
        if (strstr(load, "no"))
          i_load = 0;
        else if (strstr(load, "load"))
          i_load = 1;

        if (strstr(run, "no"))
          i_run = 0;
        else if (strstr(run, "run"))
          i_run = 1;

        if (strstr(debug, "no"))
          i_debug = 0;
        else if (strstr(debug, "debug"))
          i_debug = 1;

        if (strcspn(prio, "0123456789") > 0)
          i_prio = -1;
        else
          i_prio = atoi(prio);

        pp = ini_ProcInsert(
            sts, cp, id, name, i_load, i_run, file, i_prio, i_debug, 0, arg, 0);
        if (!pp->proc.flags.b.system && !pp->proc.flags.b.base)
          pp->proc.flags.b.user = 1;
      } while (0);
    }
    fclose(f);
  }
}