src/mod/share.mod/uf_features.c File Reference

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  uff_list_struct
struct  uff_head_t

Typedefs

typedef struct uff_list_struct uff_list_t

Functions

static void uff_init (void)
static int uff_expmem (void)
static uff_list_tuff_findentry_byflag (int flag)
static uff_list_tuff_findentry_byname (char *feature)
static void uff_insert_entry (uff_list_t *nul)
static void uff_remove_entry (uff_list_t *ul)
static void uff_addfeature (uff_table_t *0)
static void uff_addtable (uff_table_t *0)
static int uff_delfeature (uff_table_t *0)
static void uff_deltable (uff_table_t *0)
static void uf_features_parse (int idx, char *par)
static char * uf_features_dump (int idx)
static int uf_features_check (int idx, char *par)
static int uff_call_sending (int idx, char *user_file)
static int uff_call_receiving (int idx, char *user_file)
static int uff_ask_override_bots (int idx)

Variables

static uff_head_t uff_list
static char uff_sbuf [512]
static uff_table_t internal_uff_table []

Typedef Documentation

typedef struct uff_list_struct uff_list_t

Function Documentation

static int uf_features_check ( int  idx,
char *  par 
) [static]

Definition at line 283 of file uf_features.c.

References uff_table_t::ask_func, dcc, dprintf, uff_list_struct::entry, uff_table_t::flag, LOG_BOTS, nfree, nmalloc, NULL, putlog, uff_findentry_byname(), uff_sbuf, and zapfbot.

Referenced by share_feats().

00284 {
00285   char *buf, *s, *p;
00286   uff_list_t *ul;
00287 
00288   uff_sbuf[0] = 0; /* Reset static buffer  */
00289   p = s = buf = nmalloc(strlen(par) + 1); /* Allocate temp buffer */
00290   strcpy(buf, par);
00291 
00292   /* Clear all currently set features. */
00293   dcc[idx].u.bot->uff_flags = 0;
00294 
00295   /* Parse string */
00296   while ((s = strchr(s, ' ')) != NULL) {
00297     *s = '\0';
00298 
00299     /* Is the feature available and active? */
00300     ul = uff_findentry_byname(p);
00301     if (ul && (ul->entry->ask_func == NULL || ul->entry->ask_func(idx)))
00302       dcc[idx].u.bot->uff_flags |= ul->entry->flag; /* Set flag */
00303     else {
00304       /* It isn't, and our hub wants to use it! This either happens
00305        * because the hub doesn't look at the features we suggested to
00306        * use or because our admin changed the flags, so that formerly
00307        * active features are now deactivated.
00308        *
00309        * In any case, we abort user file sharing.
00310        */
00311       putlog(LOG_BOTS, "*", "Bot %s tried unsupported feature!", dcc[idx].nick);
00312       dprintf(idx, "s e Attempt to use an unsupported feature\n");
00313       zapfbot(idx);
00314 
00315       nfree(buf);
00316       return 0;
00317     }
00318     p = ++s;
00319   }
00320   nfree(buf);
00321   return 1;
00322 }

Here is the call graph for this function:

Here is the caller graph for this function:

static char* uf_features_dump ( int  idx  )  [static]

Definition at line 270 of file uf_features.c.

References uff_table_t::ask_func, uff_list_struct::entry, uff_table_t::feature, uff_list_struct::next, NULL, uff_head_t::start, and uff_sbuf.

Referenced by share_userfileq().

00271 {
00272   uff_list_t *ul;
00273 
00274   uff_sbuf[0] = 0;
00275   for (ul = uff_list.start; ul; ul = ul->next)
00276     if (ul->entry->ask_func == NULL || ul->entry->ask_func(idx)) {
00277       strcat(uff_sbuf, ul->entry->feature); /* Add feature to list  */
00278       strcat(uff_sbuf, " ");
00279     }
00280   return uff_sbuf;
00281 }

Here is the caller graph for this function:

static void uf_features_parse ( int  idx,
char *  par 
) [static]

Definition at line 236 of file uf_features.c.

References uff_table_t::ask_func, dcc, dprintf, uff_list_struct::entry, uff_table_t::feature, uff_table_t::flag, nfree, nmalloc, NULL, uff_findentry_byname(), and uff_sbuf.

Referenced by share_ufyes().

