static int ini_load(const std::string inifile_name,
		    int *ws_port, 
		    int *emove_port)
{
  FILE *fp;
  const char *section;
  const char *key;
  const char *inistring;
  int i1;

  if (NULL == (fp = fopen(inifile_name.c_str(), "r"))) {
    fprintf(stderr, "can't open ini file %s\n", inifile_name.c_str());
    return 1;
  }

  if (WS_PORT_DEFAULT == *ws_port) {
    /* no argument overrode it, so we'll look for it */
    section = "hmi";
    key = "ws_port";
    inistring = ini_find(fp, key, section);

    if (NULL == inistring) {
      fprintf(stderr, "missing ini file entry: %s\n", key);
      fclose(fp);
      return 1;
    } else if (1 != sscanf(inistring, "%i", &i1)) {
      fprintf(stderr, "gosh: bad entry: %s = %s\n", key, inistring);
      fclose(fp);
      return 1;
    }
    *ws_port = i1;
  }

  if (EMOVE_PORT_DEFAULT == *emove_port) {
    /* no argument overrode it, so we'll look for it */
    section = "hmi";
    key = "emove_port";
    inistring = ini_find(fp, key, section);

    if (NULL == inistring) {
      fprintf(stderr, "missing ini file entry: %s\n", key);
      fclose(fp);
      return 1;
    } else if (1 != sscanf(inistring, "%i", &i1)) {
      fprintf(stderr, "gosh: bad entry: %s = %s\n", key, inistring);
      fclose(fp);
      return 1;
    }
    *emove_port = i1;
  }

  fclose(fp);
  return 0;
}
static int ini_load(const std::string inifile_name, 
		    std::string& planning_app,
		    std::string& plan_file)
{
  FILE *fp;
  const char *section;
  const char *key;
  const char *inistring;
  std::string str;

  if (NULL == (fp = fopen(inifile_name.c_str(), "r"))) {
    fprintf(stderr, "can't open ini file %s\n", inifile_name.c_str());
    return 1;
  }

  if (planning_app.empty()) {
    /* no argument overrode it, so we'll look for it */
    section = "workstation";
    key = "planning_app";
    inistring = ini_find(fp, key, section);

    if (NULL == inistring) {
      fprintf(stderr, "missing ini file entry: [%s] %s\n", section, key);
      fclose(fp);
      return 1;
    } else {
      planning_app = std::string(inistring);
    }
      printf("set planning app to %s\n", planning_app.c_str());
  }

  if (plan_file.empty()) {
    /* no argument overrode it, so we'll look for it */
    section = "planner";
    key = "plan";
    inistring = ini_find(fp, key, section);

    if (NULL == inistring) {
      fprintf(stderr, "missing ini file entry: [%s] %s\n", section, key);
      fclose(fp);
      return 1;
    } else {
      plan_file = std::string(inistring);
    }
  }

  fclose(fp);
  return 0;
}
Beispiel #3
0
int
ini_getstr (char **value, char *key)
{
    if (!ini_find (key))
        return 0;
    *value = iniparser_getstring (yap_config, key, NULL);
    return 1;
}
Beispiel #4
0
int
ini_find_port (char *port, char *param)
{
    char key[MAX_KEY_SIZE];

    KEY_PORT (key, sizeof(key), port, param);
    return ini_find (key);
}
Beispiel #5
0
int
ini_find_id (char *param)
{
    char key[MAX_KEY_SIZE];

    KEY_ID (key, sizeof(key), param);
    return ini_find (key);
}
Beispiel #6
0
int
ini_find_default (char *param)
{
    char key[MAX_KEY_SIZE];

    KEY_DEF (key, sizeof(key), param);
    return ini_find (key);
}
Beispiel #7
0
int
ini_getdouble (double *value, char *key)
{
    if (!ini_find (key))
        return 0;
    *value = iniparser_getdouble (yap_config, key, -1.0);
    return 1;
}
Beispiel #8
0
int
ini_getbool (int *value, char *key)
{
    if (!ini_find (key))
        return 0;
    *value = iniparser_getboolean (yap_config, key, -1);
    return 1;
}
Beispiel #9
0
int
ini_getint (int *value, char *key)
{
    if (!ini_find (key))
        return 0;
    *value = iniparser_getint (yap_config, key, 0);
    return 1;
}