src/proto.h File Reference

#include "lush.h"
#include "misc_file.h"
Include dependency graph for proto.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define dprintf   dprintf_eggdrop
#define get_data_ptr(x)   _get_data_ptr(x,__FILE__,__LINE__)
#define wild_match(a, b)   _wild_match((unsigned char *)(a),(unsigned char *)(b))
#define wild_match_per(a, b)
#define wild_match_partial_case(a, b)
#define match_addr(a, b)   addr_match((char *)(a),(char *)(b),0,0)
#define match_useraddr(a, b)   addr_match((char *)(a),(char *)(b),1,0)
#define cmp_masks(a, b)   addr_match((char *)(a),(char *)(b),0,1)
#define cmp_usermasks(a, b)   addr_match((char *)(a),(char *)(b),1,1)
#define maskhost(a, b)   maskaddr((a),(b),3)
#define maskban(a, b)   maskaddr((a),(b),3)

Functions

int(*)(*(Function **)(global[218]))
int 
(*)(char *, char *) (const char *, const char *)
int(*)(*(Function **)(global[219]))
int 
(*)(char *, char *, int *) (const char *, const char *, int)
void bot_share (int, char *)
 int ((int(*)(char *)) global[20])(char *)
void answer_local_whom (int, int)
char * lastbot (char *)
 int ((int(*)(char *)) global[35])(char *)
 int ((int(*)(char *)) global[163])(char *)
