/[cvs]/eggdrop1.9/src/tclmisc.c
ViewVC logotype

Annotation of /eggdrop1.9/src/tclmisc.c

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.63 - (hide annotations) (download) (as text)
Tue Feb 25 06:52:19 2003 UTC (16 years, 8 months ago) by stdarg
Branch: MAIN
CVS Tags: HEAD
Changes since 1.62: +1 -1 lines
File MIME type: text/x-chdr
FILE REMOVED
* Well, I think Tcl is finally removed from the core (except for detection/configuration).

1 guppy 1.18 /*
2 tothwolf 1.53 * tclmisc.c --
3 guppy 1.18 *
4 tothwolf 1.53 * Tcl stubs for everything else
5 segfault 1.1 */
6 guppy 1.18 /*
7     * Copyright (C) 1997 Robey Pointer
8 wcc 1.58 * Copyright (C) 1999, 2000, 2001, 2002, 2003 Eggheads Development Team
9 guppy 1.18 *
10 fabian 1.5 * This program is free software; you can redistribute it and/or
11     * modify it under the terms of the GNU General Public License
12     * as published by the Free Software Foundation; either version 2
13     * of the License, or (at your option) any later version.
14 guppy 1.18 *
15 fabian 1.5 * This program is distributed in the hope that it will be useful,
16     * but WITHOUT ANY WARRANTY; without even the implied warranty of
17     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18     * GNU General Public License for more details.
19 guppy 1.18 *
20 fabian 1.5 * You should have received a copy of the GNU General Public License
21     * along with this program; if not, write to the Free Software
22     * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 segfault 1.1 */
24 tothwolf 1.53
25     #ifndef lint
26 stdarg 1.63 static const char rcsid[] = "$Id: tclmisc.c,v 1.62 2003/02/14 20:55:02 stdarg Exp $";
27 tothwolf 1.53 #endif
28 segfault 1.1
29     #include "main.h"
30     #include "modules.h"
31 wcc 1.60 #ifdef TIME_WITH_SYS_TIME
32     # include <sys/time.h>
33     # include <time.h>
34     #else
35     # ifdef HAVE_SYS_TIME_H
36     # include <sys/time.h>
37     # else
38     # include <time.h>
39     # endif
40     #endif
41     #include <sys/stat.h>
42 ite 1.37 #include "core_binds.h"
43 ite 1.41 #include "logfile.h"
44     #include "misc.h"
45 stdarg 1.56 #include "dccutil.h" /* add_note */
46 wingman 1.52 #include "net.h" /* getmyip */
47     #include "users.h" /* get_user_by_nick, get_user_by_handle */
48 segfault 1.1 #ifdef HAVE_UNAME
49     #include <sys/utsname.h>
50     #endif
51    
52 fabian 1.10 extern struct dcc_t *dcc;
53 stdarg 1.62 extern char quit_msg[];
54 fabian 1.10 extern struct userrec *userlist;
55     extern time_t now;
56     extern module_entry *module_list;
57 stdarg 1.39 extern int dcc_total;
58 segfault 1.1
59 stdarg 1.39 static unsigned int script_myip()
60 segfault 1.1 {
61 stdarg 1.39 return iptolong(getmyip());
62 segfault 1.1 }
63    
64 stdarg 1.39 static char *script_myip6()
65 drummer 1.23 {
66     #ifdef IPV6
67 stdarg 1.39 struct in6_addr ip;
68     char buf[512], *ptr;
69    
70     ip = getmyip6();
71     ptr = (char *)inet_ntop(AF_INET6, &ip, buf, sizeof(buf));
72     if (!ptr) {
73     /* Error with conversion -- return "". */
74     buf[0] = 0;
75     }
76     return(strdup(buf));
77 drummer 1.23 #else
78 stdarg 1.39 /* Empty string if there's no IPv6 support. */
79     return(strdup(""));
80 drummer 1.23 #endif
81     }
82    
83 stdarg 1.39 static int script_sendnote(char *from, char *to, char *msg)
84 fabian 1.13 {
85 stdarg 1.39 char trunc_from[NOTENAMELEN + 1], trunc_to[NOTENAMELEN + 1], trunc_msg[451];
86 segfault 1.1
87 ite 1.47 strlcpy(trunc_from, from, sizeof(trunc_from));
88     strlcpy(trunc_to, to, sizeof(trunc_to));
89     strlcpy(trunc_msg, msg, sizeof(trunc_msg));
90 stdarg 1.39 return add_note(trunc_to, trunc_from, trunc_msg, -1, 0);
91 segfault 1.1 }
92    
93 stdarg 1.45 static int script_modules(script_var_t *retval)
94 segfault 1.1 {
95 stdarg 1.45 module_entry *current;
96     dependancy *dep;
97     script_var_t *name, *version, *entry, *deplist;
98    
99     retval->type = SCRIPT_ARRAY | SCRIPT_FREE | SCRIPT_VAR;
100    
101     for (current = module_list; current; current = current->next) {
102     name = script_string(current->name, -1);
103 stdarg 1.50 version = script_dynamic_string(msprintf("%d.%d", current->major, current->minor), -1);
104 stdarg 1.45 deplist = script_list(0);
105     for (dep = dependancy_list; dep; dep = dep->next) {
106     script_var_t *depname, *depver;
107    
108     depname = script_string(dep->needed->name, -1);
109 stdarg 1.50 depver = script_copy_string(msprintf("%d.%d", dep->needed->major, dep->needed->minor), -1);
110 stdarg 1.45
111     script_list_append(deplist, script_list(2, depname, depver));
112     }
113     entry = script_list(3, name, version, deplist);
114     script_list_append(retval, entry);
115     }
116     return(0);
117 segfault 1.1 }
118    
119 stdarg 1.62 static int script_loadmod(char *modname)
120     {
121     module_load(modname);
122     return(0);
123     }
124    
125     static int script_unloadmod(char *modname)
126     {
127     module_unload(modname, NULL);
128     return(0);
129     }
130    
131 stdarg 1.45 static int script_loadhelp(char *helpfile)
132 segfault 1.1 {
133 stdarg 1.45 add_help_reference(helpfile);
134     return(0);
135 segfault 1.1 }
136    
137 stdarg 1.45 static int script_unloadhelp(char *helpfile)
138 segfault 1.1 {
139 stdarg 1.45 rem_help_reference(helpfile);
140     return(0);
141 segfault 1.1 }
142    
143 stdarg 1.45 static int script_reloadhelp()
144 segfault 1.1 {
145     reload_help_data();
146 stdarg 1.45 return(0);
147 segfault 1.1 }
148    
149 stdarg 1.39 script_command_t script_misc_cmds[] = {
150     {"", "myip", (Function) script_myip, NULL, 0, "", "", SCRIPT_UNSIGNED, 0},
151     {"", "myip6", (Function) script_myip6, NULL, 0, "", "", SCRIPT_STRING|SCRIPT_FREE, 0},
152     {"", "sendnote", (Function) script_sendnote, NULL, 3, "sss", "from to msg", SCRIPT_INTEGER, 0},
153 stdarg 1.45 {"", "modules", (Function) script_modules, NULL, 0, "", "", 0, SCRIPT_PASS_RETVAL},
154 stdarg 1.62 {"", "loadmodule", script_loadmod, NULL, 1, "s", "module", SCRIPT_INTEGER, 0},
155     {"", "unloadmodule", script_loadmod, NULL, 1, "s", "module", SCRIPT_INTEGER, 0},
156 stdarg 1.45 {"", "loadhelp", (Function) script_loadhelp, NULL, 1, "s", "filename", SCRIPT_INTEGER, 0},
157     {"", "unloadhelp", (Function) script_unloadhelp, NULL, 1, "s", "filename", SCRIPT_INTEGER, 0},
158     {"", "reloadhelp", (Function) script_reloadhelp, NULL, 0, "", "", SCRIPT_INTEGER, 0},
159 stdarg 1.39 {0}
160 segfault 1.1 };

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23