Changeset 486688f for variable.c
- Timestamp:
- Sep 28, 2002, 1:14:45 PM (22 years ago)
- Branches:
- master, barnowl_perlaim, debian, owl, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
- Children:
- 88736cb
- Parents:
- 55a4578
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
variable.c
r700c712 r486688f 430 430 431 431 /* returns 0 on success, prints a status msg if msg is true */ 432 int owl_variable_set_fromstring(owl_vardict *d, char *name, char *value, int msg ) {432 int owl_variable_set_fromstring(owl_vardict *d, char *name, char *value, int msg, int requirebool) { 433 433 owl_variable *v; 434 434 char buff2[1024]; … … 441 441 if (!v->set_fromstring_fn) { 442 442 if (msg) owl_function_makemsg("Variable %s is read-only", name); 443 return -1; 444 443 return -1; 444 } 445 if (requirebool && v->type!=OWL_VARIABLE_BOOL) { 446 if (msg) owl_function_makemsg("Variable %s is not a boolean", name); 447 return -1; 445 448 } 446 449 if (0 != v->set_fromstring_fn(v, value)) { … … 801 804 FAIL_UNLESS("set bool 1", 0==owl_variable_set_bool_on(&vd,"personalbell")); 802 805 FAIL_UNLESS("get bool 2", 1==owl_variable_get_bool(&vd,"personalbell")); 803 FAIL_UNLESS("set bool 3", 0==owl_variable_set_fromstring(&vd,"personalbell","off",0 ));806 FAIL_UNLESS("set bool 3", 0==owl_variable_set_fromstring(&vd,"personalbell","off",0,0)); 804 807 FAIL_UNLESS("get bool 4", 0==owl_variable_get_bool(&vd,"personalbell")); 805 FAIL_UNLESS("set bool 5", -1==owl_variable_set_fromstring(&vd,"personalbell","xxx",0 ));808 FAIL_UNLESS("set bool 5", -1==owl_variable_set_fromstring(&vd,"personalbell","xxx",0,0)); 806 809 FAIL_UNLESS("get bool 6", 0==owl_variable_get_bool(&vd,"personalbell")); 807 810 … … 819 822 FAIL_UNLESS("set int 1b", -1==owl_variable_set_int(&vd,"typewinsize",-3)); 820 823 FAIL_UNLESS("get int 2b", 12==owl_variable_get_int(&vd,"typewinsize")); 821 FAIL_UNLESS("set int 3", 0==owl_variable_set_fromstring(&vd,"typewinsize","9",0 ));824 FAIL_UNLESS("set int 3", 0==owl_variable_set_fromstring(&vd,"typewinsize","9",0,0)); 822 825 FAIL_UNLESS("get int 4", 9==owl_variable_get_int(&vd,"typewinsize")); 823 FAIL_UNLESS("set int 5", -1==owl_variable_set_fromstring(&vd,"typewinsize","xxx",0 ));824 FAIL_UNLESS("set int 6", -1==owl_variable_set_fromstring(&vd,"typewinsize","",0 ));826 FAIL_UNLESS("set int 5", -1==owl_variable_set_fromstring(&vd,"typewinsize","xxx",0,0)); 827 FAIL_UNLESS("set int 6", -1==owl_variable_set_fromstring(&vd,"typewinsize","",0,0)); 825 828 FAIL_UNLESS("get int 7", 9==owl_variable_get_int(&vd,"typewinsize")); 826 829 … … 833 836 FAIL_UNLESS("set enum 1b", -1==owl_variable_set_int(&vd,"webbrowser",209)); 834 837 FAIL_UNLESS("get enum 2b", OWL_WEBBROWSER_GALEON==owl_variable_get_int(&vd,"webbrowser")); 835 FAIL_UNLESS("set enum 3", 0==owl_variable_set_fromstring(&vd,"webbrowser","none",0 ));838 FAIL_UNLESS("set enum 3", 0==owl_variable_set_fromstring(&vd,"webbrowser","none",0,0)); 836 839 FAIL_UNLESS("get enum 4", OWL_WEBBROWSER_NONE==owl_variable_get_int(&vd,"webbrowser")); 837 FAIL_UNLESS("set enum 5", 0==owl_variable_set_fromstring(&vd,"webbrowser","netscape",0 ));840 FAIL_UNLESS("set enum 5", 0==owl_variable_set_fromstring(&vd,"webbrowser","netscape",0,0)); 838 841 FAIL_UNLESS("get enum 6", OWL_WEBBROWSER_NETSCAPE==owl_variable_get_int(&vd,"webbrowser")); 839 FAIL_UNLESS("set enum 7", -1==owl_variable_set_fromstring(&vd,"webbrowser","xxx",0 ));840 FAIL_UNLESS("set enum 8", -1==owl_variable_set_fromstring(&vd,"webbrowser","",0 ));841 FAIL_UNLESS("set enum 9", -1==owl_variable_set_fromstring(&vd,"webbrowser","netscapey",0 ));842 FAIL_UNLESS("set enum 7", -1==owl_variable_set_fromstring(&vd,"webbrowser","xxx",0,0)); 843 FAIL_UNLESS("set enum 8", -1==owl_variable_set_fromstring(&vd,"webbrowser","",0,0)); 844 FAIL_UNLESS("set enum 9", -1==owl_variable_set_fromstring(&vd,"webbrowser","netscapey",0,0)); 842 845 FAIL_UNLESS("get enum 10", OWL_WEBBROWSER_NETSCAPE==owl_variable_get_int(&vd,"webbrowser")); 843 846
Note: See TracChangeset
for help on using the changeset viewer.