ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/ermyth/src/send.C
Revision: 1.7
Committed: Thu Aug 30 19:56:26 2007 UTC (16 years, 9 months ago) by pippijn
Content type: text/plain
Branch: MAIN
Changes since 1.6: +3 -2 lines
Log Message:
- put faultcodes into their own namespace
- removed old files
- limited header garbage in atheme.h
- macros to inline bools for connection_t::is_*
- put some connection_t functions into the connection_t class

File Contents

# User Rev Content
1 pippijn 1.1 /*
2     * send.C: Socket I/O.
3 pippijn 1.2 * Rights to this code are documented in doc/pod/license.pod.
4 pippijn 1.1 *
5 pippijn 1.5 * Copyright © 2005-2007 Atheme Project (http://www.atheme.org)
6 pippijn 1.1 */
7    
8 pippijn 1.7 static char const rcsid[] = "$Id: send.C,v 1.6 2007-08-29 21:01:19 pippijn Exp $";
9 pippijn 1.1
10     #include "atheme.h"
11     #include "uplink.h"
12     #include "datastream.h"
13 pippijn 1.7 #include "connection.h"
14 pippijn 1.1
15     /* send a line to the server, append the \r\n */
16     int
17 pippijn 1.5 sts (char const * const fmt, ...)
18 pippijn 1.1 {
19     va_list ap;
20     char buf[513];
21     int len;
22    
23     return_val_if_fail (fmt != NULL, 1);
24    
25     va_start (ap, fmt);
26     vsnprintf (buf, 511, fmt, ap); /* leave two bytes for \r\n */
27     va_end (ap);
28    
29     slog (LG_RAWDATA, "<- %s", buf);
30    
31     len = strlen (buf);
32     buf[len++] = '\r';
33     buf[len++] = '\n';
34     buf[len] = '\0';
35    
36     cnt.bout += len;
37    
38     sendq_add (curr_uplink->conn, buf, len);
39    
40     return 0;
41     }
42    
43     void
44     reconn (void *arg)
45     {
46     if (me.connected)
47     return;
48    
49     uplink_connect ();
50     }
51    
52     /*
53     * io_loop()
54     *
55     * inputs:
56     * none
57     *
58     * outputs:
59     * none
60     *
61     * side effects:
62     * everything happens inside this loop.
63     */
64     void
65     io_loop (void)
66     {
67     time_t delay;
68    
69     while (!(runflags & (RF_SHUTDOWN | RF_RESTART)))
70     {
71     /* update the current time */
72 pippijn 1.5 NOW = time_t (now ());
73 pippijn 1.1
74     /* check for events */
75     delay = event_next_time ();
76    
77     if (delay <= NOW)
78     event_run ();
79    
80 pippijn 1.7 connection_t::select (25000);
81 pippijn 1.6
82     gc.collect ();
83 pippijn 1.1 }
84     }