Revision 8996031d

View differences:

src/config.c
113 113

  
114 114
  return 1;
115 115
}
116

  
117
const char *config_value_str_default(const struct tag *cfg_values, const char *value, const char *default_value)
118
{
119
  const char *res;
120

  
121
  res = config_value_str(cfg_values, value);
122
  return res ? res : default_value;
123
}
124

  
125
int config_value_int_default(const struct tag *cfg_values, const char *value, int *res, int default_value)
126
{
127
  int r;
128

  
129
  r = config_value_int(cfg_values, value, res);
130
  if (!r) {
131
    *res = default_value;
132
  }
133
  return r;
134
}
135

  
136
int config_value_double_default(const struct tag *cfg_values, const char *value, double *res, double default_value)
137
{
138
  int r;
139

  
140
  r = config_value_double(cfg_values, value, res);
141
  if (!r) {
142
    *res = default_value;
143
  }
144
  return r;
145
}
src/config.h
4 4

  
5 5
struct tag *config_parse(const char *cfg);
6 6
int config_value_int(const struct tag *cfg_values, const char *value, int *res);
7
int config_value_int_default(const struct tag *cfg_values, const char *value, int *res, int default_value);
7 8
int config_value_double(const struct tag *cfg_values, const char *value, double *res);
9
int config_value_double_default(const struct tag *cfg_values, const char *value, double *res, double default_value);
8 10
const char *config_value_str(const struct tag *cfg_values, const char *value);
11
const char *config_value_str_default(const struct tag *cfg_values, const char *value, const char *default_value);
9 12

  
10 13
#endif /* CONFIG_H */

Also available in: Unified diff