Changes in set.c [1a1faa0:cd428e4]
Legend:
- Unmodified
- Added
- Removed
-
set.c
r1a1faa0 rcd428e4 209 209 } 210 210 211 char *set_eval_op _root( set_t *set, char *value )211 char *set_eval_ops( set_t *set, char *value ) 212 212 { 213 213 irc_t *irc = set->data; 214 char *ret = set_eval_bool(set, value); 215 int b = bool2int(ret); 216 217 irc_write( irc, ":%s!%s@%s MODE %s %s %s", irc->mynick, irc->mynick, irc->myhost, 218 irc->channel, b?"+o":"-o", irc->mynick ); 219 return ret; 220 } 221 222 char *set_eval_op_user( set_t *set, char *value ) 223 { 224 irc_t *irc = set->data; 225 char *ret = set_eval_bool(set, value); 226 int b = bool2int(ret); 227 228 irc_write( irc, ":%s!%s@%s MODE %s %s %s", irc->mynick, irc->mynick, irc->myhost, 229 irc->channel, b?"+o":"-o", irc->nick ); 230 return ret; 231 } 232 233 /* generalized version of set_eval_op/voice_buddies */ 234 char *set_eval_mode_buddies( set_t *set, char *value, char modeflag ) 235 { 236 irc_t *irc = set->data; 237 char op[64], deop[64]; 238 int nop=0, ndeop=0; 239 user_t *u; 240 int mode; 241 242 if(!strcmp(value, "false")) 243 mode=0; 244 else if(!strcmp(value, "encrypted")) 245 mode=1; 246 else if(!strcmp(value, "trusted")) 247 mode=2; 248 else if(!strcmp(value, "notaway")) 249 mode=3; 214 215 if( g_strcasecmp( value, "user" ) == 0 ) 216 irc_write( irc, ":%s!%s@%s MODE %s %s %s %s", irc->mynick, irc->mynick, irc->myhost, 217 irc->channel, "+o-o", irc->nick, irc->mynick ); 218 else if( g_strcasecmp( value, "root" ) == 0 ) 219 irc_write( irc, ":%s!%s@%s MODE %s %s %s %s", irc->mynick, irc->mynick, irc->myhost, 220 irc->channel, "-o+o", irc->nick, irc->mynick ); 221 else if( g_strcasecmp( value, "both" ) == 0 ) 222 irc_write( irc, ":%s!%s@%s MODE %s %s %s %s", irc->mynick, irc->mynick, irc->myhost, 223 irc->channel, "+oo", irc->nick, irc->mynick ); 224 else if( g_strcasecmp( value, "none" ) == 0 ) 225 irc_write( irc, ":%s!%s@%s MODE %s %s %s %s", irc->mynick, irc->mynick, irc->myhost, 226 irc->channel, "-oo", irc->nick, irc->mynick ); 250 227 else 251 228 return NULL; 252 229 253 /* sorry for calling them op/deop - too lazy for search+replace :P */254 op[0]='\0';255 deop[0]='\0';256 for(u=irc->users; u; u=u->next) {257 /* we're only concerned with online buddies */258 if(!u->ic || !u->online)259 continue;260 261 /* just in case... */262 if(strlen(u->nick) >= 64)263 continue;264 265 /* dump out ops/deops when the corresponding name list fills up */266 if(strlen(op)+strlen(u->nick)+2 > 64) {267 char *flags = g_strnfill(nop, modeflag);268 irc_write( irc, ":%s!%s@%s MODE %s +%s%s", irc->mynick, irc->mynick, irc->myhost,269 irc->channel, flags, op );270 op[0]='\0';271 nop=0;272 g_free(flags);273 }274 if(strlen(deop)+strlen(u->nick)+2 > 64) {275 char *flags = g_strnfill(ndeop, modeflag);276 irc_write( irc, ":%s!%s@%s MODE %s -%s%s", irc->mynick, irc->mynick, irc->myhost,277 irc->channel, flags, deop );278 deop[0]='\0';279 ndeop=0;280 g_free(flags);281 }282 283 switch(mode) {284 /* "false" */285 case 0:286 g_strlcat(deop, " ", 64);287 g_strlcat(deop, u->nick, 64);288 ndeop++;289 break;290 /* "encrypted" */291 case 1:292 if(u->encrypted) {293 g_strlcat(op, " ", 64);294 g_strlcat(op, u->nick, 64);295 nop++;296 } else {297 g_strlcat(deop, " ", 64);298 g_strlcat(deop, u->nick, 64);299 ndeop++;300 }301 break;302 /* "trusted" */303 case 2:304 if(u->encrypted > 1) {305 g_strlcat(op, " ", 64);306 g_strlcat(op, u->nick, 64);307 nop++;308 } else {309 g_strlcat(deop, " ", 64);310 g_strlcat(deop, u->nick, 64);311 ndeop++;312 }313 break;314 /* "notaway" */315 case 3:316 if(u->away) {317 g_strlcat(deop, " ", 64);318 g_strlcat(deop, u->nick, 64);319 ndeop++;320 } else {321 g_strlcat(op, " ", 64);322 g_strlcat(op, u->nick, 64);323 nop++;324 }325 }326 }327 /* dump anything left in op/deop lists */328 if(*op) {329 char *flags = g_strnfill(nop, modeflag);330 irc_write( irc, ":%s!%s@%s MODE %s +%s%s", irc->mynick, irc->mynick, irc->myhost,331 irc->channel, flags, op );332 g_free(flags);333 }334 if(*deop) {335 char *flags = g_strnfill(ndeop, modeflag);336 irc_write( irc, ":%s!%s@%s MODE %s -%s%s", irc->mynick, irc->mynick, irc->myhost,337 irc->channel, flags, deop );338 g_free(flags);339 }340 341 230 return value; 342 }343 344 char *set_eval_op_buddies( set_t *set, char *value )345 {346 return set_eval_mode_buddies(set, value, 'o');347 }348 349 char *set_eval_halfop_buddies( set_t *set, char *value )350 {351 return set_eval_mode_buddies(set, value, 'h');352 }353 354 char *set_eval_voice_buddies( set_t *set, char *value )355 {356 return set_eval_mode_buddies(set, value, 'v');357 231 } 358 232 … … 371 245 return value; 372 246 } 373 374 /* possible values: never, opportunistic, manual, always */375 char *set_eval_otr_policy( set_t *set, char *value )376 {377 if ( !strcmp(value, "never") )378 return value;379 if ( !strcmp(value, "opportunistic") )380 return value;381 if ( !strcmp(value, "manual") )382 return value;383 if ( !strcmp(value, "always") )384 return value;385 return NULL;386 }
Note: See TracChangeset
for help on using the changeset viewer.