- Timestamp:
- 2009-03-12T19:10:06Z (16 years ago)
- Branches:
- master
- Children:
- 673a54c
- Parents:
- 9b55485
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
set.c
r9b55485 r823de9d 26 26 #include "bitlbee.h" 27 27 28 /* Used to use NULL for this, but NULL is actually a "valid" value. */ 29 char *SET_INVALID = "nee"; 30 28 31 set_t *set_add( set_t **head, char *key, char *def, set_eval eval, void *data ) 29 32 { … … 114 117 115 118 if( !s ) 119 /* 120 Used to do this, but it never really made sense. 116 121 s = set_add( head, key, NULL, NULL, NULL ); 117 118 if( s->eval && !( nv = s->eval( s, value ) ) ) 122 */ 123 return 0; 124 125 if( value == NULL && ( s->flags & SET_NULL_OK ) == 0 ) 126 return 0; 127 128 /* Call the evaluator. For invalid values, evaluators should now 129 return SET_INVALID, but previously this was NULL. Try to handle 130 that too if NULL is not an allowed value for this setting. */ 131 if( s->eval && ( ( nv = s->eval( s, value ) ) == SET_INVALID || 132 ( ( s->flags & SET_NULL_OK ) == 0 && nv == NULL ) ) ) 119 133 return 0; 120 134 … … 168 182 } 169 183 170 voidset_reset( set_t **head, char *key )184 int set_reset( set_t **head, char *key ) 171 185 { 172 186 set_t *s; … … 174 188 s = set_find( head, key ); 175 189 if( s ) 176 set_setstr( head, key, s->def ); 190 return set_setstr( head, key, s->def ); 191 192 return 0; 177 193 } 178 194 … … 187 203 for( ; *s; s ++ ) 188 204 if( !isdigit( *s ) ) 189 return NULL;205 return SET_INVALID; 190 206 191 207 return value; … … 194 210 char *set_eval_bool( set_t *set, char *value ) 195 211 { 196 return is_bool( value ) ? value : NULL;212 return is_bool( value ) ? value : SET_INVALID; 197 213 } 198 214 … … 209 225 } 210 226 211 char *set_eval_op_root( set_t *set, char *value )227 char* set_eval_op_root( set_t *set, char* value ) 212 228 { 213 229 irc_t *irc = set->data; 214 char *ret = set_eval_bool(set, value);230 char* ret = set_eval_bool(set, value); 215 231 int b = bool2int(ret); 216 232 217 233 irc_write( irc, ":%s!%s@%s MODE %s %s %s", irc->mynick, irc->mynick, irc->myhost, 218 irc->channel, b?"+o":"-o", irc->mynick ); 234 irc->channel, b?"+o":"-o", irc->mynick); 235 219 236 return ret; 220 237 } 221 238 222 char *set_eval_op_user( set_t *set, char *value )239 char* set_eval_op_user( set_t *set, char* value ) 223 240 { 224 241 irc_t *irc = set->data; 225 char *ret = set_eval_bool(set, value);242 char* ret = set_eval_bool(set, value); 226 243 int b = bool2int(ret); 227 244 228 245 irc_write( irc, ":%s!%s@%s MODE %s %s %s", irc->mynick, irc->mynick, irc->myhost, 229 irc->channel, b?"+o":"-o", irc->nick ); 246 irc->channel, b?"+o":"-o", irc->nick); 247 230 248 return ret; 231 249 } … … 250 268 else 251 269 return NULL; 252 270 253 271 /* sorry for calling them op/deop - too lazy for search+replace :P */ 254 272 op[0]='\0'; … … 335 353 char *flags = g_strnfill(ndeop, modeflag); 336 354 irc_write( irc, ":%s!%s@%s MODE %s -%s%s", irc->mynick, irc->mynick, irc->myhost, 337 338 339 340 355 irc->channel, flags, deop ); 356 g_free(flags); 357 } 358 341 359 return value; 342 360 } … … 370 388 return NULL; 371 389 } 390
Note: See TracChangeset
for help on using the changeset viewer.