00237 {
00238   char *buf, *s, *p;
00239   uff_list_t *ul;
00240 
00241   uff_sbuf[0] = 0; /* Reset static buffer  */
00242   p = s = buf = nmalloc(strlen(par) + 1); /* Allocate temp buffer */
00243   strcpy(buf, par);
00244 
00245   /* Clear all currently set features. */
00246   dcc[idx].u.bot->uff_flags = 0;
00247 
00248   /* Parse string */
00249   while ((s = strchr(s, ' ')) != NULL) {
00250     *s = '\0';
00251 
00252     /* Is the feature available and active? */
00253     ul = uff_findentry_byname(p);
00254     if (ul && (ul->entry->ask_func == NULL || ul->entry->ask_func(idx))) {
00255       dcc[idx].u.bot->uff_flags |= ul->entry->flag; /* Set flag */
00256       strcat(uff_sbuf, ul->entry->feature); /* Add feature to list */
00257       strcat(uff_sbuf, " ");
00258     }
00259     p = ++s;
00260   }
00261   nfree(buf);
00262 
00263   /* Send response string                                               */
00264   if (uff_sbuf[0])
00265     dprintf(idx, "s feats %s\n", uff_sbuf);
00266 }

Here is the call graph for this function:

Here is the caller graph for this function:

static void uff_addfeature ( uff_table_t 0  )  [static]

Definition at line 173 of file uf_features.c.

References uff_list_struct::entry, uff_table_t::feature, uff_table_t::flag, LOG_MISC, nmalloc, putlog, uff_findentry_byflag(), uff_findentry_byname(), and uff_insert_entry().

Referenced by uff_addtable().

00174 {
00175   uff_list_t *ul;
00176 
00177   if (uff_findentry_byname(ut->feature)) {
00178     putlog(LOG_MISC, "*", "(!) share: same feature name used twice: %s",
00179            ut->feature);
00180     return;
00181   }
00182   ul = uff_findentry_byflag(ut->flag);
00183   if (ul) {
00184     putlog(LOG_MISC, "*", "(!) share: feature flag %d used twice by %s and %s",
00185            ut->flag, ut->feature, ul->entry->feature);
00186     return;
00187   }
00188   ul = nmalloc(sizeof(uff_list_t));
00189   ul->entry = ut;
00190   uff_insert_entry(ul);
00191 }

Here is the call graph for this function:

Here is the caller graph for this function:

static void uff_addtable ( uff_table_t 0  )  [static]

Definition at line 195 of file uf_features.c.

References uff_table_t::feature, and uff_addfeature().

Referenced by compress_start(), and share_start().

00196 {
00197   if (!ut)
00198     return;
00199   for (; ut->feature; ++ut)
00200     uff_addfeature(ut);
00201 }

Here is the call graph for this function:

Here is the caller graph for this function:

static int uff_ask_override_bots ( int  idx  )  [static]

Definition at line 364 of file uf_features.c.

References overr_local_bots.

00365 {
00366   if (overr_local_bots)
00367     return 1;
00368   else
00369     return 0;
00370 }

static int uff_call_receiving ( int  idx,
char *  user_file 
) [static]

Definition at line 343 of file uf_features.c.

References dcc, uff_head_t::end, uff_list_struct::entry, uff_table_t::flag, uff_list_struct::prev, and uff_table_t::rcv.

Referenced by finish_share().

00344 {
00345   uff_list_t *ul;
00346 
00347   for (ul = uff_list.end; ul; ul = ul->prev)
00348     if (ul->entry && ul->entry->rcv &&
00349         (dcc[idx].u.bot->uff_flags & ul->entry->flag))
00350       if (!(ul->entry->rcv(idx, user_file)))
00351         return 0; /* Failed! */
00352   return 1;
00353 }

Here is the caller graph for this function:

static int uff_call_sending ( int  idx,
char *  user_file 
) [static]

Definition at line 327 of file uf_features.c.

References dcc, uff_list_struct::entry, uff_table_t::flag, uff_list_struct::next, uff_table_t::snd, and uff_head_t::start.

Referenced by start_sending_users().

00328 {
00329   uff_list_t *ul;
00330 
00331   for (ul = uff_list.start; ul; ul = ul->next)
00332     if (ul->entry && ul->entry->snd &&
00333         (dcc[idx].u.bot->uff_flags & ul->entry->flag))
00334       if (!(ul->entry->snd(idx, user_file)))
00335         return 0; /* Failed! */
00336   return 1;
00337 }

Here is the caller graph for this function:

static int uff_delfeature ( uff_table_t 0  )  [static]

Definition at line 205 of file uf_features.c.

References uff_list_struct::entry, uff_table_t::feature, uff_list_struct::next, nfree, uff_head_t::start, and uff_remove_entry().

Referenced by uff_deltable().

00206 {
00207   uff_list_t *ul;
00208 
00209   for (ul = uff_list.start; ul; ul = ul->next)
00210     if (!strcmp(ul->entry->feature, ut->feature)) {
00211       uff_remove_entry(ul);
00212       nfree(ul);
00213       return 1;
00214     }
00215   return 0;
00216 }

Here is the call graph for this function:

Here is the caller graph for this function:

