ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/ermyth/src/send.C
Revision: 1.4
Committed: Wed Jul 25 00:03:21 2007 UTC (19 years, 2 months ago) by pippijn
Content type: text/plain
Branch: MAIN
Changes since 1.3: +4 -1 lines
Log Message:
initial import

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