/* ** send_queued_write ** This is called when there is a chance that some output would ** be possible. This attempts to empty the send queue as far as ** possible, and then if any data is left, a write is rescheduled. */ void send_queued_write(struct Client *to) { int retlen; #ifndef NDEBUG struct hook_io_data hdata; #endif struct dbuf_block *first; /* ** Once socket is marked dead, we cannot start writing to it, ** even if the error is removed... */ if (IsDead(to) || IsSendqBlocked(to)) return; /* no use calling send() now */ /* Next, lets try to write some data */ if (dbuf_length(&to->localClient->buf_sendq)) { #ifndef NDEBUG hdata.connection = to; #endif do { first = to->localClient->buf_sendq.blocks.head->data; #ifdef HAVE_LIBCRYPTO if(IsSSL(to)) { retlen = safe_SSL_write(to, first->data, first->size); printf("safe_ssl_write: writing: %s\n", first->data); printf("safe_ssl_write: %d written\n", retlen); if (retlen <= 0) break; } else #endif if ((retlen = send(to->localClient->fd, first->data, first->size, 0)) <= 0) break; #ifndef NDEBUG hdata.data = ((struct dbuf_block *) to->localClient->buf_sendq.blocks.head->data)->data; hdata.len = retlen; hook_call_event("iosend", &hdata); #endif dbuf_delete(&to->localClient->buf_sendq, retlen); /* We have some data written .. update counters */ to->localClient->sendB += retlen; me.localClient->sendB += retlen; if (to->localClient->sendB > 1023) { to->localClient->sendK += (to->localClient->sendB >> 10); to->localClient->sendB &= 0x03ff; /* 2^10 = 1024, 3ff = 1023 */ } else if (me.localClient->sendB > 1023) { me.localClient->sendK += (me.localClient->sendB >> 10); me.localClient->sendB &= 0x03ff; }
/* admin_spy() * * input - pointer to client * output - none * side effects - event doing_admin is called */ static void admin_spy(struct Client *source_p) { struct hook_spy_data data; data.source_p = source_p; hook_call_event("doing_admin", &data); }
/* motd_spy() * * input - pointer to client * output - none * side effects - hook doing_motd is called */ static void motd_spy(struct Client *source_p) { struct hook_spy_data data; data.source_p = source_p; hook_call_event(doing_motd_hook, &data); }
static void cs_cmd_drop(char *origin) { user_t *u = user_find_named(origin); mychan_t *mc; char *name = strtok(NULL, " "); if (!name) { notice(chansvs.nick, origin, STR_INSUFFICIENT_PARAMS, "DROP"); notice(chansvs.nick, origin, "Syntax: DROP <#channel>"); return; } if (*name != '#') { notice(chansvs.nick, origin, STR_INVALID_PARAMS, "DROP"); notice(chansvs.nick, origin, "Syntax: DROP <#channel>"); return; } if (!(mc = mychan_find(name))) { notice(chansvs.nick, origin, "\2%s\2 is not registered.", name); return; } if (!is_founder(mc, u->myuser) && !has_priv(u, PRIV_CHAN_ADMIN)) { notice(chansvs.nick, origin, "You are not authorized to perform this operation."); return; } if (metadata_find(mc, METADATA_CHANNEL, "private:close:closer") && !has_priv(u, PRIV_CHAN_ADMIN)) { logcommand(chansvs.me, u, CMDLOG_REGISTER, "%s failed DROP (closed)", mc->name); notice(chansvs.nick, origin, "The channel \2%s\2 is closed; it cannot be dropped.", mc->name); return; } if (!is_founder(mc, u->myuser)) { logcommand(chansvs.me, u, CMDLOG_ADMIN, "%s DROP", mc->name); wallops("%s dropped the channel \2%s\2", origin, name); } else logcommand(chansvs.me, u, CMDLOG_REGISTER, "%s DROP", mc->name); snoop("DROP: \2%s\2 by \2%s\2 as \2%s\2", mc->name, u->nick, u->myuser->name); hook_call_event("channel_drop", mc); if ((config_options.chan && irccasecmp(mc->name, config_options.chan)) || !config_options.chan) part(mc->name, chansvs.nick); mychan_delete(mc->name); notice(chansvs.nick, origin, "The channel \2%s\2 has been dropped.", name); return; }
static void mo_links(struct Client *client_p, struct Client *source_p, int parc, char *parv[]) { char* mask = ""; struct Client* target_p; char clean_mask[2 * HOSTLEN + 4]; char* p; struct hook_links_data hd; dlink_node *ptr; if (parc > 2) { if (hunt_server(client_p, source_p, ":%s LINKS %s :%s", 1, parc, parv) != HUNTED_ISME) return; mask = parv[2]; } else if (parc == 2) mask = parv[1]; assert(0 != mask); if (*mask) /* only necessary if there is a mask */ mask = collapse(clean_string(clean_mask, (const unsigned char*) mask, 2 * HOSTLEN)); hd.client_p = client_p; hd.source_p = source_p; hd.mask = mask; hd.parc = parc; hd.parv = parv; hook_call_event("doing_links", &hd); for (ptr = global_serv_list.head; ptr; ptr = ptr->next) { target_p = ptr->data; if (*mask && !match(mask, target_p->name)) continue; if(target_p->info[0]) { if( (p = strchr(target_p->info,']')) ) p += 2; /* skip the nasty [IP] part */ else p = target_p->info; } else p = "(Unknown Location)"; /* We just send the reply, as if theyre here theres either no SHIDE, * or theyre an oper.. */ sendto_one(source_p, form_str(RPL_LINKS), me.name, parv[0], target_p->name, target_p->serv->up, target_p->hopcount, p); } sendto_one(source_p, form_str(RPL_ENDOFLINKS), me.name, parv[0], EmptyString(mask) ? "*" : mask); }