| 1 |
pippijn |
1.1 |
/* |
| 2 |
|
|
* 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.2 |
* $Id: main.C,v 1.1 2007-07-19 08:24:53 pippijn Exp $ |
| 8 |
pippijn |
1.1 |
*/ |
| 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 |
pippijn |
1.2 |
DECLARE_MODULE_V1 ("gameserv/main", false, _modinit, _moddeinit, "$Id: main.C,v 1.1 2007-07-19 08:24:53 pippijn Exp $", "The Ermyth Team <http://ermyth.schmorp.de>"); |
| 21 |
pippijn |
1.1 |
|
| 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 |
|
|
} |