Changeset 64735f0
- Timestamp:
- Aug 15, 2009, 7:08:18 PM (15 years ago)
- Branches:
- master, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
- Children:
- 075ba92
- Parents:
- 1077891a
- git-author:
- Anders Kaseorg <andersk@mit.edu> (08/04/09 00:34:07)
- git-committer:
- Anders Kaseorg <andersk@mit.edu> (08/15/09 19:08:18)
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
owl.h
re19eb97 r64735f0 218 218 char *description; /* detailed description */ 219 219 void *val; /* current value */ 220 int (*validate_fn)( struct _owl_variable *v, const void *newval);220 int (*validate_fn)(const struct _owl_variable *v, const void *newval); 221 221 /* returns 1 if newval is valid */ 222 222 int (*set_fn)(struct _owl_variable *v, const void *newval); … … 232 232 * should make a copy. 233 233 * returns 0 on success. */ 234 const void *(*get_fn)( struct _owl_variable *v);234 const void *(*get_fn)(const struct _owl_variable *v); 235 235 /* returns a reference to the current value. 236 236 * WARNING: this approach is hard to make 237 237 * thread-safe... */ 238 int (*get_tostring_fn)( struct _owl_variable *v,238 int (*get_tostring_fn)(const struct _owl_variable *v, 239 239 char *buf, int bufsize, const void *val); 240 240 /* converts val to a string -
variable.c
re19eb97 r64735f0 375 375 /* commonly useful */ 376 376 377 int owl_variable_int_validate_gt0( owl_variable *v, const void *newval)377 int owl_variable_int_validate_gt0(const owl_variable *v, const void *newval) 378 378 { 379 379 if (newval == NULL) return(0); … … 382 382 } 383 383 384 int owl_variable_int_validate_positive( owl_variable *v, const void *newval)384 int owl_variable_int_validate_positive(const owl_variable *v, const void *newval) 385 385 { 386 386 if (newval == NULL) return(0); … … 628 628 629 629 630 const char *owl_variable_get_description( owl_variable *v) {630 const char *owl_variable_get_description(const owl_variable *v) { 631 631 return v->description; 632 632 } 633 633 634 const char *owl_variable_get_summary( owl_variable *v) {634 const char *owl_variable_get_summary(const owl_variable *v) { 635 635 return v->summary; 636 636 } 637 637 638 const char *owl_variable_get_validsettings( owl_variable *v) {638 const char *owl_variable_get_validsettings(const owl_variable *v) { 639 639 if (v->validsettings) { 640 640 return v->validsettings; … … 839 839 /* default common functions */ 840 840 841 const void *owl_variable_get_default( owl_variable *v) {841 const void *owl_variable_get_default(const owl_variable *v) { 842 842 return v->val; 843 843 } … … 849 849 /* default functions for booleans */ 850 850 851 int owl_variable_bool_validate_default( owl_variable *v, const void *newval) {851 int owl_variable_bool_validate_default(const owl_variable *v, const void *newval) { 852 852 if (newval == NULL) return(0); 853 853 else if (*(const int*)newval==1 || *(const int*)newval==0) return(1); … … 871 871 } 872 872 873 int owl_variable_bool_get_tostring_default( owl_variable *v, char* buf, int bufsize, const void *val) {873 int owl_variable_bool_get_tostring_default(const owl_variable *v, char* buf, int bufsize, const void *val) { 874 874 if (val == NULL) { 875 875 snprintf(buf, bufsize, "<null>"); … … 889 889 /* default functions for integers */ 890 890 891 int owl_variable_int_validate_default( owl_variable *v, const void *newval) {891 int owl_variable_int_validate_default(const owl_variable *v, const void *newval) { 892 892 if (newval == NULL) return(0); 893 893 else return (1); … … 910 910 } 911 911 912 int owl_variable_int_get_tostring_default( owl_variable *v, char* buf, int bufsize, const void *val) {912 int owl_variable_int_get_tostring_default(const owl_variable *v, char* buf, int bufsize, const void *val) { 913 913 if (val == NULL) { 914 914 snprintf(buf, bufsize, "<null>"); … … 922 922 /* default functions for enums (a variant of integers) */ 923 923 924 int owl_variable_enum_validate( owl_variable *v, const void *newval) {924 int owl_variable_enum_validate(const owl_variable *v, const void *newval) { 925 925 char **enums; 926 926 int nenums, val; … … 952 952 } 953 953 954 int owl_variable_enum_get_tostring( owl_variable *v, char* buf, int bufsize, const void *val) {954 int owl_variable_enum_get_tostring(const owl_variable *v, char* buf, int bufsize, const void *val) { 955 955 char **enums; 956 956 int nenums, i; … … 973 973 /* default functions for stringeans */ 974 974 975 int owl_variable_string_validate_default( struct _owl_variable *v, const void *newval) {975 int owl_variable_string_validate_default(const struct _owl_variable *v, const void *newval) { 976 976 if (newval == NULL) return(0); 977 977 else return (1); … … 991 991 } 992 992 993 int owl_variable_string_get_tostring_default( owl_variable *v, char* buf, int bufsize, const void *val) {993 int owl_variable_string_get_tostring_default(const owl_variable *v, char* buf, int bufsize, const void *val) { 994 994 if (val == NULL) { 995 995 snprintf(buf, bufsize, "<null>");
Note: See TracChangeset
for help on using the changeset viewer.