src/userent.c File Reference

#include "main.h"
#include "users.h"
Include dependency graph for userent.c:

Go to the source code of this file.

Functions

void init_userent ()
 void ((void(*)(struct list_type *)) global[199])(struct list_type *t)
int list_type_expmem (struct list_type *t)
int def_unpack (struct userrec *u, struct user_entry *e)
int def_pack (struct userrec *u, struct user_entry *e)
int def_kill (struct user_entry *e)
int def_write_userfile (FILE *f, struct userrec *u, struct user_entry *e)
void *void *struct global (struct userrec *u, struct user_entry *e)
int def_set (struct userrec *u, struct user_entry *e, void *buf)
int def_gotshare (struct userrec *u, struct user_entry *e, char *data, int idx)
int def_tcl_get (Tcl_Interp *(*(Tcl_Interp **)(global[128])), struct userrec *u, struct user_entry *e, int argc, char **argv)
int def_tcl_set (Tcl_Interp *irp, struct userrec *u, struct user_entry *e, int argc, char **argv)
int def_expmem (struct user_entry *e)
void def_display (int idx, struct user_entry *e)
int def_dupuser (struct userrec *new, struct userrec *old, struct user_entry *e)
static void comment_display (int idx, struct user_entry *e)
struct user_entry_type(*) struct (global[194]))
int pass_set (struct userrec *u, struct user_entry *e, void *buf)
static int pass_tcl_set (Tcl_Interp *irp, struct userrec *u, struct user_entry *e, int argc, char **argv)
struct user_entry_type(*) struct (global[191]))
static int laston_unpack (struct userrec *u, struct user_entry *e)
static int laston_pack (struct userrec *u, struct user_entry *e)
static int laston_write_userfile (FILE *f, struct userrec *u, struct user_entry *e)
static int laston_kill (struct user_entry *e)
static int laston_set (struct userrec *u, struct user_entry *e, void *buf)
static int laston_tcl_get (Tcl_Interp *irp, struct userrec *u, struct user_entry *e, int argc, char **argv)
static int laston_tcl_set (Tcl_Interp *irp, struct userrec *u, struct user_entry *e, int argc, char **argv)
static int laston_expmem (struct user_entry *e)
static int laston_dupuser (struct userrec *new, struct userrec *old, struct user_entry *e)
struct user_entry_type(*) struct (global[196]))
static int botaddr_unpack (struct userrec *u, struct user_entry *e)
static int botaddr_pack (struct userrec *u, struct user_entry *e)
static int botaddr_kill (struct user_entry *e)
static int botaddr_write_userfile (FILE *f, struct userrec *u, struct user_entry *e)
static int botaddr_set (struct userrec *u, struct user_entry *e, void *buf)
static int botaddr_tcl_get (Tcl_Interp *(*(Tcl_Interp **)(global[128])), struct userrec *u, struct user_entry *e, int argc, char **argv)
static int botaddr_tcl_set (Tcl_Interp *irp, struct userrec *u, struct user_entry *e, int argc, char **argv)
static int botaddr_expmem (struct user_entry *e)
static void botaddr_display (int idx, struct user_entry *e)
static int botaddr_gotshare (struct userrec *u, struct user_entry *e, char *buf, int idx)
static int botaddr_dupuser (struct userrec *new, struct userrec *old, struct user_entry *e)
struct user_entry_type(*) struct (global[188]))
 int ((int(*)(struct userrec *, struct user_entry *, void *)) global[231])(struct userrec *u
static int hosts_dupuser (struct userrec *new, struct userrec *old, struct user_entry *e)
static int hosts_null (struct userrec *u, struct user_entry *e)
static int hosts_write_userfile (FILE *f, struct userrec *u, struct user_entry *e)
static int hosts_kill (struct user_entry *e)
static int hosts_expmem (struct user_entry *e)
static void hosts_display (int idx, struct user_entry *e)
static int hosts_set (struct userrec *u, struct user_entry *e, void *buf)
static int hosts_tcl_get (Tcl_Interp *irp, struct userrec *u, struct user_entry *e, int argc, char **argv)
static int hosts_tcl_set (Tcl_Interp *irp, struct userrec *u, struct user_entry *e, int argc, char **argv)
static int hosts_gotshare (struct userrec *u, struct user_entry *e, char *buf, int idx)
struct user_entry_type(*) struct (global[190]))
 int ((int(*)(struct list_type **, struct list_type *)) global[74])(struct list_type **h

Variables

int(* int )(global[107]))
struct userrec *struct global [94] = 0
Tcl_Interp *(* Tcl_Interp )(global[128]))
char whois_fields []
static struct user_entry_typeentry_type_list
struct user_entry_type(* struct )(global[195]))
struct user_entrye

