Changeset e19eb97 for owl.h


Ignore:
Timestamp:
Aug 15, 2009, 7:08:18 PM (16 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:
1077891a
Parents:
fa4562c
git-author:
Anders Kaseorg <andersk@mit.edu> (08/04/09 02:37:51)
git-committer:
Anders Kaseorg <andersk@mit.edu> (08/15/09 19:08:18)
Message:
Add const qualifiers for char * and void *.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
File:
1 edited

Legend:

Unmodified
Added
Removed
  • owl.h

    rc529ac8 re19eb97  
    202202#endif
    203203
    204 /* Convert char ** into char **.  This conversion is safe,
     204/* Convert char *const * into const char *const *.  This conversion is safe,
    205205 * and implicit in C++ (conv.qual 4) but for some reason not in C. */
    206 static inline char **strs(char **pstr)
     206static inline const char *const *strs(char *const *pstr)
    207207{
    208   return (char **)pstr;
     208  return (const char *const *)pstr;
    209209}
    210210
     
    218218  char *description;            /* detailed description */
    219219  void *val;                    /* current value */
    220   int  (*validate_fn)(struct _owl_variable *v, void *newval);
     220  int  (*validate_fn)(struct _owl_variable *v, const void *newval);
    221221                                /* returns 1 if newval is valid */
    222   int  (*set_fn)(struct _owl_variable *v, void *newval);
     222  int  (*set_fn)(struct _owl_variable *v, const void *newval);
    223223                                /* sets the variable to a value
    224224                                 * of the appropriate type.
     
    226226                                 * should make a copy.
    227227                                 * returns 0 on success. */
    228   int  (*set_fromstring_fn)(struct _owl_variable *v, char *newval);
     228  int  (*set_fromstring_fn)(struct _owl_variable *v, const char *newval);
    229229                                /* sets the variable to a value
    230230                                 * of the appropriate type.
     
    232232                                 * should make a copy.
    233233                                 * returns 0 on success. */
    234   void *(*get_fn)(struct _owl_variable *v);
     234  const void *(*get_fn)(struct _owl_variable *v);
    235235                                /* returns a reference to the current value.
    236236                                 * WARNING:  this approach is hard to make
    237237                                 * thread-safe... */
    238238  int  (*get_tostring_fn)(struct _owl_variable *v,
    239                           char *buf, int bufsize, void *val);
     239                          char *buf, int bufsize, const void *val);
    240240                                /* converts val to a string
    241241                                 * and puts into buf */
     
    299299 
    300300  /* These don't take any context */
    301   char *(*cmd_args_fn)(int argc, char **argv, char *buff); 
     301  char *(*cmd_args_fn)(int argc, const char *const *argv, const char *buff); 
    302302                                /* takes argv and the full command as buff.
    303303                                 * caller must free return value if !NULL */
     
    306306
    307307  /* The following also take the active context if it's valid */
    308   char *(*cmd_ctxargs_fn)(void *ctx, int argc, char **argv, char *buff); 
     308  char *(*cmd_ctxargs_fn)(void *ctx, int argc, const char *const *argv, const char *buff); 
    309309                                /* takes argv and the full command as buff.
    310310                                 * caller must free return value if !NULL */
     
    328328
    329329typedef struct _owl_pair {
    330   char *key;
     330  const char *key;
    331331  char *value;
    332332} owl_pair;
     
    342342  struct _owl_fmtext_cache * fmtext;
    343343  int delete;
    344   char *hostname;
     344  const char *hostname;
    345345  owl_list attributes;            /* this is a list of pairs */
    346346  char *timestr;
Note: See TracChangeset for help on using the changeset viewer.