ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/ermyth/modules/gameserv/main.C
Revision: 1.4
Committed: Tue Aug 28 17:08:09 2007 UTC (19 years, 1 month ago) by pippijn
Content type: text/plain
Branch: MAIN
Changes since 1.3: +16 -18 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 pippijn 1.4 * Copyright © 2005 Atheme Development Group
3 pippijn 1.2 * Rights to this code are documented in doc/pod/license.pod.
4 pippijn 1.1 *
5     * This file contains the main() routine.
6     *
7 pippijn 1.4 * $Id: main.C,v 1.3 2007-07-21 13:23:20 pippijn Exp $
8 pippijn 1.1 */
9    
10     #include "atheme.h"
11 pippijn 1.4 #include <ermyth/module.h>
12 pippijn 1.1
13 pippijn 1.4 static char const rcsid[] = "$Id: main.C,v 1.3 2007-07-21 13:23:20 pippijn Exp $";
14 pippijn 1.1
15 pippijn 1.4 REGISTER_MODULE ("gameserv/main", false, "The Ermyth Team <http://ermyth.schmorp.de>");
16 pippijn 1.1
17 pippijn 1.4 static void on_config_ready (void);
18 pippijn 1.1
19     cmdvec gs_cmdtree;
20     helpvec gs_helptree;
21    
22     /* main services client routine */
23     static void
24     gameserv (sourceinfo_t *si, int parc, char *parv[])
25     {
26     char *cmd;
27     char *text;
28     char orig[BUFSIZE];
29    
30     /* this should never happen */
31     if (parv[0][0] == '&')
32     {
33     slog (LG_ERROR, "services(): got parv with local channel: %s", parv[0]);
34     return;
35     }
36    
37     /* make a copy of the original for debugging */
38     strlcpy (orig, parv[parc - 1], BUFSIZE);
39    
40     /* lets go through this to get the command */
41     cmd = strtok (parv[parc - 1], " ");
42     text = strtok (NULL, "");
43    
44     if (!cmd)
45     return;
46     if (*cmd == '\001')
47     {
48     handle_ctcp_common (si, cmd, text);
49     return;
50     }
51    
52     /* take the command through the hash table */
53 pippijn 1.4 command_exec_split (si->service, si, cmd, text, gs_cmdtree);
54 pippijn 1.1 }
55    
56     static void
57 pippijn 1.4 on_config_ready (void)
58 pippijn 1.1 {
59     if (gamesvs.me)
60     del_service (gamesvs.me);
61    
62     gamesvs.me = add_service (gamesvs.nick, gamesvs.user, gamesvs.host, gamesvs.real, gameserv, gs_cmdtree);
63     gamesvs.disp = gamesvs.me->disp;
64     }
65    
66 pippijn 1.4 bool
67     _modinit (module *m)
68 pippijn 1.1 {
69 pippijn 1.4 ConfTable::callback.ready.attach (on_config_ready);
70 pippijn 1.1
71     if (!cold_start)
72     {
73     gamesvs.me = add_service (gamesvs.nick, gamesvs.user, gamesvs.host, gamesvs.real, gameserv, gs_cmdtree);
74     gamesvs.disp = gamesvs.me->disp;
75     }
76 pippijn 1.4
77     return true;
78 pippijn 1.1 }
79    
80     void
81 pippijn 1.4 _moddeinit ()
82 pippijn 1.1 {
83     if (gamesvs.me)
84     {
85     del_service (gamesvs.me);
86     gamesvs.me = NULL;
87     }
88 pippijn 1.4
89     ConfTable::callback.ready.detach (on_config_ready);
90 pippijn 1.1 }