void server_apply_mode(struct entity *from, struct entity *target, char *modechanges, struct manyargs *arg, int skip) { if (!verify_server(target)) { logtxt(LOG_WARNING, "Mode change on non-channel"); return; } mode_apply(from, target, &((struct server *)target)->mode, modechanges, arg, skip, server_modehook); }
int jtableP_unset(jtableP *table, void *key) { int ret; J1U(ret, table->t, (Word_t)key); if (!ret) logtxt(LOG_DEBUG, "Deletion of non-existant element in jtableP"); return ret; }
int jtableP_set(jtableP *table, void *key) { int ret; J1S(ret, table->t, (Word_t)key); if (!ret) logtxt(LOG_DEBUG, "Duplicate insert into jtableP"); return ret; }
bool TableReader::OutputError(const char* filename) { ofstream logtxt(filename, ios::out); vector<TBL_ERROR>::iterator it; for(it = TableErrors.begin();it!=TableErrors.end();it++) logtxt<<"line"<<it->LineNumber<<":"<<it->Description<<"\n"; logtxt.close(); }
void net_read(void) { static char buf[65536] = { 0 }; ssize_t oldlen, r; char *line, *lineend; struct timeval tv = { 1, 0 }; fd_set fds; FD_ZERO(&fds); FD_SET(conn, &fds); oldlen = strlen(buf); logfmt(LOG_DEBUGIO, "---- Old (%d): '%s' ----\n", oldlen, buf); logtxt(LOG_DEBUGIO, "Reading/Waiting..."); r = select(conn+1, &fds, NULL, NULL, &tv); if (r <= 0) { if (r < 0) POSIXERR("select() error"); return; } r = read(conn, buf+oldlen, sizeof(buf)-oldlen-1); /* account for \0 we add later */ logfmt(LOG_DEBUGIO, "%d bytes...\n", r); if (r == 0) { error("EOF"); return; } buf[oldlen+r] = '\0'; logfmt(LOG_DEBUGIO, "---- New (%d) buf[%d] ----\n", r, oldlen+r); logfmt(LOG_DEBUGIO, "%s\n", buf+oldlen); logtxt(LOG_DEBUGIO, "------------------\n"); line = buf; while (*line && (lineend = strpbrk(line, "\r\n"))) { while (*lineend == '\r' || *lineend == '\n') *lineend++ = '\0'; logfmt(LOG_RAW, "<- %s\n", line); handle_input(line); logfmt(LOG_DEBUGIO, "line = buf[%td], lineend = buf[%td]\n", line-buf, lineend-buf); logfmt(LOG_DEBUGIO, "line = '%s', lineend = '%s'\n", line, lineend); line = lineend; } logfmt(LOG_DEBUGIO, "---- NewOld (%zd): '%s' '%2X %2X %2X'----\n", strlen(line), line, (unsigned char)line[strlen(line)-3], (unsigned char)line[strlen(line)-2], (unsigned char)line[strlen(line)-1]); memmove(buf, line, strlen(line)+1); }
void hJOIN(struct user *from, struct channel *chan, time_t *ts) { VERIFY_USER(from); if (verify_channel0(chan)) { chanusers_join0(from); return; } VERIFY_CHANNEL(chan); if (!ts) ts = &chan->ts; else if (chan->ts != *ts) logtxt(LOG_WARNING, "JOIN with wrong channel ts."); chanusers_join(from, chan); }
static int server_modehook(struct entity *from, struct entity *target, int pls, char modechange, char *param) { struct server *s; s = (struct server *)target; if (!verify_server(s)) { logtxt(LOG_ERROR, "Mode change for not-a-server!"); return MODEHOOK_ERROR; } /* only uplink modes relevant for now */ if (s != uplink) return MODEHOOK_OK; if (modechange == 'n') pls ? uplink_with_opername() : uplink_without_opername(); return MODEHOOK_OK; }
void hBURST(struct server *from, char *chan, time_t *ts, struct manyargs *rest) { struct manyargs list; struct channel *c; struct user *u; char *tmp, *burstmode = ""; int nextpos, i; VERIFY_SERVER(from); if (from->protocol[0] == 'P') { logtxt(LOG_ERROR, "BURST after END_OF_BURST!"); return; } c = get_channel_by_name(chan); if (!c) c = add_channel(chan, *ts); if (!rest->c) return; /* handle modes if present */ nextpos = 0; tmp = rest->v[nextpos]; if (tmp && tmp[0] == '+') nextpos = 1 + channel_apply_mode((struct entity *)from, c, rest->v[0], rest, 1); /* rest->v[nextpos] is now the next parameter after the modes */ /* check the last parameter for leading % */ tmp = rest->v[nextpos]; if (rest->c - 1 > nextpos) tmp = rest->v[rest->c - 1]; if (tmp && tmp[0] == '%') { split(&list, rest->v[rest->c - 1] + 1, ' '); for (i = 0; i < list.c; i++) channel_plsban(c, NULL, list.v[i]); rest->c--; } /* no channel users */ if (!tmp) return; assert(nextpos+1 == rest->c); split(&list, rest->v[nextpos], ','); /* all that's left from rest->v[i .. rest->c] are user entries with tmps */ for (i = 0; i < list.c; i++) { tmp = list.v[i]; if ((tmp = strchr(tmp, ':'))) { *tmp++ = '\0'; burstmode = tmp; } u = get_user_by_numericstr(list.v[i]); if (!u) { logtxt(LOG_WARNING, "Burst join for non-existant user."); continue; } chanusers_join(u, c); channel_burstmode(c, u, burstmode); } }