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

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

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


Revision 1.2 - (show annotations) (download) (as text)
Thu Oct 10 04:41:59 2002 UTC (16 years, 9 months ago) by stdarg
Branch: MAIN
Changes since 1.1: +26 -2 lines
File MIME type: text/x-chdr
* Moved bind tables to libeggdrop

1 #include "main.h"
2 #include <eggdrop/users.h>
3
4 static char *script_uid_to_handle(int uid)
5 {
6 user_t *u;
7
8 u = user_lookup_by_uid(uid);
9 if (u) return(u->handle);
10 return(NULL);
11 }
12
13 static int script_handle_to_uid(char *handle)
14 {
15 user_t *u;
16
17 u = user_lookup_by_handle(handle);
18 if (u) return(u->uid);
19 return(0);
20 }
21
22 static int script_validhandle(char *handle)
23 {
24 if (user_lookup_by_handle(handle)) return(1);
25 return(0);
26 }
27
28 static int script_validuid(int uid)
29 {
30 if (user_lookup_by_uid(uid)) return(1);
31 return(0);
32 }
33
34 static int script_adduser(char *handle)
35 {
36 user_t *u;
37
38 u = user_new(handle);
39 if (!u) return(-1);
40 return(0);
41 }
42
43 static int script_user_addmask(int uid, char *ircmask)
44 {
45 user_t *u = user_lookup_by_uid(uid);
46 if (!u) return(-1);
47 user_add_ircmask(u, ircmask);
48 return(0);
49 }
50
51 static char *script_user_find(char *irchost)
52 {
53 user_t *u;
54
55 u = user_lookup_by_irchost_nocache(irchost);
56 if (u) return(u->handle);
57 return(NULL);
58 }
59
60 static char *script_user_get(int nargs, int uid, char *chan, char *setting)
61 {
62 char *value;
63 user_t *u;
64
65 /* If there's a missing arg, it's the channel. */
66 if (nargs == 2) {
67 setting = chan;
68 chan = NULL;
69 }
70
71 u = user_lookup_by_uid(uid);
72 if (!u) return(NULL);
73
74 user_get_setting(u, chan, setting, &value);
75 return(value);
76 }
77
78 static int script_user_set(int nargs, int uid, char *chan, char *setting, char *value)
79 {
80 int i;
81 user_t *u;
82
83 /* If there's a missing arg, it's the channel. */
84 if (nargs == 3) {
85 value = setting;
86 setting = chan;
87 chan = NULL;
88 }
89
90 u = user_lookup_by_uid(uid);
91 if (!u) return(-1);
92 i = user_set_setting(u, chan, setting, value);
93 return(i);
94 }
95
96 static int script_user_save(char *fname)
97 {
98 if (!fname) fname = "_users.xml";
99 user_save(fname);
100 return(0);
101 }
102
103 static int script_setflags(int uid, char *chan, char *flags)
104 {
105 user_t *u;
106
107 u = user_lookup_by_uid(uid);
108 if (!u) return(-1);
109
110 if (!flags) {
111 flags = chan;
112 chan = NULL;
113 }
114
115 //user_setflags(u, chan, flags);
116 return(0);
117 }
118
119 static char *script_getflags(int uid, char *chan)
120 {
121 user_t *u;
122
123 u = user_lookup_by_uid(uid);
124 if (!u) return(-1);
125 }
126
127 script_command_t script_new_user_cmds[] = {
128 {"", "user_uid_to_handle", script_uid_to_handle, NULL, 1, "i", "uid", SCRIPT_STRING, 0},
129 {"", "user_handle_to_uid", script_handle_to_uid, NULL, 1, "s", "handle", SCRIPT_INTEGER, 0},
130 {"", "user_validhandle", script_validhandle, NULL, 1, "s", "handle", SCRIPT_INTEGER, 0},
131 {"", "user_validuid", script_validuid, NULL, 1, "i", "uid", SCRIPT_INTEGER, 0},
132 {"", "user_add", script_adduser, NULL, 1, "s", "handle", SCRIPT_INTEGER, 0},
133 {"", "user_addmask", script_user_addmask, NULL, 2, "is", "uid ircmask", SCRIPT_INTEGER, 0},
134 {"", "user_find", script_user_find, NULL, 1, "s", "irchost", SCRIPT_STRING, 0},
135 {"", "user_get", script_user_get, NULL, 2, "iss", "uid ?channel? setting", SCRIPT_STRING, SCRIPT_VAR_ARGS | SCRIPT_PASS_COUNT},
136 {"", "user_set", script_user_set, NULL, 3, "isss", "uid ?channel? setting value", SCRIPT_INTEGER, SCRIPT_VAR_ARGS | SCRIPT_PASS_COUNT},
137 {"", "user_save", script_user_save, NULL, 0, "s", "?fname?", SCRIPT_INTEGER, SCRIPT_VAR_ARGS},
138 {0}
139 };

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23