Changeset 64735f0


Ignore:
Timestamp:
Aug 15, 2009, 7:08:18 PM (15 years ago)
Author:
Anders Kaseorg <andersk@mit.edu>
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)
Message:
Add const qualifiers for owl_variable *.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • owl.h

    re19eb97 r64735f0  
    218218  char *description;            /* detailed description */
    219219  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);
    221221                                /* returns 1 if newval is valid */
    222222  int  (*set_fn)(struct _owl_variable *v, const void *newval);
     
    232232                                 * should make a copy.
    233233                                 * returns 0 on success. */
    234   const void *(*get_fn)(struct _owl_variable *v);
     234  const void *(*get_fn)(const struct _owl_variable *v);
    235235                                /* returns a reference to the current value.
    236236                                 * WARNING:  this approach is hard to make
    237237                                 * thread-safe... */
    238   int  (*get_tostring_fn)(struct _owl_variable *v,
     238  int  (*get_tostring_fn)(const struct _owl_variable *v,
    239239                          char *buf, int bufsize, const void *val);
    240240                                /* converts val to a string
  • variable.c

    re19eb97 r64735f0  
    375375/* commonly useful */
    376376
    377 int owl_variable_int_validate_gt0(owl_variable *v, const void *newval)
     377int owl_variable_int_validate_gt0(const owl_variable *v, const void *newval)
    378378{
    379379  if (newval == NULL) return(0);
     
    382382}
    383383
    384 int owl_variable_int_validate_positive(owl_variable *v, const void *newval)
     384int owl_variable_int_validate_positive(const owl_variable *v, const void *newval)
    385385{
    386386  if (newval == NULL) return(0);
     
    628628
    629629
    630 const char *owl_variable_get_description(owl_variable *v) {
     630const char *owl_variable_get_description(const owl_variable *v) {
    631631  return v->description;
    632632}
    633633
    634 const char *owl_variable_get_summary(owl_variable *v) {
     634const char *owl_variable_get_summary(const owl_variable *v) {
    635635  return v->summary;
    636636}
    637637
    638 const char *owl_variable_get_validsettings(owl_variable *v) {
     638const char *owl_variable_get_validsettings(const owl_variable *v) {
    639639  if (v->validsettings) {
    640640    return v->validsettings;
     
    839839/* default common functions */
    840840
    841 const void *owl_variable_get_default(owl_variable *v) {
     841const void *owl_variable_get_default(const owl_variable *v) {
    842842  return v->val;
    843843}
     
    849849/* default functions for booleans */
    850850
    851 int owl_variable_bool_validate_default(owl_variable *v, const void *newval) {
     851int owl_variable_bool_validate_default(const owl_variable *v, const void *newval) {
    852852  if (newval == NULL) return(0);
    853853  else if (*(const int*)newval==1 || *(const int*)newval==0) return(1);
     
    871871}
    872872
    873 int owl_variable_bool_get_tostring_default(owl_variable *v, char* buf, int bufsize, const void *val) {
     873int owl_variable_bool_get_tostring_default(const owl_variable *v, char* buf, int bufsize, const void *val) {
    874874  if (val == NULL) {
    875875    snprintf(buf, bufsize, "<null>");
     
    889889/* default functions for integers */
    890890
    891 int owl_variable_int_validate_default(owl_variable *v, const void *newval) {
     891int owl_variable_int_validate_default(const owl_variable *v, const void *newval) {
    892892  if (newval == NULL) return(0);
    893893  else return (1);
     
    910910}
    911911
    912 int owl_variable_int_get_tostring_default(owl_variable *v, char* buf, int bufsize, const void *val) {
     912int owl_variable_int_get_tostring_default(const owl_variable *v, char* buf, int bufsize, const void *val) {
    913913  if (val == NULL) {
    914914    snprintf(buf, bufsize, "<null>");
     
    922922/* default functions for enums (a variant of integers) */
    923923
    924 int owl_variable_enum_validate(owl_variable *v, const void *newval) { 
     924int owl_variable_enum_validate(const owl_variable *v, const void *newval) { 
    925925  char **enums;
    926926  int nenums, val;
     
    952952}
    953953
    954 int owl_variable_enum_get_tostring(owl_variable *v, char* buf, int bufsize, const void *val) {
     954int owl_variable_enum_get_tostring(const owl_variable *v, char* buf, int bufsize, const void *val) {
    955955  char **enums;
    956956  int nenums, i;
     
    973973/* default functions for stringeans */
    974974
    975 int owl_variable_string_validate_default(struct _owl_variable *v, const void *newval) {
     975int owl_variable_string_validate_default(const struct _owl_variable *v, const void *newval) {
    976976  if (newval == NULL) return(0);
    977977  else return (1);
     
    991991}
    992992
    993 int owl_variable_string_get_tostring_default(owl_variable *v, char* buf, int bufsize, const void *val) {
     993int owl_variable_string_get_tostring_default(const owl_variable *v, char* buf, int bufsize, const void *val) {
    994994  if (val == NULL) {
    995995    snprintf(buf, bufsize, "<null>");
Note: See TracChangeset for help on using the changeset viewer.