Function Documentation

static void botaddr_display ( int  idx,
struct user_entry e 
) [static]

Definition at line 595 of file userent.c.

References bot_addr::address, dprintf, user_entry::extra, bot_addr::relay_port, bot_addr::telnet_port, and user_entry::u.

00596 {
00597   register struct bot_addr *bi = (struct bot_addr *) e->u.extra;
00598 
00599   dprintf(idx, "  ADDRESS: %.70s\n", bi->address);
00600   dprintf(idx, "     users: %d, bots: %d\n", bi->relay_port, bi->telnet_port);
00601 }

static int botaddr_dupuser ( struct userrec new,
struct userrec old,
struct user_entry e 
) [static]

Definition at line 625 of file userent.c.

References bot_addr::address, user_entry::extra, userrec::flags, bot_addr::relay_port, set_user, bot_addr::telnet_port, user_entry::u, USER_BOT, user_malloc, and USERENTRY_BOTADDR.

00627 {
00628   if (old->flags & USER_BOT) {
00629     struct bot_addr *bi = e->u.extra, *bi2;
00630 
00631     if (bi) {
00632       bi2 = user_malloc(sizeof(struct bot_addr));
00633 
00634       bi2->telnet_port = bi->telnet_port;
00635       bi2->relay_port = bi->relay_port;
00636       bi2->address = user_malloc(strlen(bi->address) + 1);
00637       strcpy(bi2->address, bi->address);
00638       return set_user(&USERENTRY_BOTADDR, new, bi2);
00639     }
00640   }
00641   return 0;
00642 }

static int botaddr_expmem ( struct user_entry e  )  [static]

Definition at line 588 of file userent.c.

References bot_addr::address, user_entry::extra, and user_entry::u.

00589 {
00590   register struct bot_addr *bi = (struct bot_addr *) e->u.extra;
00591 
00592   return strlen(bi->address) + 1 + sizeof(struct bot_addr);
00593 }

static int botaddr_gotshare ( struct userrec u,
struct user_entry e,
char *  buf,
int  idx 
) [static]

Definition at line 603 of file userent.c.

References bot_addr::address, botaddr_set(), egg_bzero, userrec::handle, LOG_CMDS, newsplit, putlog, bot_addr::relay_port, STAT_GETTING, bot_addr::telnet_port, and user_malloc.

00605 {
00606   struct bot_addr *bi = user_malloc(sizeof(struct bot_addr));
00607   char *arg;
00608 
00609   egg_bzero(bi, sizeof(struct bot_addr));
00610   arg = newsplit(&buf);
00611   bi->address = user_malloc(strlen(arg) + 1);
00612   strcpy(bi->address, arg);
00613   arg = newsplit(&buf);
00614   bi->telnet_port = atoi(arg);
00615   bi->relay_port = atoi(buf);
00616   if (!bi->telnet_port)
00617     bi->telnet_port = 3333;
00618   if (!bi->relay_port)
00619     bi->relay_port = bi->telnet_port;
00620   if (!(dcc[idx].status & STAT_GETTING))
00621     putlog(LOG_CMDS, "*", "%s: change botaddr %s", dcc[idx].nick, u->handle);
00622   return botaddr_set(u, e, bi);
00623 }

Here is the call graph for this function:

static int botaddr_kill ( struct user_entry e  )  [static]

Definition at line 507 of file userent.c.

References user_entry::extra, nfree, and user_entry::u.

00508 {
00509   nfree(((struct bot_addr *) (e->u.extra))->address);
00510   nfree(e->u.extra);
00511   nfree(e);
00512   return 1;
00513 }

static int botaddr_pack ( struct userrec u,
struct user_entry e 
) [static]

Definition at line 489 of file userent.c.

References bot_addr::address, list_type::extra, user_entry::extra, user_entry::list, list_type::next, nfree, NULL, bot_addr::relay_port, simple_sprintf, bot_addr::telnet_port, user_entry::u, and user_malloc.

00490 {
00491   char work[1024];
00492   struct bot_addr *bi;
00493   int l;
00494 
00495   bi = (struct bot_addr *) e->u.extra;
00496   l = simple_sprintf(work, "%s:%u/%u", bi->address, bi->telnet_port,
00497                      bi->relay_port);
00498   e->u.list = user_malloc(sizeof(struct list_type));
00499   e->u.list->next = NULL;
00500   e->u.list->extra = user_malloc(l + 1);
00501   strcpy(e->u.list->extra, work);
00502   nfree(bi->address);
00503   nfree(bi);
00504   return 1;
00505 }

static int botaddr_set ( struct userrec u,
struct user_entry e,
void *  buf 
) [static]