void tell_bots (int)
 void ((void(*)(int, int)) global[276])(int
int botlink (char *, int, char *)
int botunlink (int, char *, char *, char *)
void dump_links (int)
void addbot (char *, char *, char *, char, int)
 void ((void(*)(int, char *, char, int)) global[34])(int
void rembot (char *)
struct tand_t_structfindbot (char *)
void unvia (int, struct tand_t_struct *)
void check_botnet_pings ()
int partysock (char *, char *)
int addparty (char *, char *, int, char, int, char *, int *)
void remparty (char *, int)
void partystat (char *, int, int, int)
int partynick (char *, int, char *)
int partyidle (char *, char *)
void partysetidle (char *, int, int)
void partyaway (char *, int, char *)
 void ((void(*)(int)) global[36])(int)
void tandem_relay (int, char *, int)
int getparty (char *, int)
 int ((int(*)(char *, char *, char *, int, int)) global[164])(char *
 int ((int(*)()) global[23])()
void tandout_but ()
char *char *int global (int)
char * unsigned_int_to_base10 (unsigned int)
char *char *int global (unsigned int)
void tell_verbose_uptime (int)
void tell_verbose_status (int)
void tell_settings (int)
 int ((int(*)(char *)) global[200])(char *)
 int ((int(*)(char *)) global[215])(char *)
char * maskname (int)
 void ((void(*)(void)) global[58])()
void rehash ()
void reload ()
void chanprog ()
void check_timers ()
void check_utimers ()
 void ((void(*)(char *)) global[162])(char *s)
void set_chanlist (const char *host, struct userrec *rec)
 void ((void(*)(void)) global[57])(void)
 void ((void(*)(const char *nick)) global[266])(const char *nick)
 int ((int(*)(struct userrec *, int)) global[207])(struct userrec *
 int ((int(*)(struct userrec *, char *, int, int)) global[208])(struct userrec *
 int ((int(*)(char *)) global[202])(char *)
void failed_link (int)
 void ((void(*)(int, char *)) global[289])(int
char * int ((int(*)(char *)) global[290])(char *)
void dupwait_notify (char *)
 int ((int(*)(void)) global[297])()
int findidx (int)
 int ((int(*)(int)) global[130])(int)
char * add_cr (char *)
 void (global[69])()
 void (global[70])()
 void ((void(*)()) global[71])()
void dcc_chatter (int)
 void ((void(*)(int)) global[81])(int)
 void ((void(*)(int)) global[281])(int)
 void ((void(*)(int)) global[246])(int)
 void ((void(*)(char *)) global[152])(char *)
void tell_dcc (int)
void not_away (int)
void set_away (int, char *)
void * _get_data_ptr (int, char *, int)
void dcc_remove_lost (void)
void do_boot (int, char *, char *)
 int ((int(*)(time_t *, struct chat_info *, int)) global[166])(time_t *
 void ((void(*)(int, struct chat_info *)) global[167])(int
struct chat_info *struct dcc_tfind_idx (int)
 int ((int(*)(struct dcc_table *, int)) global[80])(struct dcc_table *
void del_dcc (int)
 void ((void(*)(int, struct dcc_table *, int)) global[242])(int
void block_dns_hostbyip (IP)
void block_dns_ipbyhost (char *)
 void ((void(*)(IP, char *, int)) global[235])(IP
 void ((void(*)(char *, IP, int)) global[236])(char *
 void ((void(*)(IP)) global[241])(IP)
 void ((void(*)(char *)) global[240])(char *)
 int ((int(*)(struct userrec *, int, char *)) global[206])(struct userrec *
char * void ((void(*)(char *)) global[228])(char *)
 int ((int(*)(char *)) global[165])(char *)
int exist_lang_section (char *)
 void (global[143])(const char *
 int ((int(*)(void)) global[168])(void)
void eggContext (const char *, int, const char *)
void eggContextNote (const char *, int, const char *, const char *)
void eggAssert (const char *, int, const char *)
void backup_userfile (void)
int mainloop (int)
int casecharcmp (unsigned char, unsigned char)
int charcmp (unsigned char, unsigned char)
int _wild_match (register unsigned char *, register unsigned char *)
int _wild_match_per (register unsigned char *, register unsigned char *, int(*)(unsigned char, unsigned char), int(*)(unsigned char, unsigned char), unsigned char *)
 int ((int(*)(const char *, const char *, int, int)) global[294])(char *
 int ((int(*)(const char *, const char *)) global[295])(char *
char *int cidr_match (char *, char *, int)
int cron_match (const char *, const char *)
char * n_strdup (const char *, const char *, int)
void * n_malloc (int, const char *, int)
void * n_realloc (void *, int, const char *, int)
 void ((void(*)(void *, char *, int)) global[37])(void *
 void ((void(*)(char *)) global[169])(char *)
void tell_mem_status_dcc (int)
void debug_mem_to_dcc (int)
 int ((int(*)(char *dst, const char *src, size_t max)) global[265])(char *
 int ((int(*)(char *, const char *)) global[91])(char *
char * void (global[197])()
void flushlogs ()
void check_logsize ()
 void ((void(*)(char *, char *, char)) global[139])(char *
void splitcn (char *, char *, char, size_t)
 void ((void(*)(char **)) global[293])(char **)
char *char *char global (char **)
void stridx (char *, char *, int)
void dumplots (int, const char *, const char *)
 void ((void(*)(time_t, time_t, char *)) global[134])(time_t
char * void ((void(*)(time_t, time_t, char *)) global[133])(time_t
char char * void ((void(*)(time_t, time_t, char *)) global[135])(time_t
char char char *void help_subst (char *, char *, struct flag_record *, int, char *)
 void ((void(*)(int, char *)) global[204])(int
char * void ((void(*)(int)) global[155])(int)
 void ((void(*)(int, char *, struct flag_record *, int)) global[156])(int
void tellwildhelp (int, char *, struct flag_record *)
void tellallhelp (int, char *, struct flag_record *)
 void ((void(*)(char *, char *, struct flag_record *, int)) global[157])(char *
 void ((void(*)(char *)) global[159])(char *)
 void ((void(*)(char *)) global[158])(char *)
void debug_help (int)
void reload_help_data (void)
char * extracthostname (char *)
void show_banner (int i)
 void ((void(*)(char *, int)) global[243])(char *
 int ((int(*)(const char *)) global[291])(const char *)
 int ((int(*)(const char *)) global[257])(const char *)
void logsuffix_change (char *)
char *char *char global (const char *, const char, const char)
char *char *char global (char *, const char, register const char)
 void ((void(*)(char *, register const char)) global[264])(char *
 int ((int(*)(const char *)) global[292])(const char *)
 void ((void(*)(char *, char *)) global[271])(char *
char * void ((void(*)(const char *, char *, int)) global[154])(const char *
 IP ((IP(*)(char *)) global[90])(char *)
unsigned long (0xffffffff &(long)(htonl((unsigned long) IP)))
 IP ((IP(*)(void)) global[77])()
 void ((void(*)(char *)) global[78])(char *)
void setsock (int, int)
 int ((int(*)(int sock, int options)) global[234])(int
int alloctclsock (int, int, Tcl_FileProc *, ClientData)
 int ((int(*)(int)) global[82])(int)
 void ((void(*)(int)) global[83])(int)
void killtclsock (int)
 int ((int(*)(int, char *, unsigned long *, unsigned short *, int)) global[76])(int
 int ((int(*)(int *)) global[84])(int *)
 int ((int(*)(IP addr, int *port)) global[261])(IP addr
int * int ((int(*)(char *, int)) global[87])(char *
 int ((int(*)(int, char *, char *)) global[85])(int
char char *int open_telnet_raw (int, char *, int)
 void ((void(*)(int, char *, unsigned int)) global[79])(int
void dequeue_sockets ()
int preparefdset (fd_set *, sock_list *, int, int, int)
int sockread (char *, int *, sock_list *, int, int)
int sockgets (char *, int *)
void tell_netdebug (int)
 int ((int(*)(char *, char *, char *, char *)) global[214])(char *
char char char * int ((int(*)(char *, char *, IP, char *, char *)) global[239])(char *
char char char *char char char
*char *char *IP 
global (IP)
 int ((int(*)(int, int)) global[248])(int
 int ((int(*)(int, int, int)) global[269])(int sock
 int ((int(*)(int)) global[270])(int idx)
struct threaddatathreaddata ()
int init_threaddata (int)
void protect_tcl ()
void unprotect_tcl ()
 void ((void(*)(char *, char *)) global[148])(char *
char * int ((int(*)(const char *)) global[149])(char *fname)
 void ((void(*)(struct list_type *)) global[199])(struct list_type *)
int list_type_expmem (struct list_type *)
 int ((int(*)(struct userrec *, struct user_entry *, void *)) global[231])()
struct userrec *struct userrec
*struct 
global (struct userrec *, char *, char *, char *, int)
 void ((void(*)(char *, char *)) global[52])(char *
char *void clear_masks (struct maskrec *)
 void ((void(*)(struct userrec *)) global[61])(struct userrec *)
 int ((int(*)(struct userrec *, char *)) global[38])(struct userrec *
char * int ((int(*)(char *, char *)) global[53])(char *
char *char *int ishost_for_handle (char *, char *)
 int ((int(*)(struct userrec *)) global[62])(struct userrec *)
 int ((int(*)(char *)) global[51])(char *)
void freeuser (struct userrec *)
 int ((int(*)(struct userrec *, char *)) global[59])(struct userrec *
char *void correct_handle (char *)
 int ((int(*)(struct userrec *, FILE *, int)) global[60])(struct userrec *
 int ((int(*)(FILE *, int)) global[282])(FILE *f
 void ((void(*)(int)) global[55])(int)
struct userreccheck_dcclist_hand (char *)
 void ((void(*)(struct userrec *, char *, time_t)) global[160])(struct userrec *
 void ((void(*)(char *))(global[193]))(char *)
char *char *char global (char *)
 int ((int(*)(struct flag_record *, int)) global[296])(struct flag_record *fr
 void ((void(*)(char *, char *, char *, time_t)) global[140])(char *
 int ((int(*)(char *)) global[142])(char *)
void tell_ignores (int, char *)
 int ((int(*)(char *)) global[141])(char *)
void check_expired_ignores ()
void autolink_cycle (char *)
void tell_file_stats (int, char *)
void tell_user_ident (int, char *, int)
void tell_users_match (int, char *, int, int, int, char *)
 int ((int(*)(char *, struct userrec **)) global[54])(char *
struct userrec **int _rfc_casecmp (const char *, const char *)
int _rfc_ncasecmp (const char *, const char *, int)
int _rfc_toupper (int)
int _rfc_tolower (int)

Variables

void(* encrypt_pass )(char *, char *)
char *(* encrypt_string )(char *, char *)
char *(* decrypt_string )(char *, char *)
int(* rfc_toupper )(int)
int(* rfc_tolower )(int)
int(* match_noterej )(struct userrec *, char *)
 int
char char
void(*(* Function )(global[68])))()
void(* sharein )(int, char *)
void(* dns_hostbyip )(IP)
void(* dns_ipbyhost )(char *)
 IP
const char size_t
 time_t
int operation
int int sock_options
int md

Define Documentation

#define cmp_masks ( a,
 )     addr_match((char *)(a),(char *)(b),0,1)

Definition at line 207 of file proto.h.

#define cmp_usermasks ( a,
 )     addr_match((char *)(a),(char *)(b),1,1)

Definition at line 208 of file proto.h.

Referenced by hosts_set().

#define dprintf   dprintf_eggdrop

Definition at line 37 of file proto.h.

#define get_data_ptr (  )     _get_data_ptr(x,__FILE__,__LINE__)

Definition at line 153 of file proto.h.

#define maskban ( a,
 )     maskaddr((a),(b),3)

Definition at line 260 of file proto.h.

#define maskhost ( a,
 )     maskaddr((a),(b),3)

Definition at line 259 of file proto.h.

#define match_addr ( a,
 )     addr_match((char *)(a),(char *)(b),0,0)

Definition at line 205 of file proto.h.

#define match_useraddr ( a,
 )     addr_match((char *)(a),(char *)(b),1,0)

Definition at line 206 of file proto.h.

Referenced by global(), and int().

#define wild_match ( a,
 )     _wild_match((unsigned char *)(a),(unsigned char *)(b))

Definition at line 199 of file proto.h.

#define wild_match_partial_case ( a,
 ) 
Value:
_wild_match_per((unsigned char *)(a),     \
                            (unsigned char *)(b),casecharcmp,charcmp,          \
                            (unsigned char *)strchr((b),' '))

Definition at line 202 of file proto.h.

#define wild_match_per ( a,
 ) 
Value:
_wild_match_per((unsigned char *)(a),              \
                            (unsigned char *)(b),casecharcmp,NULL,NULL)

Definition at line 200 of file proto.h.


Function Documentation

int(* )(*(Function**)(global[218]))int (*)(char *, char *) ( const char *  ,
const char *   
)
int(* )(*(Function**)(global[219]))int (*)(char *, char *, int *) ( const char *  ,
const char *  ,
int   
)
void* _get_data_ptr ( int  ,
char *  ,
int   
)

Definition at line 477 of file dccutil.c.

References egg_bzero, egg_snprintf, n_malloc(), and nmalloc.

00478 {
00479   char *p;
00480 #ifdef DEBUG_MEM
00481   char x[1024];
00482 
00483   p = strrchr(file, '/');
00484   egg_snprintf(x, sizeof x, "dccutil.c:%s", p ? p + 1 : file);
00485   p = n_malloc(size, x, line);
00486 #else
00487   p = nmalloc(size);
00488 #endif
00489   egg_bzero(p, size);
00490   return p;
00491 }

Here is the call graph for this function:

struct userrec** int _rfc_casecmp ( const char *  ,
const char *   
) [read]

Definition at line 30 of file rfc1459.c.

References rfc_toupper.

00031 {
00032   register unsigned char *str1 = (unsigned char *) s1;
00033   register unsigned char *str2 = (unsigned char *) s2;
00034   register int res;
00035 
00036   while (!(res = rfc_toupper(*str1) - rfc_toupper(*str2))) {
00037     if (*str1 == '\0')
00038       return 0;
00039     str1++;
00040     str2++;
00041   }
00042   return res;
00043 }

int _rfc_ncasecmp ( const char *  ,
const char *  ,
int   
)

Definition at line 45 of file rfc1459.c.

References rfc_toupper.

00046 {
00047   register unsigned char *s1 = (unsigned char *) str1;
00048   register unsigned char *s2 = (unsigned char *) str2;
00049   register int res;
00050 
00051   while (!(res = rfc_toupper(*s1) - rfc_toupper(*s2))) {
00052     s1++;
00053     s2++;
00054     n--;
00055     if (!n || (*s1 == '\0' && *s2 == '\0'))
00056       return 0;
00057   }
00058   return res;
00059 }

int _rfc_tolower ( int   ) 

Definition at line 64 of file rfc1459.c.

References char, and rfc_tolowertab.

00065 {
00066   return rfc_tolowertab[(unsigned char) (c)];
00067 }

int _rfc_toupper ( int   ) 

Definition at line 69 of file rfc1459.c.

References char, and rfc_touppertab.

00070 {
00071   return rfc_touppertab[(unsigned char) (c)];
00072 }

int _wild_match ( register unsigned char *  ,
register unsigned char *   
)

Definition at line 157 of file match.c.

References MATCH, NOMATCH, WILDQ, and WILDS.

00158 {
00159   unsigned char *ma = m, *na = n, *lsm = 0, *lsn = 0;
00160   int match = 1;
00161   register int sofar = 0;
00162 
00163   /* null strings should never match */
00164   if ((ma == 0) || (na == 0) || (!*ma) || (!*na))
00165     return NOMATCH;
00166   /* find the end of each string */
00167   while (*(++m));
00168   m--;
00169   while (*(++n));
00170   n--;
00171 
00172   while (n >= na) {
00173     /* If the mask runs out of chars before the string, fall back on
00174      * a wildcard or fail. */
00175     if (m < ma) {
00176       if (lsm) {
00177         n = --lsn;
00178         m = lsm;
00179         if (n < na)
00180           lsm = 0;
00181         sofar = 0;
00182       }
00183       else
00184         return NOMATCH;
00185     }
00186 
00187     switch (*m) {
00188     case WILDS:                /* Matches anything */
00189       do
00190         m--;                    /* Zap redundant wilds */
00191       while ((m >= ma) && (*m == WILDS));
00192       lsm = m;
00193       lsn = n;
00194       match += sofar;
00195       sofar = 0;                /* Update fallback pos */
00196       if (m < ma)
00197         return MATCH;
00198       continue;                 /* Next char, please */
00199     case WILDQ:
00200       m--;
00201       n--;
00202       continue;                 /* '?' always matches */
00203     }
00204     if (toupper(*m) == toupper(*n)) {   /* If matching char */
00205       m--;
00206       n--;
00207       sofar++;                  /* Tally the match */
00208       continue;                 /* Next char, please */
00209     }
00210     if (lsm) {                  /* To to fallback on '*' */
00211       n = --lsn;
00212       m = lsm;
00213       if (n < na)
00214         lsm = 0;                /* Rewind to saved pos */
00215       sofar = 0;
00216       continue;                 /* Next char, please */
00217     }
00218     return NOMATCH;             /* No fallback=No match */
00219   }
00220   while ((m >= ma) && (*m == WILDS))
00221     m--;                        /* Zap leftover %s & *s */
00222   return (m >= ma) ? NOMATCH : MATCH;   /* Start of both = match */
00223 }

int _wild_match_per ( register unsigned char *  ,
register unsigned char *  ,
int(*)(unsigned char, unsigned char)  ,
int(*)(unsigned char, unsigned char)  ,
unsigned char *   
)

Definition at line 54 of file match.c.

References NOMATCH, NULL, PERMATCH, QUOTE, WILDP, WILDQ, WILDS, and WILDT.

00058 {
00059   unsigned char *ma = m, *lsm = 0, *lsn = 0, *lpm = 0, *lpn = 0;
00060   int match = 1, saved = 0, space;
00061   register unsigned int sofar = 0;
00062 
00063   /* null strings should never match */
00064   if ((m == 0) || (n == 0) || (!*n) || (!cmp1))
00065     return NOMATCH;
00066 
00067   if (!cmp2)                    /* Don't change cmpfunc if it's not valid */
00068     chgpoint = NULL;
00069 
00070   while (*n) {
00071     if (*m == WILDT) {          /* Match >=1 space */
00072       space = 0;                /* Don't need any spaces */
00073       do {
00074         m++;
00075         space++;
00076       }                         /* Tally 1 more space ... */
00077       while ((*m == WILDT) || (*m == ' '));     /*  for each space or ~ */
00078       sofar += space;           /* Each counts as exact */
00079       while (*n == ' ') {
00080         n++;
00081         space--;
00082       }                         /* Do we have enough? */
00083       if (space <= 0)
00084         continue;               /* Had enough spaces! */
00085     }
00086     /* Do the fallback       */
00087     else {
00088       switch (*m) {
00089       case 0:
00090         do
00091           m--;                  /* Search backwards */
00092         while ((m > ma) && (*m == '?'));        /* For first non-? char */
00093         if ((m > ma) ? ((*m == '*') && (m[-1] != QUOTE)) : (*m == '*'))
00094           return PERMATCH;      /* nonquoted * = match */
00095         break;
00096       case WILDP:
00097         while (*(++m) == WILDP);        /* Zap redundant %s */
00098         if (*m != WILDS) {      /* Don't both if next=* */
00099           if (*n != ' ') {      /* WILDS can't match ' ' */
00100             lpm = m;
00101             lpn = n;            /* Save '%' fallback spot */
00102             saved += sofar;
00103             sofar = 0;          /* And save tally count */
00104           }
00105           continue;             /* Done with '%' */
00106         }
00107         /* FALL THROUGH */
00108       case WILDS:
00109         do
00110           m++;                  /* Zap redundant wilds */
00111         while ((*m == WILDS) || (*m == WILDP));
00112         lsm = m;
00113         lsn = n;
00114         lpm = 0;                /* Save '*' fallback spot */
00115         match += (saved + sofar);       /* Save tally count */
00116         saved = sofar = 0;
00117         continue;               /* Done with '*' */
00118       case WILDQ:
00119         m++;
00120         n++;
00121         continue;               /* Match one char */
00122       case QUOTE:
00123         m++;                    /* Handle quoting */
00124       }
00125       if (((!chgpoint || n < chgpoint) && !(*cmp1)(*m, *n)) ||
00126           (chgpoint && n >= chgpoint && !(*cmp2)(*m, *n))) { /* If matching */
00127         m++;
00128         n++;
00129         sofar++;
00130         continue;               /* Tally the match */
00131       }
00132 #ifdef WILDT
00133     }
00134 #endif
00135     if (lpm) {                  /* Try to fallback on '%' */
00136       n = ++lpn;
00137       m = lpm;
00138       sofar = 0;                /* Restore position */
00139       if ((*n | 32) == 32)
00140         lpm = 0;                /* Can't match 0 or ' ' */
00141       continue;                 /* Next char, please */
00142     }
00143     if (lsm) {                  /* Try to fallback on '*' */
00144       n = ++lsn;
00145       m = lsm;                  /* Restore position */
00146       saved = sofar = 0;
00147       continue;                 /* Next char, please */
00148     }
00149     return NOMATCH;             /* No fallbacks=No match */
00150   }
00151   while ((*m == WILDS) || (*m == WILDP))
00152     m++;                        /* Zap leftover %s & *s */
00153   return (*m) ? NOMATCH : PERMATCH;     /* End of both = match */
00154 }

char* add_cr ( char *   ) 

Definition at line 132 of file dccutil.c.

00133 {
00134   static char WBUF[1024];
00135   char *p, *q;
00136 
00137   for (p = buf, q = WBUF; *p; p++, q++) {
00138     if (*p == '\n')
00139       *q++ = '\r';
00140     *q = *p;
00141   }
00142   *q = *p;
00143   return WBUF;
00144 }

void addbot ( char *  ,
char *  ,
char *  ,
char  ,
int   
)

Definition at line 86 of file botnet.c.

References botnetnick, egg_strcasecmp, findbot(), HANDLEN, LOG_BOTS, nmalloc, putlog, tands, and tand_t_struct::via.

Referenced by bot_nlinked(), and bot_version().

00087 {
00088   tand_t **ptr = &tandbot, *ptr2;
00089 
00090   while (*ptr) {
00091     if (!egg_strcasecmp((*ptr)->bot, who))
00092       putlog(LOG_BOTS, "*", "!!! Duplicate botnet bot entry!!");
00093     ptr = &((*ptr)->next);
00094   }
00095   ptr2 = nmalloc(sizeof(tand_t));
00096   strncpy(ptr2->bot, who, HANDLEN);
00097   ptr2->bot[HANDLEN] = 0;
00098   ptr2->share = flag;
00099   ptr2->ver = vernum;
00100   ptr2->next = *ptr;
00101   *ptr = ptr2;
00102   /* May be via itself */
00103   ptr2->via = findbot(from);
00104   if (!egg_strcasecmp(next, botnetnick))
00105     ptr2->uplink = (tand_t *) 1;
00106   else
00107     ptr2->uplink = findbot(next);
00108   tands++;
00109 }

Here is the call graph for this function:

Here is the caller graph for this function:

int addparty ( char *  ,
char *  ,
int  ,
char  ,
int  ,
char *  ,
int *   
)

Definition at line 141 of file botnet.c.

References party_t::away, party_t::bot, party_t::chan, egg_strcasecmp, party_t::flag, party_t::from, HANDLEN, maxparty, nfree, party_t::nick, nmalloc, now, nrealloc, parties, party_t::sock, party_t::status, and party_t::timer.

Referenced by bot_join().

00143 {
00144   int i;
00145 
00146   for (i = 0; i < parties; i++) {
00147     /* Just changing the channel of someone already on? */
00148     if (!egg_strcasecmp(party[i].bot, bot) && (party[i].sock == sock)) {
00149       int oldchan = party[i].chan;
00150 
00151       party[i].chan = chan;
00152       party[i].timer = now;
00153       if (from[0]) {
00154         if (flag == ' ')
00155           flag = '-';
00156         party[i].flag = flag;
00157         if (party[i].from)
00158           nfree(party[i].from);
00159         party[i].from = nmalloc(strlen(from) + 1);
00160         strcpy(party[i].from, from);
00161       }
00162       *idx = i;
00163       return oldchan;
00164     }
00165   }
00166   /* New member */
00167   if (parties == maxparty) {
00168     maxparty += 50;
00169     party = (party_t *) nrealloc((void *) party, maxparty * sizeof(party_t));
00170   }
00171   strncpy(party[parties].nick, nick, HANDLEN);
00172   party[parties].nick[HANDLEN] = 0;
00173   strncpy(party[parties].bot, bot, HANDLEN);
00174   party[parties].bot[HANDLEN] = 0;
00175   party[parties].chan = chan;
00176   party[parties].sock = sock;
00177   party[parties].status = 0;
00178   party[parties].away = 0;
00179   party[parties].timer = now;   /* cope. */
00180   if (from[0]) {
00181     if (flag == ' ')
00182       flag = '-';
00183     party[parties].flag = flag;
00184     party[parties].from = nmalloc(strlen(from) + 1);
00185     strcpy(party[parties].from, from);
00186   } else {
00187     party[parties].flag = ' ';
00188     party[parties].from = nmalloc(10);
00189     strcpy(party[parties].from, "(unknown)");
00190   }
00191   *idx = parties;
00192   parties++;
00193   return -1;
00194 }

Here is the caller graph for this function:

int alloctclsock ( int  ,
int  ,
Tcl_FileProc *  ,
ClientData   
)
void answer_local_whom ( int  ,
int   
)

Definition at line 429 of file botnet.c.

References chat_info::away, BOT_BOTNETUSERS, BOT_LOCALCHAN, BOT_PARTYLINE, BOT_USERSONCHAN, botnetnick, chat_info::channel, dcc_t::chat, days, DCC_CHAT, dcc_total, dprintf, egg_snprintf, party_t::flag, from, geticon, GLOBAL_CHANS, dcc_t::host, interp, MISC_AWAY, now, NULL, parties, PLSTAT_AWAY, simple_sprintf, tcl_resultempty(), tcl_resultstring(), party_t::timer, timer, dcc_t::timeval, and dcc_t::u.

Referenced by cmd_whom().

00430 {
00431   char format[81];
00432   char c, idle[40];
00433   int i, t, nicklen, botnicklen, total = 0;
00434 
00435   if (chan == -1)
00436     dprintf(idx, "%s (+: %s, *: %s)\n", BOT_BOTNETUSERS, BOT_PARTYLINE,
00437             BOT_LOCALCHAN);
00438   else if (chan > 0) {
00439     simple_sprintf(idle, "assoc %d", chan);
00440     if ((Tcl_Eval(interp, idle) != TCL_OK) || tcl_resultempty())
00441       dprintf(idx, "%s %s%d:\n", BOT_USERSONCHAN,
00442               (chan < GLOBAL_CHANS) ? "" : "*", chan % GLOBAL_CHANS);
00443     else
00444       dprintf(idx, "%s '%s%s' (%s%d):\n", BOT_USERSONCHAN,
00445               (chan < GLOBAL_CHANS) ? "" : "*", tcl_resultstring(),
00446               (chan < GLOBAL_CHANS) ? "" : "*", chan % GLOBAL_CHANS);
00447   }
00448   /* Find longest nick and botnick */
00449   nicklen = botnicklen = 0;
00450   for (i = 0; i < dcc_total; i++)
00451     if (dcc[i].type == &DCC_CHAT) {
00452       if ((chan == -1) || ((chan >= 0) && (dcc[i].u.chat->channel == chan))) {
00453         t = strlen(dcc[i].nick);
00454         if (t > nicklen)
00455           nicklen = t;
00456         t = strlen(botnetnick);
00457         if (t > botnicklen)
00458           botnicklen = t;
00459       }
00460     }
00461   for (i = 0; i < parties; i++) {
00462     if ((chan == -1) || ((chan >= 0) && (party[i].chan == chan))) {
00463       t = strlen(party[i].nick);
00464       if (t > nicklen)
00465         nicklen = t;
00466       t = strlen(party[i].bot);
00467       if (t > botnicklen)
00468         botnicklen = t;
00469     }
00470   }
00471   if (nicklen < 9)
00472     nicklen = 9;
00473   if (botnicklen < 9)
00474     botnicklen = 9;
00475 
00476   egg_snprintf(format, sizeof format, "%%-%us   %%-%us  %%s\n",
00477                nicklen, botnicklen);
00478   dprintf(idx, format, " Nick", " Bot", " Host");
00479   dprintf(idx, format, "----------", "---------", "--------------------");
00480   egg_snprintf(format, sizeof format, "%%c%%-%us %%c %%-%us  %%s%%s\n",
00481                nicklen, botnicklen);
00482   for (i = 0; i < dcc_total; i++)
00483     if (dcc[i].type == &DCC_CHAT) {
00484       if ((chan == -1) || ((chan >= 0) && (dcc[i].u.chat->channel == chan))) {
00485         c = geticon(i);
00486         if (c == '-')
00487           c = ' ';
00488         if (now - dcc[i].timeval > 300) {
00489           unsigned long days, hrs, mins;
00490 
00491           days = (now - dcc[i].timeval) / 86400;
00492           hrs = ((now - dcc[i].timeval) - (days * 86400)) / 3600;
00493           mins = ((now - dcc[i].timeval) - (hrs * 3600)) / 60;
00494           if (days > 0)
00495             sprintf(idle, " [idle %lud%luh]", days, hrs);
00496           else if (hrs > 0)
00497             sprintf(idle, " [idle %luh%lum]", hrs, mins);
00498           else
00499             sprintf(idle, " [idle %lum]", mins);
00500         } else
00501           idle[0] = 0;
00502         total++;
00503         dprintf(idx, format, c, dcc[i].nick,
00504                 (dcc[i].u.chat->channel == 0) && (chan == -1) ? '+' :
00505                 (dcc[i].u.chat->channel >= GLOBAL_CHANS) &&
00506                 (chan == -1) ? '*' : ' ', botnetnick, dcc[i].host, idle);
00507         if (dcc[i].u.chat->away != NULL)
00508           dprintf(idx, "   AWAY: %s\n", dcc[i].u.chat->away);
00509       }
00510     }
00511   for (i = 0; i < parties; i++) {
00512     if ((chan == -1) || ((chan >= 0) && (party[i].chan == chan))) {
00513       c = party[i].flag;
00514       if (c == '-')
00515         c = ' ';
00516       if (party[i].timer == 0L)
00517         strcpy(idle, " [idle?]");
00518       else if (now - party[i].timer > 300) {
00519         unsigned long days, hrs, mins;
00520 
00521         days = (now - party[i].timer) / 86400;
00522         hrs = ((now - party[i].timer) - (days * 86400)) / 3600;
00523         mins = ((now - party[i].timer) - (hrs * 3600)) / 60;
00524         if (days > 0)
00525           sprintf(idle, " [idle %lud%luh]", days, hrs);
00526         else if (hrs > 0)
00527           sprintf(idle, " [idle %luh%lum]", hrs, mins);
00528         else
00529           sprintf(idle, " [idle %lum]", mins);
00530       } else
00531         idle[0] = 0;
00532       total++;
00533       dprintf(idx, format, c, party[i].nick,
00534               (party[i].chan == 0) && (chan == -1) ? '+' : ' ',
00535               party[i].bot, party[i].from, idle);
00536       if (party[i].status & PLSTAT_AWAY)
00537         dprintf(idx, "   %s: %s\n", MISC_AWAY,
00538                 party[i].away ? party[i].away : "");
00539     }
00540   }
00541   dprintf(idx, "Total users: %d\n", total);
00542 }

Here is the call graph for this function:

Here is the caller graph for this function:

void autolink_cycle ( char *   ) 

Referenced by botlink_resolve_failure(), core_secondly(), failed_link(), and main().

Here is the caller graph for this function:

void backup_userfile ( void   ) 

Definition at line 509 of file main.c.

References copyfile, egg_snprintf, LOG_MISC, putlog, quiet_save, USERF_BACKUP, and userfile.

Referenced by main().

00510 {
00511   char s[125];
00512 
00513   if (quiet_save < 2)
00514     putlog(LOG_MISC, "*", USERF_BACKUP);
00515   egg_snprintf(s, sizeof s, "%s~bak", userfile);
00516   copyfile(userfile, s);
00517 }

Here is the caller graph for this function:

void block_dns_hostbyip ( IP   ) 

Definition at line 458 of file dns.c.

References alarmret, call_hostbyip, iptostr, NULL, resolve_timeout, strncpyz, and UHOSTLEN.

00459 {
00460   struct hostent *hp;
00461   unsigned long addr = htonl(ip);
00462   static char s[UHOSTLEN];
00463 
00464   if (!sigsetjmp(alarmret, 1)) {
00465     alarm(resolve_timeout);
00466     hp = gethostbyaddr((char *) &addr, sizeof(addr), AF_INET);
00467     alarm(0);
00468     if (hp)
00469       strncpyz(s, hp->h_name, sizeof s);
00470     else
00471       strcpy(s, iptostr(addr));
00472   } else {
00473     hp = NULL;
00474     strcpy(s, iptostr(addr));
00475   }
00476   /* Call hooks. */
00477   call_hostbyip(ip, s, hp ? 1 : 0);
00478 }

void block_dns_ipbyhost ( char *   ) 

Definition at line 480 of file dns.c.

References alarmret, call_ipbyhost, egg_inet_aton, and resolve_timeout.

00481 {
00482   struct in_addr inaddr;
00483 
00484   /* Check if someone passed us an IP address as hostname
00485    * and return it straight away */
00486   if (egg_inet_aton(host, &inaddr)) {
00487     call_ipbyhost(host, ntohl(inaddr.s_addr), 1);
00488     return;
00489   }
00490   if (!sigsetjmp(alarmret, 1)) {
00491     struct hostent *hp;
00492     struct in_addr *in;
00493     IP ip = 0;
00494 
00495     alarm(resolve_timeout);
00496     hp = gethostbyname(host);
00497     alarm(0);
00498 
00499     if (hp) {
00500       in = (struct in_addr *) (hp->h_addr_list[0]);
00501       ip = (IP) (in->s_addr);
00502       call_ipbyhost(host, ntohl(ip), 1);
00503       return;
00504     }
00505     /* Fall through. */
00506   }
00507   call_ipbyhost(host, 0, 0);
00508 }

void bot_share ( int  ,
char *   
)

Definition at line 1421 of file botcmd.c.

References sharein.

Referenced by bot_version().

01422 {
01423   sharein(idx, par);
01424 }

Here is the caller graph for this function:

int botlink ( char *  ,
int  ,
char *   
)

Definition at line 978 of file botnet.c.

References bot_addr::address, BOT_ALREADYLINKED, BOT_ALREADYLINKING, BOT_BOTUNKNOWN, BOT_CANTLINKMYSELF, BOT_LINKING, BOT_NOTELNETADDY, botlink_resolve_failure(), botlink_resolve_success(), botnetnick, correct_handle(), dns_info::cptr, DCC_BOT_NEW, dcc_dnsipbyhost, DCC_DNSWAIT, DCC_FORK_BOT, DCC_TOOMANYDCCS1, dcc_total, dcc_t::dns, dns_info::dns_failure, dns_info::dns_success, dns_info::dns_type, dprintf, egg_strcasecmp, userrec::flags, get_data_ptr, get_user, get_user_by_handle, dcc_t::host, dns_info::host, dns_info::ibuf, in_chain, increase_socks_max, LOG_BOTS, max_dcc, MISC_CHADDRFORMAT, MISC_USEFORMAT, new_dcc, now, dcc_t::port, putlog, RES_IPBYHOST, bot_addr::telnet_port, dcc_t::timeval, dns_info::type, dcc_t::u, dcc_t::user, user, USER_BOT, and USERENTRY_BOTADDR.

Referenced by bot_link(), and cmd_link().

00979 {
00980   struct bot_addr *bi;
00981   struct userrec *u;
00982   register int i;
00983 
00984   u = get_user_by_handle(userlist, nick);
00985   if (!u || !(u->flags & USER_BOT)) {
00986     if (idx >= 0)
00987       dprintf(idx, "%s %s\n", nick, BOT_BOTUNKNOWN);
00988   } else if (!egg_strcasecmp(nick, botnetnick)) {
00989     if (idx >= 0)
00990       dprintf(idx, "%s\n", BOT_CANTLINKMYSELF);
00991   } else if (in_chain(nick) && (idx != -3)) {
00992     if (idx >= 0)
00993       dprintf(idx, "%s\n", BOT_ALREADYLINKED);
00994   } else {
00995     for (i = 0; i < dcc_total; i++)
00996       if ((dcc[i].user == u) &&
00997           ((dcc[i].type == &DCC_FORK_BOT) || (dcc[i].type == &DCC_BOT_NEW))) {
00998         if (idx >= 0)
00999           dprintf(idx, "%s\n", BOT_ALREADYLINKING);
01000         return 0;
01001       }
01002     /* Address to connect to is in 'info' */
01003     bi = (struct bot_addr *) get_user(&USERENTRY_BOTADDR, u);
01004     if (!bi || !strlen(bi->address) || !bi->telnet_port ||
01005         (bi->telnet_port <= 0)) {
01006       if (idx >= 0) {
01007         dprintf(idx, "%s '%s'.\n", BOT_NOTELNETADDY, nick);
01008         dprintf(idx, "%s .chaddr %s %s\n",
01009                 MISC_USEFORMAT, nick, MISC_CHADDRFORMAT);
01010       }
01011     } else if (dcc_total == max_dcc && increase_socks_max()) {
01012       if (idx >= 0)
01013         dprintf(idx, "%s\n", DCC_TOOMANYDCCS1);
01014     } else {
01015       correct_handle(nick);
01016 
01017       if (idx > -2)
01018         putlog(LOG_BOTS, "*", "%s %s at %s:%d ...", BOT_LINKING, nick,
01019                bi->address, bi->telnet_port);
01020 
01021       i = new_dcc(&DCC_DNSWAIT, sizeof(struct dns_info));
01022       dcc[i].timeval = now;
01023       dcc[i].port = bi->telnet_port;
01024       dcc[i].user = u;
01025       strcpy(dcc[i].nick, nick);
01026       strcpy(dcc[i].host, bi->address);
01027       dcc[i].u.dns->ibuf = idx;
01028       dcc[i].u.dns->cptr = get_data_ptr(strlen(linker) + 1);
01029       strcpy(dcc[i].u.dns->cptr, linker);
01030       dcc[i].u.dns->host = get_data_ptr(strlen(dcc[i].host) + 1);
01031       strcpy(dcc[i].u.dns->host, dcc[i].host);
01032       dcc[i].u.dns->dns_success = botlink_resolve_success;
01033       dcc[i].u.dns->dns_failure = botlink_resolve_failure;
01034       dcc[i].u.dns->dns_type = RES_IPBYHOST;
01035       dcc[i].u.dns->type = &DCC_FORK_BOT;
01036       dcc_dnsipbyhost(bi->address);
01037       return 1;
01038     }
01039   }
01040   return 0;
01041 }

Here is the call graph for this function:

Here is the caller graph for this function:

int botunlink ( int  ,
char *  ,
char *  ,
char *   
)

Definition at line 871 of file botnet.c.

References b_status, tand_t_struct::bot, BOT_BREAKLINK, BOT_ENDLINKATTEMPT, BOT_KILLLINKATTEMPT, BOT_NOTCONNECTED, BOT_UNLINKALL, BOT_UNLINKEDFROM, BOT_WIPEBOTTABLE, botnet_send_unlinked, bots_in_subtree, chatout, check_tcl_chpt(), DCC_BOT, DCC_BOT_NEW, DCC_FORK_BOT, dcc_total, dprintf, egg_strcasecmp, findbot(), interp, killsock, LOG_BOTS, LOG_MISC, lostdcc, parties, putlog, rembot(), share_unlinks, simple_sprintf, STAT_SHARE, and users_in_subtree.

Referenced by bot_unlink(), and cmd_unlink().

00872 {
00873   char s[20];
00874   register int i;
00875   int bots, users;
00876   tand_t *bot;
00877 
00878   if (nick[0] == '*')
00879     dprintf(idx, "%s\n", BOT_UNLINKALL);
00880   for (i = 0; i < dcc_total; i++) {
00881     if ((nick[0] == '*') || !egg_strcasecmp(dcc[i].nick, nick)) {
00882       if (dcc[i].type == &DCC_FORK_BOT) {
00883         if (idx >= 0)
00884           dprintf(idx, "%s: %s -> %s.\n", BOT_KILLLINKATTEMPT,
00885                   dcc[i].nick, dcc[i].host);
00886         putlog(LOG_BOTS, "*", "%s: %s -> %s:%d",
00887                BOT_KILLLINKATTEMPT, dcc[i].nick, dcc[i].host, dcc[i].port);
00888         killsock(dcc[i].sock);
00889         lostdcc(i);
00890         if (nick[0] != '*')
00891           return 1;
00892       } else if (dcc[i].type == &DCC_BOT_NEW) {
00893         if (idx >= 0)
00894           dprintf(idx, "%s %s.\n", BOT_ENDLINKATTEMPT, dcc[i].nick);
00895         putlog(LOG_BOTS, "*", "%s %s @ %s:%d",
00896                "Stopped trying to link", dcc[i].nick, dcc[i].host, dcc[i].port);
00897         killsock(dcc[i].sock);
00898         lostdcc(i);
00899         if (nick[0] != '*')
00900           return 1;
00901       } else if (dcc[i].type == &DCC_BOT) {
00902         char s[1024];
00903 
00904         if (idx >= 0)
00905           dprintf(idx, "%s %s.\n", BOT_BREAKLINK, dcc[i].nick);
00906         else if ((idx == -3) && (b_status(i) & STAT_SHARE) && !share_unlinks)
00907           return -1;
00908         bot = findbot(dcc[i].nick);
00909         bots = bots_in_subtree(bot);
00910         users = users_in_subtree(bot);
00911         if (reason && reason[0]) {
00912           simple_sprintf(s, "%s %s (%s (%s)) (lost %d bot%s and %d user%s)",
00913                          BOT_UNLINKEDFROM, dcc[i].nick, reason, from, bots,
00914                          (bots != 1) ? "s" : "", users, (users != 1) ?
00915                          "s" : "");
00916           dprintf(i, "bye %s\n", reason);
00917         } else {
00918           simple_sprintf(s, "%s %s (%s) (lost %d bot%s and %d user%s)",
00919                          BOT_UNLINKEDFROM, dcc[i].nick, from, bots,
00920                          (bots != 1) ? "s" : "", users,
00921                          (users != 1) ? "s" : "");
00922           dprintf(i, "bye No reason\n");
00923         }
00924         chatout("*** %s\n", s);
00925         botnet_send_unlinked(i, dcc[i].nick, s);
00926         killsock(dcc[i].sock);
00927         lostdcc(i);
00928         if (nick[0] != '*')
00929           return 1;
00930       }
00931     }
00932   }
00933   if (idx >= 0 && nick[0] != '*')
00934     dprintf(idx, "%s\n", BOT_NOTCONNECTED);
00935   if (nick[0] != '*') {
00936     bot = findbot(nick);
00937     if (bot) {
00938       /* The internal bot list is desynched from the dcc list
00939        * sometimes. While we still search for the bug, provide
00940        * an easy way to clear out those `ghost'-bots.
00941        * Fabian (2000-08-02)  */
00942       char *ghost = "BUG!!: Found bot `%s' in internal bot list, but it\n"
00943                     "   shouldn't have been there! Removing.\n"
00944                     "   This is a known bug we haven't fixed yet. If this\n"
00945                     "   bot is the newest eggdrop version available and you\n"
00946                     "   know a *reliable* way to reproduce the bug, please\n"
00947                     "   contact us - we need your help!\n";
00948       if (idx >= 0)
00949         dprintf(idx, ghost, nick);
00950       else
00951         putlog(LOG_MISC, "*", ghost, nick);
00952       rembot(bot->bot);
00953       return 1;
00954     }
00955   }
00956   if (nick[0] == '*') {
00957     dprintf(idx, "%s\n", BOT_WIPEBOTTABLE);
00958     while (tandbot)
00959       rembot(tandbot->bot);
00960     while (parties) {
00961       parties--;
00962       /* Assert? */
00963       if (party[i].chan >= 0)
00964         check_tcl_chpt(party[i].bot, party[i].nick, party[i].sock,
00965                        party[i].chan);
00966     }
00967     strcpy(s, "killassoc &");
00968     Tcl_Eval(interp, s);
00969   }
00970   return 0;
00971 }

Here is the call graph for this function:

Here is the caller graph for this function:

int casecharcmp ( unsigned  char,
unsigned  char 
)

Definition at line 41 of file match.c.

References rfc_toupper.

00042 {
00043   return (rfc_toupper(a) - rfc_toupper(b));
00044 }

void chanprog (  ) 

Definition at line 429 of file chanprog.c.

References admin, botnetnick, call_hook, check_tcl_event, log_t::chname, configfile, conmask, egg_snprintf, log_t::f, fatal, log_t::filename, log_t::flags, userrec::flags, HANDLEN, helpdir, HOOK_REHASH, LF_EXPIRING, make_rand_str, make_userfile, log_t::mask, max_logs, MISC_CANTWRITETEMP, MISC_NOCONFIGFILE, MISC_NOUSERFILE, MISC_NOUSERFILE2, MISC_USERFCREATE1, MISC_USERFCREATE2, MISC_USERFEXISTS, module_find, nfree, NULL, origbotname, protect_readonly, readtclprog, readuserfile, reaffirm_owners, strncpyz, tempdir, and userfile.

Referenced by main(), and rehash().

00430 {
00431   int i;
00432   FILE *f;
00433   char s[161], rands[8];
00434 
00435   admin[0]   = 0;
00436   helpdir[0] = 0;
00437   tempdir[0] = 0;
00438   conmask    = 0;
00439 
00440   for (i = 0; i < max_logs; i++)
00441     logs[i].flags |= LF_EXPIRING;
00442 
00443   /* Turn off read-only variables (make them write-able) for rehash */
00444   protect_readonly = 0;
00445 
00446   /* Now read it */
00447   if (!readtclprog(configfile))
00448     fatal(MISC_NOCONFIGFILE, 0);
00449 
00450   for (i = 0; i < max_logs; i++) {
00451     if (logs[i].flags & LF_EXPIRING) {
00452       if (logs[i].filename != NULL) {
00453         nfree(logs[i].filename);
00454         logs[i].filename = NULL;
00455       }
00456       if (logs[i].chname != NULL) {
00457         nfree(logs[i].chname);
00458         logs[i].chname = NULL;
00459       }
00460       if (logs[i].f != NULL) {
00461         fclose(logs[i].f);
00462         logs[i].f = NULL;
00463       }
00464       logs[i].mask = 0;
00465       logs[i].flags = 0;
00466     }
00467   }
00468 
00469   /* We should be safe now */
00470   call_hook(HOOK_REHASH);
00471   protect_readonly = 1;
00472 
00473   if (!botnetnick[0])
00474     strncpyz(botnetnick, origbotname, HANDLEN + 1);
00475 
00476   if (!botnetnick[0])
00477     fatal("I don't have a botnet nick!!\n", 0);
00478 
00479   if (!userfile[0])
00480     fatal(MISC_NOUSERFILE2, 0);
00481 
00482   if (!readuserfile(userfile, &userlist)) {
00483     if (!make_userfile) {
00484       char tmp[178];
00485 
00486       egg_snprintf(tmp, sizeof tmp, MISC_NOUSERFILE, configfile);
00487       fatal(tmp, 0);
00488     }
00489     printf("\n\n%s\n", MISC_NOUSERFILE2);
00490     if (module_find("server", 0, 0))
00491       printf(MISC_USERFCREATE1, origbotname);
00492     printf("%s\n\n", MISC_USERFCREATE2);
00493   } else if (make_userfile) {
00494     make_userfile = 0;
00495     printf("%s\n", MISC_USERFEXISTS);
00496   }
00497 
00498   if (helpdir[0])
00499     if (helpdir[strlen(helpdir) - 1] != '/')
00500       strcat(helpdir, "/");
00501 
00502   if (tempdir[0])
00503     if (tempdir[strlen(tempdir) - 1] != '/')
00504       strcat(tempdir, "/");
00505 
00506   /* Test tempdir: it's vital. */
00507 
00508   /* Possible file race condition solved by using a random string
00509    * and the process id in the filename.
00510    * FIXME: This race is only partitially fixed. We could still be
00511    *        overwriting an existing file / following a malicious
00512    *        link.
00513    */
00514   make_rand_str(rands, 7); /* create random string */
00515   sprintf(s, "%s.test-%u-%s", tempdir, getpid(), rands);
00516   f = fopen(s, "w");
00517   if (f == NULL)
00518     fatal(MISC_CANTWRITETEMP, 0);
00519   fclose(f);
00520   unlink(s);
00521   reaffirm_owners();
00522   check_tcl_event("userfile-loaded");
00523 }

Here is the caller graph for this function:

int charcmp ( unsigned  char,
unsigned  char 
)

Definition at line 46 of file match.c.

00047 {
00048   return (a - b);
00049 }

void check_botnet_pings (  ) 

Definition at line 1597 of file botnet.c.

References tand_t_struct::bot, BOT_BOTNOTLEAFLIKE, BOT_DISCONNECTED, BOT_PINGTIMEOUT, botnet_send_ping(), botnet_send_reject(), botnet_send_unlinked, botnetnick, bots_in_subtree, chatout, DCC_BOT, dcc_total, dprintf, findbot(), killsock, LOG_BOTS, lostdcc, tand_t_struct::next, NULL, putlog, simple_sprintf, STAT_LEAF, STAT_PINGED, STAT_WARNED, dcc_t::status, users_in_subtree, and tand_t_struct::via.

Referenced by core_secondly().

01598 {
01599   int i;
01600   int bots, users;
01601   tand_t *bot;
01602 
01603   for (i = 0; i < dcc_total; i++)
01604     if (dcc[i].type == &DCC_BOT)
01605       if (dcc[i].status & STAT_PINGED) {
01606         char s[1024];
01607 
01608         putlog(LOG_BOTS, "*", "%s: %s", BOT_PINGTIMEOUT, dcc[i].nick);
01609         bot = findbot(dcc[i].nick);
01610         bots = bots_in_subtree(bot);
01611         users = users_in_subtree(bot);
01612         simple_sprintf(s, "%s: %s (lost %d bot%s and %d user%s)",
01613                        BOT_PINGTIMEOUT, dcc[i].nick, bots,
01614                        (bots != 1) ? "s" : "", users, (users != 1) ? "s" : "");
01615         chatout("*** %s\n", s);
01616         botnet_send_unlinked(i, dcc[i].nick, s);
01617         killsock(dcc[i].sock);
01618         lostdcc(i);
01619       }
01620   for (i = 0; i < dcc_total; i++)
01621     if (dcc[i].type == &DCC_BOT) {
01622       botnet_send_ping(i);
01623       dcc[i].status |= STAT_PINGED;
01624     }
01625   for (i = 0; i < dcc_total; i++)
01626     if ((dcc[i].type == &DCC_BOT) && (dcc[i].status & STAT_LEAF)) {
01627       tand_t *bot, *via = findbot(dcc[i].nick);
01628 
01629       for (bot = tandbot; bot; bot = bot->next) {
01630         if ((via == bot->via) && (bot != via)) {
01631           /* Not leaflike behavior */
01632           if (dcc[i].status & STAT_WARNED) {
01633             char s[1024];
01634 
01635             putlog(LOG_BOTS, "*", "%s %s (%s).", BOT_DISCONNECTED,
01636                    dcc[i].nick, BOT_BOTNOTLEAFLIKE);
01637             dprintf(i, "bye %s\n", BOT_BOTNOTLEAFLIKE);
01638             bot = findbot(dcc[i].nick);
01639             bots = bots_in_subtree(bot);
01640             users = users_in_subtree(bot);
01641             simple_sprintf(s, "%s %s (%s) (lost %d bot%s and %d user%s)",
01642                            BOT_DISCONNECTED, dcc[i].nick, BOT_BOTNOTLEAFLIKE,
01643                            bots, (bots != 1) ? "s" : "", users, (users != 1) ?
01644                            "s" : "");
01645             chatout("*** %s\n", s);
01646             botnet_send_unlinked(i, dcc[i].nick, s);
01647             killsock(dcc[i].sock);
01648             lostdcc(i);
01649           } else {
01650             botnet_send_reject(i, botnetnick, NULL, bot->bot, NULL, NULL);
01651             dcc[i].status |= STAT_WARNED;
01652           }
01653         } else
01654           dcc[i].status &= ~STAT_WARNED;
01655       }
01656     }
01657 }

Here is the call graph for this function:

Here is the caller graph for this function:

struct userrec* check_dcclist_hand ( char *   )  [read]

Definition at line 190 of file userrec.c.

References dcc_total, egg_strcasecmp, NULL, and dcc_t::user.

Referenced by global().

00191 {
00192   int i;
00193 
00194   for (i = 0; i < dcc_total; i++)
00195     if (!egg_strcasecmp(dcc[i].nick, handle))
00196       return dcc[i].user;
00197   return NULL;
00198 }

Here is the caller graph for this function:

void check_expired_ignores (  ) 

Referenced by core_secondly().

Here is the caller graph for this function:

void check_logsize (  ) 

Definition at line 664 of file misc.c.

References egg_snprintf, log_t::f, keep_all_logs, LOG_MISC, max_logs, max_logsize, MISC_CLOGS, movefile, NULL, and putlog.

Referenced by core_minutely(), and core_secondly().

00665 {
00666   struct stat ss;
00667   int i;
00668 
00669 /* int x=1; */
00670   char buf[1024];               /* Should be plenty */
00671 
00672   if (!keep_all_logs && max_logsize > 0) {
00673     for (i = 0; i < max_logs; i++) {
00674       if (logs[i].filename) {
00675         if (stat(logs[i].filename, &ss) != 0) {
00676           break;
00677         }
00678         if ((ss.st_size >> 10) > max_logsize) {
00679           if (logs[i].f) {
00680             /* write to the log before closing it huh.. */
00681             putlog(LOG_MISC, "*", MISC_CLOGS, logs[i].filename, ss.st_size);
00682             fflush(logs[i].f);
00683             fclose(logs[i].f);
00684             logs[i].f = NULL;
00685           }
00686 
00687           egg_snprintf(buf, sizeof buf, "%s.yesterday", logs[i].filename);
00688           buf[1023] = 0;
00689           unlink(buf);
00690           movefile(logs[i].filename, buf);
00691         }
00692       }
00693     }
00694   }
00695 }

Here is the caller graph for this function:

void check_timers (  ) 
void check_utimers (  ) 
char* int cidr_match ( char *  ,
char *  ,
int   
)

Definition at line 328 of file match.c.

References NOMATCH.

Referenced by addr_match(), mask_match(), and tcl_matchcidr().

00329 {
00330 #ifdef IPV6
00331   int c, af = AF_INET;
00332   u_8bit_t block[16], addr[16];
00333 
00334   if (count < 1)
00335     return NOMATCH;
00336   if (strchr(m, ':') || strchr(n, ':')) {
00337     af = AF_INET6;
00338     if (count > 128)
00339       return NOMATCH;
00340   } else if (count > 32)
00341       return NOMATCH;
00342   if (inet_pton(af, m, &block) != 1 ||
00343       inet_pton(af, n, &addr) != 1)
00344     return NOMATCH;
00345   for (c = 0; c < (count / 8); c++)
00346     if (block[c] != addr[c])
00347       return NOMATCH;
00348   if (!(count % 8))
00349     return 1;
00350   count = 8 - (count % 8);
00351   return ((block[c] >> count) == (addr[c] >> count));
00352 
00353 #else
00354   IP block, addr;
00355 
00356   if (count < 1 || count > 32)
00357     return NOMATCH;
00358   block = ntohl(inet_addr(m));
00359   addr = ntohl(inet_addr(n));
00360   if (block == INADDR_NONE || addr == INADDR_NONE)
00361     return NOMATCH;
00362   count = 32 - count;
00363   return ((block >> count) == (addr >> count));
00364 #endif
00365 }

Here is the caller graph for this function:

char* void clear_masks ( struct maskrec  ) 

Definition at line 251 of file userrec.c.

References maskrec::desc, maskrec::mask, maskrec::next, nfree, NULL, and maskrec::user.

Referenced by void().

00252 {
00253   maskrec *temp = NULL;
00254 
00255   for (; m; m = temp) {
00256     temp = m->next;
00257     if (m->mask)
00258       nfree(m->mask);
00259     if (m->user)
00260       nfree(m->user);
00261     if (m->desc)
00262       nfree(m->desc);
00263     nfree(m);
00264   }
00265 }

Here is the caller graph for this function:

char* void correct_handle ( char *   ) 

Definition at line 238 of file userrec.c.

References get_user_by_handle, userrec::handle, and NULL.

Referenced by botlink(), cmd_su(), and dcc_telnet_id().

00239 {
00240   struct userrec *u;
00241 
00242   u = get_user_by_handle(userlist, handle);
00243   if (u == NULL || handle == u->handle)
00244     return;
00245   strcpy(handle, u->handle);
00246 }

Here is the caller graph for this function:

int cron_match ( const char *  ,
const char *   
)

Definition at line 420 of file match.c.

References cron_matchfld(), newsplit, nfree, and nmalloc.

00421 {
00422   int d = 0, i, m = 1, t[5];
00423   char *p, *q, *buf;
00424 
00425   if (!mask[0])
00426     return 0;
00427   if (sscanf(match, "%d %d %d %d %d",
00428              &t[0], &t[1], &t[2], &t[3], &t[4]) < 5)
00429     return 0;
00430   buf = nmalloc(strlen(mask) + 1);
00431   strcpy(buf, mask);
00432   for (p = buf, i = 0; *p && i < 5; i++) {
00433     q = newsplit(&p);
00434     if (!strcmp(q, "*"))
00435       continue;
00436     m = (cron_matchfld(q, t[i]) ||
00437         (i == 4 && !t[i] && cron_matchfld(q, 7)));
00438     if (i == 2)
00439       d = m;
00440     else if (!m || (i == 3 && d))
00441       break;
00442   }
00443   nfree(buf);
00444   return m;
00445 }

Here is the call graph for this function:

void dcc_chatter ( int   ) 

Definition at line 261 of file dccutil.c.

References botnet_send_join_idx, botnetnick, chat_info::channel, chanout_but, dcc_t::chat, check_tcl_chjn, check_tcl_chon, chat_info::con_chan, DCC_CHAT, dcc_total, FR_ANYWH, FR_CHAN, FR_GLOBAL, get_user_flagrec, geticon, GLOBAL_CHANS, dcc_t::nick, NULL, show_motd, dcc_t::sock, dcc_t::u, and user.

Referenced by cmd_su(), dcc_chat(), dcc_chat_pass(), dcc_telnet_pw(), detect_dcc_flood(), do_boot(), and main().

00262 {
00263   int i, j;
00264   struct flag_record fr = { FR_GLOBAL | FR_CHAN | FR_ANYWH, 0, 0, 0, 0, 0 };
00265 
00266   get_user_flagrec(dcc[idx].user, &fr, NULL);
00267   show_motd(idx);
00268   i = dcc[idx].u.chat->channel;
00269   dcc[idx].u.chat->channel = 234567;
00270   j = dcc[idx].sock;
00271   strcpy(dcc[idx].u.chat->con_chan, "***");
00272   check_tcl_chon(dcc[idx].nick, dcc[idx].sock);
00273   /* Still there? */
00274   if ((idx >= dcc_total) || (dcc[idx].sock != j))
00275     return;                     /* Nope */
00276   /* Tcl script may have taken control */
00277   if (dcc[idx].type == &DCC_CHAT) {
00278     if (!strcmp(dcc[idx].u.chat->con_chan, "***"))
00279       strcpy(dcc[idx].u.chat->con_chan, "*");
00280     if (dcc[idx].u.chat->channel == 234567) {
00281       /* If the chat channel has already been altered it's *highly*
00282        * probably join/part messages have been broadcast everywhere,
00283        * so dont bother sending them
00284        */
00285       if (i == -2)
00286         i = 0;
00287       dcc[idx].u.chat->channel = i;
00288       if ((dcc[idx].u.chat->channel >= 0) &&
00289           (dcc[idx].u.chat->channel < GLOBAL_CHANS))
00290         botnet_send_join_idx(idx, -1);
00291       check_tcl_chjn(botnetnick, dcc[idx].nick, dcc[idx].u.chat->channel,
00292                      geticon(idx), dcc[idx].sock, dcc[idx].host);
00293     }
00294     /* But *do* bother with sending it locally */
00295     if (!dcc[idx].u.chat->channel) {
00296       chanout_but(-1, 0, "*** %s joined the party line.\n", dcc[idx].nick);
00297     } else if (dcc[idx].u.chat->channel > 0) {
00298       chanout_but(-1, dcc[idx].u.chat->channel,
00299                   "*** %s joined the channel.\n", dcc[idx].nick);
00300     }
00301   }
00302 }

Here is the caller graph for this function:

void dcc_remove_lost ( void   ) 

Definition at line 370 of file dccutil.c.

References DCC_LOST, dcc_total, NULL, removedcc, dcc_t::sock, and dcc_t::type.

Referenced by mainloop().

00371 {
00372   int i;
00373 
00374   for (i = 0; i < dcc_total; i++) {
00375     if (dcc[i].type == &DCC_LOST) {
00376       dcc[i].type = NULL;
00377       dcc[i].sock = -1;
00378       removedcc(i);
00379       i--;
00380     }
00381   }
00382 }

Here is the caller graph for this function:

void debug_help ( int   ) 

Definition at line 1160 of file misc.c.

References dprintf, help_ref::first, help_list, help_list_t::name, help_ref::name, help_list_t::next, help_ref::next, and help_list_t::type.

Referenced by cmd_debug().

01161 {
01162   struct help_ref *current;
01163   struct help_list_t *item;
01164 
01165   for (current = help_list; current; current = current->next) {
01166     dprintf(idx, "HELP FILE(S): %s\n", current->name);
01167     for (item = current->first; item; item = item->next) {
01168       dprintf(idx, "   %s (%s)\n", item->name, (item->type == 0) ? "msg/" :
01169               (item->type == 1) ? "" : "set/");
01170     }
01171   }
01172 }

Here is the caller graph for this function:

void debug_mem_to_dcc ( int   ) 

Definition at line 117 of file mem.c.

References dprintf, egg_strcasecmp, expmem_botnet(), expmem_chanprog(), expmem_dccutil(), expmem_dns(), expmem_language(), expmem_misc(), expmem_modules(), expmem_net(), expmem_tcl(), expmem_tcldcc(), expmem_tclhash(), expmem_tclmisc(), expmem_users(), _module_entry::funcs, MODCALL_EXPMEM, _module_entry::name, _module_entry::next, NULL, and tell_netdebug().

Referenced by cmd_debug().

00118 {
00119 #ifdef DEBUG_MEM
00120 #  define MAX_MEM 13
00121   unsigned long exp[MAX_MEM], use[MAX_MEM], l;
00122   int i, j;
00123   char fn[20], sofar[81];
00124   module_entry *me;
00125   char *p;
00126 
00127   exp[0] = expmem_language();
00128   exp[1] = expmem_chanprog();
00129   exp[2] = expmem_misc();
00130   exp[3] = expmem_users();
00131   exp[4] = expmem_net();
00132   exp[5] = expmem_dccutil();
00133   exp[6] = expmem_botnet();
00134   exp[7] = expmem_tcl();
00135   exp[8] = expmem_tclhash();
00136   exp[9] = expmem_tclmisc();
00137   exp[10] = expmem_modules(1);
00138   exp[11] = expmem_tcldcc();
00139   exp[12] = expmem_dns();
00140 
00141   for (me = module_list; me; me = me->next)
00142     me->mem_work = 0;
00143 
00144   for (i = 0; i < MAX_MEM; i++)
00145     use[i] = 0;
00146 
00147   for (i = 0; i < lastused; i++) {
00148     strcpy(fn, memtbl[i].file);
00149     p = strchr(fn, ':');
00150     if (p)
00151       *p = 0;
00152     l = memtbl[i].size;
00153     if (!strcmp(fn, "language.c"))
00154       use[0] += l;
00155     else if (!strcmp(fn, "chanprog.c"))
00156       use[1] += l;
00157     else if (!strcmp(fn, "misc.c"))
00158       use[2] += l;
00159     else if (!strcmp(fn, "userrec.c"))
00160       use[3] += l;
00161     else if (!strcmp(fn, "net.c"))
00162       use[4] += l;
00163     else if (!strcmp(fn, "dccutil.c"))
00164       use[5] += l;
00165     else if (!strcmp(fn, "botnet.c"))
00166       use[6] += l;
00167     else if (!strcmp(fn, "tcl.c"))
00168       use[7] += l;
00169     else if (!strcmp(fn, "tclhash.c"))
00170       use[8] += l;
00171     else if (!strcmp(fn, "tclmisc.c"))
00172       use[9] += l;
00173     else if (!strcmp(fn, "modules.c"))
00174       use[10] += l;
00175     else if (!strcmp(fn, "tcldcc.c"))
00176       use[11] += l;
00177     else if (!strcmp(fn, "dns.c"))
00178       use[12] += l;
00179     else if (p) {
00180       for (me = module_list; me; me = me->next)
00181         if (!strcmp(fn, me->name))
00182           me->mem_work += l;
00183     } else
00184       dprintf(idx, "Not logging file %s!\n", fn);
00185   }
00186 
00187   for (i = 0; i < MAX_MEM; i++) {
00188     switch (i) {
00189     case 0:
00190       strcpy(fn, "language.c");
00191       break;
00192     case 1:
00193       strcpy(fn, "chanprog.c");
00194       break;
00195     case 2:
00196       strcpy(fn, "misc.c");
00197       break;
00198     case 3:
00199       strcpy(fn, "userrec.c");
00200       break;
00201     case 4:
00202       strcpy(fn, "net.c");
00203       break;
00204     case 5:
00205       strcpy(fn, "dccutil.c");
00206       break;
00207     case 6:
00208       strcpy(fn, "botnet.c");
00209       break;
00210     case 7:
00211       strcpy(fn, "tcl.c");
00212       break;
00213     case 8:
00214       strcpy(fn, "tclhash.c");
00215       break;
00216     case 9:
00217       strcpy(fn, "tclmisc.c");
00218       break;
00219     case 10:
00220       strcpy(fn, "modules.c");
00221       break;
00222     case 11:
00223       strcpy(fn, "tcldcc.c");
00224       break;
00225     case 12:
00226       strcpy(fn, "dns.c");
00227       break;
00228     }
00229 
00230     if (use[i] == exp[i])
00231       dprintf(idx, "File '%-10s' accounted for %lu/%lu (ok)\n", fn, exp[i],
00232               use[i]);
00233     else {
00234       dprintf(idx, "File '%-10s' accounted for %lu/%lu (debug follows:)\n",
00235               fn, exp[i], use[i]);
00236       strcpy(sofar, "   ");
00237       for (j = 0; j < lastused; j++) {
00238         if ((p = strchr(memtbl[j].file, ':')))
00239           *p = 0;
00240         if (!egg_strcasecmp(memtbl[j].file, fn)) {
00241           if (p)
00242             sprintf(&sofar[strlen(sofar)], "%-10s/%-4d:(%04d) ",
00243                     p + 1, memtbl[j].line, memtbl[j].size);
00244           else
00245             sprintf(&sofar[strlen(sofar)], "%-4d:(%04d) ",
00246                     memtbl[j].line, memtbl[j].size);
00247 
00248           if (strlen(sofar) > 60) {
00249             sofar[strlen(sofar) - 1] = 0;
00250             dprintf(idx, "%s\n", sofar);
00251             strcpy(sofar, "   ");
00252           }
00253         }
00254         if (p)
00255           *p = ':';
00256       }
00257       if (sofar[0]) {
00258         sofar[strlen(sofar) - 1] = 0;
00259         dprintf(idx, "%s\n", sofar);
00260       }
00261     }
00262   }
00263 
00264   for (me = module_list; me; me = me->next) {
00265     Function *f = me->funcs;
00266     int expt = 0;
00267 
00268     if ((f != NULL) && (f[MODCALL_EXPMEM] != NULL))
00269       expt = f[MODCALL_EXPMEM] ();
00270     if (me->mem_work == expt)
00271       dprintf(idx, "Module '%-10s' accounted for %lu/%lu (ok)\n", me->name,
00272               expt, me->mem_work);
00273     else {
00274       dprintf(idx, "Module '%-10s' accounted for %lu/%lu (debug follows:)\n",
00275               me->name, expt, me->mem_work);
00276       strcpy(sofar, "   ");
00277       for (j = 0; j < lastused; j++) {
00278         strcpy(fn, memtbl[j].file);
00279         if ((p = strchr(fn, ':')) != NULL) {
00280           *p = 0;
00281           if (!egg_strcasecmp(fn, me->name)) {
00282             sprintf(&sofar[strlen(sofar)], "%-10s/%-4d:(%04X) ", p + 1,
00283                     memtbl[j].line, memtbl[j].size);
00284             if (strlen(sofar) > 60) {
00285               sofar[strlen(sofar) - 1] = 0;
00286               dprintf(idx, "%s\n", sofar);
00287               strcpy(sofar, "   ");
00288             }
00289             *p = ':';
00290           }
00291         }
00292       }
00293       if (sofar[0]) {
00294         sofar[strlen(sofar) - 1] = 0;
00295         dprintf(idx, "%s\n", sofar);
00296       }
00297     }
00298   }
00299 
00300   dprintf(idx, "--- End of debug memory list.\n");
00301 #else
00302   dprintf(idx, "Compiled without extensive memory debugging (sorry).\n");
00303 #endif
00304   tell_netdebug(idx);
00305 }

Here is the call graph for this function:

Here is the caller graph for this function:

void del_dcc ( int   ) 
void dequeue_sockets (  ) 

Referenced by mainloop().

Here is the caller graph for this function:

void do_boot ( int  ,
char *  ,
char *   
)

Definition at line 603 of file dccutil.c.

References backgrd, botnet_send_part_idx, chat_info::channel, chanout_but, dcc_t::chat, check_tcl_chof, DCC_BOOTED1, DCC_BOOTED2, DCC_BOOTED3, DCC_CHAT, dcc_chatter(), DCT_CHAT, DP_STDOUT, dprintf, egg_snprintf, GLOBAL_CHANS, killsock, lostdcc, STDOUT, dcc_t::type, and dcc_t::u.

Referenced by append_line(), bot_reject(), and cmd_boot().

00604 {
00605   int files = (dcc[idx].type != &DCC_CHAT);
00606 
00607   dprintf(idx, DCC_BOOTED1);
00608   dprintf(idx, DCC_BOOTED2, files ? "file section" : "bot",
00609           by, reason[0] ? ": " : ".", reason);
00610   /* If it's a partyliner (chatterer :) */
00611   /* Horrible assumption that DCT_CHAT using structure uses same format
00612    * as DCC_CHAT */
00613   if ((dcc[idx].type->flags & DCT_CHAT) && (dcc[idx].u.chat->channel >= 0)) {
00614     char x[1024];
00615 
00616     egg_snprintf(x, sizeof x, DCC_BOOTED3, by, dcc[idx].nick,
00617                  reason[0] ? ": " : "", reason);
00618     chanout_but(idx, dcc[idx].u.chat->channel, "*** %s.\n", x);
00619     if (dcc[idx].u.chat->channel < GLOBAL_CHANS)
00620       botnet_send_part_idx(idx, x);
00621   }
00622   check_tcl_chof(dcc[idx].nick, dcc[idx].sock);
00623   if ((dcc[idx].sock != STDOUT) || backgrd) {
00624     killsock(dcc[idx].sock);
00625     lostdcc(idx);
00626     /* Entry must remain in the table so it can be logged by the caller */
00627   } else {
00628     dprintf(DP_STDOUT, "\n### SIMULATION RESET\n\n");
00629     dcc_chatter(idx);
00630   }
00631   return;
00632 }

Here is the call graph for this function:

Here is the caller graph for this function:

void dump_links ( int   ) 

Definition at line 733 of file botnet.c.

References chat_info::away, b_numver, tand_t_struct::bot, bot_flags, BOT_ISOLATE, botnetnick, chat_info::channel, dcc_t::chat, DCC_CHAT, dcc_total, from, geticon, GLOBAL_CHANS, NEAT_BOTNET, tand_t_struct::next, now, parties, PLSTAT_AWAY, tand_t_struct::share, simple_sprintf, timer, tputs, dcc_t::u, tand_t_struct::uplink, and user.

Referenced by bot_version().

00734 {
00735   register int i, l;
00736   char x[1024];
00737   tand_t *bot;
00738 
00739   for (bot = tandbot; bot; bot = bot->next) {
00740     char *p;
00741 
00742     if (bot->uplink == (tand_t *) 1)
00743       p = botnetnick;
00744     else
00745       p = bot->uplink->bot;
00746 #ifndef NO_OLD_BOTNET
00747     if (b_numver(z) < NEAT_BOTNET)
00748       l = simple_sprintf(x, "nlinked %s %s %c%d\n", bot->bot,
00749                          p, bot->share, bot->ver);
00750     else
00751 #endif
00752       l = simple_sprintf(x, "n %s %s %c%D\n", bot->bot, p,
00753                          bot->share, bot->ver);
00754     tputs(dcc[z].sock, x, l);
00755   }
00756   if (!(bot_flags(dcc[z].user) & BOT_ISOLATE)) {
00757     /* Dump party line members */
00758     for (i = 0; i < dcc_total; i++) {
00759       if (dcc[i].type == &DCC_CHAT) {
00760         if ((dcc[i].u.chat->channel >= 0) &&
00761             (dcc[i].u.chat->channel < GLOBAL_CHANS)) {
00762 #ifndef NO_OLD_BOTNET
00763           if (b_numver(z) < NEAT_BOTNET)
00764             l = simple_sprintf(x, "join %s %s %d %c%d %s\n",
00765                                botnetnick, dcc[i].nick,
00766                                dcc[i].u.chat->channel, geticon(i),
00767                                dcc[i].sock, dcc[i].host);
00768           else
00769 #endif
00770             l = simple_sprintf(x, "j !%s %s %D %c%D %s\n",
00771                                botnetnick, dcc[i].nick,
00772                                dcc[i].u.chat->channel, geticon(i),
00773                                dcc[i].sock, dcc[i].host);
00774           tputs(dcc[z].sock, x, l);
00775 #ifndef NO_OLD_BOTNET
00776           if (b_numver(z) < NEAT_BOTNET) {
00777             if (dcc[i].u.chat->away) {
00778               l = simple_sprintf(x, "away %s %d %s\n", botnetnick,
00779                                  dcc[i].sock, dcc[i].u.chat->away);
00780               tputs(dcc[z].sock, x, l);
00781             }
00782             l = simple_sprintf(x, "idle %s %d %d\n", botnetnick,
00783                                dcc[i].sock, now - dcc[i].timeval);
00784           } else
00785 #endif
00786             l = simple_sprintf(x, "i %s %D %D %s\n", botnetnick,
00787                                dcc[i].sock, now - dcc[i].timeval,
00788                                dcc[i].u.chat->away ? dcc[i].u.chat->away : "");
00789           tputs(dcc[z].sock, x, l);
00790         }
00791       }
00792     }
00793     for (i = 0; i < parties; i++) {
00794 #ifndef NO_OLD_BOTNET
00795       if (b_numver(z) < NEAT_BOTNET)
00796         l = simple_sprintf(x, "join %s %s %d %c%d %s\n",
00797                            party[i].bot, party[i].nick,
00798                            party[i].chan, party[i].flag,
00799                            party[i].sock, party[i].from);
00800       else
00801 #endif
00802         l = simple_sprintf(x, "j %s %s %D %c%D %s\n",
00803                            party[i].bot, party[i].nick,
00804                            party[i].chan, party[i].flag,
00805                            party[i].sock, party[i].from);
00806       tputs(dcc[z].sock, x, l);
00807       if ((party[i].status & PLSTAT_AWAY) || (party[i].timer != 0)) {
00808 #ifndef NO_OLD_BOTNET
00809         if (b_numver(z) < NEAT_BOTNET) {
00810           if (party[i].status & PLSTAT_AWAY) {
00811             l = simple_sprintf(x, "away %s %d %s\n", party[i].bot,
00812                                party[i].sock, party[i].away);
00813             tputs(dcc[z].sock, x, l);
00814           }
00815           l = simple_sprintf(x, "idle %s %d %d\n", party[i].bot,
00816                              party[i].sock, now - party[i].timer);
00817         } else
00818 #endif
00819           l = simple_sprintf(x, "i %s %D %D %s\n", party[i].bot,
00820                              party[i].sock, now - party[i].timer,
00821                              party[i].away ? party[i].away : "");
00822         tputs(dcc[z].sock, x, l);
00823       }
00824     }
00825   }
00826 }

Here is the caller graph for this function:

void dumplots ( int  ,
const char *  ,
const char *   
)

Definition at line 420 of file misc.c.

References dprintf.

Referenced by cmd_set(), and cmd_tcl().

00421 {
00422   const char *p = data, *q, *n;
00423   const int max_data_len = 500 - strlen(prefix);
00424 
00425   if (!*data) {
00426     dprintf(idx, "%s\n", prefix);
00427     return;
00428   }
00429   while (strlen(p) > max_data_len) {
00430     q = p + max_data_len;
00431     /* Search for embedded linefeed first */
00432     n = strchr(p, '\n');
00433     if (n && n < q) {
00434       /* Great! dump that first line then start over */
00435       dprintf(idx, "%s%.*s\n", prefix, n - p, p);
00436       p = n + 1;
00437     } else {
00438       /* Search backwards for the last space */
00439       while (*q != ' ' && q != p)
00440         q--;
00441       if (q == p)
00442         q = p + max_data_len;
00443       dprintf(idx, "%s%.*s\n", prefix, q - p, p);
00444       p = q;
00445       if (*q == ' ')
00446         p++;
00447     }
00448   }
00449   /* Last trailing bit: split by linefeeds if possible */
00450   n = strchr(p, '\n');
00451   while (n) {
00452     dprintf(idx, "%s%.*s\n", prefix, n - p, p);
00453     p = n + 1;
00454     n = strchr(p, '\n');
00455   }
00456   if (*p)
00457     dprintf(idx, "%s%s\n", prefix, p);  /* Last trailing bit */
00458 }

Here is the caller graph for this function:

void dupwait_notify ( char *   ) 

Definition at line 1347 of file dcc.c.

References Assert, dupwait_info::atr, dcc_telnet_pass(), dcc_total, dcc_t::dupwait, and egg_strcasecmp.

Referenced by rembot().

01348 {
01349   register int idx;
01350 
01351   Assert(who);
01352   for (idx = 0; idx < dcc_total; idx++)
01353     if ((dcc[idx].type == &DCC_DUPWAIT) &&
01354         !egg_strcasecmp(dcc[idx].nick, who)) {
01355       dcc_telnet_pass(idx, dcc[idx].u.dupwait->atr);
01356       break;
01357     }
01358 }

Here is the call graph for this function:

Here is the caller graph for this function:

void eggAssert ( const char *  ,
int  ,
const char *   
)
void eggContext ( const char *  ,
int  ,
const char *   
)
void eggContextNote ( const char *  ,
int  ,
const char *  ,
const char *   
)
int exist_lang_section ( char *   ) 

Definition at line 294 of file language.c.

References lang_st::next, and lang_st::section.

00295 {
00296   lang_sec *ls;
00297 
00298   for (ls = langsection; ls; ls = ls->next)
00299     if (!strcmp(section, ls->section))
00300       return 1;
00301   return 0;
00302 }

char* extracthostname ( char *   ) 

Definition at line 1351 of file misc.c.

01352 {
01353   char *p = strrchr(hostmask, '@');
01354 
01355   return p ? p + 1 : "";
01356 }

void failed_link ( int   ) 

Definition at line 250 of file dcc.c.

References add_note, dcc_t::addr, autolink_cycle(), botnetnick, DCC_LINKFAIL, egg_snprintf, failed_link(), getsock, dcc_t::host, iptostr, killsock, LOG_BOTS, lostdcc, dcc_t::nick, now, open_telnet_raw(), dcc_t::port, putlog, dcc_t::sock, SOCK_STRONGCONN, dcc_t::timeval, and dcc_t::u.

Referenced by botlink_resolve_success(), and failed_link().

00251 {
00252   char s[81], s1[512];
00253 
00254   if (dcc[idx].port >= dcc[idx].u.bot->port + 3) {
00255     if (dcc[idx].u.bot->linker[0]) {
00256       egg_snprintf(s, sizeof s, "Couldn't link to %s.", dcc[idx].nick);
00257       strcpy(s1, dcc[idx].u.bot->linker);
00258       add_note(s1, botnetnick, s, -2, 0);
00259     }
00260     if (dcc[idx].u.bot->numver >= -1)
00261       putlog(LOG_BOTS, "*", DCC_LINKFAIL, dcc[idx].nick);
00262     killsock(dcc[idx].sock);
00263     strcpy(s, dcc[idx].nick);
00264     lostdcc(idx);
00265     autolink_cycle(s);          /* Check for more auto-connections */
00266     return;
00267   }
00268 
00269   /* Try next port */
00270   killsock(dcc[idx].sock);
00271   dcc[idx].sock = getsock(SOCK_STRONGCONN);
00272   dcc[idx].port++;
00273   dcc[idx].timeval = now;
00274   if (dcc[idx].sock < 0 ||
00275       open_telnet_raw(dcc[idx].sock, dcc[idx].addr ?
00276                       iptostr(htonl(dcc[idx].addr)) : dcc[idx].host,
00277                       dcc[idx].port) < 0) {
00278     failed_link(idx);
00279   }
00280 }

Here is the call graph for this function:

Here is the caller graph for this function:

struct chat_info* struct dcc_t* find_idx ( int   )  [read]
struct tand_t_struct* findbot ( char *   )  [read]

Definition at line 74 of file botnet.c.

References tand_t_struct::bot, egg_strcasecmp, tand_t_struct::next, and NULL.

Referenced by addbot(), bot_bye(), bot_linked(), bot_thisbot(), bot_unlinked(), botunlink(), check_botnet_pings(), cont_link(), eof_dcc_bot(), free_dcc_bot_(), in_chain(), lastbot(), nextbot(), updatebot(), and zapfbot().

00075 {
00076   tand_t *ptr;
00077 
00078   for (ptr = tandbot; ptr; ptr = ptr->next)
00079     if (!egg_strcasecmp(ptr->bot, who))
00080       return ptr;
00081   return NULL;
00082 }

Here is the caller graph for this function:

int findidx ( int   ) 

Definition at line 111 of file dccutil.c.

References dcc_total, DCT_VALIDIDX, dcc_table::flags, dcc_t::sock, and dcc_t::type.

Referenced by tcl_dccdumpfile().

00112 {
00113   int j;
00114 
00115   for (j = 0; j < dcc_total; j++)
00116     if ((dcc[j].sock == z) && (dcc[j].type->flags & DCT_VALIDIDX))
00117       return j;
00118   return -1;
00119 }

Here is the caller graph for this function:

void flushlogs (  ) 

Definition at line 699 of file misc.c.

References egg_strftime(), log_ts, max_logs, MISC_LOGREPEAT, now, NULL, quick_logs, and log_t::repeats.

Referenced by core_minutely(), core_secondly(), fatal(), and mainloop().

00700 {
00701   int i;
00702 
00703   /* Logs may not be initialised yet. */
00704   if (!logs)
00705     return;
00706 
00707   /* Now also checks to see if there's a repeat message and
00708    * displays the 'last message repeated...' stuff too <cybah>
00709    */
00710   for (i = 0; i < max_logs; i++) {
00711     if (logs[i].f != NULL) {
00712       if ((logs[i].repeats > 0) && quick_logs) {
00713         /* Repeat.. if quicklogs used then display 'last message
00714          * repeated x times' and reset repeats.
00715          */
00716         char stamp[33];
00717 
00718         egg_strftime(stamp, sizeof(stamp) - 1, log_ts, localtime(&now));
00719         fprintf(logs[i].f, "%s ", stamp);
00720         fprintf(logs[i].f, MISC_LOGREPEAT, logs[i].repeats);
00721         /* Reset repeats */
00722         logs[i].repeats = 0;
00723       }
00724       fflush(logs[i].f);
00725     }
00726   }
00727 }

Here is the call graph for this function:

Here is the caller graph for this function:

void freeuser ( struct userrec  ) 

Definition at line 704 of file userrec.c.

References userrec::chanrec, userrec::entries, list_type::extra, chanuserrec::info, user_entry_type::kill, user_entry::list, user_entry::name, list_type::next, user_entry::next, chanuserrec::next, nfree, NULL, user_entry::type, user_entry::u, and ut.

Referenced by int(), and void().

00705 {
00706   struct user_entry *ue, *ut;
00707   struct chanuserrec *ch, *z;
00708 
00709   if (u == NULL)
00710     return;
00711 
00712   ch = u->chanrec;
00713   while (ch) {
00714     z = ch;
00715     ch = ch->next;
00716     if (z->info != NULL)
00717       nfree(z->info);
00718     nfree(z);
00719   }
00720   u->chanrec = NULL;
00721   for (ue = u->entries; ue; ue = ut) {
00722     ut = ue->next;
00723     if (ue->name) {
00724       struct list_type *lt, *ltt;
00725 
00726       for (lt = ue->u.list; lt; lt = ltt) {
00727         ltt = lt->next;
00728         nfree(lt->extra);
00729         nfree(lt);
00730       }
00731       nfree(ue->name);
00732       nfree(ue);
00733     } else
00734       ue->type->kill(ue);
00735   }
00736   nfree(u);
00737 }

Here is the caller graph for this function:

int getparty ( char *  ,
int   
)

Definition at line 225 of file botnet.c.

References egg_strcasecmp, and parties.

Referenced by bot_away(), bot_part(), and botnet_send_away().

00226 {
00227   int i;
00228 
00229   for (i = 0; i < parties; i++) {
00230     if (!egg_strcasecmp(party[i].bot, bot) && (party[i].sock == sock)) {
00231       return i;
00232     }
00233   }
00234   return -1;
00235 }

Here is the caller graph for this function:

char* char* char global ( char *   ) 

Definition at line 308 of file userrec.c.

00309 {
00310   struct userrec *u, *ret;
00311   struct list_type *q;
00312   int cnt, i;
00313   char host2[UHOSTLEN];
00314 
00315   if (host == NULL)
00316     return NULL;
00317   rmspace(host);
00318   if (!host[0])
00319     return NULL;
00320   ret = check_chanlist(host);
00321   cnt = 0;
00322   if (ret != NULL) {
00323     cache_hit++;
00324     return ret;
00325   }
00326   cache_miss++;
00327   strncpyz(host2, host, sizeof host2);
00328   host = fixfrom(host);
00329   for (u = userlist; u; u = u->next) {
00330     q = get_user(&USERENTRY_HOSTS, u);
00331     for (; q; q = q->next) {
00332       i = match_useraddr(q->extra, host);
00333       if (i > cnt) {
00334         ret = u;
00335         cnt = i;
00336       }
00337     }
00338   }
00339   if (ret != NULL) {
00340     lastuser = ret;
00341     set_chanlist(host2, ret);
00342   }
00343   return ret;
00344 }

struct userrec* struct userrec* struct global ( struct userrec ,
char *  ,
char *  ,
char *  ,
int   
) [read]

Definition at line 617 of file userrec.c.

References build_flags, userrec::chanrec, clear_chanlist, xtra_key::data, default_flags, default_uflags, userrec::entries, fixfrom, userrec::flags, userrec::flags_udef, FR_GLOBAL, flag_record::global, userrec::handle, xtra_key::key, userrec::next, nfree, nmalloc, noshare, now, NULL, set_user, shareout, strncpyz, flag_record::udef_global, USER_DEFAULT, USER_UNSHARED, USERENTRY_HOSTS, USERENTRY_PASS, and USERENTRY_XTRA.

00619 {
00620   struct userrec *u, *x;
00621   struct xtra_key *xk;
00622   int oldshare = noshare;
00623   long tv;
00624 
00625   noshare = 1;
00626   u = nmalloc(sizeof *u);
00627 
00628   /* u->next=bu; bu=u; */
00629   strncpyz(u->handle, handle, sizeof u->handle);
00630   u->next = NULL;
00631   u->chanrec = NULL;
00632   u->entries = NULL;
00633   if (flags != USER_DEFAULT) {  /* drummer */
00634     u->flags = flags;
00635     u->flags_udef = 0;
00636   } else {
00637     u->flags = default_flags;
00638     u->flags_udef = default_uflags;
00639   }
00640   set_user(&USERENTRY_PASS, u, pass);
00641   if (!noxtra) {
00642     char *now2;
00643     xk = nmalloc(sizeof *xk);
00644     xk->key = nmalloc(8);
00645     strcpy(xk->key, "created");
00646     now2 = nmalloc(15);
00647     tv = now;
00648     sprintf(now2, "%li", tv);
00649     xk->data = nmalloc(strlen(now2) + 1);
00650     sprintf(xk->data, "%li", tv);
00651     set_user(&USERENTRY_XTRA, u, xk);
00652     nfree(now2);
00653   }
00654   /* Strip out commas -- they're illegal */
00655   if (host && host[0]) {
00656     char *p;
00657 
00658     /* About this fixfrom():
00659      *   We should use this fixfrom before every call of adduser()
00660      *   but its much easier to use here...  (drummer)
00661      *   Only use it if we have a host :) (dw)
00662      */
00663     host = fixfrom(host);
00664 
00665     p = strchr(host, ',');
00666     while (p != NULL) {
00667       *p = '?';
00668       p = strchr(host, ',');
00669     }
00670     set_user(&USERENTRY_HOSTS, u, host);
00671   } else
00672     set_user(&USERENTRY_HOSTS, u, "none");
00673   if (bu == userlist)
00674     clear_chanlist();
00675   noshare = oldshare;
00676   if ((!noshare) && (handle[0] != '*') && (!(flags & USER_UNSHARED)) &&
00677       (bu == userlist)) {
00678     struct flag_record fr = { FR_GLOBAL, 0, 0, 0, 0, 0 };
00679     char x[100];
00680 
00681     fr.global = u->flags;
00682 
00683     fr.udef_global = u->flags_udef;
00684     build_flags(x, &fr, 0);
00685     shareout(NULL, "n %s %s %s %s\n", handle, host && host[0] ? host : "none",
00686              pass, x);
00687   }
00688   if (bu == NULL)
00689     bu = u;
00690   else {
00691     if ((bu == userlist) && (lastuser != NULL))
00692       x = lastuser;
00693     else
00694       x = bu;
00695     while (x->next != NULL)
00696       x = x->next;
00697     x->next = u;
00698     if (bu == userlist)
00699       lastuser = u;
00700   }
00701   return bu;
00702 }

char char char* char char char* char* char* IP global ( IP   ) 
Type Constraints
char* char* char global ( char *  ,
const   char,
register const   char 
)
char* char* char global ( const char *  ,
const   char,
const   char 
)
char* char* char global ( char **   ) 
char* char* int global ( unsigned  int  ) 
char* char* int global ( int   ) 
char char char* void help_subst ( char *  ,
char *  ,
struct flag_record ,
int  ,
char *   
)
Type Constraints

Definition at line 802 of file misc.c.

References admin, blind, botname, botnetnick, break_down_flags, cols, colsofar, colstr, chanset_t::dname, egg_snprintf, egg_strcasecmp, egg_strftime(), flagrec_eq, FR_CHAN, FR_GLOBAL, glob_hilite, HELP_BOLD, HELP_BUF_LEN, HELP_FLASH, HELP_IRC, HELP_REV, HELP_UNDER, my_strcpy, network, chanset_t::next, nfree, nmalloc, now, NULL, strncpyz, subst_addcol(), subwidth, ver, and version.

Referenced by bot_motd(), display_tellhelp(), show_banner(), show_motd(), showhelp(), and sub_lang().

00804 {
00805   char xx[HELP_BUF_LEN + 1], sub[161], *current, *q, chr, *writeidx,
00806        *readidx, *towrite;
00807   struct chanset_t *chan;
00808   int i, j, center = 0;
00809   static int help_flags;
00810 
00811 #ifdef HAVE_UNAME
00812   struct utsname uname_info;
00813 #endif
00814 
00815   if (s == NULL) {
00816     /* Used to reset substitutions */
00817     blind = 0;
00818     cols = 0;
00819     subwidth = 70;
00820     if (colstr != NULL) {
00821       nfree(colstr);
00822       colstr = NULL;
00823     }
00824     help_flags = isdcc;
00825     return;
00826   }
00827   strncpyz(xx, s, sizeof xx);
00828   readidx = xx;
00829   writeidx = s;
00830   current = strchr(readidx, '%');
00831   while (current) {
00832     /* Are we about to copy a chuck to the end of the buffer?
00833      * if so return
00834      */
00835     if ((writeidx + (current - readidx)) >= (s + HELP_BUF_LEN)) {
00836       strncpy(writeidx, readidx, (s + HELP_BUF_LEN) - writeidx);
00837       s[HELP_BUF_LEN] = 0;
00838       return;
00839     }
00840     chr = *(current + 1);
00841     *current = 0;
00842     if (!blind)
00843       writeidx += my_strcpy(writeidx, readidx);
00844     towrite = NULL;
00845     switch (chr) {
00846     case 'b':
00847       if (glob_hilite(*flags)) {
00848         if (help_flags & HELP_IRC) {
00849           towrite = "\002";
00850         } else if (help_flags & HELP_BOLD) {
00851           help_flags &= ~HELP_BOLD;
00852           towrite = "\033[0m";
00853         } else {
00854           help_flags |= HELP_BOLD;
00855           towrite = "\033[1m";
00856         }
00857       }
00858       break;
00859     case 'v':
00860       if (glob_hilite(*flags)) {
00861         if (help_flags & HELP_IRC) {
00862           towrite = "\026";
00863         } else if (help_flags & HELP_REV) {
00864           help_flags &= ~HELP_REV;
00865           towrite = "\033[0m";
00866         } else {
00867           help_flags |= HELP_REV;
00868           towrite = "\033[7m";
00869         }
00870       }
00871       break;
00872     case '_':
00873       if (glob_hilite(*flags)) {
00874         if (help_flags & HELP_IRC) {
00875           towrite = "\037";
00876         } else if (help_flags & HELP_UNDER) {
00877           help_flags &= ~HELP_UNDER;
00878           towrite = "\033[0m";
00879         } else {
00880           help_flags |= HELP_UNDER;
00881           towrite = "\033[4m";
00882         }
00883       }
00884       break;
00885     case 'f':
00886       if (glob_hilite(*flags)) {
00887         if (help_flags & HELP_FLASH) {
00888           if (help_flags & HELP_IRC)
00889             towrite = "\002\037";
00890           else
00891             towrite = "\033[0m";
00892           help_flags &= ~HELP_FLASH;
00893         } else {
00894           help_flags |= HELP_FLASH;
00895           if (help_flags & HELP_IRC)
00896             towrite = "\037\002";
00897           else
00898             towrite = "\033[5m";
00899         }
00900       }
00901       break;
00902     case 'U':
00903 #ifdef HAVE_UNAME
00904       if (uname(&uname_info) >= 0) {
00905         egg_snprintf(sub, sizeof sub, "%s %s", uname_info.sysname,
00906                      uname_info.release);
00907         towrite = sub;
00908       } else
00909 #endif
00910         towrite = "*UNKNOWN*";
00911       break;
00912     case 'B':
00913       towrite = (isdcc ? botnetnick : botname);
00914       break;
00915     case 'V':
00916       towrite = ver;
00917       break;
00918     case 'E':
00919       towrite = version;
00920       break;
00921     case 'A':
00922       towrite = admin;
00923       break;
00924     case 'n':
00925       towrite = network;
00926       break;
00927     case 'T':
00928       egg_strftime(sub, 6, "%H:%M", localtime(&now));
00929       towrite = sub;
00930       break;
00931     case 'N':
00932       towrite = strchr(nick, ':');
00933       if (towrite)
00934         towrite++;
00935       else
00936         towrite = nick;
00937       break;
00938     case 'C':
00939       if (!blind)
00940         for (chan = chanset; chan; chan = chan->next) {
00941           if ((strlen(chan->dname) + writeidx + 2) >= (s + HELP_BUF_LEN)) {
00942             strncpy(writeidx, chan->dname, (s + HELP_BUF_LEN) - writeidx);
00943             s[HELP_BUF_LEN] = 0;
00944             return;
00945           }
00946           writeidx += my_strcpy(writeidx, chan->dname);
00947           if (chan->next) {
00948             *writeidx++ = ',';
00949             *writeidx++ = ' ';
00950           }
00951         }
00952       break;
00953     case '{':
00954       q = current;
00955       current++;
00956       while ((*current != '}') && (*current))
00957         current++;
00958       if (*current) {
00959         *current = 0;
00960         current--;
00961         q += 2;
00962         /* Now q is the string and p is where the rest of the fcn expects */
00963         if (!strncmp(q, "help=", 5)) {
00964           if (topic && egg_strcasecmp(q + 5, topic))
00965             blind |= 2;
00966           else
00967             blind &= ~2;
00968         } else if (!(blind & 2)) {
00969           if (q[0] == '+') {
00970             struct flag_record fr = { FR_GLOBAL | FR_CHAN, 0, 0, 0, 0, 0 };
00971 
00972             break_down_flags(q + 1, &fr, NULL);
00973 
00974             /* We used to check flagrec_ok(), but we can use flagrec_eq()
00975              * instead because lower flags are automatically added now.
00976              */
00977             if (!flagrec_eq(&fr, flags))
00978               blind |= 1;
00979             else
00980               blind &= ~1;
00981           } else if (q[0] == '-')
00982             blind &= ~1;
00983           else if (!egg_strcasecmp(q, "end")) {
00984             blind &= ~1;
00985             subwidth = 70;
00986             if (cols) {
00987               sub[0] = 0;
00988               subst_addcol(sub, "\377");
00989               nfree(colstr);
00990               colstr = NULL;
00991               cols = 0;
00992               towrite = sub;
00993             }
00994           } else if (!egg_strcasecmp(q, "center"))
00995             center = 1;
00996           else if (!strncmp(q, "cols=", 5)) {
00997             char *r;
00998 
00999             cols = atoi(q + 5);
01000             colsofar = 0;
01001             colstr = nmalloc(1);
01002             colstr[0] = 0;
01003             r = strchr(q + 5, '/');
01004             if (r != NULL)
01005               subwidth = atoi(r + 1);
01006           }
01007         }
01008       } else
01009         current = q;            /* no } so ignore */
01010       break;
01011     default:
01012       if (!blind) {
01013         *writeidx++ = chr;
01014         if (writeidx >= (s + HELP_BUF_LEN)) {
01015           *writeidx = 0;
01016           return;
01017         }
01018       }
01019     }
01020     if (towrite && !blind) {
01021       if ((writeidx + strlen(towrite)) >= (s + HELP_BUF_LEN)) {
01022         strncpy(writeidx, towrite, (s + HELP_BUF_LEN) - writeidx);
01023         s[HELP_BUF_LEN] = 0;
01024         return;
01025       }
01026       writeidx += my_strcpy(writeidx, towrite);
01027     }
01028     if (chr) {
01029       readidx = current + 2;
01030       current = strchr(readidx, '%');
01031     } else {
01032       readidx = current + 1;
01033       current = NULL;
01034     }
01035   }
01036   if (!blind) {
01037     i = strlen(readidx);
01038     if (i && ((writeidx + i) >= (s + HELP_BUF_LEN))) {
01039       strncpy(writeidx, readidx, (s + HELP_BUF_LEN) - writeidx);
01040       s[HELP_BUF_LEN] = 0;
01041       return;
01042     }
01043     strcpy(writeidx, readidx);
01044   } else
01045     *writeidx = 0;
01046   if (center) {
01047     strcpy(xx, s);
01048     i = 35 - (strlen(xx) / 2);
01049     if (i > 0) {
01050       s[0] = 0;
01051       for (j = 0; j < i; j++)
01052         s[j] = ' ';
01053       strcpy(s + i, xx);
01054     }
01055   }
01056   if (cols) {
01057     strcpy(xx, s);
01058     s[0] = 0;
01059     subst_addcol(s, xx);
01060   }
01061 }

Here is the call graph for this function:

Here is the caller graph for this function:

int init_threaddata ( int   ) 

Definition at line 735 of file tcl.c.

References threaddata::blocktime, increase_socks_max, threaddata::mainloopfunc, threaddata::mainthread, threaddata::MAXSOCKS, NULL, tclthreadmainloop(), and threaddata().

00736 {
00737   struct threaddata *td = threaddata();
00738 /* Nested evaluation (vwait/update) of the event loop only
00739  * processes Tcl events (after/fileevent) for now. Using
00740  * eggdrops mainloop() requires caution regarding reentrance.
00741  * (check_tcl_* -> Tcl_Eval() -> mainloop() -> check_tcl_* etc.)
00742  */
00743 /* td->mainloopfunc = mainthread ? mainloop : tclthreadmainloop; */
00744   td->mainloopfunc = tclthreadmainloop;
00745   td->socklist = NULL;
00746   td->mainthread = mainthread;
00747   td->blocktime.tv_sec = 1;
00748   td->blocktime.tv_usec = 0;
00749   td->MAXSOCKS = 0;
00750   increase_socks_max();
00751   return 0;
00752 }

Here is the call graph for this function:

int ( (int(*)(char *, struct userrec **))  global[54]  ) 
int ( (int(*)(char *))  global[141]  ) 

Definition at line 56 of file users.c.

References global_ign, igrec::igmask, match_useraddr, and igrec::next.

00057 {
00058   struct igrec *ir;
00059 
00060   for (ir = global_ign; ir; ir = ir->next)
00061     if (match_useraddr(ir->igmask, uhost))
00062       return 1;
00063   return 0;
00064 }

int ( (int(*)(char *))  global[142]  ) 

Definition at line 80 of file users.c.

References global_ign, igrec::next, nfree, noshare, NULL, rfc_casecmp, shareout, str_escape, and strncpyz.

00081 {
00082   int i, j;
00083   struct igrec **u;
00084   struct igrec *t;
00085   char temp[256];
00086 
00087   i = 0;
00088   if (!strchr(ign, '!') && (j = atoi(ign))) {
00089     for (u = &global_ign, j--; *u && j; u = &((*u)->next), j--);
00090     if (*u) {
00091       strncpyz(temp, (*u)->igmask, sizeof temp);
00092       i = 1;
00093     }
00094   } else {
00095     /* find the matching host, if there is one */
00096     for (u = &global_ign; *u && !i; u = &((*u)->next))
00097       if (!rfc_casecmp(ign, (*u)->igmask)) {
00098         strncpyz(temp, ign, sizeof temp);
00099         i = 1;
00100         break;
00101       }
00102   }
00103   if (i) {
00104     if (!noshare) {
00105       char *mask = str_escape(temp, ':', '\\');
00106 
00107       if (mask) {
00108         shareout(NULL, "-i %s\n", mask);
00109         nfree(mask);
00110       }
00111     }
00112     nfree((*u)->igmask);
00113     if ((*u)->msg)
00114       nfree((*u)->msg);
00115     if ((*u)->user)
00116       nfree((*u)->user);
00117     t = *u;
00118     *u = (*u)->next;
00119     nfree(t);
00120   }
00121   return i;
00122 }

int ( (int(*)(struct flag_record *, int))  global[296]  ) 
int ( (int(*)(FILE *, int))  global[282]  ) 
int ( (int(*)(struct userrec *, FILE *, int))  global[60]  ) 
int ( (int(*)(struct userrec *, char *))  global[59]  ) 
int ( (int(*)(char *))  global[51]  ) 

Definition at line 739 of file userrec.c.

References clear_chanlist, egg_strcasecmp, userrec::flags, freeuser(), userrec::handle, userrec::next, noshare, NULL, shareout, dcc_t::user, user, and USER_UNSHARED.

00740 {
00741   struct userrec *u = userlist, *prev = NULL;
00742   int fnd = 0;
00743 
00744   while ((u != NULL) && (!fnd)) {
00745     if (!egg_strcasecmp(u->handle, handle))
00746       fnd = 1;
00747     else {
00748       prev = u;
00749       u = u->next;
00750     }
00751   }
00752   if (!fnd)
00753     return 0;
00754   if (prev == NULL)
00755     userlist = u->next;
00756   else
00757     prev->next = u->next;
00758   if (!noshare && (handle[0] != '*') && !(u->flags & USER_UNSHARED))
00759     shareout(NULL, "k %s\n", handle);
00760   for (fnd = 0; fnd < dcc_total; fnd++)
00761     if (dcc[fnd].user == u)
00762       dcc[fnd].user = 0;        /* Clear any dcc users for this entry,
00763                                  * null is safe-ish */
00764   clear_chanlist();
00765   freeuser(u);
00766   lastuser = NULL;
00767   return 1;
00768 }

Here is the call graph for this function:

int ( (int(*)(struct userrec *))  global[62]  ) 

Definition at line 156 of file userrec.c.

References userrec::next.

00157 {
00158   int tot = 0;
00159   struct userrec *u;
00160 
00161   for (u = bu; u; u = u->next)
00162     tot++;
00163   return tot;
00164 }

char* int ( (int(*)(char *, char *))  global[53]  ) 
int ( (int(*)(struct userrec *, char *))  global[38]  ) 
int ( (int(*)(struct userrec *, struct user_entry *, void *))  global[231]  ) 
char* int ( (int(*)(const char *))  global[149]  ) 

Definition at line 934 of file tcl.c.

References EGG_CONST, file_readable, interp, LOG_MISC, NULL, and putlog.

00935 {
00936   int code;
00937   EGG_CONST char *result;
00938 #ifdef USE_TCL_ENCODING
00939   Tcl_DString dstr;
00940 #endif
00941 
00942   if (!file_readable(fname))
00943     return 0;
00944 
00945   code = Tcl_EvalFile(interp, fname);
00946   result = Tcl_GetVar(interp, "errorInfo", TCL_GLOBAL_ONLY);
00947 
00948 #ifdef USE_TCL_ENCODING
00949   /* properly convert string to system encoding. */
00950   Tcl_DStringInit(&dstr);
00951   Tcl_UtfToExternalDString(NULL, result, -1, &dstr);
00952   result = Tcl_DStringValue(&dstr);
00953 #endif
00954 
00955   if (code != TCL_OK) {
00956     putlog(LOG_MISC, "*", "Tcl error in file '%s':", fname);
00957     putlog(LOG_MISC, "*", "%s", result);
00958     code = 0; /* JJM: refactored to remove premature return */
00959   } else {
00960     /* Refresh internal variables */
00961     code = 1;
00962   }
00963 
00964 #ifdef USE_TCL_ENCODING
00965   Tcl_DStringFree(&dstr);
00966 #endif
00967 
00968   return code;
00969 }

int ( (int(*)(int))  global[270]  ) 
int ( (int(*)(int, int, int))  global[269]  ) 
int ( (int(*)(int, int))  global[248]  ) 
char char char* int ( (int(*)(char *, char *, IP, char *, char *))  global[239]  ) 
int ( (int(*)(char *, char *, char *, char *))  global[214]  ) 
int ( (int(*)(int, char *, char *))  global[85]  ) 
int* int ( (int(*)(char *, int))  global[87]  ) 
int ( (int(*)(IP addr, int *port))  global[261]  ) 
int ( (int(*)(int *))  global[84]  )  [inline]
int ( (int(*)(int, char *, unsigned long *, unsigned short *, int))  global[76]  ) 
int ( (int(*)(int))  global[82]  ) 
int ( (int(*)(int sock, int options))  global[234]  ) 
int ( (int(*)(const char *))  global[292]  )  const
int ( (int(*)(const char *))  global[257]  )  const
int ( (int(*)(const char *))  global[291]  )  const
int ( (int(*)(char *, const char *))  global[91]  ) 
int ( (int(*)(char *dst, const char *src, size_t max))  global[265]  ) 
int ( (int(*)(const char *, const char *))  global[295]  ) 
int ( (int(*)(const char *, const char *, int, int))  global[294]  ) 
int ( (int(*)(void))  global[168]  ) 
int ( (int(*)(char *))  global[165]  ) 
int ( (int(*)(struct userrec *, int, char *))  global[206]  ) 
int ( (int(*)(struct dcc_table *, int))  global[80]  ) 
int ( (int(*)(time_t *, struct chat_info *, int))  global[166]  ) 
int ( (int(*)(int))  global[130]  ) 
int ( (int(*)(void))  global[297]  ) 
char* int ( (int(*)(char *))  global[290]  ) 
int ( (int(*)(char *))  global[202]  ) 
int ( (int(*)(struct userrec *, char *, int, int))  global[208]  ) 
int ( (int(*)(struct userrec *, int))  global[207]  ) 
int ( (int(*)(char *))  global[215]  ) 
int ( (int(*)(char *))  global[200]  ) 
int ( (int(*)())  global[23]  ) 
int ( (int(*)(char *, char *, char *, int, int))  global[164]  ) 
int ( (int(*)(char *))  global[163]  ) 
int ( (int(*)(char *))  global[35]  ) 
int ( (int(*)(char *))  global[20]  ) 
IP ( (IP(*)(void))  global[77]  ) 

Definition at line 108 of file net.c.

References fatal, hostname, myip, and NULL.

00109 {
00110   struct hostent *hp;
00111   char s[121];
00112   IP ip;
00113   struct in_addr *in;
00114   if (myip[0]) {
00115     if ((myip[strlen(myip) - 1] >= '0') && (myip[strlen(myip) - 1] <= '9'))
00116       return (IP) inet_addr(myip);
00117   }
00118   /* Also could be pre-defined */
00119   if (hostname[0])
00120     hp = gethostbyname(hostname);
00121   else {
00122     gethostname(s, 120);
00123     hp = gethostbyname(s);
00124   }
00125   if (hp == NULL)
00126     fatal("Hostname self-lookup failed. Please set 'my-ip' in the config "
00127           "file.", 0);
00128   in = (struct in_addr *) (hp->h_addr_list[0]);
00129   ip = (IP) (in->s_addr);
00130   return ip;
00131 }

IP ( (IP(*)(char *))  global[90]  ) 

Definition at line 78 of file net.c.

00079 {
00080   IP ret = 0;
00081 
00082   while ((*s >= '0') && (*s <= '9')) {
00083     ret *= 10;
00084     ret += ((*s) - '0');
00085     s++;
00086   }
00087   return ret;
00088 }

char* char* int ishost_for_handle ( char *  ,
char *   
)
void killtclsock ( int   ) 
char* lastbot ( char *   ) 

Definition at line 415 of file botnet.c.

References tand_t_struct::bot, botnetnick, findbot(), and tand_t_struct::uplink.

Referenced by bot_unlinked(), botnet_send_unlinked(), and cmd_unlink().

00416 {
00417   tand_t *bot = findbot(who);
00418 
00419   if (!bot)
00420     return "*";
00421   else if (bot->uplink == (tand_t *) 1)
00422     return botnetnick;
00423   else
00424     return bot->uplink->bot;
00425 }

Here is the call graph for this function:

Here is the caller graph for this function:

int list_type_expmem ( struct list_type  ) 

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:

void logsuffix_change ( char *   ) 

Definition at line 639 of file misc.c.

References debug0, log_t::f, logfile_suffix, max_logs, and NULL.

Referenced by tcl_eggstr().

00640 {
00641   int i;
00642   char *s2 = logfile_suffix;
00643 
00644   /* If the suffix didn't really change, ignore. It's probably a rehash. */
00645   if (s && s2 && !strcmp(s, s2))
00646     return;
00647 
00648   debug0("Logfile suffix changed. Closing all open logs.");
00649   strcpy(logfile_suffix, s);
00650   while (s2[0]) {
00651     if (s2[0] == ' ')
00652       s2[0] = '_';
00653     s2++;
00654   }
00655   for (i = 0; i < max_logs; i++) {
00656     if (logs[i].f) {
00657       fflush(logs[i].f);
00658       fclose(logs[i].f);
00659       logs[i].f = NULL;
00660     }
00661   }
00662 }

Here is the caller graph for this function:

unsigned long ( 0xffffffff &  long)(htonl((unsigned long) IP)  ) 

Referenced by botfl_set(), and get_user_flagrec().

Here is the caller graph for this function:

int mainloop ( int   ) 

Definition at line 715 of file main.c.

References dcc_table::activity, argc, argv, backgrd, botnetnick, call_hook, check_tcl_event, dcc_remove_lost(), dcc_total, dependancy_list, dequeue_sockets(), do_restart, do_tcl_sync(), e, dcc_table::eof, fatal, flushlogs(), _module_entry::funcs, garbage_collect(), HOOK_IDLE, HOOK_LOADED, HOOK_SECONDLY, init_language(), init_tcl(), itraffic_bn_today, itraffic_dcc_today, itraffic_irc_today, itraffic_trans_today, itraffic_unknown_today, kill_tcl(), killsock, LOG_MISC, lostdcc, MOD_STAGNANT, MODCALL_START, module_unload, _module_entry::name, _dependancy::needed, user_entry::next, _dependancy::next, _module_entry::next, nfree, now, NULL, putlog, rehash(), restart_chons(), dcc_t::sock, sockgets(), STDOUT, and dcc_t::type.

Referenced by main().

00716 {
00717   static int socket_cleanup = 0;
00718   int xx, i, eggbusy = 1, tclbusy = 0, old_do_restart;
00719   char buf[520];
00720 
00721   /* Lets move some of this here, reducing the numer of actual
00722    * calls to periodic_timers
00723    */
00724   now = time(NULL);
00725   /*
00726    * FIXME: Get rid of this, it's ugly and wastes lots of cpu.
00727    *
00728    * pre-1.3.0 Eggdrop had random() in the once a second block below.
00729    *
00730    * This attempts to keep random() more random by constantly
00731    * calling random() and updating the state information.
00732    */
00733   random();                /* Woop, lets really jumble things */
00734 
00735   /* If we want to restart, we have to unwind to the toplevel.
00736    * Tcl will Panic if we kill the interp with Tcl_Eval in progress.
00737    * This is done by returning -1 in tickle_WaitForEvent.
00738    */
00739   if (do_restart && do_restart != -2 && !toplevel)
00740     return -1;
00741 
00742   /* Once a second */
00743   if (now != then) {
00744     call_hook(HOOK_SECONDLY);
00745     then = now;
00746   }
00747 
00748   /* Only do this every so often. */
00749   if (!socket_cleanup) {
00750     socket_cleanup = 5;
00751 
00752     /* Remove dead dcc entries. */
00753     dcc_remove_lost();
00754 
00755     /* Check for server or dcc activity. */
00756     dequeue_sockets();
00757   } else
00758     socket_cleanup--;
00759 
00760   /* Free deleted binds, only if not recursing. */
00761   if (toplevel)
00762     garbage_collect();
00763 
00764   xx = sockgets(buf, &i);
00765   if (xx >= 0) {              /* Non-error */
00766     int idx;
00767 
00768     for (idx = 0; idx < dcc_total; idx++)
00769       if (dcc[idx].sock == xx) {
00770         if (dcc[idx].type && dcc[idx].type->activity) {
00771           /* Traffic stats */
00772           if (dcc[idx].type->name) {
00773             if (!strncmp(dcc[idx].type->name, "BOT", 3))
00774               itraffic_bn_today += strlen(buf) + 1;
00775             else if (!strcmp(dcc[idx].type->name, "SERVER"))
00776               itraffic_irc_today += strlen(buf) + 1;
00777             else if (!strncmp(dcc[idx].type->name, "CHAT", 4))
00778               itraffic_dcc_today += strlen(buf) + 1;
00779             else if (!strncmp(dcc[idx].type->name, "FILES", 5))
00780               itraffic_dcc_today += strlen(buf) + 1;
00781             else if (!strcmp(dcc[idx].type->name, "SEND"))
00782               itraffic_trans_today += strlen(buf) + 1;
00783             else if (!strncmp(dcc[idx].type->name, "GET", 3))
00784               itraffic_trans_today += strlen(buf) + 1;
00785             else
00786               itraffic_unknown_today += strlen(buf) + 1;
00787           }
00788           dcc[idx].type->activity(idx, buf, i);
00789         } else
00790           putlog(LOG_MISC, "*",
00791                  "!!! untrapped dcc activity: type %s, sock %d",
00792                  dcc[idx].type->name, dcc[idx].sock);
00793         break;
00794       }
00795   } else if (xx == -1) {        /* EOF from someone */
00796     int idx;
00797 
00798     if (i == STDOUT && !backgrd)
00799       fatal("END OF FILE ON TERMINAL", 0);
00800     for (idx = 0; idx < dcc_total; idx++)
00801       if (dcc[idx].sock == i) {
00802         if (dcc[idx].type && dcc[idx].type->eof)
00803           dcc[idx].type->eof(idx);
00804         else {
00805           putlog(LOG_MISC, "*",
00806                  "*** ATTENTION: DEAD SOCKET (%d) OF TYPE %s UNTRAPPED",
00807                  i, dcc[idx].type ? dcc[idx].type->name : "*UNKNOWN*");
00808           killsock(i);
00809           lostdcc(idx);
00810         }
00811         idx = dcc_total + 1;
00812       }
00813     if (idx == dcc_total) {
00814       putlog(LOG_MISC, "*",
00815              "(@) EOF socket %d, not a dcc socket, not anything.", i);
00816       close(i);
00817       killsock(i);
00818     }
00819   } else if (xx == -2 && errno != EINTR) {      /* select() error */
00820     putlog(LOG_MISC, "*", "* Socket error #%d; recovering.", errno);
00821     for (i = 0; i < dcc_total; i++) {
00822       if ((fcntl(dcc[i].sock, F_GETFD, 0) == -1) && (errno == EBADF)) {
00823         putlog(LOG_MISC, "*",
00824                "DCC socket %d (type %d, name '%s') expired -- pfft",
00825                dcc[i].sock, dcc[i].type, dcc[i].nick);
00826         killsock(dcc[i].sock);
00827         lostdcc(i);
00828         i--;
00829       }
00830     }
00831   } else if (xx == -3) {
00832     call_hook(HOOK_IDLE);
00833     socket_cleanup = 0;       /* If we've been idle, cleanup & flush */
00834     eggbusy = 0;
00835   } else if (xx == -5) {
00836     eggbusy = 0;
00837     tclbusy = 1;
00838   }
00839 
00840 /* restart/rehash is performed here, reset do_restart ASAP to prevent
00841  * doing it again if rehash() recurses in Tcl_Eval() */
00842   if (do_restart) {
00843     old_do_restart = do_restart;
00844     do_restart = 0;
00845     if (old_do_restart == -2)
00846       rehash();
00847     else if (!toplevel)
00848       return -1; /* Unwind to toplevel before restarting */
00849     else {
00850       /* Unload as many modules as possible */
00851       int f = 1;
00852       module_entry *p;
00853       Function startfunc;
00854       char name[256];
00855 
00856       /* oops, I guess we should call this event before tcl is restarted */
00857       check_tcl_event("prerestart");
00858 
00859       while (f) {
00860         f = 0;
00861         for (p = module_list; p != NULL; p = p->next) {
00862           dependancy *d = dependancy_list;
00863           int ok = 1;
00864 
00865           while (ok && d) {
00866             if (d->needed == p)
00867               ok = 0;
00868             d = d->next;
00869           }
00870           if (ok) {
00871             strcpy(name, p->name);
00872             if (module_unload(name, botnetnick) == NULL) {
00873               f = 1;
00874               break;
00875             }
00876           }
00877         }
00878       }
00879 
00880       /* Make sure we don't have any modules left hanging around other than
00881        * "eggdrop" and the two that are supposed to be.
00882        */
00883       for (f = 0, p = module_list; p; p = p->next) {
00884         if (strcmp(p->name, "eggdrop") && strcmp(p->name, "encryption") &&
00885             strcmp(p->name, "uptime")) {
00886           f++;
00887         }
00888       }
00889       if (f != 0) {
00890         putlog(LOG_MISC, "*", MOD_STAGNANT);
00891       }
00892 
00893       flushlogs();
00894       kill_tcl();
00895       init_tcl(argc, argv);
00896       init_language(0);
00897 
00898       /* this resets our modules which we didn't unload (encryption and uptime) */
00899       for (p = module_list; p; p = p->next) {
00900         if (p->funcs) {
00901           startfunc = p->funcs[MODCALL_START];
00902           startfunc(NULL);
00903         }
00904       }
00905 
00906       rehash();
00907       restart_chons();
00908       call_hook(HOOK_LOADED);
00909     }
00910     eggbusy = 1;
00911   }
00912 
00913 #ifdef USE_TCL_EVENTS
00914   if (!eggbusy) {
00915 /* Process all pending tcl events */
00916 
00917 #  ifdef REPLACE_NOTIFIER
00918     tclevent_t *e;
00919     if (Tcl_ServiceAll())
00920       tclbusy = 1;
00921     while (tclevents) {
00922       e = tclevents;
00923       tclevents = tclevents->next;
00924       tclbusy = 1;
00925       do_tcl_sync(e->context, e->script, e->callback, 1);
00926       nfree(e);
00927     }
00928 #  else
00929     while (Tcl_DoOneEvent(TCL_DONT_WAIT | TCL_ALL_EVENTS))
00930       tclbusy = 1;
00931 #  endif /* REPLACE_NOTIFIER */
00932 
00933 #endif   /* USE_TCL_EVENTS   */
00934   }

Here is the call graph for this function:

Here is the caller graph for this function:

char* maskname ( int   ) 

Definition at line 188 of file flags.c.

References LOG_BOTNET, LOG_BOTS, LOG_BOTSHARE, LOG_CMDS, LOG_DEBUG, LOG_FILES, LOG_JOIN, LOG_LEV1, LOG_LEV2, LOG_LEV3, LOG_LEV4, LOG_LEV5, LOG_LEV6, LOG_LEV7, LOG_LEV8, LOG_MISC, LOG_MODES, LOG_MSGS, LOG_PUBLIC, LOG_RAW, LOG_SERV, LOG_SRVOUT, LOG_WALL, my_strcpy, and raw_log.

Referenced by cmd_console(), and tell_settings().

00189 {
00190   static char s[207];           /* Change this if you change the levels */
00191   int i = 0;
00192 
00193   s[0] = 0;
00194   if (x & LOG_MSGS)
00195     i += my_strcpy(s, "msgs, ");
00196   if (x & LOG_PUBLIC)
00197     i += my_strcpy(s + i, "public, ");
00198   if (x & LOG_JOIN)
00199     i += my_strcpy(s + i, "joins, ");
00200   if (x & LOG_MODES)
00201     i += my_strcpy(s + i, "kicks/modes, ");
00202   if (x & LOG_CMDS)
00203     i += my_strcpy(s + i, "cmds, ");
00204   if (x & LOG_MISC)
00205     i += my_strcpy(s + i, "misc, ");
00206   if (x & LOG_BOTS)
00207     i += my_strcpy(s + i, "bots, ");
00208   if ((x & LOG_RAW) && raw_log)
00209     i += my_strcpy(s + i, "raw, ");
00210   if (x & LOG_FILES)
00211     i += my_strcpy(s + i, "files, ");
00212   if (x & LOG_SERV)
00213     i += my_strcpy(s + i, "server, ");
00214   if (x & LOG_DEBUG)
00215     i += my_strcpy(s + i, "debug, ");
00216   if (x & LOG_WALL)
00217     i += my_strcpy(s + i, "wallops, ");
00218   if ((x & LOG_SRVOUT) && raw_log)
00219     i += my_strcpy(s + i, "server output, ");
00220   if ((x & LOG_BOTNET) && raw_log)
00221     i += my_strcpy(s + i, "botnet traffic, ");
00222   if ((x & LOG_BOTSHARE) && raw_log)
00223     i += my_strcpy(s + i, "share traffic, ");
00224   if (x & LOG_LEV1)
00225     i += my_strcpy(s + i, "level 1, ");
00226   if (x & LOG_LEV2)
00227     i += my_strcpy(s + i, "level 2, ");
00228   if (x & LOG_LEV3)
00229     i += my_strcpy(s + i, "level 3, ");
00230   if (x & LOG_LEV4)
00231     i += my_strcpy(s + i, "level 4, ");
00232   if (x & LOG_LEV5)
00233     i += my_strcpy(s + i, "level 5, ");
00234   if (x & LOG_LEV6)
00235     i += my_strcpy(s + i, "level 6, ");
00236   if (x & LOG_LEV7)
00237     i += my_strcpy(s + i, "level 7, ");
00238   if (x & LOG_LEV8)
00239     i += my_strcpy(s + i, "level 8, ");
00240   if (i)
00241     s[i - 2] = 0;
00242   else
00243     strcpy(s, "none");
00244   return s;
00245 }

Here is the caller graph for this function:

void* n_malloc ( int  ,
const char *  ,
int   
)

Definition at line 341 of file mem.c.

References fatal, LOG_MISC, malloc, NULL, and putlog.

Referenced by _get_data_ptr(), _user_malloc(), n_malloc_null(), and n_realloc().

00342 {
00343   void *x;
00344 
00345   x = (void *) malloc(size);
00346   if (x == NULL) {
00347     putlog(LOG_MISC, "*", "*** FAILED MALLOC %s (%d) (%d): %s", file, line,
00348            size, strerror(errno));
00349     fatal("Memory allocation failed", 0);
00350   }
00351 #ifdef DEBUG_MEM
00352   addtomemtbl(x, size, file, line);
00353 #endif
00354   return x;
00355 }

Here is the caller graph for this function:

void* n_realloc ( void *  ,
int  ,
const char *  ,
int   
)

Definition at line 357 of file mem.c.

References LOG_MISC, n_malloc(), NULL, and putlog.

Referenced by _user_realloc().

00358 {
00359   void *x;
00360   int i = 0;
00361 
00362 #ifdef DEBUG_MEM
00363   char *p;
00364 #endif
00365 
00366   /* ptr == NULL is valid. Avoiding duplicate code further down */
00367   if (!ptr)
00368     return n_malloc(size, file, line);
00369 
00370   x = (void *) realloc(ptr, size);
00371   if (x == NULL && size > 0) {
00372     i = i;
00373     putlog(LOG_MISC, "*", "*** FAILED REALLOC %s (%d)", file, line);
00374     return NULL;
00375   }
00376 #ifdef DEBUG_MEM
00377   for (i = 0; (i < lastused) && (memtbl[i].ptr != ptr); i++);
00378   if (i == lastused) {
00379     putlog(LOG_MISC, "*", "*** ATTEMPTING TO REALLOC NON-MALLOC'D PTR: %s (%d)",
00380            file, line);
00381     return NULL;
00382   }
00383   memused -= memtbl[i].size;
00384   memtbl[i].ptr = x;
00385   memtbl[i].line = line;
00386   memtbl[i].size = size;
00387   p = strrchr(file, '/');
00388   strncpy(memtbl[i].file, p ? p + 1 : file, 19);
00389   memtbl[i].file[19] = 0;
00390   memused += size;
00391 #endif
00392   return x;
00393 }

Here is the call graph for this function:

Here is the caller graph for this function:

char* n_strdup ( const char *  ,
const char *  ,
int   
)

Definition at line 329 of file mem.c.

References egg_strdup().

00330 {
00331   char *x;
00332 
00333   x = egg_strdup(s);
00334 /* compat strdup uses nmalloc itself */
00335 #if defined(DEBUG_MEM) && defined(HAVE_STRDUP)
00336   addtomemtbl(x, strlen(s)+1, file, line);
00337 #endif
00338   return x;
00339 }

Here is the call graph for this function:

void not_away ( int   ) 

Definition at line 431 of file dccutil.c.

References chat_info::away, botnet_send_away(), botnetnick, chat_info::channel, chanout_but, dcc_t::chat, check_tcl_away(), dprintf, GLOBAL_CHANS, nfree, dcc_t::nick, NULL, and dcc_t::u.

Referenced by cmd_back(), cmd_chat(), cmd_me(), dcc_chat(), and set_away().

00432 {
00433   if (dcc[idx].u.chat->away == NULL) {
00434     dprintf(idx, "You weren't away!\n");
00435     return;
00436   }
00437   if (dcc[idx].u.chat->channel >= 0) {
00438     chanout_but(-1, dcc[idx].u.chat->channel,
00439                 "*** %s is no longer away.\n", dcc[idx].nick);
00440     if (dcc[idx].u.chat->channel < GLOBAL_CHANS) {
00441       botnet_send_away(-1, botnetnick, dcc[idx].sock, NULL, idx);
00442     }
00443   }
00444   dprintf(idx, "You're not away any more.\n");
00445   nfree(dcc[idx].u.chat->away);
00446   dcc[idx].u.chat->away = NULL;
00447   check_tcl_away(botnetnick, dcc[idx].sock, NULL);
00448 }

Here is the call graph for this function:

Here is the caller graph for this function:

char char* int open_telnet_raw ( int  ,
char *  ,
int   
)

Referenced by botlink_resolve_success(), failed_link(), failed_tandem_relay(), and tandem_relay_resolve_success().

Here is the caller graph for this function:

void partyaway ( char *  ,
int  ,
char *   
)

Definition at line 274 of file botnet.c.

References party_t::away, egg_strcasecmp, nfree, nmalloc, and parties.

Referenced by bot_away(), and bot_idle().

00275 {
00276   int i;
00277 
00278   for (i = 0; i < parties; i++) {
00279     if ((!egg_strcasecmp(party[i].bot, bot)) && (party[i].sock == sock)) {
00280       if (party[i].away)
00281         nfree(party[i].away);
00282       if (msg[0]) {
00283         party[i].away = nmalloc(strlen(msg) + 1);
00284         strcpy(party[i].away, msg);
00285       } else
00286         party[i].away = 0;
00287     }
00288   }
00289 }

Here is the caller graph for this function:

int partyidle ( char *  ,
char *   
)

Definition at line 239 of file botnet.c.

References egg_strcasecmp, now, parties, and party_t::timer.

Referenced by bot_actchan(), and bot_chan2().

00240 {
00241   int i, ok = 0;
00242 
00243   for (i = 0; i < parties; i++) {
00244     if ((!egg_strcasecmp(party[i].bot, bot)) &&
00245         (!egg_strcasecmp(party[i].nick, nick))) {
00246       party[i].timer = now;
00247       ok = 1;
00248     }
00249   }
00250   return ok;
00251 }

Here is the caller graph for this function:

int partynick ( char *  ,
int  ,
char *   
)

Definition at line 255 of file botnet.c.

References egg_strcasecmp, HANDLEN, party_t::nick, and parties.

Referenced by bot_nickchange().

00256 {
00257   char work[HANDLEN + 1];
00258   int i;
00259 
00260   for (i = 0; i < parties; i++) {
00261     if (!egg_strcasecmp(party[i].bot, bot) && (party[i].sock == sock)) {
00262       strcpy(work, party[i].nick);
00263       strncpy(party[i].nick, nick, HANDLEN);
00264       party[i].nick[HANDLEN] = 0;
00265       strcpy(nick, work);
00266       return i;
00267     }
00268   }
00269   return -1;
00270 }

Here is the caller graph for this function:

void partysetidle ( char *  ,
int  ,
int   
)

Definition at line 212 of file botnet.c.

References egg_strcasecmp, now, parties, time_t, and party_t::timer.

Referenced by bot_idle().

00213 {
00214   int i;
00215 
00216   for (i = 0; i < parties; i++) {
00217     if ((!egg_strcasecmp(party[i].bot, bot)) && (party[i].sock == sock)) {
00218       party[i].timer = (now - (time_t) secs);
00219     }
00220   }
00221 }

Here is the caller graph for this function:

int partysock ( char *  ,
char *   
)

Definition at line 127 of file botnet.c.

References egg_strcasecmp, parties, and party_t::sock.

Referenced by bot_away(), bot_idle(), bot_join(), and bot_part().

00128 {
00129   int i;
00130 
00131   for (i = 0; i < parties; i++) {
00132     if ((!egg_strcasecmp(party[i].bot, bot)) &&
00133         (!egg_strcasecmp(party[i].nick, nick)))
00134       return party[i].sock;
00135   }
00136   return 0;
00137 }

Here is the caller graph for this function:

void partystat ( char *  ,
int  ,
int  ,
int   
)

Definition at line 198 of file botnet.c.

References egg_strcasecmp, parties, and party_t::status.

Referenced by bot_away(), and bot_idle().

00199 {
00200   int i;
00201 
00202   for (i = 0; i < parties; i++) {
00203     if ((!egg_strcasecmp(party[i].bot, bot)) && (party[i].sock == sock)) {
00204       party[i].status |= add;
00205       party[i].status &= ~rem;
00206     }
00207   }
00208 }

Here is the caller graph for this function:

int preparefdset ( fd_set *  ,
sock_list ,
int  ,
int  ,
int   
)
void protect_tcl (  ) 
void rehash (  ) 

Definition at line 545 of file chanprog.c.

References call_hook, chanprog(), clear_userlist, HOOK_PRE_REHASH, noshare, and NULL.

Referenced by mainloop().

00546 {
00547   call_hook(HOOK_PRE_REHASH);
00548   noshare = 1;
00549   clear_userlist(userlist);
00550   noshare = 0;
00551   userlist = NULL;
00552   chanprog();
00553 }

Here is the call graph for this function:

Here is the caller graph for this function:

void reload (  ) 

Definition at line 527 of file chanprog.c.

References call_hook, check_tcl_event, clear_userlist, fatal, file_readable, HOOK_READ_USERFILE, LOG_MISC, MISC_CANTRELOADUSER, MISC_MISSINGUSERF, noshare, NULL, putlog, readuserfile, reaffirm_owners, and userfile.

Referenced by cmd_reload(), and tcl_reload().

00528 {
00529   if (!file_readable(userfile)) {
00530     putlog(LOG_MISC, "*", MISC_CANTRELOADUSER);
00531     return;
00532   }
00533 
00534   noshare = 1;
00535   clear_userlist(userlist);
00536   noshare = 0;
00537   userlist = NULL;
00538   if (!readuserfile(userfile, &userlist))
00539     fatal(MISC_MISSINGUSERF, 0);
00540   reaffirm_owners();
00541   check_tcl_event("userfile-loaded");
00542   call_hook(HOOK_READ_USERFILE);
00543 }

Here is the caller graph for this function:

void reload_help_data ( void   ) 

Definition at line 1140 of file misc.c.

References add_help_reference, help_ref::first, help_list, help_ref::name, help_list_t::name, help_list_t::next, help_ref::next, nfree, and NULL.

Referenced by cmd_rehelp(), and tcl_reloadhelp().

01141 {
01142   struct help_ref *current = help_list, *next;
01143   struct help_list_t *item;
01144 
01145   help_list = NULL;
01146   while (current) {
01147     while ((item = current->first)) {
01148       current->first = item->next;
01149       nfree(item->name);
01150       nfree(item);
01151     }
01152     add_help_reference(current->name);
01153     nfree(current->name);
01154     next = current->next;
01155     nfree(current);
01156     current = next;
01157   }
01158 }

Here is the caller graph for this function:

void rembot ( char *   ) 

Definition at line 292 of file botnet.c.

References check_tcl_disc(), dupwait_notify(), egg_strcasecmp, get_user_by_handle, tand_t_struct::next, nfree, nmalloc, now, NULL, strncpyz, tands, and touch_laston.

Referenced by bot_unlinked(), botunlink(), free_dcc_bot_(), and unvia().

00293 {
00294   tand_t **ptr = &tandbot, *ptr2;
00295   struct userrec *u;
00296   char *who = NULL;
00297   size_t len = 0;
00298 
00299   /* Need to save the nick for later as it MAY be a pointer to ptr->bot, and we free(ptr) in here. */
00300   len = strlen(whoin);
00301   who = nmalloc(len + 1);
00302   strncpyz(who, whoin, len + 1);
00303 
00304   while (*ptr) {
00305     if (!egg_strcasecmp((*ptr)->bot, who))
00306       break;
00307     ptr = &((*ptr)->next);
00308   }
00309   if (!*ptr) {
00310     /* May have just .unlink *'d. */
00311     nfree(who);
00312     return;
00313   }
00314   check_tcl_disc(who);
00315 
00316   u = get_user_by_handle(userlist, who);
00317   if (u != NULL)
00318     touch_laston(u, "unlinked", now);
00319 
00320   ptr2 = *ptr;
00321   *ptr = ptr2->next;
00322   nfree(ptr2);
00323   tands--;
00324 
00325   dupwait_notify(who);
00326   nfree(who);
00327 }

Here is the call graph for this function:

Here is the caller graph for this function:

void remparty ( char *  ,
int   
)

Definition at line 329 of file botnet.c.

References party_t::away, party_t::chan, egg_strcasecmp, party_t::flag, party_t::from, from, nfree, parties, party_t::sock, party_t::status, and party_t::timer.

Referenced by bot_part(), and rempartybot().

00330 {
00331   int i;
00332 
00333   for (i = 0; i < parties; i++)
00334     if ((!egg_strcasecmp(party[i].bot, bot)) && (party[i].sock == sock)) {
00335       parties--;
00336       if (party[i].from)
00337         nfree(party[i].from);
00338       if (party[i].away)
00339         nfree(party[i].away);
00340       if (i < parties) {
00341         strcpy(party[i].bot, party[parties].bot);
00342         strcpy(party[i].nick, party[parties].nick);
00343         party[i].chan = party[parties].chan;
00344         party[i].sock = party[parties].sock;
00345         party[i].flag = party[parties].flag;
00346         party[i].status = party[parties].status;
00347         party[i].timer = party[parties].timer;
00348         party[i].from = party[parties].from;
00349         party[i].away = party[parties].away;
00350       }
00351     }
00352 }

Here is the caller graph for this function:

void set_away ( int  ,
char *   
)

Definition at line 450 of file dccutil.c.

References chat_info::away, botnet_send_away(), botnetnick, chat_info::channel, chanout_but, dcc_t::chat, check_tcl_away(), dprintf, GLOBAL_CHANS, nfree, dcc_t::nick, nmalloc, not_away(), NULL, and dcc_t::u.

Referenced by cmd_away().

00451 {
00452   if (s == NULL) {
00453     not_away(idx);
00454     return;
00455   }
00456   if (!s[0]) {
00457     not_away(idx);
00458     return;
00459   }
00460   if (dcc[idx].u.chat->away != NULL)
00461     nfree(dcc[idx].u.chat->away);
00462   dcc[idx].u.chat->away = nmalloc(strlen(s) + 1);
00463   strcpy(dcc[idx].u.chat->away, s);
00464   if (dcc[idx].u.chat->channel >= 0) {
00465     chanout_but(-1, dcc[idx].u.chat->channel,
00466                 "*** %s is now away: %s\n", dcc[idx].nick, s);
00467     if (dcc[idx].u.chat->channel < GLOBAL_CHANS) {
00468       botnet_send_away(-1, botnetnick, dcc[idx].sock, s, idx);
00469     }
00470   }
00471   dprintf(idx, "You are now away.\n");
00472   check_tcl_away(botnetnick, dcc[idx].sock, s);
00473 }

Here is the call graph for this function:

Here is the caller graph for this function:

void set_chanlist ( const char *  host,
struct userrec rec 
)

Definition at line 199 of file chanprog.c.

References chanset_t::channel, egg_strcasecmp, chan_t::member, memstruct::next, chanset_t::next, memstruct::nick, rfc_casecmp, splitnick, strncpyz, UHOSTLEN, memstruct::user, and memstruct::userhost.

Referenced by global().

00200 {
00201   char *nick, *uhost, buf[UHOSTLEN];
00202   register memberlist *m;
00203   register struct chanset_t *chan;
00204 
00205   strncpyz(buf, host, sizeof buf);
00206   uhost = buf;
00207   nick = splitnick(&uhost);
00208   for (chan = chanset; chan; chan = chan->next)
00209     for (m = chan->channel.member; m && m->nick[0]; m = m->next)
00210       if (!rfc_casecmp(nick, m->nick) && !egg_strcasecmp(uhost, m->userhost))
00211         m->user = rec;
00212 }

Here is the caller graph for this function:

void setsock ( int  ,
int   
)

Referenced by main().

Here is the caller graph for this function:

void show_banner ( int  i  ) 

Definition at line 1396 of file misc.c.

References bannerfile, botnetnick, dcc_t::chat, chat_info::con_chan, dprintf, FR_CHAN, FR_GLOBAL, get_user_flagrec, help_subst(), is_file, NULL, and user.

Referenced by dcc_telnet_got_ident().

01397 {
01398   FILE *vv;
01399   char s[1024];
01400   struct flag_record fr = { FR_GLOBAL | FR_CHAN, 0, 0, 0, 0, 0 };
01401 
01402   if (!is_file(bannerfile))
01403     return;
01404 
01405   vv = fopen(bannerfile, "r");
01406   if (!vv)
01407     return;
01408 
01409   get_user_flagrec(dcc[idx].user, &fr, dcc[idx].u.chat->con_chan);
01410   /* reset the help_subst variables to their defaults */
01411   help_subst(NULL, NULL, 0, 0, NULL);
01412   while (!feof(vv)) {
01413     fgets(s, 120, vv);
01414     if (!feof(vv)) {
01415       if (!s[0])
01416         strcpy(s, " \n");
01417       help_subst(s, dcc[idx].nick, &fr, 0, botnetnick);
01418       dprintf(idx, "%s", s);
01419     }
01420   }
01421   fclose(vv);
01422 }

Here is the call graph for this function:

Here is the caller graph for this function:

int sockgets ( char *  ,
int *   
)

Referenced by mainloop().

Here is the caller graph for this function:

int sockread ( char *  ,
int *  ,
sock_list ,
int  ,
int   
)
void splitcn ( char *  ,
char *  ,
char  ,
size_t   
)

Definition at line 231 of file misc.c.

References NULL, and strncpyz.

Referenced by cmd_boot().

00232 {
00233   char *p = strchr(rest, divider);
00234 
00235   if (p == NULL) {
00236     if (first != rest && first)
00237       first[0] = 0;
00238     return;
00239   }
00240   *p = 0;
00241   if (first != NULL)
00242     strncpyz(first, rest, max);
00243   if (first != rest)
00244     /*    In most circumstances, strcpy with src and dst being the same buffer
00245      *  can produce undefined results. We're safe here, as the src is
00246      *  guaranteed to be at least 2 bytes higher in memory than dest. <Cybah>
00247      */
00248     strcpy(rest, p + 1);
00249 }

Here is the caller graph for this function:

void stridx ( char *  ,
char *  ,
int   
)
void tandem_relay ( int  ,
char *  ,
int   
)
void tandout_but (  ) 
void tell_bots ( int   ) 

Definition at line 546 of file botnet.c.

References tand_t_struct::bot, BOT_NOBOTSLINKED, botnetnick, dprintf, HANDLEN, MISC_TOTAL, tand_t_struct::next, and tands.

Referenced by cmd_bots().

00547 {
00548   char s[512];
00549   int i;
00550   tand_t *bot;
00551 
00552   if (!tands) {
00553     dprintf(idx, "%s\n", BOT_NOBOTSLINKED);
00554     return;
00555   }
00556   strcpy(s, botnetnick);
00557   i = strlen(botnetnick);
00558 
00559   for (bot = tandbot; bot; bot = bot->next) {
00560     if (i > (500 - HANDLEN)) {
00561       dprintf(idx, "Bots: %s\n", s);
00562       s[0] = 0;
00563       i = 0;
00564     }
00565     if (i) {
00566       s[i++] = ',';
00567       s[i++] = ' ';
00568     }
00569     strcpy(s + i, bot->bot);
00570     i += strlen(bot->bot);
00571   }
00572   if (s[0])
00573     dprintf(idx, "Bots: %s\n", s);
00574   dprintf(idx, "%s: %d\n", MISC_TOTAL, tands + 1);
00575 }

Here is the caller graph for this function:

void tell_dcc ( int   ) 

Definition at line 387 of file dccutil.c.

References dcc_total, dcc_table::display, dprintf, egg_snprintf, and dcc_t::type.

Referenced by cmd_dccstat().

00388 {
00389   int i, j;
00390   char other[160];
00391   char format[81];
00392   int nicklen;
00393 
00394   /* calculate max nicklen */
00395   nicklen = 0;
00396   for (i = 0; i < dcc_total; i++) {
00397     if (strlen(dcc[i].nick) > nicklen)
00398       nicklen = strlen(dcc[i].nick);
00399   }
00400   if (nicklen < 9)
00401     nicklen = 9;
00402 
00403   egg_snprintf(format, sizeof format, "%%-4s %%-8s %%-5s %%-%us %%-17s %%s\n",
00404                nicklen);
00405   dprintf(zidx, format, "SOCK", "ADDR", "PORT", "NICK", "HOST", "TYPE");
00406   dprintf(zidx, format, "----", "--------", "-----", "---------",
00407           "-----------------", "----");
00408 
00409   egg_snprintf(format, sizeof format, "%%-4d %%08X %%5d %%-%us %%-17s %%s\n",
00410                nicklen);
00411   /* Show server */
00412   for (i = 0; i < dcc_total; i++) {
00413     j = strlen(dcc[i].host);
00414     if (j > 17)
00415       j -= 17;
00416     else
00417       j = 0;
00418     if (dcc[i].type && dcc[i].type->display)
00419       dcc[i].type->display(i, other);
00420     else {
00421       sprintf(other, "?:%lX  !! ERROR !!", (long) dcc[i].type);
00422       break;
00423     }
00424     dprintf(zidx, format, dcc[i].sock, dcc[i].addr, dcc[i].port, dcc[i].nick,
00425             dcc[i].host + j, other);
00426   }
00427 }

Here is the caller graph for this function:

void tell_file_stats ( int  ,
char *   
)

Referenced by cmd_filestats(), and cmd_stats().

Here is the caller graph for this function:

void tell_ignores ( int  ,
char *   
)

Referenced by cmd_ignores().

Here is the caller graph for this function:

void tell_mem_status_dcc ( int   ) 

Definition at line 98 of file mem.c.

References dprintf, expected_memory, and MEMTBLSIZE.

Referenced by cmd_status(), and core_secondly().

00099 {
00100 #ifdef DEBUG_MEM
00101   int exp;
00102   float per;
00103 
00104   exp = expected_memory();      /* in main.c ? */
00105   per = ((lastused * 1.0) / (MEMTBLSIZE * 1.0)) * 100.0;
00106   dprintf(idx, "Memory table: %d/%d (%.1f%% full)\n", lastused, MEMTBLSIZE,
00107           per);
00108   per = ((exp * 1.0) / (memused * 1.0)) * 100.0;
00109   if (per != 100.0)
00110     dprintf(idx, "Memory fault: only accounting for %d/%ld (%.1f%%)\n",
00111             exp, memused, per);
00112   dprintf(idx, "Memory table itself occupies an additional %dk static\n",
00113           (int) (sizeof(memtbl) / 1024));
00114 #endif
00115 }

Here is the caller graph for this function:

void tell_netdebug ( int   ) 

Referenced by debug_mem_to_dcc().

Here is the caller graph for this function:

void tell_settings ( int   ) 

Definition at line 366 of file chanprog.c.

References botnetnick, build_flags, default_flags, dprintf, firewall, firewallport, FR_GLOBAL, flag_record::global, helpdir, ignore_time, maskname(), masktype, max_logs, MISC_NEWUSERFLAGS, MISC_NOTIFY, MISC_PERMOWNER, moddir, motdfile, notify_new, NULL, owner, tempdir, and userfile.

Referenced by cmd_status().

00367 {
00368   char s[1024];
00369   int i;
00370   struct flag_record fr = { FR_GLOBAL, 0, 0, 0, 0, 0 };
00371 
00372   dprintf(idx, "Botnet nickname: %s\n", botnetnick);
00373   if (firewall[0])
00374     dprintf(idx, "Firewall: %s:%d\n", firewall, firewallport);
00375   dprintf(idx, "Userfile: %s\n", userfile);
00376   dprintf(idx, "Motd: %s\n",  motdfile);
00377   dprintf(idx, "Directories:\n");
00378 #ifndef STATIC
00379   dprintf(idx, "  Help   : %s\n", helpdir);
00380   dprintf(idx, "  Temp   : %s\n", tempdir);
00381   dprintf(idx, "  Modules: %s\n", moddir);
00382 #else
00383   dprintf(idx, "  Help: %s\n", helpdir);
00384   dprintf(idx, "  Temp: %s\n", tempdir);
00385 #endif
00386   fr.global = default_flags;
00387 
00388   build_flags(s, &fr, NULL);
00389   dprintf(idx, "%s [%s], %s: %s\n", MISC_NEWUSERFLAGS, s,
00390           MISC_NOTIFY, notify_new);
00391   if (owner[0])
00392     dprintf(idx, "%s: %s\n", MISC_PERMOWNER, owner);
00393   for (i = 0; i < max_logs; i++)
00394     if (logs[i].filename != NULL) {
00395       dprintf(idx, "Logfile #%d: %s on %s (%s: %s)\n", i + 1,
00396               logs[i].filename, logs[i].chname,
00397               masktype(logs[i].mask), maskname(logs[i].mask));
00398     }
00399   dprintf(idx, "Ignores last %d minute%s.\n", ignore_time,
00400           (ignore_time != 1) ? "s" : "");
00401 }

Here is the call graph for this function:

Here is the caller graph for this function:

void tell_user_ident ( int  ,
char *  ,
int   
)

Referenced by cmd_whois().

Here is the caller graph for this function:

void tell_users_match ( int  ,
char *  ,
int  ,
int  ,
int  ,
char *   
)

Referenced by cmd_match().

Here is the caller graph for this function:

void tell_verbose_status ( int   ) 

Definition at line 265 of file chanprog.c.

References admin, backgrd, botnetnick, cache_hit, cache_miss, con_chan, configfile, count_users, dprintf, expected_memory, int, interp, max_socks, MISC_BACKGROUND, MISC_CACHEHIT, MISC_LOGMODE, MISC_ONLINEFOR, MISC_STATMODE, MISC_TCLHVERSION, MISC_TCLLIBRARY, MISC_TCLVERSION, MISC_TERMMODE, now, online_since, TCL_PATCH_LEVEL, tcl_resultstring(), tcl_threaded(), term_z, threaddata(), time_t, and ver.

Referenced by cmd_status(), and core_secondly().

00266 {
00267   char s[256], s1[121], s2[81];
00268   char *vers_t, *uni_t;
00269   int i;
00270   time_t now2 = now - online_since, hr, min;
00271 #ifdef HAVE_GETRUSAGE
00272   struct rusage ru;
00273 #else
00274 #  ifdef HAVE_CLOCK
00275   clock_t cl;
00276 #  endif
00277 #endif
00278 #ifdef HAVE_UNAME
00279   struct utsname un;
00280 
00281   if (!uname(&un) < 0) {
00282 #endif
00283     vers_t = " ";
00284     uni_t  = "*unknown*";
00285 #ifdef HAVE_UNAME
00286   } else {
00287     vers_t = un.release;
00288     uni_t  = un.sysname;
00289   }
00290 #endif
00291 
00292   i = count_users(userlist);
00293   dprintf(idx, "I am %s, running %s: %d user%s (mem: %uk).\n",
00294           botnetnick, ver, i, i == 1 ? "" : "s",
00295           (int) (expected_memory() / 1024));
00296 
00297   s[0] = 0;
00298   if (now2 > 86400) {
00299     /* days */
00300     sprintf(s, "%d day", (int) (now2 / 86400));
00301     if ((int) (now2 / 86400) >= 2)
00302       strcat(s, "s");
00303     strcat(s, ", ");
00304     now2 -= (((int) (now2 / 86400)) * 86400);
00305   }
00306   hr = (time_t) ((int) now2 / 3600);
00307   now2 -= (hr * 3600);
00308   min = (time_t) ((int) now2 / 60);
00309   sprintf(&s[strlen(s)], "%02d:%02d", (int) hr, (int) min);
00310   s1[0] = 0;
00311   if (backgrd)
00312     strcpy(s1, MISC_BACKGROUND);
00313   else {
00314     if (term_z)
00315       strcpy(s1, MISC_TERMMODE);
00316     else if (con_chan)
00317       strcpy(s1, MISC_STATMODE);
00318     else
00319       strcpy(s1, MISC_LOGMODE);
00320   }
00321 #ifdef HAVE_GETRUSAGE
00322   getrusage(RUSAGE_SELF, &ru);
00323   hr = (int) ((ru.ru_utime.tv_sec + ru.ru_stime.tv_sec) / 60);
00324   min = (int) ((ru.ru_utime.tv_sec + ru.ru_stime.tv_sec) - (hr * 60));
00325   sprintf(s2, "CPU: %02d:%02d", (int) hr, (int) min);    /* Actally min/sec */
00326 #else
00327 #  ifdef HAVE_CLOCK
00328   cl = (clock() / CLOCKS_PER_SEC);
00329   hr = (int) (cl / 60);
00330   min = (int) (cl - (hr * 60));
00331   sprintf(s2, "CPU: %02d:%02d", (int) hr, (int) min);    /* Actually min/sec */
00332 #  else
00333   sprintf(s2, "CPU: unknown");
00334 #  endif
00335 #endif
00336   dprintf(idx, "%s %s (%s) - %s - %s: %4.1f%%\n", MISC_ONLINEFOR,
00337           s, s1, s2, MISC_CACHEHIT,
00338           100.0 * ((float) cache_hit) / ((float) (cache_hit + cache_miss)));
00339 
00340   dprintf(idx, "Configured with: " EGG_AC_ARGS "\n");
00341   if (admin[0])
00342     dprintf(idx, "Admin: %s\n", admin);
00343 
00344   dprintf(idx, "Config file: %s\n", configfile);
00345   dprintf(idx, "OS: %s %s\n", uni_t, vers_t);
00346 
00347   /* info library */
00348   dprintf(idx, "%s %s\n", MISC_TCLLIBRARY,
00349           ((interp) && (Tcl_Eval(interp, "info library") == TCL_OK)) ?
00350           tcl_resultstring() : "*unknown*");
00351 
00352   /* info tclversion/patchlevel */
00353   dprintf(idx, "%s %s (%s %s)\n", MISC_TCLVERSION,
00354           ((interp) && (Tcl_Eval(interp, "info patchlevel") == TCL_OK)) ?
00355           tcl_resultstring() : (Tcl_Eval(interp, "info tclversion") == TCL_OK) ?
00356           tcl_resultstring() : "*unknown*", MISC_TCLHVERSION,
00357           TCL_PATCH_LEVEL ? TCL_PATCH_LEVEL : "*unknown*");
00358 
00359   if (tcl_threaded())
00360     dprintf(idx, "Tcl is threaded.\n");
00361   dprintf(idx, "Socket table: %d/%d\n", threaddata()->MAXSOCKS, max_socks);
00362 }

Here is the call graph for this function:

Here is the caller graph for this function:

void tell_verbose_uptime ( int   ) 

Definition at line 230 of file chanprog.c.

References backgrd, con_chan, dprintf, int, MISC_BACKGROUND, MISC_LOGMODE, MISC_ONLINEFOR, MISC_STATMODE, MISC_TERMMODE, now, online_since, term_z, and time_t.

Referenced by cmd_uptime().

00231 {
00232   char s[256], s1[121];
00233   time_t now2, hr, min;
00234 
00235   now2 = now - online_since;
00236   s[0] = 0;
00237   if (now2 > 86400) {
00238     /* days */
00239     sprintf(s, "%d day", (int) (now2 / 86400));
00240     if ((int) (now2 / 86400) >= 2)
00241       strcat(s, "s");
00242     strcat(s, ", ");
00243     now2 -= (((int) (now2 / 86400)) * 86400);
00244   }
00245   hr = (time_t) ((int) now2 / 3600);
00246   now2 -= (hr * 3600);
00247   min = (time_t) ((int) now2 / 60);
00248   sprintf(&s[strlen(s)], "%02d:%02d", (int) hr, (int) min);
00249   s1[0] = 0;
00250   if (backgrd)
00251     strcpy(s1, MISC_BACKGROUND);
00252   else {
00253     if (term_z)
00254       strcpy(s1, MISC_TERMMODE);
00255     else if (con_chan)
00256       strcpy(s1, MISC_STATMODE);
00257     else
00258       strcpy(s1, MISC_LOGMODE);
00259   }
00260   dprintf(idx, "%s %s  (%s)\n", MISC_ONLINEFOR, s, s1);
00261 }

Here is the caller graph for this function:

void tellallhelp ( int  ,
char *  ,
struct flag_record  
)

Definition at line 1304 of file misc.c.

References display_tellhelp(), dprintf, egg_snprintf, help_ref::first, help_list, helpdir, IRC_NOHELP2, help_ref::name, help_list_t::name, help_list_t::next, help_ref::next, and help_list_t::type.

Referenced by cmd_help().

01305 {
01306   struct help_ref *current;
01307   struct help_list_t *item;
01308   FILE *f;
01309   char s[1024];
01310 
01311   s[0] = '\0';
01312   for (current = help_list; current; current = current->next)
01313     for (item = current->first; item; item = item->next)
01314       if (!strcmp(match, item->name) && item->type) {
01315 
01316         if (item->type == 1)
01317           egg_snprintf(s, sizeof s, "%s%s", helpdir, current->name);
01318         else
01319           egg_snprintf(s, sizeof s, "%sset/%s", helpdir, current->name);
01320         if ((f = fopen(s, "r")))
01321           display_tellhelp(idx, item->name, f, flags);
01322       }
01323   if (!s[0])
01324     dprintf(idx, "%s\n", IRC_NOHELP2);
01325 }

Here is the call graph for this function:

Here is the caller graph for this function:

void tellwildhelp ( int  ,
char *  ,
struct flag_record  
)

Definition at line 1280 of file misc.c.

References display_tellhelp(), dprintf, egg_snprintf, help_ref::first, help_list, helpdir, IRC_NOHELP2, help_ref::name, help_list_t::name, help_list_t::next, help_ref::next, help_list_t::type, and wild_match.

Referenced by cmd_help().

01281 {
01282   struct help_ref *current;
01283   struct help_list_t *item;
01284   FILE *f;
01285   char s[1024];
01286 
01287   s[0] = '\0';
01288   for (current = help_list; current; current = current->next)
01289     for (item = current->first; item; item = item->next)
01290       if (wild_match(match, item->name) && item->type) {
01291         if (item->type == 1)
01292           egg_snprintf(s, sizeof s, "%s%s", helpdir, current->name);
01293         else
01294           egg_snprintf(s, sizeof s, "%sset/%s", helpdir, current->name);
01295         if ((f = fopen(s, "r")))
01296           display_tellhelp(idx, item->name, f, flags);
01297       }
01298   if (!s[0])
01299     dprintf(idx, "%s\n", IRC_NOHELP2);
01300 }

Here is the call graph for this function:

Here is the caller graph for this function:

struct threaddata* threaddata (  )  [read]

Definition at line 722 of file tcl.c.

Referenced by expmem_dccutil(), expmem_net(), increase_socks_max(), init_threaddata(), tcl_eggint(), and tell_verbose_status().

00723 {
00724   static struct threaddata tsd;
00725   return &tsd;
00726 }

Here is the caller graph for this function:

void unprotect_tcl (  ) 
char* unsigned_int_to_base10 ( unsigned  int  ) 

Definition at line 122 of file botmsg.c.

Referenced by EGG_VARARGS_DEF().

00123 {
00124   static char buf_base10[16];
00125   int i = 15;
00126 
00127   buf_base10[15] = 0;
00128   if (!val) {
00129     buf_base10[14] = '0';
00130     return buf_base10 + 14;
00131   }
00132   while (val) {
00133     i--;
00134     buf_base10[i] = '0' + (val % 10);
00135     val /= 10;
00136   }
00137   return buf_base10 + i;
00138 }

Here is the caller graph for this function:

void unvia ( int  ,
struct tand_t_struct  
)

Definition at line 371 of file botnet.c.

References tand_t_struct::bot, tand_t_struct::next, rembot(), rempartybot(), tandout_but(), unvia(), and tand_t_struct::uplink.

Referenced by bot_thisbot(), bot_unlinked(), free_dcc_bot_(), and unvia().

00372 {
00373   tand_t *bot, *bot2;
00374 
00375   if (!who)
00376     return;                     /* Safety */
00377   rempartybot(who->bot);
00378   bot = tandbot;
00379   while (bot) {
00380     if (bot->uplink == who) {
00381       unvia(idx, bot);
00382       bot2 = bot->next;
00383       rembot(bot->bot);
00384       bot = bot2;
00385     } else
00386       bot = bot->next;
00387   }
00388 #ifndef NO_OLD_BOTNET
00389   /* Every bot unvia's bots behind anyway, so why send msg's for
00390    * EVERY one? - will this break things?!
00391    */
00392   tandout_but(idx, "unlinked %s\n", who->bot);
00393 #endif
00394 }

Here is the call graph for this function:

Here is the caller graph for this function:

void ( (void(*)(char *, char *, char *, time_t))  global[140]  ) 
void ( (void(*)(char *))(global[193])   ) 
void ( (void(*)(struct userrec *, char *, time_t))  global[160]  ) 
void ( (void(*)(int))  global[55]  ) 
void ( (void(*)(struct userrec *))  global[61]  ) 

Definition at line 267 of file userrec.c.

References chanset_t::bans, clear_chanlist, clear_masks(), dcc_total, delignore, chanset_t::exempts, freeuser(), global_exempts, global_invites, igrec::igmask, chanset_t::invites, chanset_t::next, userrec::next, NULL, and user.

00268 {
00269   struct userrec *u, *v;
00270   int i;
00271 
00272   for (u = bu; u; u = v) {
00273     v = u->next;
00274     freeuser(u);
00275   }
00276   if (userlist == bu) {
00277     struct chanset_t *cst;
00278 
00279     for (i = 0; i < dcc_total; i++)
00280       dcc[i].user = NULL;
00281     clear_chanlist();
00282     lastuser = NULL;
00283 
00284     while (global_ign)
00285       delignore(global_ign->igmask);
00286 
00287     clear_masks(global_bans);
00288     clear_masks(global_exempts);
00289     clear_masks(global_invites);
00290     global_exempts = global_invites = global_bans = NULL;
00291 
00292     for (cst = chanset; cst; cst = cst->next) {
00293       clear_masks(cst->bans);
00294       clear_masks(cst->exempts);
00295       clear_masks(cst->invites);
00296 
00297       cst->bans = cst->exempts = cst->invites = NULL;
00298     }
00299   }
00300   /* Remember to set your userlist to NULL after calling this */
00301 }

Here is the call graph for this function:

void ( (void(*)(char *, char *))  global[52]  ) 
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 }

void ( (void(*)(char *, char *))  global[148]  ) 
void ( (void(*)(int, char *, unsigned int))  global[79]  ) 
void ( (void(*)(int))  global[83]  ) 
void ( (void(*)(char *))  global[78]  ) 

Definition at line 133 of file net.c.

00134 {
00135   switch (errno) {
00136   case EADDRINUSE:
00137     strcpy(s, "Address already in use");
00138     break;
00139   case EADDRNOTAVAIL:
00140     strcpy(s, "Cannot assign requested address");
00141     break;
00142   case EAFNOSUPPORT:
00143     strcpy(s, "Address family not supported");
00144     break;
00145   case EALREADY:
00146     strcpy(s, "Socket already in use");
00147     break;
00148   case EBADF:
00149     strcpy(s, "Socket descriptor is bad");
00150     break;
00151   case ECONNREFUSED:
00152     strcpy(s, "Connection refused");
00153     break;
00154   case EFAULT:
00155     strcpy(s, "Bad address");
00156     break;
00157   case EINPROGRESS:
00158     strcpy(s, "Operation in progress");
00159     break;
00160   case EINTR:
00161     strcpy(s, "Timeout");
00162     break;
00163   case EINVAL:
00164     strcpy(s, "Invalid argument");
00165     break;
00166   case EISCONN:
00167     strcpy(s, "Socket already connected");
00168     break;
00169   case ENETUNREACH:
00170     strcpy(s, "Network unreachable");
00171     break;
00172   case ENOTSOCK:
00173     strcpy(s, "Socket operation on non-socket");
00174     break;
00175   case ETIMEDOUT:
00176     strcpy(s, "Connection timed out");
00177     break;
00178   case ENOTCONN:
00179     strcpy(s, "Socket is not connected");
00180     break;
00181   case EHOSTUNREACH:
00182     strcpy(s, "No route to host");
00183     break;
00184   case EPIPE:
00185     strcpy(s, "Broken pipe");
00186     break;
00187 #ifdef ECONNRESET
00188   case ECONNRESET:
00189     strcpy(s, "Connection reset by peer");
00190     break;
00191 #endif
00192 #ifdef EACCES
00193   case EACCES:
00194     strcpy(s, "Permission denied");
00195     break;
00196 #endif
00197 #ifdef EMFILE
00198   case EMFILE:
00199     strcpy(s, "Too many open files");
00200     break;
00201 #endif
00202   case 0:
00203     strcpy(s, "Error 0");
00204     break;
00205   default:
00206     sprintf(s, "Unforseen error %d", errno);
00207     break;
00208   }
00209 }

char* void ( (void(*)(const char *, char *, int))  global[154]  )  const
void ( (void(*)(char *, char *))  global[271]  ) 
void ( (void(*)(char *, register const char))  global[264]  ) 
void ( (void(*)(char *, int))  global[243]  ) 
void ( (void(*)(char *))  global[158]  ) 
void ( (void(*)(char *))  global[159]  ) 
void ( (void(*)(char *, char *, struct flag_record *, int))  global[157]  ) 
void ( (void(*)(int, char *, struct flag_record *, int))  global[156]  ) 
char* void ( (void(*)(int))  global[155]  ) 
void ( (void(*)(int, char *))  global[204]  ) 
char char* void ( (void(*)(time_t, time_t, char *))  global[135]  ) 
Type Constraints
char* void ( (void(*)(time_t, time_t, char *))  global[133]  ) 
Type Constraints
void ( (void(*)(time_t, time_t, char *))  global[134]  ) 
void ( (void(*)(char **))  global[293]  ) 
void ( (void(*)(char *, char *, char))  global[139]  ) 
char* void ( global  [197]  ) 
void ( (void(*)(char *))  global[169]  ) 
void ( (void(*)(void *, char *, int))  global[37]  ) 
void ( global  [143]  )  const
char* void ( (void(*)(char *))  global[228]  ) 
Type Constraints
void ( (void(*)(char *))  global[240]  ) 
void ( (void(*)(IP))  global[241]  ) 
void ( (void(*)(char *, IP, int))  global[236]  ) 
void ( (void(*)(IP, char *, int))  global[235]  ) 
void ( (void(*)(int, struct dcc_table *, int))  global[242]  ) 
void ( (void(*)(int, struct chat_info *))  global[167]  ) 
void ( (void(*)(char *))  global[152]  ) 
void ( (void(*)(int))  global[246]  ) 
void ( (void(*)(int))  global[281]  ) 
void ( (void(*)(int))  global[81]  ) 
void ( (void(*)())  global[71]  ) 
void ( global  [70]  ) 
void ( global  [69]  ) 
void ( (void(*)(int, char *))  global[289]  ) 
void ( (void(*)(const char *nick))  global[266]  )  const
void ( (void(*)(void))  global[57]  ) 
void ( (void(*)(char *))  global[162]  ) 
void ( (void(*)(void))  global[58]  ) 
void ( (void(*)(int))  global[36]  ) 
void ( (void(*)(int, char *, char, int))  global[34]  ) 
void ( (void(*)(int, int))  global[276]  ) 

Variable Documentation

register const char

Definition at line 73 of file proto.h.

Referenced by _rfc_tolower(), _rfc_toupper(), EGG_VARARGS_DEF(), and strchr_unescape().

char*(* decrypt_string)(char *, char *)
void(* dns_hostbyip)(IP)

Referenced by dcc_dnshostbyip(), and tcl_dnshostbyip().

void(* dns_ipbyhost)(char *)

Referenced by dcc_dnsipbyhost(), and tcl_dnsipbyhost().

void(* encrypt_pass)(char *, char *)

Referenced by main(), and pass_set().

char*(* encrypt_string)(char *, char *)
void(* (* Function)(global[68])))()
int [read]

Definition at line 68 of file proto.h.

char char char* char IP

Definition at line 166 of file proto.h.

int(* match_noterej)(struct userrec *, char *)

Referenced by add_note().

int md

Definition at line 325 of file proto.h.

Referenced by cmd_strip().

int operation

Definition at line 289 of file proto.h.

int(* rfc_tolower)(int)
int(* rfc_toupper)(int)
void(* sharein)(int, char *)

Referenced by bot_share().

const char size_t

Definition at line 220 of file proto.h.

int int sock_options

Definition at line 289 of file proto.h.

char char time_t

Generated on 7 Sep 2016 for Eggdrop by  doxygen 1.6.1