/* * send.C: Socket I/O. * * Copyright © 2007 Pippijn van Steenhoven / The Ermyth Team * Rights to this code are as documented in COPYING. * * * Portions of this file were derived from sources bearing the following license: * Rights to this code are documented in doc/pod/license.pod. * Copyright © 2005-2007 Atheme Project (http://www.atheme.org) */ static char const rcsid[] = "$Id: send.C,v 1.9 2007/09/22 14:27:30 pippijn Exp $"; #include "atheme.h" #include #include #include "uplink.h" #include "datastream.h" #include "connection.h" /* send a line to the server, append the \r\n */ int sts (char const * const fmt, ...) { va_list ap; char buf[513]; int len; return_val_if_fail (fmt != NULL, 1); va_start (ap, fmt); vsnprintf (buf, 511, fmt, ap); /* leave two bytes for \r\n */ va_end (ap); slog (LG_RAWDATA, "<- %s", buf); len = strlen (buf); buf[len++] = '\r'; buf[len++] = '\n'; buf[len] = '\0'; cnt.bout += len; sendq_add (curr_uplink->conn, buf, len); return 0; } void reconn (void *arg) { if (me.connected) return; uplink_connect (); } /* * io_loop() * * inputs: * none * * outputs: * none * * side effects: * everything happens inside this loop. */ void io_loop (void) { time_t delay; while (!(runflags & (RF_SHUTDOWN | RF_RESTART))) { /* update the current time */ NOW = time_t (now ()); /* check for events */ delay = event_next_time (); if (delay <= NOW) event_run (); connection_t::select (25000); gc.collect (); } }