Definition at line 526 of file userent.c.

References bot_addr::address, user_entry::extra, userrec::flags, userrec::handle, nfree, noshare, NULL, bot_addr::relay_port, shareout, bot_addr::telnet_port, user_entry::u, and USER_UNSHARED.

Referenced by botaddr_gotshare(), and botaddr_tcl_set().

00527 {
00528   register struct bot_addr *bi = (struct bot_addr *) e->u.extra;
00529 
00530   if (!bi && !buf)
00531     return 1;
00532   if (bi != buf) {
00533     if (bi) {
00534       nfree(bi->address);
00535       nfree(bi);
00536     }
00537     bi = e->u.extra = buf;
00538   }
00539   if (bi && !noshare && !(u->flags & USER_UNSHARED)) {
00540     shareout(NULL, "c BOTADDR %s %s %d %d\n", u->handle,
00541              bi->address, bi->telnet_port, bi->relay_port);
00542   }
00543   return 1;
00544 }

Here is the caller graph for this function:

static int botaddr_tcl_get ( Tcl_Interp *(Tcl_Interp **)(global[128]),
struct userrec u,
struct user_entry e,
int  argc,
char **  argv 
) [static]

Definition at line 546 of file userent.c.

References bot_addr::address, user_entry::extra, NULL, bot_addr::relay_port, bot_addr::telnet_port, and user_entry::u.

00548 {
00549   register struct bot_addr *bi = (struct bot_addr *) e->u.extra;
00550   char number[20];
00551 
00552   sprintf(number, " %d", bi->telnet_port);
00553   Tcl_AppendResult(interp, bi->address, number, NULL);
00554   sprintf(number, " %d", bi->relay_port);
00555   Tcl_AppendResult(interp, number, NULL);
00556   return TCL_OK;
00557 }

static int botaddr_tcl_set ( Tcl_Interp irp,
struct userrec u,
struct user_entry e,
int  argc,
char **  argv 
) [static]

Definition at line 559 of file userent.c.

References bot_addr::address, BADARGS, botaddr_set(), egg_bzero, user_entry::extra, userrec::flags, nfree, bot_addr::relay_port, bot_addr::telnet_port, user_entry::u, USER_BOT, and user_malloc.

00561 {
00562   register struct bot_addr *bi = (struct bot_addr *) e->u.extra;
00563 
00564   BADARGS(4, 6, " handle type address ?telnetport ?relayport??");
00565 
00566   if (u->flags & USER_BOT) {
00567     /* Silently ignore for users */
00568     if (!bi) {
00569       bi = user_malloc(sizeof(struct bot_addr));
00570       egg_bzero(bi, sizeof(struct bot_addr));
00571     } else
00572       nfree(bi->address);
00573     bi->address = user_malloc(strlen(argv[3]) + 1);
00574     strcpy(bi->address, argv[3]);
00575     if (argc > 4)
00576       bi->telnet_port = atoi(argv[4]);
00577     if (argc > 5)
00578       bi->relay_port = atoi(argv[5]);
00579     if (!bi->telnet_port)
00580       bi->telnet_port = 3333;
00581     if (!bi->relay_port)
00582       bi->relay_port = bi->telnet_port;
00583     botaddr_set(u, e, bi);
00584   }
00585   return TCL_OK;
00586 }

Here is the call graph for this function:

static int botaddr_unpack ( struct userrec u,
struct user_entry e 
) [static]

Definition at line 461 of file userent.c.

References bot_addr::address, egg_bzero, user_entry::extra, list_type::extra, user_entry::list, list_type_kill, bot_addr::relay_port, bot_addr::telnet_port, user_entry::u, and user_malloc.

00462 {
00463   char *p, *q;
00464   struct bot_addr *bi = user_malloc(sizeof(struct bot_addr));
00465 
00466   egg_bzero(bi, sizeof(struct bot_addr));
00467 
00468   if (!(q = strchr((p = e->u.list->extra), ':'))) {
00469     bi->address = user_malloc(strlen(p) + 1);
00470     strcpy(bi->address, p);
00471   } else {
00472     bi->address = user_malloc((q - p) + 1);
00473     strncpy(bi->address, p, q - p);
00474     bi->address[q - p] = 0;
00475     q++;
00476     bi->telnet_port = atoi(q);
00477     if ((q = strchr(q, '/')))
00478       bi->relay_port = atoi(q + 1);
00479   }
00480   if (!bi->telnet_port)
00481     bi->telnet_port = 3333;
00482   if (!bi->relay_port)
00483     bi->relay_port = bi->telnet_port;
00484   list_type_kill(e->u.list);
00485   e->u.extra = bi;
00486   return 1;
00487 }

