return default_string;
}
+bool_t lp_config_get_range(LpConfig *lpconfig, const char *section, const char *key, int *min, int *max, int default_min, int default_max) {
+ const char *str = lp_config_get_string(lpconfig, section, key, NULL);
+ if (str != NULL) {
+ char *minusptr = strchr(str, '-');
+ if ((minusptr == NULL) || (minusptr == str)) {
+ *min = default_min;
+ *max = default_max;
+ return FALSE;
+ }
+ *min = atoi(str);
+ *max = atoi(minusptr + 1);
+ return TRUE;
+ } else {
+ *min = default_min;
+ *max = default_max;
+ return TRUE;
+ }
+}
+
int lp_config_get_int(LpConfig *lpconfig,const char *section, const char *key, int default_value){
const char *str=lp_config_get_string(lpconfig,section,key,NULL);
if (str!=NULL) {
lpconfig->modified++;
}
+void lp_config_set_range(LpConfig *lpconfig, const char *section, const char *key, int min_value, int max_value) {
+ char tmp[30];
+ snprintf(tmp, sizeof(tmp), "%i-%i", min_value, max_value);
+ lp_config_set_string(lpconfig, section, key, tmp);
+}
+
void lp_config_set_int(LpConfig *lpconfig,const char *section, const char *key, int value){
char tmp[30];
snprintf(tmp,sizeof(tmp),"%i",value);
**/
const char *lp_config_get_string(LpConfig *lpconfig, const char *section, const char *key, const char *default_string);
int lp_config_read_file(LpConfig *lpconfig, const char *filename);
+/**
+ * Retrieves a configuration item as a range, given its section, key, and default min and max values.
+ *
+ * @ingroup misc
+ * @return TRUE if the value is successfully parsed as a range, FALSE otherwise.
+ * If FALSE is returned, min and max are filled respectively with default_min and default_max values.
+ */
+bool_t lp_config_get_range(LpConfig *lpconfig, const char *section, const char *key, int *min, int *max, int default_min, int default_max);
/**
* Retrieves a configuration item as an integer, given its section, key, and default value.
*
* @ingroup misc
**/
void lp_config_set_string(LpConfig *lpconfig,const char *section, const char *key, const char *value);
+/**
+ * Sets a range config item
+ *
+ * @ingroup misc
+ */
+void lp_config_set_range(LpConfig *lpconfig, const char *section, const char *key, int min_value, int max_value);
/**
* Sets an integer config item
*