예제 #1
0
static int get_opt_value (Isis_Option_Type *opt, char *option, char **vp)
{
   unsigned int i, num;
   char **option_names;

   if ((opt == NULL) || (option == NULL))
     return 0;

   option_names = opt->option_names;
   num = opt->num_options;

   for (i = 0; i < num; i++)
     {
        if (0 != isis_strcasecmp (option, option_names[i]))
          continue;

        if (NULL == (*vp = opt->option_values[i]))
          {
             isis_vmesg (FAIL, I_ERROR, __FILE__, __LINE__, "%s option %s requires a value",
                         opt->subsystem, option);
             return -1;
          }

        return 1;
     }
   return 0;
}
예제 #2
0
static int eval_option (char *subsystem, char *optname, char *value, void *clientdata) /*{{{*/
{
   Isis_Kernel_t *k = (Isis_Kernel_t *)clientdata;

   (void) subsystem;
   (void) optname;

   if (k == NULL)
     return -1;

   if (0 == isis_strcasecmp (value, "all"))
     k->allows_ignoring_model_intervals = 0;
   else if (0 == isis_strcasecmp (value, "noticed"))
     k->allows_ignoring_model_intervals = 1;
   else
     {
        isis_vmesg (FAIL, I_ERROR, __FILE__, __LINE__, "unrecognized kernel option '%s'",
                    value ? value : "<null>");
        return -1;
     }

   return 0;
}
예제 #3
0
static Isis_Option_Table_Type *find_option (char *name, Isis_Option_Table_Type *t)
{
   if (t == NULL)
     return NULL;

   while (t->optname != NULL)
     {
        if (0 == isis_strcasecmp (t->optname, name))
          return t;

        t++;
     }

   return NULL;
}
예제 #4
0
int isis_is_option_present (char *options, char *option, char **value)
{
   unsigned int i, num;
   Isis_Option_Type *opt;
   int status;
   char **option_names;

   if (options == NULL)
     return 0;

   if (option == NULL)
     return 0;

   opt = isis_parse_option_string (options);
   if (opt == NULL)
     return -1;

   option_names = opt->option_names;
   num = opt->num_options;

   status = 0;

   for (i = 0; i < num; i++)
     {
        if (0 != isis_strcasecmp (option, option_names[i]))
          continue;

        status = 1;

        if (value != NULL)
          {
             char *val = opt->option_values[i];

             if (val != NULL)
               {
                  if (NULL == (val = isis_make_string (val)))
                    status = -1;
               }
             *value = val;
          }
        break;
     }

   isis_free_options (opt);
   return status;
}
예제 #5
0
int cfits_test_keyword (const char *test_value, const char *keyword, cfitsfile *fptr)
{
   char value[CFLEN_VALUE];

   if (NULL == test_value || NULL == keyword || NULL == fptr)
     return -1;

   if (-1 == cfits_read_string_keyword(value, keyword, fptr))
     return -1;

   if (NULL == value)
     {
        isis_vmesg (WARN, I_KEY_NOT_FOUND, __FILE__, __LINE__, "%s", keyword);
        return 1;
     }

   return isis_strcasecmp (value, test_value);
}
예제 #6
0
static int check_for_help (Isis_Option_Type *opt, Isis_Option_Table_Type *t)
{
   unsigned int n, i;
   char **names;

   names = opt->option_names;
   n = opt->num_options;

   for (i = 0; i < n; i++)
     {
        if (0 == isis_strcasecmp (names[i], "HELP"))
          {
             fprintf (stdout, "Specify \"%s;default\" to restore defaults.\n", opt->subsystem);
             fprintf (stdout, "Valid options for subsystem \"%s\" include:\n", opt->subsystem);
             while (t->optname != NULL)
               {
                  char *v;

                  if (t->value_flags & ISIS_OPT_REQUIRES_VALUE)
                    v = "=value";
                  else if (t->value_flags & ISIS_OPT_NO_VALUE)
                    v = "";
                  else
                    v = "[=value]";

                  fprintf (stdout, "%8s%-10s %s\n", t->optname, v,
                           (t->help_string ? t->help_string : ""));
                  if (t->default_value_string)
                    {
                       fprintf (stdout, "         default:  %-s='%-s'\n",
                                t->optname, t->default_value_string);
                    }

                  t++;
               }

             return 1;
          }
     }
   return 0;
}
예제 #7
0
static int check_for_keyword (Isis_Option_Type *opt, Isis_Option_Table_Type *t,
                              void *client_data,
                              char *keyword,
                              int (*action)(char *, Isis_Option_Table_Type *, void *))
{
   unsigned int n, i;
   char **names;

   (void) t;

   names = opt->option_names;
   n = opt->num_options;

   for (i = 0; i < n; i++)
     {
        if (0 == isis_strcasecmp (names[i], keyword))
          {
             names[i][0] = 0;
             return (*action)(opt->subsystem, t, client_data);
          }
     }

   return 0;
}