static int botaddr_write_userfile ( FILE *  f,
struct userrec u,
struct user_entry e 
) [static]

Definition at line 515 of file userent.c.

References bot_addr::address, user_entry::extra, user_entry_type::name, bot_addr::relay_port, bot_addr::telnet_port, user_entry::type, and user_entry::u.

00517 {
00518   register struct bot_addr *bi = (struct bot_addr *) e->u.extra;
00519 
00520   if (fprintf(f, "--%s %s:%u/%u\n", e->type->name, bi->address,
00521               bi->telnet_port, bi->relay_port) == EOF)
00522     return 0;
00523   return 1;
00524 }

static void comment_display ( int  idx,
struct user_entry e 
) [static]

Definition at line 193 of file userent.c.

References dprintf, user_entry::string, user_entry::u, user, and USER_MASTER.

00194 {
00195   if (dcc[idx].user && (dcc[idx].user->flags & USER_MASTER))
00196     dprintf(idx, "  COMMENT: %.70s\n", e->u.string);
00197 }

void def_display ( int  idx,
struct user_entry e 
)

Definition at line 183 of file userent.c.

References dprintf, user_entry_type::name, user_entry::string, user_entry::type, and user_entry::u.

00184 {
00185   dprintf(idx, "  %s: %s\n", e->type->name, e->u.string);
00186 }

int def_dupuser ( struct userrec new,
struct userrec old,
struct user_entry e 
)

Definition at line 188 of file userent.c.

References set_user, user_entry::string, user_entry::type, and user_entry::u.

00189 {
00190   return set_user(e->type, new, e->u.string);
00191 }

int def_expmem ( struct user_entry e  ) 

Definition at line 178 of file userent.c.

References user_entry::string, and user_entry::u.

00179 {
00180   return strlen(e->u.string) + 1;
00181 }

int def_gotshare ( struct userrec u,
struct user_entry e,
char *  data,
int  idx 
)

Definition at line 155 of file userent.c.

References userrec::handle, LOG_CMDS, user_entry_type::name, putlog, user_entry_type::set, and user_entry::type.

00156 {
00157   putlog(LOG_CMDS, "*", "%s: change %s %s", dcc[idx].nick, e->type->name,
00158          u->handle);
00159   return e->type->set(u, e, data);
00160 }

int def_kill ( struct user_entry e  ) 

Definition at line 98 of file userent.c.

References nfree, user_entry::string, and user_entry::u.

00099 {
00100   nfree(e->u.string);
00101   nfree(e);
00102   return 1;
00103 }

int def_pack ( struct userrec u,
struct user_entry e 
)

Definition at line 87 of file userent.c.

References list_type::extra, user_entry::list, list_type::next, NULL, user_entry::string, user_entry::u, and user_malloc.

00088 {
00089   char *tmp;
00090 
00091   tmp = e->u.string;
00092   e->u.list = user_malloc(sizeof(struct list_type));
00093   e->u.list->next = NULL;
00094   e->u.list->extra = tmp;
00095   return 1;
00096 }

int def_set ( struct userrec u,
struct user_entry e,
void *  buf 
)

Definition at line 117 of file userent.c.

References userrec::flags, userrec::handle, user_entry_type::name, nfree, noshare, NULL, share_greet, shareout, user_entry::string, strncpyz, user_entry::type, user_entry::u, USER_BOT, user_realloc, USER_UNSHARED, and USERENTRY_INFO.

00118 {
00119   char *string = (char *) buf;
00120 
00121   if (string && !string[0])
00122     string = NULL;
00123   if (!string && !e->u.string)
00124     return 1;
00125   if (string) {
00126     int l = strlen(string);
00127     char *i;
00128 
00129     if (l > 160)
00130       l = 160;
00131 
00132 
00133     e->u.string = user_realloc(e->u.string, l + 1);
00134 
00135     strncpyz(e->u.string, string, l + 1);
00136 
00137     for (i = e->u.string; *i; i++)
00138       /* Allow bold, inverse, underline, color text here...
00139        * But never add cr or lf!! --rtc
00140        */
00141       if ((unsigned int) *i < 32 && !strchr("\002\003\026\037", *i))
00142         *i = '?';
00143   } else {
00144     nfree(e->u.string);
00145     e->u.string = NULL;
00146   }
00147   if (!noshare && !(u->flags & (USER_BOT | USER_UNSHARED))) {
00148     if (e->type != &USERENTRY_INFO || share_greet)
00149       shareout(NULL, "c %s %s %s\n", e->type->name, u->handle,
00150                e->u.string ? e->u.string : "");
00151   }
00152   return 1;
00153 }

