return true;
}
+bool cf_set_uint(struct CfValue *cv, const char *value)
+{
+ unsigned int *ptr = cv->value_p;
+ char *end;
+ unsigned long val;
+
+ errno = 0;
+ val = strtoul(value, &end, 0);
+ if (end == value || *end != 0) {
+ /* reject partial parse */
+ if (!errno)
+ errno = EINVAL;
+ return false;
+ }
+ *ptr = val;
+ return true;
+}
+
bool cf_set_str(struct CfValue *cv, const char *value)
{
char **dst_p = cv->value_p;
return cv->buf;
}
+const char *cf_get_uint(struct CfValue *cv)
+{
+ unsigned int *p = cv->value_p;
+ snprintf(cv->buf, cv->buflen, "%u", *p);
+ return cv->buf;
+}
+
const char *cf_get_time_double(struct CfValue *cv)
{
double *p = cv->value_p;
bool cf_set_filename(struct CfValue *cv, const char *value);
/** Setter for int */
bool cf_set_int(struct CfValue *cv, const char *value);
+/** Setter for unsigned int */
+bool cf_set_uint(struct CfValue *cv, const char *value);
/** Setter for time-usec */
bool cf_set_time_usec(struct CfValue *cv, const char *value);
/** Setter for time-double */
const char *cf_get_str(struct CfValue *cv);
/** Getter for int */
const char *cf_get_int(struct CfValue *cv);
+/** Getter for unsigned int */
+const char *cf_get_uint(struct CfValue *cv);
/** Getter for time-usec */
const char *cf_get_time_usec(struct CfValue *cv);
/** Getter for time-double */
#define CF_FILE { cf_set_filename, cf_get_str }
/** Ops for integer */
#define CF_INT { cf_set_int, cf_get_int }
+/** Ops for unsigned integer */
+#define CF_UINT { cf_set_uint, cf_get_uint }
/** Ops for boolean */
#define CF_BOOL { cf_set_int, cf_get_int }
/** Ops for time as usec */