ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/ermyth/src/send.C
Revision: 1.1
Committed: Thu Jul 19 08:24:59 2007 UTC (19 years, 3 months ago) by pippijn
Content type: text/plain
Branch: MAIN
Log Message:
initial import. the most important changes since Atheme are:
- fixed many memory leaks
- fixed many bugs
- converted to C++ and use more STL containers
- added a (not very enhanced yet) perl module
- greatly improved XML-RPC speed
- added a JSON-RPC module with code from json-cpp
- added a valgrind memcheck module to operserv
- added a more object oriented base64 implementation
- added a specialised unit test framework
- improved stability
- use gettimeofday() if available
- reworked adding/removing commands
- MemoServ IGNORE DEL can now remove indices

File Contents

# User Rev Content
1 pippijn 1.1 /*
2     * send.C: Socket I/O.
3     * Rights to this code are documented in doc/LICENSE.
4     *
5     * Copyright © 2005-2007 Atheme Project (http://www.atheme.org)
6     */
7    
8     static char const rcsid[] = "$Id";
9    
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     }
81     }