int def_tcl_get ( Tcl_Interp *(Tcl_Interp **)(global[128]),
struct userrec u,
struct user_entry e,
int  argc,
char **  argv 
)

Definition at line 162 of file userent.c.

References NULL, user_entry::string, and user_entry::u.

00164 {
00165   Tcl_AppendResult(interp, e->u.string, NULL);
00166   return TCL_OK;
00167 }

int def_tcl_set ( Tcl_Interp irp,
struct userrec u,
struct user_entry e,
int  argc,
char **  argv 
)

Definition at line 169 of file userent.c.

References BADARGS, user_entry_type::set, and user_entry::type.

00171 {
00172   BADARGS(4, 4, " handle type setting");
00173 
00174   e->type->set(u, e, argv[3]);
00175   return TCL_OK;
00176 }

int def_unpack ( struct userrec u,
struct user_entry e 
)

Definition at line 76 of file userent.c.

References list_type::extra, user_entry::list, list_type_kill, NULL, user_entry::string, and user_entry::u.

00077 {
00078   char *tmp;
00079 
00080   tmp = e->u.list->extra;
00081   e->u.list->extra = NULL;
00082   list_type_kill(e->u.list);
00083   e->u.string = tmp;
00084   return 1;
00085 }

int def_write_userfile ( FILE *  f,
struct userrec u,
struct user_entry e 
)

Definition at line 105 of file userent.c.

References user_entry_type::name, user_entry::string, user_entry::type, and user_entry::u.

00106 {
00107   if (fprintf(f, "--%s %s\n", e->type->name, e->u.string) == EOF)
00108     return 0;
00109   return 1;
00110 }

void* void* struct global ( struct userrec u,
struct user_entry e 
)

Definition at line 112 of file userent.c.

References user_entry::string, and user_entry::u.

00113 {
00114   return e->u.string;
00115 }

static void hosts_display ( int  idx,
struct user_entry e 
) [static]

Definition at line 969 of file userent.c.

References dprintf, list_type::extra, user_entry::list, list_type::next, and user_entry::u.

00970 {
00971   char s[1024];
00972   struct list_type *q;
00973 
00974   s[0] = 0;
00975   strcpy(s, "  HOSTS: ");
00976   for (q = e->u.list; q; q = q->next) {
00977     if (s[0] && !s[9])
00978       strcat(s, q->extra);
00979     else if (!s[0])
00980       sprintf(s, "         %s", q->extra);
00981     else {
00982       if (strlen(s) + strlen(q->extra) + 2 > 65) {
00983         dprintf(idx, "%s\n", s);
00984         sprintf(s, "         %s", q->extra);
00985       } else {
00986         strcat(s, ", ");
00987         strcat(s, q->extra);
00988       }
00989     }
00990   }
00991   if (s[0])
00992     dprintf(idx, "%s\n", s);
00993 }

static int hosts_dupuser ( struct userrec new,
struct userrec old,
struct user_entry e 
) [static, read]
Type Constraints

Definition at line 931 of file userent.c.

References list_type::extra, user_entry::extra, list_type::next, set_user, user_entry::u, and USERENTRY_HOSTS.

00933 {
00934   struct list_type *h;
00935 
00936   for (h = e->u.extra; h; h = h->next)
00937     set_user(&USERENTRY_HOSTS, new, h->extra);
00938   return 1;
00939 }

static int hosts_expmem ( struct user_entry e  )  [static]

Definition at line 964 of file userent.c.

References user_entry::list, list_type_expmem(), and user_entry::u.

00965 {
00966   return list_type_expmem(e->u.list);
00967 }

Here is the call graph for this function:

static int hosts_gotshare ( struct userrec u,
struct user_entry e,
char *  buf,
int  idx 
) [static]

Definition at line 1059 of file userent.c.

01061 {
01062   /* doh, try to be too clever and it bites your butt */
01063   return 0;
01064 }

static int hosts_kill ( struct user_entry e  )  [static]

Definition at line 957 of file userent.c.

References user_entry::list, list_type_kill, nfree, and user_entry::u.

00958 {
00959   list_type_kill(e->u.list);
00960   nfree(e);
00961   return 1;
00962 }

static int hosts_null ( struct userrec u,
struct user_entry e 
) [static]

Definition at line 941 of file userent.c.

00942 {
00943   return 1;
00944 }

static int hosts_set ( struct userrec u,
struct user_entry e,
void *  buf 
) [static]

Definition at line 995 of file userent.c.

References cmp_usermasks, egg_strcasecmp, list_type::extra, user_entry::list, list_type_kill, list_type::next, nfree, NULL, user_entry::u, and user_malloc.

