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