#include <eggdrop/eggdrop.h>
#include "egg_script_internal.h"
Go to the source code of this file.
Functions | |
static char * | script_uid_to_handle (int uid) |
static int | script_handle_to_uid (user_t *u) |
static int | script_validhandle (char *handle) |
static int | script_validuid (int uid) |
static int | script_adduser (char *handle) |
static int | script_get_ircmasks (script_var_t *retval, user_t *u) |
static char * | script_user_find (char *irchost) |
static char * | script_user_get (int nargs, user_t *u, char *chan, char *setting) |
static int | script_user_set (int nargs, user_t *u, char *chan, char *setting, char *value) |
static int | script_user_save (char *fname) |
static int | script_setflags (user_t *u, char *chan, char *flags) |
static char * | script_getflags (user_t *u, char *chan) |
static int | script_matchflags (void *client_data, user_t *u, char *chan, char *flagstr) |
Variables | |
static const char | rcsid [] = "$Id: scriptuser.c,v 1.13 2008-10-17 15:57:43 sven Exp $" |
script_command_t | script_new_user_cmds [] |
static int script_adduser | ( | char * | handle | ) | [static] |
Definition at line 54 of file scriptuser.c.
References user_new().
00055 { 00056 user_t *u; 00057 00058 u = user_new(handle); 00059 if (!u) return(-1); 00060 return(0); 00061 }
static int script_get_ircmasks | ( | script_var_t * | retval, | |
user_t * | u | |||
) | [static] |
Definition at line 63 of file scriptuser.c.
References user::ircmasks, script_var_b::len, user::nircmasks, SCRIPT_ARRAY, SCRIPT_STRING, script_var_b::type, and script_var_b::value.
00064 { 00065 retval->type = SCRIPT_ARRAY | SCRIPT_STRING; 00066 retval->len = u->nircmasks; 00067 retval->value = u->ircmasks; 00068 return(0); 00069 }
static char* script_getflags | ( | user_t * | u, | |
char * | chan | |||
) | [static] |
Definition at line 127 of file scriptuser.c.
References flag_to_str(), NULL, and user_get_flags().
00128 { 00129 flags_t flags; 00130 char flagstr[64]; 00131 00132 if (user_get_flags(u, chan, &flags)) return(NULL); 00133 flag_to_str(&flags, flagstr); 00134 return strdup(flagstr); 00135 }
static int script_handle_to_uid | ( | user_t * | u | ) | [static] |
Definition at line 36 of file scriptuser.c.
References user::uid.
00037 { 00038 if (u) return(u->uid); 00039 return(0); 00040 }
static int script_matchflags | ( | void * | client_data, | |
user_t * | u, | |||
char * | chan, | |||
char * | flagstr | |||
) | [static] |
Definition at line 137 of file scriptuser.c.
References flag_from_str(), flag_match_partial(), flag_match_subset(), NULL, and user_get_flags().
00138 { 00139 flags_t flags_left, flags_right; 00140 int r = 0; 00141 00142 if (!flagstr) { 00143 flagstr = chan; 00144 chan = NULL; 00145 } 00146 if (user_get_flags(u, chan, &flags_right)) return(0); 00147 flag_from_str(&flags_left, flagstr); 00148 00149 switch ((int)client_data) { 00150 case 0: 00151 /* Are all bits on in left also on in right? */ 00152 r = flag_match_subset(&flags_left, &flags_right); 00153 break; 00154 case 1: 00155 /* Is at least one bit on in the left also on in right? */ 00156 r = flag_match_partial(&flags_left, &flags_right); 00157 break; 00158 } 00159 return(r); 00160 }
static int script_setflags | ( | user_t * | u, | |
char * | chan, | |||
char * | flags | |||
) | [static] |
Definition at line 116 of file scriptuser.c.
References NULL, and user_set_flags_str().
00117 { 00118 if (!flags) { 00119 flags = chan; 00120 chan = NULL; 00121 } 00122 00123 user_set_flags_str(u, chan, flags); 00124 return(0); 00125 }
static char* script_uid_to_handle | ( | int | uid | ) | [static] |
Definition at line 27 of file scriptuser.c.
References user::handle, NULL, and user_lookup_by_uid().
00028 { 00029 user_t *u; 00030 00031 u = user_lookup_by_uid(uid); 00032 if (u) return(u->handle); 00033 return(NULL); 00034 }
static char* script_user_find | ( | char * | irchost | ) | [static] |
Definition at line 71 of file scriptuser.c.
References user::handle, NULL, and user_lookup_by_irchost_nocache().
00072 { 00073 user_t *u; 00074 00075 u = user_lookup_by_irchost_nocache(irchost); 00076 if (u) return(u->handle); 00077 return(NULL); 00078 }
static char* script_user_get | ( | int | nargs, | |
user_t * | u, | |||
char * | chan, | |||
char * | setting | |||
) | [static] |
Definition at line 80 of file scriptuser.c.
References NULL, and user_get_setting().
00081 { 00082 char *value; 00083 00084 /* If there's a missing arg, it's the channel. */ 00085 if (nargs == 2) { 00086 setting = chan; 00087 chan = NULL; 00088 } 00089 00090 user_get_setting(u, chan, setting, &value); 00091 return(value); 00092 }
static int script_user_save | ( | char * | fname | ) | [static] |
Definition at line 109 of file scriptuser.c.
References user_save().
00110 { 00111 if (!fname) fname = "_users.xml"; 00112 user_save(fname); 00113 return(0); 00114 }
static int script_user_set | ( | int | nargs, | |
user_t * | u, | |||
char * | chan, | |||
char * | setting, | |||
char * | value | |||
) | [static] |
Definition at line 94 of file scriptuser.c.
References NULL, and user_set_setting().
00095 { 00096 int i; 00097 00098 /* If there's a missing arg, it's the channel. */ 00099 if (nargs == 3) { 00100 value = setting; 00101 setting = chan; 00102 chan = NULL; 00103 } 00104 00105 i = user_set_setting(u, chan, setting, value); 00106 return(i); 00107 }
static int script_validhandle | ( | char * | handle | ) | [static] |
Definition at line 42 of file scriptuser.c.
References user_lookup_by_handle().
00043 { 00044 if (user_lookup_by_handle(handle)) return(1); 00045 return(0); 00046 }
static int script_validuid | ( | int | uid | ) | [static] |
Definition at line 48 of file scriptuser.c.
References user_lookup_by_uid().
00049 { 00050 if (user_lookup_by_uid(uid)) return(1); 00051 return(0); 00052 }
const char rcsid[] = "$Id: scriptuser.c,v 1.13 2008-10-17 15:57:43 sven Exp $" [static] |
Definition at line 21 of file scriptuser.c.
Initial value:
{ {"user", "uid_to_handle", script_uid_to_handle, NULL, 1, "i", "uid", SCRIPT_STRING, 0}, {"user", "handle_to_uid", script_handle_to_uid, NULL, 1, "U", "handle", SCRIPT_INTEGER, 0}, {"user", "validhandle", script_validhandle, NULL, 1, "s", "handle", SCRIPT_INTEGER, 0}, {"user", "validuid", script_validuid, NULL, 1, "i", "uid", SCRIPT_INTEGER, 0}, {"user", "add", script_adduser, NULL, 1, "s", "handle", SCRIPT_INTEGER, 0}, {"user", "delete", user_delete, NULL, 1, "U", "user", SCRIPT_INTEGER, 0}, {"user", "addmask", user_add_ircmask, NULL, 2, "Us", "user ircmask", SCRIPT_INTEGER, 0}, {"user", "getmasks", script_get_ircmasks, NULL, 1, "U", "user", 0, SCRIPT_PASS_RETVAL}, {"user", "delmask", user_del_ircmask, NULL, 2, "Us", "user ircmask", SCRIPT_INTEGER, 0}, {"user", "find", script_user_find, NULL, 1, "s", "irchost", SCRIPT_STRING, 0}, {"user", "get", script_user_get, NULL, 2, "Uss", "user ?channel? setting", SCRIPT_STRING, SCRIPT_VAR_ARGS | SCRIPT_PASS_COUNT}, {"user", "set", script_user_set, NULL, 3, "Usss", "user ?channel? setting value", SCRIPT_INTEGER, SCRIPT_VAR_ARGS | SCRIPT_PASS_COUNT}, {"user", "getflags", script_getflags, NULL, 1, "Us", "user ?chan?", SCRIPT_STRING | SCRIPT_FREE, SCRIPT_VAR_ARGS}, {"user", "setflags", script_setflags, NULL, 2, "Uss", "user ?chan? flags", SCRIPT_INTEGER, SCRIPT_VAR_ARGS}, {"user", "matchflags", script_matchflags, 0, 2, "Uss", "user ?chan? flags", SCRIPT_INTEGER, SCRIPT_VAR_ARGS | SCRIPT_PASS_CDATA}, {"user", "matchflags_or", script_matchflags, (void *)1, 2, "Uss", "user ?chan? flags", SCRIPT_INTEGER, SCRIPT_VAR_ARGS | SCRIPT_PASS_CDATA}, {"user", "load", user_save, NULL, 0, "s", "?fname?", SCRIPT_INTEGER, SCRIPT_VAR_ARGS}, {"user", "save", script_user_save, NULL, 0, "s", "?fname?", SCRIPT_INTEGER, SCRIPT_VAR_ARGS}, {"user", "haspass", user_has_pass, NULL, 1, "U", "user", SCRIPT_INTEGER, 0}, {"user", "checkpass", user_check_pass, NULL, 2, "Us", "user pass", SCRIPT_INTEGER, 0}, {"user", "setpass", user_set_pass, NULL, 2, "Us", "user pass", SCRIPT_INTEGER, 0}, {0} }
Definition at line 162 of file scriptuser.c.