00996 {
00997   if (!buf || !egg_strcasecmp(buf, "none")) {
00998     /* When the bot crashes, it's in this part, not in the 'else' part */
00999     list_type_kill(e->u.list);
01000     e->u.list = NULL;
01001   } else {
01002     char *host = buf, *p = strchr(host, ',');
01003     struct list_type **t;
01004 
01005     /* Can't have ,'s in hostmasks */
01006     while (p) {
01007       *p = '?';
01008       p = strchr(host, ',');
01009     }
01010     /* fred1: check for redundant hostmasks with
01011      * controversial "superpenis" algorithm ;) */
01012     /* I'm surprised Raistlin hasn't gotten involved in this controversy */
01013     t = &(e->u.list);
01014     while (*t) {
01015       if (cmp_usermasks(host, (*t)->extra)) {
01016         struct list_type *u;
01017 
01018         u = *t;
01019         *t = (*t)->next;
01020         if (u->extra)
01021           nfree(u->extra);
01022         nfree(u);
01023       } else
01024         t = &((*t)->next);
01025     }
01026     *t = user_malloc(sizeof(struct list_type));
01027 
01028     (*t)->next = NULL;
01029     (*t)->extra = user_malloc(strlen(host) + 1);
01030     strcpy((*t)->extra, host);
01031   }
01032   return 1;
01033 }

static int hosts_tcl_get ( Tcl_Interp irp,
struct userrec u,
struct user_entry e,
int  argc,
char **  argv 
) [static]

Definition at line 1035 of file userent.c.

References BADARGS, list_type::extra, user_entry::list, list_type::next, and user_entry::u.

01037 {
01038   struct list_type *x;
01039 
01040   BADARGS(3, 3, " handle HOSTS");
01041 
01042   for (x = e->u.list; x; x = x->next)
01043     Tcl_AppendElement(irp, x->extra);
01044   return TCL_OK;
01045 }

static int hosts_tcl_set ( Tcl_Interp irp,
struct userrec u,
struct user_entry e,
int  argc,
char **  argv 
) [static]

Definition at line 1047 of file userent.c.

References addhost_by_handle, BADARGS, and userrec::handle.

01049 {
01050   BADARGS(3, 4, " handle HOSTS ?host?");
01051 
01052   if (argc == 4)
01053     addhost_by_handle(u->handle, argv[3]);
01054   else
01055     addhost_by_handle(u->handle, "none");       /* drummer */
01056   return TCL_OK;
01057 }

static int hosts_write_userfile ( FILE *  f,
struct userrec u,
struct user_entry e 
) [static]

Definition at line 946 of file userent.c.

References list_type::extra, user_entry::extra, list_type::next, and user_entry::u.

00948 {
00949   struct list_type *h;
00950 
00951   for (h = e->u.extra; h; h = h->next)
00952     if (fprintf(f, "--HOSTS %s\n", h->extra) == EOF)
00953       return 0;
00954   return 1;
00955 }

void init_userent (  ) 
int ( (int(*)(struct list_type **, struct list_type *))  global[74]  ) 
int ( (int(*)(struct userrec *, struct user_entry *, void *))  global[231]  ) 
static int laston_dupuser ( struct userrec new,
struct userrec old,
struct user_entry e 
) [static]

Definition at line 428 of file userent.c.

References user_entry::extra, laston_info::laston, laston_info::lastonplace, set_user, user_entry::u, user_malloc, and USERENTRY_LASTON.

00430 {
00431   struct laston_info *li = e->u.extra, *li2;
00432 
00433   if (li) {
00434     li2 = user_malloc(sizeof(struct laston_info));
00435 
00436     li2->laston = li->laston;
00437     li2->lastonplace = user_malloc(strlen(li->lastonplace) + 1);
00438     strcpy(li2->lastonplace, li->lastonplace);
00439     return set_user(&USERENTRY_LASTON, new, li2);
00440   }
00441   return 0;
00442 }

static int laston_expmem ( struct user_entry e  )  [static]

Definition at line 422 of file userent.c.

References user_entry::extra, laston_info::lastonplace, and user_entry::u.

00423 {
00424   return sizeof(struct laston_info) +
00425     strlen(((struct laston_info *) (e->u.extra))->lastonplace) + 1;
00426 }

static int laston_kill ( struct user_entry e  )  [static]

Definition at line 340 of file userent.c.

References user_entry::extra, nfree, and user_entry::u.

00341 {
00342   if (((struct laston_info *) (e->u.extra))->lastonplace)
00343     nfree(((struct laston_info *) (e->u.extra))->lastonplace);
00344   nfree(e->u.extra);
00345   nfree(e);
00346   return 1;
00347 }

static int laston_pack ( struct userrec u,
struct user_entry e 
) [static]

