/* * send.C: Socket I/O. * 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.4 2007/07/25 00:03:21 pippijn Exp $"; #include "atheme.h" #include "uplink.h" #include "datastream.h" /* send a line to the server, append the \r\n */ int sts (char *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 (NULL); /* check for events */ delay = event_next_time (); if (delay <= NOW) event_run (); connection_select (25000); // garbage collection gc::cleanup (); } }