/[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.5 - (show annotations) (download) (as text)
Sun Nov 3 23:16:09 2002 UTC (16 years, 11 months ago) by stdarg
Branch: MAIN
CVS Tags: HEAD
Changes since 1.4: +0 -0 lines
File MIME type: text/x-chdr
FILE REMOVED
* Moved md5 code to lib/eggdrop so I can use it for password hashing
* Passwords are stored as standard hex encoding of md5(salt + password)
* Started moving script interface functions to modules/script

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

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23