Definition at line 308 of file userent.c.

References list_type::extra, user_entry::extra, laston_info::laston, laston_info::lastonplace, user_entry::list, list_type::next, nfree, NULL, user_entry::u, and user_malloc.

00309 {
00310   char work[1024];
00311   long tv;
00312   struct laston_info *li;
00313   int l;
00314 
00315   li = (struct laston_info *) e->u.extra;
00316   tv = li->laston;
00317   l = sprintf(work, "%lu %s", tv, li->lastonplace);
00318   e->u.list = user_malloc(sizeof(struct list_type));
00319   e->u.list->next = NULL;
00320   e->u.list->extra = user_malloc(l + 1);
00321   strcpy(e->u.list->extra, work);
00322   nfree(li->lastonplace);
00323   nfree(li);
00324   return 1;
00325 }

static int laston_set ( struct userrec u,
struct user_entry e,
void *  buf 
) [static]

Definition at line 349 of file userent.c.

References user_entry::extra, laston_info::lastonplace, nfree, and user_entry::u.

00350 {
00351   struct laston_info *li = (struct laston_info *) e->u.extra;
00352 
00353   if (li != buf) {
00354     if (li) {
00355       nfree(li->lastonplace);
00356       nfree(li);
00357     }
00358 
00359     li = e->u.extra = buf;
00360   }
00361   /* donut share laston info */
00362   return 1;
00363 }

static int laston_tcl_get ( Tcl_Interp irp,
struct userrec u,
struct user_entry e,
int  argc,
char **  argv 
) [static]

Definition at line 365 of file userent.c.

References BADARGS, userrec::chanrec, user_entry::extra, int_to_base10, laston_info::laston, laston_info::lastonplace, chanuserrec::next, NULL, rfc_casecmp, and user_entry::u.

00367 {
00368   struct laston_info *li = (struct laston_info *) e->u.extra;
00369   char number[20];
00370   long tv;
00371   struct chanuserrec *cr;
00372 
00373   BADARGS(3, 4, " handle LASTON ?channel?");
00374 
00375   if (argc == 4) {
00376     for (cr = u->chanrec; cr; cr = cr->next)
00377       if (!rfc_casecmp(cr->channel, argv[3])) {
00378         Tcl_AppendResult(irp, int_to_base10(cr->laston), NULL);
00379         break;
00380       }
00381     if (!cr)
00382       Tcl_AppendResult(irp, "0", NULL);
00383   } else {
00384     tv = li->laston;
00385     sprintf(number, "%lu ", tv);
00386     Tcl_AppendResult(irp, number, li->lastonplace, NULL);
00387   }
00388   return TCL_OK;
00389 }

static int laston_tcl_set ( Tcl_Interp irp,
struct userrec u,
struct user_entry e,
int  argc,
char **  argv 
) [static]

Definition at line 391 of file userent.c.

References BADARGS, CHANMETA, chanuserrec::channel, userrec::chanrec, laston_info::laston, chanuserrec::laston, laston_info::lastonplace, chanuserrec::next, rfc_casecmp, set_user, user_malloc, and USERENTRY_LASTON.

00393 {
00394   struct laston_info *li;
00395   struct chanuserrec *cr;
00396 
00397   BADARGS(4, 5, " handle LASTON time ?place?");
00398 
00399   if ((argc == 5) && argv[4][0] && strchr(CHANMETA, argv[4][0])) {
00400     /* Search for matching channel */
00401     for (cr = u->chanrec; cr; cr = cr->next)
00402       if (!rfc_casecmp(cr->channel, argv[4])) {
00403         cr->laston = atoi(argv[3]);
00404         break;
00405       }
00406   }
00407   /* Save globally */
00408   li = user_malloc(sizeof(struct laston_info));
00409 
00410   if (argc == 5) {
00411     li->lastonplace = user_malloc(strlen(argv[4]) + 1);
00412     strcpy(li->lastonplace, argv[4]);
00413   } else {
00414     li->lastonplace = user_malloc(1);
00415     li->lastonplace[0] = 0;
00416   }
00417   li->laston = atoi(argv[3]);
00418   set_user(&USERENTRY_LASTON, u, li);
00419   return TCL_OK;
00420 }

static int laston_unpack ( struct userrec u,
struct user_entry e 
) [static]

Definition at line 290 of file userent.c.

References user_entry::extra, list_type::extra, laston_info::laston, laston_info::lastonplace, user_entry::list, list_type_kill, newsplit, user_entry::u, and user_malloc.

