ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/ermyth/src/send.C
Revision: 1.8
Committed: Sun Sep 16 18:54:45 2007 UTC (19 years, 1 month ago) by pippijn
Content type: text/plain
Branch: MAIN
Changes since 1.7: +7 -2 lines
Log Message:
#defines to enum

File Contents

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