ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/ermyth/src/send.C
Revision: 1.5
Committed: Tue Aug 28 17:08:12 2007 UTC (19 years, 1 month ago) by pippijn
Content type: text/plain
Branch: MAIN
Changes since 1.4: +4 -7 lines
Log Message:
- changed name
- updated the example config to the new system
- added more documentation
- enhanced documentation generators
- added a link to the pdf to the website
- added an RSS feed generator
- transitioned hooks to c++ callbacks
- did various merges with upstream along the way
- added const where appropriate
- removed the old block allocator
- fixed most memory leaks
- transitioned some dictionaries to std::map
- transitioned some lists to std::vector
- made some free functions members where appropriate
- renamed string to dynstr and added a static string ststr
- use NOW instead of time (NULL) if possible
- completely reworked database backends, crypto handlers and protocol handlers
  to use an object factory
- removed the old module system. ermyth does not do any dynamic loading anymore
- fixed most of the build system
- reworked how protocol commands work

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.5 static char const rcsid[] = "$Id: send.C,v 1.4 2007-07-25 00:03:21 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 pippijn 1.5 sts (char const * const fmt, ...)
17 pippijn 1.1 {
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 pippijn 1.5 NOW = time_t (now ());
72 pippijn 1.1
73     /* check for events */
74     delay = event_next_time ();
75    
76     if (delay <= NOW)
77     event_run ();
78    
79     connection_select (25000);
80     }
81     }