void do_rkicksay(COMMAND_ARGS) { /* * on_msg checks: CARGS */ KickSay *kick; char *channel; channel = chop(&rest); /* cant be NULL (CARGS) */ if (!ischannel(channel) && *channel != '*') goto usage; if (!*rest) goto usage; if (!(kick = find_kicksay(rest,channel))) { to_user(from,"I'm not kicking on that"); return; } to_user(from,"No longer kicking on %s",kick->mask); remove_kicksay(kick); current->ul_save++; return; usage: usage(from); /* usage for CurrentCmd->name */ }
void do_note(COMMAND_ARGS) { User *u; Note *n; Strp *sp,**np; char header[MSGLEN]; /* * no-args is handled in on_msg() */ if (!(u = find_handle(rest))) { to_user(from,TEXT_UNKNOWNUSER,rest); return; } to_user(from,"Enter your note for %s, end with \".\" on a line by itself", u->name); set_mallocdoer(do_note); n = Calloc(sizeof(Note) + StrlenX(from,to,u->name,NULL)); n->start = now; n->next = notelist; notelist = n; n->to = stringcat(n->from,from) + 1; n->user = stringcat(n->to,to) + 1; stringcpy(n->user,rest); /* * add a note header */ sprintf(header,"\001%s %s",from,time2str(now)); append_strp(&u->note,header); }
bool GenScaleIm<TObj>::do_it_gen(Pt2dr tr,REAL sc,Pt2di pW0,Pt2di pW1) { _tr = tr; _sc = sc; XTransfo.Set(_tr.x,_sc); YTransfo.Set(_tr.y,_sc); _CoeffPds = round_ni(100.0/sc); pt_set_min_max(pW0,pW1); Pt2dr pu0 = Sup(Pt2dr(to_user(Pt2dr(pW0))),Pt2dr(0.0,0.0)); Pt2dr pu1 = Inf(Pt2dr(to_user(Pt2dr(pW1))),Pt2dr(_SzU)); pW0 = Sup(Pt2di(0,0),round_down(to_window(pu0))); pW1 = Inf(_SzW ,round_up(to_window(pu1))); _pW0 = pW0; _pW1 = pW1; _xU0 = std::max(0 , round_down(0.5+x_to_user(_pW0.x-0.5))); _xU1 = std::min(_SzU.x , round_up (0.5+x_to_user(_pW1.x-0.5))); _yU0 = std::max(0 , round_down(0.5+y_to_user(_pW0.y-0.5))); _yU1 = std::min(_SzU.y , round_up (0.5+y_to_user(_pW1.y-0.5))); if ((_xU0 >=_xU1) || (_yU0 >= _yU1)) return false; for (INT ux=_xU0; ux<=_xU1 ; ux++) { _u2wX[ux] = FitInWX(PremPixelU2WX(ux)); } for (INT uy=_yU0; uy<=_yU1 ; uy++) { _u2wY[uy] = FitInWY(PremPixelU2WY(uy)); } for (INT wx= 0;wx<= _SzW.x ; wx++) { _Cw2uX[wx] = PixCenterW2U_x(wx); } for (INT wy=0;wy<= _SzW.y ; wy++) { _Cw2uY[wy] = PixCenterW2U_y(wy); } return true; }
/** * Create a file or directory that hides path below root_rw */ static int do_create_whiteout(const char *path, int root_rw, enum whiteout mode) { char metapath[PATHLEN_MAX]; int res = -1; to_root(); // whiteouts are root business if (BUILD_PATH(metapath, METADIR, path)) { syslog (LOG_WARNING, "%s(): Path too long\n", __func__); goto out; } // p MUST be without path to branch prefix here! 2 x root_rw is correct here! // this creates e.g. branch/.unionfs/some_directory path_create_cutlast(metapath, root_rw, root_rw); char p[PATHLEN_MAX]; if (BUILD_PATH(p, uopt.roots[root_rw].path, metapath, HIDETAG)) { syslog (LOG_WARNING, "%s(): Path too long\n", __func__); goto out; } if (mode == WHITEOUT_FILE) { res = open(p, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR); if (res == -1) goto out; res = close(res); } else res = mkdir(p, S_IRWXU); out: to_user(); return res; }
void do_info(COMMAND_ARGS) { ChanStats *stats; Chan *chan; char *p; char text[MSGLEN]; ulong avg; if (current->chanlist == NULL) { to_user(from,ERR_NOCHANNELS); return; } to_user(from,"\037channel\037 " "\037average\037 \037peak\037 \037low\037"); for(chan=current->chanlist;chan;chan=chan->next) { *(p = text) = 0; p = Strcat(p,chan->name); if (chan == current->activechan) p = Strcat(p," (current)"); if ((stats = chan->stats)) { if (stats && stats->flags == CSTAT_PARTIAL) p = Strcat(p," (partial)"); while(p < text+35) *(p++) = ' '; if (stats->LHuserseconds > 0) { avg = stats->LHuserseconds / (60*60); } else { avg = (stats->userpeak + stats->userlow) / 2; } sprintf(p,"%-7lu %-4i %i",avg,stats->userpeak,stats->userlow); to_user(from,FMT_PLAIN,text); sprintf(text,"Messages: %i Notices: %i Joins: %i Parts: %i Kicks: %i Quits: %i", stats->privmsg,stats->notice,stats->joins,stats->parts,stats->kicks,stats->quits); } else { Strcpy(p," (no current data)"); } to_user(from,FMT_PLAIN,text); } }
void do_rshit(COMMAND_ARGS) { /* * on_msg checks: CARGS */ Shit *shit; char *chan,*nick,*nuh; int uaccess; chan = chop(&rest); if (!chan || !*chan || (!ischannel(chan) && *chan != '*')) { usage(from); /* usage for CurrentCmd->name */ return; } if ((uaccess = get_useraccess(from,chan)) < cmdaccess) return; if ((nick = chop(&rest)) == NULL) { to_user(from,"No nick or userhost specified"); return; } if ((nuh = nick2uh(from,nick)) == NULL) return; if ((shit = find_shit(nuh,chan)) == NULL) { to_user(from,"%s is not in my shit list on that channel",nuh); return; } if ((get_useraccess(shit->from,chan)) > uaccess) { to_user(from,"The person who did this shitlist has a higher level than you"); return; } remove_shit(shit); to_user(from,"User %s is no longer being s*****d on %s",nuh,chan); }
void do_random_msg(COMMAND_ARGS) { char *filename,*message; filename = CurrentCmd->cmdarg; if (*rest) { to = chop(&rest); if (ischannel(to) && (get_authaccess(from,to) < cmdaccess)) return; } else if (!ischannel(to)) { usage(from); /* usage for CurrentCmd->name */ return; } if ((message = randstring(filename)) == NULL) { to_user(from,ERR_FILEOPEN,filename); return; } /* * send message to target nick/channel */ to_server("PRIVMSG %s :%s\n",to,message); /* * if its not a channel we send a copy to the user who did the command also */ if (!ischannel(to)) { to_user(from,"(%s) %s",to,message); } }
void do_randtopic(COMMAND_ARGS) { /* * on_msg checks CAXS */ Chan *chan = CurrentChan; char *topic; /* * the bot can set a random topic if chanmode is -t */ if (chan->bot_is_op || chan->topprot == FALSE) { if ((topic = randstring(RANDTOPICSFILE)) == NULL) { to_user(from,ERR_FILEOPEN,RANDTOPICSFILE); return; } to_server("TOPIC %s :%s\n",to,topic); to_user(from,TEXT_TOPICCHANGED,to); return; } to_user(from,ERR_NOTOPPED,to); }
void usage_command(char *to, const char *arg) { char *pt; int i; for(i=0;ulist[i].command;i++) { if (!Strcasecmp(arg,ulist[i].command)) { pt = ulist[i].usage; to_user_q(to,(pt) ? "Usage: %s %s" : "Usage: %s",ulist[i].command,pt); return; } } to_user(to,"Usage: (missing)"); }
static int elem_read_volume(selem_none_t *s, int dir, selem_ctl_type_t type) { snd_ctl_elem_value_t *ctl; unsigned int idx; int err; selem_ctl_t *c = &s->ctls[type]; snd_ctl_elem_value_alloca(&ctl); if ((err = snd_hctl_elem_read(c->elem, ctl)) < 0) return err; for (idx = 0; idx < s->str[dir].channels; idx++) { unsigned int idx1 = idx; if (idx >= c->values) idx1 = 0; s->str[dir].vol[idx] = to_user(s, dir, c, snd_ctl_elem_value_get_integer(ctl, idx1)); } return 0; }
int catch_note(char *from, char *to, char *rest) { User *u; Note *n,**pp; Strp *sp,**np; #ifdef DEBUG debug("(catch_note) from = %s, to = %s, rest = %s\n",from,to,rest); #endif /* DEBUG */ pp = ¬elist; while(*pp) { n = *pp; #ifdef DEBUG debug("(catch_note) n->from = %s, n->to = %s\n",n->from,n->to); #endif /* DEBUG */ if (!stringcasecmp(from,n->from) && !stringcasecmp(to,n->to)) { #ifdef DEBUG debug("(catch_note) note to user = %s\n",n->user); #endif /* DEBUG */ if (rest[0] == '.' && rest[1] == 0) { to_user(from,"Note for %s has been saved",n->user); *pp = n->next; Free((char**)&n); return(TRUE); } if (!(u = find_handle(n->user))) return(TRUE); append_strp(&u->note,rest); return(TRUE); } if ((now - n->start) > 120) { *pp = n->next; Free((char**)&n); return(TRUE); } pp = &(*pp)->next; } return(FALSE); }
void print_help(char *from, char *line, int len) { char *lp; int tl; tl = TRUE; if ((strlen(line) + len) > 70) { lp = line; while(*lp) { if (*lp == '\037') tl = !tl; if (tl) *lp = tolowertab[(uchar)*lp]; lp++; } to_user(from,FMT_PLAIN,line); *line = 0; } }
void do_read(COMMAND_ARGS) { Strp *sp,**pp; User *user; char *opt,*sender; int which,n,sz; if (CurrentDCC) user = CurrentUser; else if ((user = get_authuser(from,ANY_CHANNEL)) == NULL) return; sz = n = 0; for(sp=user->note;sp;sp=sp->next) { if (*sp->p == 1) n++; else sz += strlen(sp->p); } if (rest && (opt = chop(&rest))) { which = asc2int(opt); if (errno || !which) goto read_usage; if (which < -n || which > n) { to_user(from,"invalid message number"); return; } n = 0; pp = &user->note; while(*pp) { sp = *pp; if (*sp->p == 1) n++; if (which == n) { opt = sp->p + 1; sender = chop(&opt); to_user(from,"From: %s on %s",sender,opt); opt[-1] = ' '; to_user(from," "); sp = sp->next; while(sp && *sp->p != 1) { to_user(from,FMT_PLAIN,sp->p); sp = sp->next; } to_user(from," "); return; } else if (which == -n) { while(TRUE) { *pp = sp->next; Free((char**)&sp); sp = *pp; if (!sp || *sp->p == 1) break; } to_user(from,"message number %i has been deleted",-which); return; } } } to_user(from,(n) ? "you have %i message%s (%i bytes)" : "you have no messages",n,(n == 1) ? "" : "s",sz); return; read_usage: usage(from); /* usage for CurrentCmd->name */ }
void send_spy(const char *src, const char *format, ...) { Chan *chan; Mech *backup; Spy *spy; va_list msg; const char *tempsrc; char tempdata[MAXLEN]; int fd; int printed = FALSE; tempsrc = (src == SPYSTR_STATUS) ? time2medium(now) : src; #ifdef DEBUG debug("(send_spy) src %s format = '%s'\n",src,format); #endif /* DEBUG */ for(spy=current->spylist;spy;spy=spy->next) { if ((*src == '#' || *src == '*') && spy->t_src == SPY_CHANNEL) { if ((*src != '*') && stringcasecmp(spy->src,src)) continue; if ((chan = find_channel_ac(spy->src)) == NULL) continue; if (find_chanuser(chan,CurrentNick) == NULL) continue; tempsrc = spy->src; } else /* * by using string constants we can compare addresses */ if (spy->src != src) continue; if (!printed) { printed = TRUE; va_start(msg,format); vsprintf(tempdata,format,msg); va_end(msg); } switch(spy->t_dest) { case SPY_DCC: to_file(spy->dcc->sock,"[%s] %s\n",tempsrc,tempdata); break; case SPY_CHANNEL: if (spy->destbot >= 0) { backup = current; for(current=botlist;current;current=current->next) { if (current->guid == spy->destbot) { to_server("PRIVMSG %s :[%s] %s\n",spy->dest,tempsrc,tempdata); break; } } current = backup; } else { to_user(spy->dest,"[%s] %s",tempsrc,tempdata); } break; case SPY_FILE: if ((fd = open(spy->dest,O_WRONLY|O_CREAT|O_APPEND,NEWFILEMODE)) >= 0) { to_file(fd,"[%s] %s\n",logtime(now),tempdata); close(fd); } } } }
int begin_redirect(char *from, char *args) { char *pt,*nick; if (!args) return(0); pt = STRCHR(args,'>'); if (pt) { *pt = 0; nick = pt+1; pt--; while((pt > args) && (*pt == ' ')) { *pt = 0; pt--; } while(*nick == ' ') nick++; if (*nick) { #ifdef DEBUG debug("(begin_redirect) from %s --> %s\n",from,nick); #endif /* DEBUG */ if (ischannel(nick)) { if (find_channel_ac(nick)) { redirect.to = stringdup(nick); redirect.method = R_PRIVMSG; return(0); } else { to_user(from,ERR_CHAN,nick); return(-1); } } if (*nick == '>') { nick++; while(*nick == ' ') nick++; if (!*nick) { to_user(from,"Missing name for redirect."); return(-1); } if (is_safepath(nick,FILE_MAY_EXIST) != FILE_IS_SAFE) // redirect output is appended { to_user(from,"Bad filename."); return(-1); } redirect.to = stringdup(nick); redirect.method = R_FILE; return(0); } if ((pt = find_nuh(nick))) { redirect.to = stringdup(nick); redirect.method = R_NOTICE; return(0); } else { to_user(from,TEXT_UNKNOWNUSER,nick); return(-1); } } else { to_user(from,"Bad redirect"); return(-1); } } return(0); }
void do_help(COMMAND_ARGS) { char line[MSGLEN]; char *pt; int i,level,axs; int cur,nxt,count,ci,tl; int in; if (dcc_only_command(from)) return; axs = get_maxaccess(from); if (!*rest) { cur = -1; *line = 0; help_loop: count = 0; nxt = OWNERLEVEL; for(i=0;mcmd[i].name;i++) { tl = acmd[i]; if ((tl < nxt) && (tl > cur)) nxt = tl; if (tl != cur) continue; if (count == 0) sprintf(line,"\037Level %3i\037: ",cur); count++; } if (!count) { cur = nxt; goto help_loop; } ci = count; for(i=0;mcmd[i].name;i++) { tl = acmd[i]; if (tl != cur) continue; if (ci != count) Strcat(line,", "); print_help(from,line,strlen(mcmd[i].name)); if (*line == 0) Strcpy(line," "); Strcat(line,(char*)mcmd[i].name); count--; } print_help(from,line,500); if ((cur != OWNERLEVEL) && (nxt <= axs)) cur = nxt; else return; goto help_loop; } level = a2i(rest); if (!errno) { if ((level > axs) || (level < 0)) level = axs; to_user(from,"\037Commands available at Level %i:\037",level); *line = 0; ci = 0; for(i=0;mcmd[i].name;i++) { if (acmd[i] <= level) { if (ci != 0) Strcat(line,", "); ci++; print_help(from,line,strlen(mcmd[i].name)); Strcat(line,(char*)mcmd[i].name); } } if (ci) print_help(from,line,58); else to_user(from,TEXT_NONE); return; } if (STRCHR(rest,'*')) { line[0] = 0; ci = 0; to_user(from,"\037Commands that match query %s\037:",rest); for(i=0;mcmd[i].name;i++) { if ((!matches(rest,(char*)mcmd[i].name)) && (acmd[i] <= axs)) { if (ci != 0) Strcat(line,", "); ci++; print_help(from,line,strlen(mcmd[i].name)); Strcat(line,(char*)mcmd[i].name); } } if (ci) print_help(from,line,500); else to_user(from,TEXT_NONE); return; } /* * We dont want to show help for "../../../../../../etc/passwd" */ if (!is_safepath(rest)) return; pt = Strcpy(line,HELPDIR); for(i=0;(rest[i]);i++) { if (rest[i] >= 'a' && rest[i] <= 'z') *pt = rest[i] - 0x20; else *pt = rest[i]; pt++; } *pt = 0; #ifdef DEBUG debug("(do_help) help file check: %s\n",line); #endif /* DEBUG */ if ((in = open(line,O_RDONLY)) < 0) { to_user(from,"No help found for \"%s\"",rest); return; } #ifdef DEBUG debug("(do_help) helpfile for = '%s'\n",rest); #endif /* DEBUG */ table_buffer("\037Help on %s\037",rest); level = access_needed(rest); if (level > 200) table_buffer("Level needed: Command disabled"); else if (level > 0) table_buffer("Level needed: %i",level); for(i=0;ulist[i].command;i++) { if (!Strcasecmp(rest,ulist[i].command)) { pt = (ulist[i].usage) ? ulist[i].usage : ""; table_buffer("Usage: %s %s",ulist[i].command,pt); break; } } readline(in,&do_help_callback); /* readline closes in */ table_send(from,0); }
void do_kicksay(COMMAND_ARGS) { /* * on_msg checks: CARGS */ KickSay *kick; char *channel,*mask; int inum; channel = chop(&rest); if (!channel) { if (!current->kicklist) { to_user(from,"Kicksay list is empty"); return; } if (dcc_only_command(from)) return; table_buffer("\037channel\037\t\037action\037\t\037string\037\t\037kick reason\037"); for(kick=current->kicklist;kick;kick=kick->next) { table_buffer("%s\t%s\t%s\t%s",kick->chan,ks_actions[kick->action],kick->mask,kick->reason); } table_send(from,2); return; } if (ischannel(channel) || *channel == '*') { if (get_useraccess(from,channel) < cmdaccess) return; inum = DEFAULT_KS_LEVEL; if (*rest != '"') { inum = a2i(chop(&rest)); if (errno || inum < 0 || inum > MAX_KS_LEVEL) return; } mask = get_token(&rest,"\""); if (!mask || !*mask) goto usage; /* * check for previously existing kicks */ if ((kick = find_kicksay(mask,channel)) != NULL) { to_user(from,"I'm already kicking on \"%s\"",kick->mask); return; } /* * dig out the reason (the rest) */ while(rest && *rest == ' ') rest++; if (!*rest) goto usage; /* * add it to the list */ set_mallocdoer(do_kicksay); kick = (KickSay*)Calloc(sizeof(KickSay) + Strlen(channel,mask,rest,NULL)); kick->next = current->kicklist; current->kicklist = kick; kick->action = inum; if (!matches("\\*?*\\*",mask)) kick->chan = Strcpy(kick->mask,mask) + 1; else { kick->mask[0] = '*'; Strcpy(kick->mask+1,mask); kick->chan = Strcat(kick->mask,MATCH_ALL) + 1; } kick->reason = Strcpy(kick->chan,channel) + 1; Strcpy(kick->reason,rest); to_user(from,"Now kicking on \"%s\" on %s",mask,channel); current->ul_save++; return; } usage: usage(from); /* usage for CurrentCmd->name */ }
void do_greet(COMMAND_ARGS) { /* * on_msg checks: CARGS */ User *user; char *handle; int isfile; if ((handle = chop(&rest)) == NULL) goto usage; if ((user = find_handle(handle)) == NULL) { to_user(from,TEXT_UNKNOWNUSER,handle); return; } if (!usercanmodify(from,user)) { to_user(from,TEXT_USEROWNSYOU,user->name); return; } isfile = FALSE; if (*rest == '@' || *rest == '%') { isfile = *rest; rest++; while(*rest == ' ') rest++; } if (*rest) { if (isfile) { if (!is_safepath(rest)) goto usage; } user->x.x.greetfile = (isfile == '@') ? TRUE : FALSE; user->x.x.randline = (isfile == '%') ? TRUE : FALSE; set_mallocdoer(do_greet); user->greet = Strdup(rest); to_user(from,"greeting for user %s has been set to: %s%s",user->name,user->greet, (isfile == '@') ? " (file)" : ((isfile == '%') ? " (random line from file)" : "")); current->ul_save++; } else if (isfile) { goto usage; } else if (user->greet) { Free((char**)&user->greet); to_user(from,"greeting for user %s has been removed",user->name); current->ul_save++; } return; usage: usage(from); /* usage for CurrentCmd->name */ }
/* * SHIT <channel|*> <nick|mask> <action> [expire] <reason> */ void do_shit(COMMAND_ARGS) { /* * on_msg checks CARGS */ char *channel,*nick,*nuh; int shitlevel,days,uaccess,shitaccess; if (CurrentCmd->name == C_QSHIT) { channel = MATCH_ALL; } else { channel = chop(&rest); if (!ischannel(channel) && *channel != '*') { usage: usage(from); /* usage for CurrentCmd->name */ return; } } if ((uaccess = get_useraccess(from,channel)) < cmdaccess) return; if ((nick = chop(&rest)) == NULL) goto usage; if (CurrentCmd->name == C_QSHIT) { shitlevel = DEFAULTSHITLEVEL; days = 86400 * DEFAULTSHITLENGTH; if (*rest == 0) rest = TEXT_DEFAULTSHIT; } else { shitlevel = asc2int(chop(&rest)); if (errno) goto usage; if (shitlevel < 1 || shitlevel > MAXSHITLEVEL) { to_user(from,"Valid levels are from 1 thru " MAXSHITLEVELSTRING); return; } /* * option: expire in XXX days */ days = 86400 * 30; if (*rest >= '1' && *rest <= '9') { days = 86400 * asc2int(chop(&rest)); if (errno) goto usage; } if (*rest == 0) goto usage; } #ifdef CHANBAN if (shitlevel == SHIT_CHANBAN) { nuh = nick; } else #endif /* CHANBAN */ { if ((nuh = nick2uh(from,nick)) == NULL) return; if (find_shit(nuh,channel)) { to_user(from,TEXT_ALREADYSHITTED,nuh); return; } if (uaccess != OWNERLEVEL) { shitaccess = get_useraccess(nuh,channel); if (shitaccess > uaccess) { to_user(from,TEXT_SHITLOWACCESS,nuh); return; } } format_uh(nuh,FUH_USERHOST); } #ifdef DEBUG debug("(do_shit) adding %s to %s (Level %i)\n",nuh,channel,shitlevel); #endif /* DEBUG */ add_shit(from,channel,nuh,rest,shitlevel,now + days); to_user(from,TEXT_HASSHITTED,nuh,channel); to_user(from,TEXT_SHITEXPIRES,time2str(now + days)); check_shit(); }
void do_bigsay(COMMAND_ARGS) { /* * on_msg checks CARGS + CAXS */ BigC *bigc; Strp *sp; char output[MSGLEN]; char *pt,*tail,*temp; int i,x,sz; #ifdef DEBUG debug("(do_bigsay) rest = \"%s\"\n",rest); #endif /* DEBUG */ Strcpy(output,BIGSAY_DEFAULTFONT); if (read_bigcharset(output) < 0) { to_user(from,ERR_FILEOPEN,output); return; } for(i=0;i<charheight;i++) { sz = 0; *output = 0; tail = output; for(pt=rest;*pt;pt++) { /* find a matching character */ if (*pt == ' ') { x = spacewidth; while(x--) *(tail++) = ' '; *tail = 0; continue; } for(bigc=fontlist;bigc;bigc=bigc->next) { if (STRCHR(bigc->chars,*pt)) { sp = bigc->data; for(x=0;x<i;x++) if (sp) sp = sp->next; temp = Strcat(tail,sp->p); while(temp < (tail + bigc->width)) *(temp++) = ' '; if (pt[1]) { x = kerning; while(x--) *(temp++) = ' '; } *temp = 0; tail = temp; break; } } } temp = NULL; for(tail=output;*tail;tail++) { if (!temp && *tail == ' ') temp = tail; if (*tail != ' ') temp = NULL; } if (temp) { if (temp == output) temp++; *temp = 0; } to_user_q(from,FMT_PLAIN,output); } }
void do_clearshit(COMMAND_ARGS) { purge_shitlist(); to_user(from,TEXT_CLEAREDSHITLIST); }
void do_set(COMMAND_ARGS) { /* * on_msg checks: */ Chan *chan; UniVar *univar,*varval; char tmp[MSGLEN]; char *pp,*channel,*name; int n,which,i,sz,limit,uaccess; /* * */ channel = get_channel2(to,&rest); chan = find_channel_ny(channel); name = chop(&rest); /* * empty args, its "set" or "set #channel" */ if (!name) { if (!chan) { to_user(from,ERR_CHAN,channel); return; } if (!CurrentDCC) return; i = CHANSET_SIZE; limit = SIZE_VARS - 1; univar = current->setting; *tmp = 0; if ((uaccess = get_useraccess(from,GLOBAL_CHANNEL))) to_user(from,str_underline("Global settings")); second_pass: for(;i<limit;i++) { if (uaccess < VarName[i].uaccess) continue; varval = (IsProc(i)) ? current->setting[i].proc_var : &univar[i]; sz = Strlen2(tmp,VarName[i].name); if (IsStr(i)) { sz += (varval->str_var) ? strlen(varval->str_var) : 7; } if (sz > 58) { to_user(from,FMT_PLAIN,tmp); *tmp = 0; } if (IsInt(i)) { pp = tolowercat(tmp,VarName[i].name); sprintf(pp,(IsChar(i)) ? "=`%c' " : "=%i ",varval->int_var); } else if (IsStr(i)) { pp = tolowercat(tmp,VarName[i].name); sprintf(pp,(varval->str_var) ? "=\"%s\" " : "=(unset) ",varval->str_var); } else if (IsTog(i)) { pp = Strcat(tmp,(varval->int_var) ? "+" : "-"); pp = tolowercat(pp,VarName[i].name); pp[0] = ' '; pp[1] = 0; } } if (*tmp && tmp[1]) to_user(from,FMT_PLAIN,tmp); if (limit != CHANSET_SIZE) { to_user(from,"\037Channel settings: %s\037",(chan) ? chan->name : rest); i = 0; limit = CHANSET_SIZE; univar = chan->setting; *tmp = 0; uaccess = get_useraccess(from,(chan) ? chan->name : rest); goto second_pass; } return; } /* * alter a setting */ if ((which = find_setting(name)) == -1) { set_usage: usage(from); /* usage for CurrentCmd->name */ return; } if ((which < CHANSET_SIZE) && *channel != '*') { if (!chan) { to_user(from,ERR_CHAN,channel); return; } /* * its a channel setting */ channel = chan->name; varval = &chan->setting[which]; } else { /* * its a global setting */ channel = MATCH_ALL; varval = ¤t->setting[which]; } if (VarName[which].uaccess > get_authaccess(from,channel)) return; /* * Check each type and process `rest' if needed. */ n = 0; if (IsChar(which)) { if (rest[1]) goto set_usage; } else if (IsNum(which)) { if (IsTog(which)) { if (!Strcasecmp(rest,"ON")) { n = 1; goto num_data_ok; } else if (!Strcasecmp(rest,"OFF")) { /* n is 0 by default */ goto num_data_ok; } } n = a2i((rest = chop(&rest))); if (errno || n < VarName[which].min || n > VarName[which].max) { to_user(from,"Possible values are %i through %i",VarName[which].min,VarName[which].max); return; } } num_data_ok: /* * */ if ((which < CHANSET_SIZE) && *channel == '*') { for(chan=current->chanlist;chan;chan=chan->next) { if (IsNum(which)) { chan->setting[which].int_var = n; } else if (IsStr(which)) { Free((char**)&chan->setting[which].str_var); if (*rest) { set_mallocdoer(do_set); chan->setting[which].str_var = Strdup(rest); } } } channel = "(all channels)"; } else { if (IsProc(which)) varval = varval->proc_var; if (IsChar(which)) varval->char_var = *rest; else if (IsNum(which)) varval->int_var = n; else { if (varval->str_var) Free((char**)&varval->str_var); if (*rest) { set_mallocdoer(do_set); varval->str_var = Strdup(rest); } } } to_user(from,"Var: %s On: %s Set to: %s",VarName[which].name, (which >= CHANSET_SIZE) ? "(global)" : channel,(*rest) ? rest : NULLSTR); if (VarName[which].func) VarName[which].func(&VarName[which]); }