void check_botinfo(BotInfo *binfo, const char *channel) { Chan *chan; ChanUser *cu; Mech *backup; char *userhost; userhost = getuh(binfo->nuh); backup = current; for(current=botlist;current;current=current->next) { for(chan=current->chanlist;chan;chan=chan->next) { if (channel && Strcasecmp(channel,chan->name)) continue; if ((cu = find_chanbot(chan,binfo->nuh)) == NULL) continue; if (!Strcasecmp(cu->userhost,userhost)) { cu->flags |= CU_NEEDOP; send_mode(chan,50,QM_CHANUSER,'+','o',(void*)cu); } } } current = backup; }
struct cookie * get_cookie_info(Str domain, Str path, Str name) { struct cookie *p; for (p = First_cookie; p; p = p->next) { if (Strcasecmp(p->domain, domain) == 0 && Strcmp(p->path, path) == 0 && Strcasecmp(p->name, name) == 0) return p; } return NULL; }
void check_botjoin(Chan *chan, ChanUser *cu) { BotNet *bn; BotInfo *binfo; #ifdef DEBUG debug("(check_botjoin) chan = %s; cu = %s!%s\n",chan->name,cu->nick,cu->userhost); #endif /* DEBUG */ for(bn=botnetlist;bn;bn=bn->next) { if (bn->status != BN_LINKED) continue; for(binfo=bn->botinfo;binfo;binfo=binfo->next) { if (!nickcmp(cu->nick,binfo->nuh) && !Strcasecmp(cu->userhost,getuh(binfo->nuh))) { if ((cu = find_chanbot(chan,binfo->nuh)) == NULL) return; cu->flags |= CU_NEEDOP; send_mode(chan,50,QM_CHANUSER,'+','o',(void*)cu); #ifdef DEBUG debug("(check_botjoin) CU_NEEDOP set, mode pushed\n"); #endif /* DEBUG */ return; } } } }
Shit *find_shit(const char *userhost, const char *channel) { Shit *shit,*save; int num,best; if (!userhost) return(NULL); save = NULL; best = 0; for(shit=current->shitlist;shit;shit=shit->next) { if (!channel || !Strcasecmp(channel,shit->chan) || (*shit->chan == '*') || (*channel == '*')) { num = num_matches(shit->mask,userhost); if (num > best) { best = num; save = shit; } } } if (save && save->expire < now) { remove_shit(save); save = NULL; } return(save); }
int SearchSLabels(SLABELS *SL, char *str){ uint32_t n; for(n = 0 ; n < SL->idx ; ++n) if(Strcasecmp(SL->names[n], str) == 0) return 1; return 0; }
void check_kicksay(Chan *chan, ChanUser *doer, char *text) { KickSay *kick,*save; char *mask; int action; save = NULL; action = -1; for(kick=current->kicklist;kick;kick=kick->next) { if (*kick->chan == '*' || !Strcasecmp(chan->name,kick->chan)) { if (!matches(kick->mask,text)) { if (kick->action > action) { action = kick->action; save = kick; } } } } if (save) { if (!action) { if (doer->flags & CU_KSWARN) action = 1; if (!(doer->flags & CU_KSWARN)) { doer->flags |= CU_KSWARN; to_server("NOTICE %s :%s\n",doer->nick,save->reason); } } if (action > 1) { mask = format_uh(get_nuh(doer),FUH_USERHOST); if (action > 2) { add_shit("Auto KS",chan->name,mask,save->reason,2,now+3600); } if (!(doer->flags & CU_BANNED)) { doer->flags |= CU_BANNED; send_mode(chan,90,QM_RAWMODE,'+','b',mask); } } if (action && !(doer->flags & CU_KICKED)) { doer->flags |= CU_KICKED; send_kick(chan,CurrentNick,FMT_PLAIN,save->reason); } } }
/* * The rest */ int find_setting(char *name) { int i; for(i=0;VarName[i].name;i++) { if (!Strcasecmp(name,VarName[i].name)) return(i); } return(-1); }
Str find_cookie(ParsedURL *pu) { Str tmp; struct cookie *p, *p1, *fco = NULL; int version = 0; char *fq_domainname, *domainname; dump(Strnew_charp("GET")); load_cookies_sync(); fq_domainname = FQDN(pu->host); check_expired_cookies(); for (p = First_cookie; p; p = p->next) { domainname = (p->version == 0) ? fq_domainname : pu->host; if (p->flag & COO_USE && match_cookie(pu, p, domainname)) { for (p1 = fco; p1 && Strcasecmp(p1->name, p->name); p1 = p1->next) ; if (p1) continue; p1 = New(struct cookie); bcopy(p, p1, sizeof(struct cookie)); p1->next = fco; fco = p1; if (p1->version > version) version = p1->version; } } if (!fco) return NULL; tmp = Strnew(); if (version > 0) Strcat(tmp, Sprintf("$Version=\"%d\"; ", version)); Strcat(tmp, make_cookie(fco)); for (p1 = fco->next; p1; p1 = p1->next) { Strcat_charp(tmp, "; "); Strcat(tmp, make_cookie(p1)); if (version > 0) { if (p1->flag & COO_PATH) Strcat(tmp, Sprintf("; $Path=\"%s\"", p1->path->ptr)); if (p1->flag & COO_DOMAIN) Strcat(tmp, Sprintf("; $Domain=\"%s\"", p1->domain->ptr)); if (p1->portl) Strcat(tmp, Sprintf("; $Port=\"%s\"", portlist2str(p1->portl))); } } return tmp; }
/* * * commands for variables * */ void do_esay(COMMAND_ARGS) { /* * on_msg checks CAXS + CARGS */ char output[MSGLEN]; char c,*chp; int i,n; ec_end = output + MSGLEN - 20; ec_src = rest; rest = STREND(rest); ec_dest = output; c = 0; chp = NULL; while(*ec_src) { if (*ec_src != '$') { *(ec_dest++) = *(ec_src++); continue; } for(i=0;ecmd[i].len;i++) { if ((rest - ec_src) >= ecmd[i].len) { chp = ec_src + ecmd[i].len; c = *chp; *chp = 0; } n = Strcasecmp(ecmd[i].name,ec_src); if (c) { *chp = c; c = 0; } if (!n) { ec_src += ecmd[i].len; ecmd[i].func(from,to); break; } } if (!ecmd[i].len) { *(ec_dest++) = *(ec_src++); } } *ec_dest = 0; to_user_q(from,FMT_PLAIN,output); }
static int tokenId(lex_Context* c, const char* idBegin) { const int len = c->sourceCodeCursor - idBegin; strncpy(c->id, idBegin, len); assert(len < lex_MAX_ID_LENGTH); c->id[len] = 0; if (0 == Strcasecmp(c->id, "if")) return token(c, tokIF); else if (0 == Strcasecmp(c->id, "then")) return token(c, tokTHEN); else if (0 == Strcasecmp(c->id, "else")) return token(c, tokELSE); else if (0 == Strcasecmp(c->id, "endif")) return token(c, tokENDIF); else if (0 == Strcasecmp(c->id, "and")) return token(c, tokAND); else if (0 == Strcasecmp(c->id, "or")) return token(c, tokOR); else if (0 == Strcasecmp(c->id, "not")) return token(c, tokNOT); else if (0 == Strcasecmp(c->id, "goto")) return token(c, tokGOTO); else return token(c, tokID); }
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)"); }
void do_usage(COMMAND_ARGS) { /* * on_msg checks: CARGS */ char *cmd; int i; cmd = chop(&rest); for(i=0;mcmd[i].name;i++) { if (!Strcasecmp(cmd,mcmd[i].name)) { usage_command(from,mcmd[i].name); return; } } to_user_q(from,"Unknown command: %s",cmd); }
KickSay *find_kicksay(char *text, char *channel) { KickSay *kick,*save; int num,best; save = NULL; best = 0; for(kick=current->kicklist;kick;kick=kick->next) { if (!channel || *kick->chan == '*' || !Strcasecmp(channel,kick->chan)) { num = num_matches(kick->mask,text); if (num > best) { best = num; save = kick; } } } return(save); }
/* Initialize ProvReg strucutre from given directory */ _Use_decl_annotations_ MI_Result ProvReg_Init(ProvReg* self, const char* directory) { RegFile* reg = NULL; Dir* dir = NULL; Dir* dir2 = NULL; MI_Result r = MI_RESULT_FAILED; /* Zero-fill self */ memset(self, 0, sizeof(*self)); dir = Dir_Open(directory); if (!dir) { return r; } /* Initialize batch allocator */ Batch_Init(&self->batch, BATCH_MAX_PAGES); /* For each namespace directory in 'omirgister' */ for (;;) { DirEnt* ent = Dir_Read(dir); if (!ent) { break; } /* Ignore system directories */ if (strcmp(ent->name, ".") == 0 || strcmp(ent->name, "..") == 0) continue; /* Skip 'CVS' directories */ if (strcmp(ent->name, "CVS") == 0) continue; /* Scan .reg files in the current namespace directory */ { char path[PAL_MAX_PATH_SIZE]; Strlcpy(path, directory, sizeof(path)); Strlcat(path, "/", sizeof(path)); Strlcat(path, ent->name, sizeof(path)); /* Skip if not a dir */ if(!Isdir(path)) continue; dir2 = Dir_Open(path); if (!dir2) { goto failed; } for (;;) { DirEnt* ent2 = Dir_Read(dir2); if (!ent2) { break; } /* Ignore system directories */ if (strcmp(ent2->name,".") == 0 || strcmp(ent2->name,"..") == 0) { continue; } /* Skip non-reg file */ { char* affix = Strrchr(ent2->name, '.'); if (!affix || (Strcasecmp(&affix[1], "reg") != 0)) continue; } /* Load the reg file */ { char regPath[PAL_MAX_PATH_SIZE]; /* Form path to .reg file */ Strlcpy(regPath, path, sizeof(regPath)); Strlcat(regPath, "/", sizeof(regPath)); Strlcat(regPath, ent2->name, sizeof(regPath)); /* Create new reg file object */ reg = RegFile_New(regPath); if (!reg) { trace_ProvReg_SkipRegFile(scs(regPath)); continue; } /* For each class in the reg file */ { RegClass* rc; char* p = ent->name; /* Transpose NAMESPACE_SEPARATOR characters to '/' * characters */ while (*p) { if (*p == NAMESPACE_SEPARATOR) *p = '/'; p++; } for (rc = reg->classesHead; rc; rc = rc->next) { if (_AddEntry(self, ent->name, reg, rc) != 0) { goto failed; } } } /* For each extraClass in the reg file */ { RegClass* rc; char* p = ent->name; /* Transpose NAMESPACE_SEPARATOR characters to '/' * characters */ while (*p) { if (*p == NAMESPACE_SEPARATOR) *p = '/'; p++; } for (rc = reg->extraClassesHead; rc; rc = rc->next) { if (_AddEntryForExtraClass(self, ent->name, reg, rc) != 0) { goto failed; } } } /* Delete the current entry */ RegFile_Delete(reg); reg = NULL; } } /* Close the directory */ Dir_Close(dir2); dir2 = NULL; } } r = MI_RESULT_OK; failed: if (dir2) { Dir_Close(dir2); } if (dir) { Dir_Close(dir); } if (r != MI_RESULT_OK) { ProvReg_Destroy(self); memset(self, 0, sizeof(*self)); } if(reg) { RegFile_Delete(reg); reg = NULL; } return r; }
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); }
static int SDLGL_OpenVideo(void *obj, Uint w, Uint h, int depth, Uint flags) { char buf[16]; AG_Driver *drv = obj; AG_DriverSw *dsw = obj; AG_DriverSDLGL *sgl = obj; Uint32 sFlags = SDL_OPENGL; int newDepth; /* Set the requested display options. */ if (flags & AG_VIDEO_RESIZABLE) { sFlags |= SDL_RESIZABLE; } if (flags & AG_VIDEO_ANYFORMAT) { sFlags |= SDL_ANYFORMAT; } if (flags & AG_VIDEO_HWPALETTE) { sFlags |= SDL_HWPALETTE; } if (flags & AG_VIDEO_DOUBLEBUF) { sFlags |= SDL_DOUBLEBUF; } if (flags & AG_VIDEO_FULLSCREEN) { sFlags |= SDL_FULLSCREEN; } if (flags & AG_VIDEO_NOFRAME) { sFlags |= SDL_NOFRAME; } if (flags & AG_VIDEO_OVERLAY) dsw->flags |= AG_DRIVER_SW_OVERLAY; if (flags & AG_VIDEO_BGPOPUPMENU) dsw->flags |= AG_DRIVER_SW_BGPOPUP; /* Apply the output capture settings. */ if (AG_Defined(drv, "out")) { char *ext; AG_GetString(drv, "out", buf, sizeof(buf)); if ((ext = strrchr(buf, '.')) != NULL && ext[1] != '\0') { if (Strcasecmp(&ext[1], "jpeg") == 0 || Strcasecmp(&ext[1], "jpg") == 0) { sgl->outMode = AG_SDLGL_OUT_JPEG; if ((sgl->outPath = TryStrdup(buf)) == NULL) return (-1); } else if (Strcasecmp(&ext[1], "png") == 0) { sgl->outMode = AG_SDLGL_OUT_PNG; if ((sgl->outPath = TryStrdup(buf)) == NULL) return (-1); } else { AG_SetError("Invalid out= argument: `%s'", buf); return (-1); } if (AG_Defined(drv, "outFirst")) { AG_GetString(drv, "outFirst", buf, sizeof(buf)); sgl->outFrame = atoi(buf); } else { sgl->outFrame = 0; } if (AG_Defined(drv, "outLast")) { AG_GetString(drv, "outLast", buf, sizeof(buf)); sgl->outLast = atoi(buf); } } } /* Apply the default resolution settings. */ if (w == 0 && AG_Defined(drv, "width")) { AG_GetString(drv, "width", buf, sizeof(buf)); w = atoi(buf); } if (h == 0 && AG_Defined(drv, "height")) { AG_GetString(drv, "height", buf, sizeof(buf)); h = atoi(buf); } if (depth == 0 && AG_Defined(drv, "depth")) { AG_GetString(drv, "depth", buf, sizeof(buf)); depth = atoi(buf); } /* Set the video mode. Force hardware palette in 8bpp. */ Verbose(_("SDLGL: Setting mode %dx%d (%d bpp)\n"), w, h, depth); newDepth = SDL_VideoModeOK(w, h, depth, sFlags); if (newDepth == 8) { Verbose(_("Enabling hardware palette")); sFlags |= SDL_HWPALETTE; } if ((sgl->s = SDL_SetVideoMode((int)w, (int)h, newDepth, sFlags)) == NULL) { AG_SetError("Setting %dx%dx%d mode: %s", w, h, newDepth, SDL_GetError()); return (-1); } SDL_EnableUNICODE(1); if ((drv->videoFmt = AG_SDL_GetPixelFormat(sgl->s)) == NULL) { goto fail; } dsw->w = sgl->s->w; dsw->h = sgl->s->h; dsw->depth = (Uint)drv->videoFmt->BitsPerPixel; Verbose(_("SDLGL: New display (%dbpp)\n"), (int)drv->videoFmt->BitsPerPixel); /* Initialize clipping rectangles. */ if (InitClipRects(sgl, dsw->w, dsw->h) == -1) goto fail; /* Create the cursors. */ if (AG_SDL_InitDefaultCursor(sgl) == -1 || AG_InitStockCursors(drv) == -1) goto fail; /* Initialize the GL viewport. */ AG_GL_InitContext( AG_RECT(0, 0, AGDRIVER_SW(sgl)->w, AGDRIVER_SW(sgl)->h)); if (!(dsw->flags & AG_DRIVER_SW_OVERLAY)) { ClearBackground(); } /* Initialize the output capture buffer. */ Free(sgl->outBuf); if ((sgl->outBuf = AG_TryMalloc(dsw->w*dsw->h*4)) == NULL) { AG_Verbose("Out of memory for buffer; disabling capture\n"); sgl->outMode = AG_SDLGL_OUT_NONE; } /* Toggle fullscreen if requested. */ if (AG_CfgBool("view.full-screen")) { if (!SDL_WM_ToggleFullScreen(sgl->s)) AG_SetCfgBool("view.full-screen", 0); } return (0); fail: if (drv->videoFmt) { AG_PixelFormatFree(drv->videoFmt); drv->videoFmt = NULL; } return (-1); }
void do_seen(COMMAND_ARGS) { Seen *seen; char ago[35]; /* enought for "36500 days, 23 hours and 59 minutes" (100 years) */ char *chan,*fmt,*n,*u,*c1,*c2,*c3; time_t when; int d,h,m,mul; chan = get_channel(to,&rest); mul = get_maxaccess(from); if (!*rest) { if (mul) to_user_q(from,"Who do you want me look for?"); return; } n = chop(&rest); if (!is_nick(n)) { if (mul) to_user_q(from,ERR_NICK,n); return; } if (!nickcmp(n,current->nick)) { fmt = "%s is me you dweeb!"; } else if (!nickcmp(n,from)) { fmt = "Trying to find yourself %s?"; } else { for(seen=seenlist;seen;seen=seen->next) { if (!Strcasecmp(n,seen->nick)) break; } if (!seen) { fmt = "I have no memory of %s"; } else { when = now - seen->when; d = when / 86400; h = (when -= d * 86400) / 3600; m = (when -= h * 3600) / 60; *ago = 0; c2 = ago; if (d) { sprintf(c2,"%i day%s, ",d,EXTRA_CHAR(d)); } if (h || d) { sprintf(ago,"%s%i hour%s and ",ago,h,EXTRA_CHAR(h)); } sprintf(ago,"%s%i minute%s",ago,m,EXTRA_CHAR(m)); n = seen->nick; u = seen->userhost; c1 = seen->pa; c2 = ago; switch(seen->t) { case SEEN_PARTED: fmt = "%s (%s) parted from %s, %s ago"; break; case SEEN_QUIT: fmt = "%s (%s) signed off with message \"%s\", %s ago"; break; case SEEN_NEWNICK: fmt = "%s (%s) changed nicks to %s, %s ago"; break; case SEEN_KICKED: c2 = seen->pb; c3 = ago; fmt = "%s (%s) was kicked by %s with message \"%s\", %s ago"; } } } to_user_q(from,fmt,n,u,c1,c2,c3); }
/* Insert a new character at current cursor position. */ static int Insert(AG_Editable *ed, AG_EditableBuffer *buf, AG_KeySym keysym, Uint keymod, Uint32 ch) { Uint32 ins[3]; int i, nIns; Uint32 uch = ch; if (keysym == 0) return (0); #ifdef __APPLE__ if ((keymod & AG_KEYMOD_LMETA) || (keymod & AG_KEYMOD_RMETA)) return (0); #endif if (!(ed->flags & AG_EDITABLE_NOLATIN1)) { for (i = 0; ; i++) { const struct ag_key_mapping *km = &agKeymapLATIN1[i]; if (keysym == km->key) { if (((keymod & AG_KEYMOD_ALT) && (keymod & AG_KEYMOD_SHIFT) && (km->modmask == (AG_KEYMOD_ALT|AG_KEYMOD_SHIFT)))) { uch = km->unicode; break; } else if (keymod & AG_KEYMOD_ALT && km->modmask == AG_KEYMOD_ALT) { uch = km->unicode; break; } } else if (km->key == AG_KEY_LAST) { break; } } } if (uch == 0) { return (0); } if (uch == '\r') { uch = '\n'; } if (Strcasecmp(ed->encoding, "US-ASCII") == 0 && !isascii((int)uch)) return (0); if (agTextComposition) { if ((nIns = AG_KeyInputCompose(ed, uch, ins)) == 0) return (0); } else { ins[0] = uch; nIns = 1; } ins[nIns] = '\0'; if (ed->sel != 0) { AG_EditableDelete(ed, buf); } if (AG_EditableGrowBuffer(ed, buf, ins, (size_t)nIns) == -1) { Verbose("Insert Failed: %s\n", AG_GetError()); return (0); } if (ed->pos == buf->len) { /* Append */ for (i = 0; i < nIns; i++) buf->s[buf->len + i] = ins[i]; } else { /* Insert */ memmove(&buf->s[ed->pos + nIns], &buf->s[ed->pos], (buf->len - ed->pos)*sizeof(Uint32)); for (i = 0; i < nIns; i++) buf->s[ed->pos + i] = ins[i]; } buf->len += nIns; buf->s[buf->len] = '\0'; ed->pos += nIns; if (!(ed->flags & AG_EDITABLE_MULTILINE)) { /* Optimize case */ int wIns; AG_TextSizeUCS4(ins, &wIns, NULL); ed->xScrollPx += wIns; } else { ed->xScrollTo = &ed->xCurs; ed->yScrollTo = &ed->yCurs; } ed->flags |= AG_EDITABLE_BLINK_ON; return (1); }
int read_bigcharset_callback(char *rest) { Strp *sp,**pp; char *opt; int *n,sz; if (charlines) { charlines--; sz = strlen(rest); if (sz > newchar->width) newchar->width = sz; pp = &newchar->data; while(*pp) pp = &(*pp)->next; set_mallocdoer(read_bigcharset_callback); *pp = sp = (Strp*)Calloc(sizeof(Strp) + sz); /* Calloc sets to zero sp->next = NULL; */ Strcpy(sp->p,rest); return(FALSE); } opt = chop(&rest); n = NULL; if (!Strcasecmp(opt,"chars") && charheight) { charlines = charheight; opt = chop(&rest); set_mallocdoer(read_bigcharset_callback); newchar = (BigC*)Calloc(sizeof(BigC) + strlen(opt)); /* Calloc sets to zero newchar->width = 0; newchar->data = NULL; */ newchar->next = fontlist; fontlist = newchar; Strcpy(newchar->chars,opt); } else if (!Strcasecmp(opt,"spacewidth")) { n = &spacewidth; } else if (!Strcasecmp(opt,"charheight")) { n = &charheight; } else if (!Strcasecmp(opt,"kerning")) { n = &kerning; } else if (!Strcasecmp(opt,"fontname")) { opt = chop(&rest); if (fontname && !Strcasecmp(fontname,opt)) { fontlist = orig_fontlist; charlines = orig_charlines; charheight = orig_charheight; spacewidth = orig_spacewidth; kerning = orig_kerning; orig_fontlist = NULL; return(TRUE); } Free((char**)&fontname); set_mallocdoer(read_bigcharset_callback); fontname = Strdup(opt); } if (n) { *n = a2i(rest); if (errno) *n = 0; } return(FALSE); }
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]); }
int insert_bookmark(char *bmark, struct parsed_tagarg *data) { char *url, *title, *section; FILE *f; TextList *tl = newTextList(); int section_found = 0; int bmark_added = 0; Str tmp, section_tmp; url = tag_get_value(data, "url"); title = tag_get_value(data, "title"); section = tag_get_value(data, "newsection"); if (section == NULL || *section == '\0') section = tag_get_value(data, "section"); if (section == NULL || *section == '\0') section = DEFAULT_SECTION; if (url == NULL || *url == '\0' || title == NULL || *title == '\0') { /* Bookmark not added */ return FALSE; } url = html_quote(url); title = html_quote(title); section = html_quote(section); f = fopen(bmark, "r"); if (f == NULL) return create_new_bookmark(bmark, section, title, url, "w"); section_tmp = Sprintf("<h2>%s</h2>\n", section); for (;;) { tmp = Strfgets(f); if (tmp->length == 0) break; if (Strcasecmp(tmp, section_tmp) == 0) section_found = 1; if (section_found && !bmark_added) { Strremovefirstspaces(tmp); if (Strcmp_charp(tmp, end_section) == 0) { pushText(tl, Sprintf("<li><a href=\"%s\">%s</a>\n", url, title)->ptr); bmark_added = 1; } } if (!bmark_added && Strcasecmp_charp(tmp, "</body>\n") == 0) { pushText(tl, Sprintf("<h2>%s</h2>\n<ul>\n", section)->ptr); pushText(tl, Sprintf("<li><a href=\"%s\">%s</a>\n", url, title)->ptr); pushText(tl, end_section); pushText(tl, "</ul>\n"); bmark_added = 1; } pushText(tl, tmp->ptr); } fclose(f); if (!bmark_added) { /* Bookmark not added; perhaps the bookmark file is ill-formed */ /* In this case, a new bookmark is appeneded after the bookmark file */ return create_new_bookmark(bmark, section, title, url, "a"); } f = fopen(bmark, "w"); while (tl->nitem) { fputs(popText(tl), f); } fclose(f); return TRUE; }