Changeset 7125cb3
- Timestamp:
- 2008-08-24T18:01:05Z (16 years ago)
- Branches:
- master
- Children:
- f3579fd
- Parents:
- 934dddf3
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
account.c
r934dddf3 r7125cb3 77 77 /* Double-check: We refuse to edit on-line accounts. */ 78 78 if( set->flags & ACC_SET_OFFLINE_ONLY && acc->ic ) 79 return NULL;79 return SET_INVALID; 80 80 81 81 if( strcmp( set->key, "server" ) == 0 ) … … 89 89 else 90 90 { 91 acc->server = NULL;91 acc->server = g_strdup( set->def ); 92 92 return g_strdup( set->def ); 93 93 } 94 }95 else if( value == NULL )96 {97 /* Noop, the other three can't be NULL. */98 94 } 99 95 else if( strcmp( set->key, "username" ) == 0 ) … … 105 101 else if( strcmp( set->key, "password" ) == 0 ) 106 102 { 107 g_free( acc->pass ); 108 acc->pass = g_strdup( value ); 109 return NULL; /* password shouldn't be visible in plaintext! */ 103 if( value ) 104 { 105 g_free( acc->pass ); 106 acc->pass = g_strdup( value ); 107 return NULL; /* password shouldn't be visible in plaintext! */ 108 } 109 else 110 { 111 /* NULL can (should) be stored in the set_t 112 variable, but is otherwise not correct. */ 113 return SET_INVALID; 114 } 110 115 } 111 116 else if( strcmp( set->key, "auto_connect" ) == 0 ) 112 117 { 113 118 if( !is_bool( value ) ) 114 return NULL;119 return SET_INVALID; 115 120 116 121 acc->auto_connect = bool2int( value ); … … 118 123 } 119 124 120 return NULL;125 return SET_INVALID; 121 126 } 122 127 … … 258 263 259 264 /* Sure, call me evil for implementing my own fscanf here, but it's 260 dead simple and I 'm immediately at the next part to parse. */265 dead simple and I immediately know where to continue parsing. */ 261 266 262 267 if( *value == 0 ) … … 291 296 struct account_reconnect_delay p; 292 297 293 return account_reconnect_delay_parse( value, &p ) ? value : NULL;298 return account_reconnect_delay_parse( value, &p ) ? value : SET_INVALID; 294 299 } 295 300 -
account.h
r934dddf3 r7125cb3 56 56 int account_reconnect_delay( account_t *a ); 57 57 58 #define ACC_SET_NOSAVE 159 #define ACC_SET_OFFLINE_ONLY 260 #define ACC_SET_ONLINE_ONLY 458 #define ACC_SET_NOSAVE 0x01 59 #define ACC_SET_OFFLINE_ONLY 0x02 60 #define ACC_SET_ONLINE_ONLY 0x04 61 61 62 62 #endif -
irc.c
r934dddf3 r7125cb3 77 77 struct sockaddr_storage sock; 78 78 socklen_t socklen = sizeof( sock ); 79 set_t *s; 79 80 80 81 irc = g_new0( irc_t, 1 ); … … 136 137 irc_connection_list = g_slist_append( irc_connection_list, irc ); 137 138 138 set_add( &irc->set, "away_devoice", "true", set_eval_away_devoice, irc ); 139 set_add( &irc->set, "auto_connect", "true", set_eval_bool, irc ); 140 set_add( &irc->set, "auto_reconnect", "false", set_eval_bool, irc ); 141 set_add( &irc->set, "auto_reconnect_delay", "5*3<900", set_eval_account_reconnect_delay, irc ); 142 set_add( &irc->set, "buddy_sendbuffer", "false", set_eval_bool, irc ); 143 set_add( &irc->set, "buddy_sendbuffer_delay", "200", set_eval_int, irc ); 144 set_add( &irc->set, "charset", "utf-8", set_eval_charset, irc ); 145 set_add( &irc->set, "debug", "false", set_eval_bool, irc ); 146 set_add( &irc->set, "default_target", "root", NULL, irc ); 147 set_add( &irc->set, "display_namechanges", "false", set_eval_bool, irc ); 148 set_add( &irc->set, "handle_unknown", "root", NULL, irc ); 149 set_add( &irc->set, "lcnicks", "true", set_eval_bool, irc ); 150 set_add( &irc->set, "ops", "both", set_eval_ops, irc ); 151 set_add( &irc->set, "password", NULL, passchange, irc ); 152 set_add( &irc->set, "private", "true", set_eval_bool, irc ); 153 set_add( &irc->set, "query_order", "lifo", NULL, irc ); 154 set_add( &irc->set, "root_nick", irc->mynick, set_eval_root_nick, irc ); 155 set_add( &irc->set, "save_on_quit", "true", set_eval_bool, irc ); 156 set_add( &irc->set, "simulate_netsplit", "true", set_eval_bool, irc ); 157 set_add( &irc->set, "strip_html", "true", NULL, irc ); 158 set_add( &irc->set, "to_char", ": ", set_eval_to_char, irc ); 159 set_add( &irc->set, "typing_notice", "false", set_eval_bool, irc ); 139 s = set_add( &irc->set, "away_devoice", "true", set_eval_away_devoice, irc ); 140 s = set_add( &irc->set, "auto_connect", "true", set_eval_bool, irc ); 141 s = set_add( &irc->set, "auto_reconnect", "false", set_eval_bool, irc ); 142 s = set_add( &irc->set, "auto_reconnect_delay", "5*3<900", set_eval_account_reconnect_delay, irc ); 143 s = set_add( &irc->set, "buddy_sendbuffer", "false", set_eval_bool, irc ); 144 s = set_add( &irc->set, "buddy_sendbuffer_delay", "200", set_eval_int, irc ); 145 s = set_add( &irc->set, "charset", "utf-8", set_eval_charset, irc ); 146 s = set_add( &irc->set, "debug", "false", set_eval_bool, irc ); 147 s = set_add( &irc->set, "default_target", "root", NULL, irc ); 148 s = set_add( &irc->set, "display_namechanges", "false", set_eval_bool, irc ); 149 s = set_add( &irc->set, "handle_unknown", "root", NULL, irc ); 150 s = set_add( &irc->set, "lcnicks", "true", set_eval_bool, irc ); 151 s = set_add( &irc->set, "ops", "both", set_eval_ops, irc ); 152 s = set_add( &irc->set, "password", NULL, passchange, irc ); 153 s->flags |= SET_NULL_OK; 154 s = set_add( &irc->set, "private", "true", set_eval_bool, irc ); 155 s = set_add( &irc->set, "query_order", "lifo", NULL, irc ); 156 s = set_add( &irc->set, "root_nick", irc->mynick, set_eval_root_nick, irc ); 157 s = set_add( &irc->set, "save_on_quit", "true", set_eval_bool, irc ); 158 s = set_add( &irc->set, "simulate_netsplit", "true", set_eval_bool, irc ); 159 s = set_add( &irc->set, "strip_html", "true", NULL, irc ); 160 s = set_add( &irc->set, "to_char", ": ", set_eval_to_char, irc ); 161 s = set_add( &irc->set, "typing_notice", "false", set_eval_bool, irc ); 160 162 161 163 conf_loaddefaults( irc ); -
protocols/jabber/jabber.c
r934dddf3 r7125cb3 70 70 71 71 s = set_add( &acc->set, "server", NULL, set_eval_account, acc ); 72 s->flags |= ACC_SET_NOSAVE | ACC_SET_OFFLINE_ONLY ;72 s->flags |= ACC_SET_NOSAVE | ACC_SET_OFFLINE_ONLY | SET_NULL_OK; 73 73 74 74 s = set_add( &acc->set, "ssl", "false", set_eval_bool, acc ); -
protocols/jabber/jabber_util.c
r934dddf3 r7125cb3 37 37 /* Priority is a signed 8-bit integer, according to RFC 3921. */ 38 38 if( i < -128 || i > 127 ) 39 return NULL;39 return SET_INVALID; 40 40 } 41 41 else 42 return NULL;42 return SET_INVALID; 43 43 44 44 /* Only run this stuff if the account is online ATM, -
protocols/nogaim.c
r934dddf3 r7125cb3 928 928 int st; 929 929 930 if( ( g_strcasecmp( value, "true" ) == 0 ) || ( g_strcasecmp( value, "yes" ) == 0 ) || ( g_strcasecmp( value, "on" ) == 0 ) ) 931 st = 1; 932 else if( ( g_strcasecmp( value, "false" ) == 0 ) || ( g_strcasecmp( value, "no" ) == 0 ) || ( g_strcasecmp( value, "off" ) == 0 ) ) 933 st = 0; 934 else if( sscanf( value, "%d", &st ) != 1 ) 935 return( NULL ); 936 937 st = st != 0; 930 if( !is_bool( value ) ) 931 return SET_INVALID; 932 933 st = bool2int( value ); 938 934 939 935 /* Horror.... */ … … 979 975 } 980 976 981 return ( set_eval_bool( set, value ) );977 return value; 982 978 } 983 979 -
root_commands.c
r934dddf3 r7125cb3 610 610 irc->mynick = g_strdup( cmd[2] ); 611 611 612 /* If we're called internally (user did "set root_nick"), 613 let's not go O(INF). :-) */ 612 614 if( strcmp( cmd[0], "set_rename" ) != 0 ) 613 615 set_setstr( &irc->set, "root_nick", cmd[2] ); … … 633 635 } 634 636 635 return strcmp( irc->mynick, new_nick ) == 0 ? new_nick : NULL;637 return strcmp( irc->mynick, new_nick ) == 0 ? new_nick : SET_INVALID; 636 638 } 637 639 -
set.c
r934dddf3 r7125cb3 25 25 #define BITLBEE_CORE 26 26 #include "bitlbee.h" 27 28 /* Used to use NULL for this, but NULL is actually a "valid" value. */ 29 char *SET_INVALID = "nee"; 27 30 28 31 set_t *set_add( set_t **head, char *key, char *def, set_eval eval, void *data ) … … 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 … … 187 201 for( ; *s; s ++ ) 188 202 if( !isdigit( *s ) ) 189 return NULL;203 return SET_INVALID; 190 204 191 205 return value; … … 194 208 char *set_eval_bool( set_t *set, char *value ) 195 209 { 196 return is_bool( value ) ? value : NULL;210 return is_bool( value ) ? value : SET_INVALID; 197 211 } 198 212 … … 226 240 irc->channel, "-oo", irc->nick, irc->mynick ); 227 241 else 228 return NULL;242 return SET_INVALID; 229 243 230 244 return value; -
set.h
r934dddf3 r7125cb3 44 44 typedef char *(*set_eval) ( struct set *set, char *value ); 45 45 46 extern char *SET_INVALID; 47 48 #define SET_NULL_OK 0x0100 49 46 50 typedef struct set 47 51 { … … 61 65 this (yet?). */ 62 66 63 /* Eval: Returns NULL if the value is incorrect or exactly the64 passed value variable. When returning a corrected value,67 /* Eval: Returns SET_INVALID if the value is incorrect or exactly 68 the passed value variable. When returning a corrected value, 65 69 set_setstr() should be able to free() the returned string! */ 66 70 set_eval eval;
Note: See TracChangeset
for help on using the changeset viewer.