static void uff_deltable ( uff_table_t 0  )  [static]

Definition at line 220 of file uf_features.c.

References uff_table_t::feature, and uff_delfeature().

Referenced by compress_close(), and share_close().

00221 {
00222   if (!ut)
00223     return;
00224   for (; ut->feature; ++ut)
00225     (int) uff_delfeature(ut);
00226 }

Here is the call graph for this function:

Here is the caller graph for this function:

static int uff_expmem ( void   )  [static]

Definition at line 90 of file uf_features.c.

References uff_list_struct::next, and uff_head_t::start.

Referenced by share_expmem().

00091 {
00092   uff_list_t *ul;
00093   int tot = 0;
00094 
00095   for (ul = uff_list.start; ul; ul = ul->next)
00096     tot += sizeof(uff_list_t);
00097   return tot;
00098 }

Here is the caller graph for this function:

static uff_list_t* uff_findentry_byflag ( int  flag  )  [static]

Definition at line 104 of file uf_features.c.

References uff_list_struct::entry, uff_table_t::flag, uff_list_struct::next, NULL, and uff_head_t::start.

Referenced by uff_addfeature().

00105 {
00106   uff_list_t *ul;
00107 
00108   for (ul = uff_list.start; ul; ul = ul->next)
00109     if (ul->entry->flag & flag)
00110       return ul;
00111   return NULL;
00112 }

Here is the caller graph for this function:

static uff_list_t* uff_findentry_byname ( char *  feature  )  [static]

Definition at line 117 of file uf_features.c.

References uff_list_struct::entry, uff_table_t::feature, uff_list_struct::next, NULL, and uff_head_t::start.

Referenced by uf_features_check(), uf_features_parse(), and uff_addfeature().

00118 {
00119   uff_list_t *ul;
00120 
00121   for (ul = uff_list.start; ul; ul = ul->next)
00122     if (!strcmp(ul->entry->feature, feature))
00123       return ul;
00124   return NULL;
00125 }

Here is the caller graph for this function:

static void uff_init ( void   )  [static]

Definition at line 83 of file uf_features.c.

References egg_bzero.

Referenced by share_start().

00084 {
00085   egg_bzero(&uff_list, sizeof(uff_head_t));
00086 }

Here is the caller graph for this function:

static void uff_insert_entry ( uff_list_t nul  )  [static]

Definition at line 129 of file uf_features.c.

References uff_head_t::end, uff_list_struct::entry, uff_list_struct::next, NULL, uff_list_struct::prev, uff_table_t::priority, and uff_head_t::start.

Referenced by uff_addfeature().

00130 {
00131   uff_list_t *ul, *lul = NULL;
00132 
00133   ul = uff_list.start;
00134   while (ul && ul->entry->priority < nul->entry->priority) {
00135     lul = ul;
00136     ul = ul->next;
00137   }
00138 
00139   nul->prev = NULL;
00140   nul->next = NULL;
00141   if (lul) {
00142     if (lul->next)
00143       lul->next->prev = nul;
00144     nul->next = lul->next;
00145     nul->prev = lul;
00146     lul->next = nul;
00147   } else if (ul) {
00148     uff_list.start->prev = nul;
00149     nul->next = uff_list.start;
00150     uff_list.start = nul;
00151   } else
00152     uff_list.start = nul;
00153   if (!nul->next)
00154     uff_list.end = nul;
00155 }

Here is the caller graph for this function:

static void uff_remove_entry ( uff_list_t ul  )  [static]

Definition at line 159 of file uf_features.c.

References uff_head_t::end, uff_list_struct::next, uff_list_struct::prev, and uff_head_t::start.

Referenced by uff_delfeature().

00160 {
00161   if (!ul->next)
00162     uff_list.end = ul->prev;
00163   else
00164     ul->next->prev = ul->prev;
00165   if (!ul->prev)
00166     uff_list.start = ul->next;
00167   else
00168     ul->prev->next = ul->next;
00169 }

Here is the caller graph for this function:


Variable Documentation

Initial value:
 {
  {"overbots",  0x000001  , uff_ask_override_bots, 0,  0 ,  0 },
  {"invites",   0x000002  ,    0 ,                  0,  0 ,  0 },
  {"exempts",   0x000004  ,    0 ,                  0,  0 ,  0 },
  { 0 ,       0,             0 ,                  0,  0 ,  0 }
}

Definition at line 377 of file uf_features.c.

Referenced by share_close(), and share_start().

uff_head_t uff_list [static]

Definition at line 75 of file uf_features.c.

char uff_sbuf[512] [static]

Definition at line 76 of file uf_features.c.

Referenced by uf_features_check(), uf_features_dump(), and uf_features_parse().


Generated on 7 Sep 2016 for Eggdrop by  doxygen 1.6.1