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

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

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


Revision 1.63 - (show annotations) (download) (as text)
Tue Feb 25 06:52:19 2003 UTC (16 years, 3 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 /*
2 * tclmisc.c --
3 *
4 * Tcl stubs for everything else
5 */
6 /*
7 * Copyright (C) 1997 Robey Pointer
8 * Copyright (C) 1999, 2000, 2001, 2002, 2003 Eggheads Development Team
9 *
10 * 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 *
15 * 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 *
20 * 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 */
24
25 #ifndef lint
26 static const char rcsid[] = "$Id: tclmisc.c,v 1.62 2003/02/14 20:55:02 stdarg Exp $";
27 #endif
28
29 #include "main.h"
30 #include "modules.h"
31 #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 #include "core_binds.h"
43 #include "logfile.h"
44 #include "misc.h"
45 #include "dccutil.h" /* add_note */
46 #include "net.h" /* getmyip */
47 #include "users.h" /* get_user_by_nick, get_user_by_handle */
48 #ifdef HAVE_UNAME
49 #include <sys/utsname.h>
50 #endif
51
52 extern struct dcc_t *dcc;
53 extern char quit_msg[];
54 extern struct userrec *userlist;
55 extern time_t now;
56 extern module_entry *module_list;
57 extern int dcc_total;
58
59 static unsigned int script_myip()
60 {
61 return iptolong(getmyip());
62 }
63
64 static char *script_myip6()
65 {
66 #ifdef IPV6
67 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 #else
78 /* Empty string if there's no IPv6 support. */
79 return(strdup(""));
80 #endif
81 }
82
83 static int script_sendnote(char *from, char *to, char *msg)
84 {
85 char trunc_from[NOTENAMELEN + 1], trunc_to[NOTENAMELEN + 1], trunc_msg[451];
86
87 strlcpy(trunc_from, from, sizeof(trunc_from));
88 strlcpy(trunc_to, to, sizeof(trunc_to));
89 strlcpy(trunc_msg, msg, sizeof(trunc_msg));
90 return add_note(trunc_to, trunc_from, trunc_msg, -1, 0);
91 }
92
93 static int script_modules(script_var_t *retval)
94 {
95 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 version = script_dynamic_string(msprintf("%d.%d", current->major, current->minor), -1);
104 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 depver = script_copy_string(msprintf("%d.%d", dep->needed->major, dep->needed->minor), -1);
110
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 }
118
119 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 static int script_loadhelp(char *helpfile)
132 {
133 add_help_reference(helpfile);
134 return(0);
135 }
136
137 static int script_unloadhelp(char *helpfile)
138 {
139 rem_help_reference(helpfile);
140 return(0);
141 }
142
143 static int script_reloadhelp()
144 {
145 reload_help_data();
146 return(0);
147 }
148
149 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 {"", "modules", (Function) script_modules, NULL, 0, "", "", 0, SCRIPT_PASS_RETVAL},
154 {"", "loadmodule", script_loadmod, NULL, 1, "s", "module", SCRIPT_INTEGER, 0},
155 {"", "unloadmodule", script_loadmod, NULL, 1, "s", "module", SCRIPT_INTEGER, 0},
156 {"", "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 {0}
160 };

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23