00291 {
00292   char *par, *arg;
00293   struct laston_info *li;
00294 
00295   par = e->u.list->extra;
00296   arg = newsplit(&par);
00297   if (!par[0])
00298     par = "???";
00299   li = user_malloc(sizeof(struct laston_info));
00300   li->lastonplace = user_malloc(strlen(par) + 1);
00301   li->laston = atoi(arg);
00302   strcpy(li->lastonplace, par);
00303   list_type_kill(e->u.list);
00304   e->u.extra = li;
00305   return 1;
00306 }

static int laston_write_userfile ( FILE *  f,
struct userrec u,
struct user_entry e 
) [static]

Definition at line 327 of file userent.c.

References user_entry::extra, laston_info::laston, laston_info::lastonplace, and user_entry::u.

00329 {
00330   long tv;
00331   struct laston_info *li = (struct laston_info *) e->u.extra;
00332 
00333   tv = li->laston;
00334   if (fprintf(f, "--LASTON %lu %s\n", tv,
00335               li->lastonplace ? li->lastonplace : "") == EOF)
00336     return 0;
00337   return 1;
00338 }

int list_type_expmem ( struct list_type t  ) 

Definition at line 66 of file userent.c.

References list_type::extra, and list_type::next.

Referenced by expmem_users(), and hosts_expmem().

00067 {
00068   int tot = 0;
00069 
00070   for (; t; t = t->next)
00071     tot += sizeof(struct list_type) + strlen(t->extra) + 1;
00072 
00073   return tot;
00074 }

Here is the caller graph for this function:

int pass_set ( struct userrec u,
struct user_entry e,
void *  buf 
)

Definition at line 233 of file userent.c.

References encrypt_pass, user_entry::extra, userrec::flags, userrec::handle, nfree, noshare, NULL, shareout, user_entry::u, USER_BOT, user_malloc, and USER_UNSHARED.

Referenced by pass_tcl_set().

00234 {
00235   char new[32];
00236   register char *pass = buf;
00237 
00238   if (e->u.extra)
00239     nfree(e->u.extra);
00240   if (!pass || !pass[0] || (pass[0] == '-'))
00241     e->u.extra = NULL;
00242   else {
00243     unsigned char *p = (unsigned char *) pass;
00244 
00245     if (strlen(pass) > 30)
00246       pass[30] = 0;
00247     while (*p) {
00248       if ((*p <= 32) || (*p == 127))
00249         *p = '?';
00250       p++;
00251     }
00252     if ((u->flags & USER_BOT) || (pass[0] == '+'))
00253       strcpy(new, pass);
00254     else
00255       encrypt_pass(pass, new);
00256     e->u.extra = user_malloc(strlen(new) + 1);
00257     strcpy(e->u.extra, new);
00258   }
00259   if (!noshare && !(u->flags & (USER_BOT | USER_UNSHARED)))
00260     shareout(NULL, "c PASS %s %s\n", u->handle, pass ? pass : "");
00261   return 1;
00262 }

Here is the caller graph for this function:

static int pass_tcl_set ( Tcl_Interp irp,
struct userrec u,
struct user_entry e,
int  argc,
char **  argv 
) [static]

Definition at line 264 of file userent.c.

References BADARGS, NULL, and pass_set().

00266 {
00267   BADARGS(3, 4, " handle PASS ?newpass?");
00268 
00269   pass_set(u, e, argc == 3 ? NULL : argv[3]);
00270   return TCL_OK;
00271 }

Here is the call graph for this function:

struct user_entry_type(*) struct ( global  [190]  )  [read]
struct user_entry_type(*) struct ( global  [188]  )  [read]
struct user_entry_type(*) struct ( global  [196]  )  [read]
struct user_entry_type(*) struct ( global  [191]  )  [read]
struct user_entry_type(*) struct ( global  [194]  )  [read]
void ( (void(*)(struct list_type *))  global[199]  ) 

Definition at line 53 of file userent.c.

References list_type::extra, list_type::next, and nfree.

00054 {
00055   struct list_type *u;
00056 
00057   while (t) {
00058     u = t->next;
00059     if (t->extra)
00060       nfree(t->extra);
00061     nfree(t);
00062     t = u;
00063   }
00064 }


Variable Documentation

struct user_entry* e
struct user_entry_type* entry_type_list [static]

Definition at line 37 of file userent.c.

int int global[99] = 0 [read]

Definition at line 31 of file userent.c.

int(* int)(global[107])) [read]

Definition at line 39 of file modules.h.

struct user_entry_type(* struct)(global[190])) ( global  [195]  )  [read]
Initial value:
Tcl_Interp*(* Tcl_Interp)(global[128]))
char whois_fields[]

Definition at line 70 of file tcl.c.


Generated on 7 Sep 2016 for Eggdrop by  doxygen 1.6.1