src/mod/notes.mod/cmdsnote.c File Reference

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

Go to the source code of this file.

Functions

static void cmd_pls_noteign (struct userrec *u, int idx, char *par)
static void cmd_mns_noteign (struct userrec *u, int idx, char *par)
static void cmd_noteigns (struct userrec *u, int idx, char *par)
static void cmd_fwd (struct userrec *u, int idx, char *par)
static void cmd_notes (struct userrec *u, int idx, char *par)
static void cmd_note (struct userrec *u, int idx, char *par)

Variables

static cmd_t notes_cmds []

Function Documentation

static void cmd_fwd ( struct userrec u,
int  idx,
char *  par 
) [static]

Definition at line 152 of file cmdsnote.c.

References dcc, dprintf, egg_strcasecmp, userrec::flags, get_user_by_handle, LOG_CMDS, newsplit, NOTES_FWD_BOTNAME, NOTES_FWD_CHANGED, NOTES_FWD_FOR, NOTES_FWD_OWNER, NOTES_NO_SUCH_USER, NOTES_USAGE, NULL, putlog, set_user, USER_OWNER, USERENTRY_FWD, and userlist.

00153 {
00154   char *handle;
00155   struct userrec *u1;
00156 
00157   if (!par[0]) {
00158     dprintf(idx, "%s: fwd <handle> [user@bot]\n", NOTES_USAGE);
00159     return;
00160   }
00161   handle = newsplit(&par);
00162   u1 = get_user_by_handle(userlist, handle);
00163   if (!u1) {
00164     dprintf(idx, "%s\n", NOTES_NO_SUCH_USER);
00165     return;
00166   }
00167   if ((u1->flags & USER_OWNER) && egg_strcasecmp(handle, dcc[idx].nick)) {
00168     dprintf(idx, "%s\n", NOTES_FWD_OWNER);
00169     return;
00170   }
00171   if (!par[0]) {
00172     putlog(LOG_CMDS, "*", "#%s# fwd %s", dcc[idx].nick, handle);
00173     dprintf(idx, NOTES_FWD_FOR, handle);
00174     set_user(&USERENTRY_FWD, u1, NULL);
00175     return;
00176   }
00177   /* Thanks to vertex & dw */
00178   if (strchr(par, '@') == NULL) {
00179     dprintf(idx, "%s\n", NOTES_FWD_BOTNAME);
00180     return;
00181   }
00182   putlog(LOG_CMDS, "*", "#%s# fwd %s %s", dcc[idx].nick, handle, par);
00183   dprintf(idx, NOTES_FWD_CHANGED, handle, par);
00184   set_user(&USERENTRY_FWD, u1, par);
00185 }

static void cmd_mns_noteign ( struct userrec u,
int  idx,
char *  par 
) [static]

Definition at line 70 of file cmdsnote.c.

References dcc, del_note_ignore(), dprintf, FR_CHAN, FR_GLOBAL, get_user_by_handle, get_user_flagrec, glob_master, glob_owner, userrec::handle, LOG_CMDS, newsplit, nfree, nmalloc, NOTES_IGN_NOTFOUND, NOTES_IGN_OTHERS, NOTES_IGN_REM, NOTES_UNKNOWN_USER, NOTES_USAGE, putlog, and userlist.

00071 {
00072   struct userrec *u2;
00073   char *handle, *mask, *buf, *p;
00074 
00075   if (!par[0]) {
00076     dprintf(idx, "%s: -noteign [handle] <ignoremask>\n", NOTES_USAGE);
00077     return;
00078   }
00079   putlog(LOG_CMDS, "*", "#%s# -noteign %s", dcc[idx].nick, par);
00080   p = buf = nmalloc(strlen(par) + 1);
00081   strcpy(p, par);
00082   handle = newsplit(&p);
00083   mask = newsplit(&p);
00084   if (mask[0]) {
00085     u2 = get_user_by_handle(userlist, handle);
00086     if (u != u2) {
00087       struct flag_record fr = { FR_GLOBAL | FR_CHAN, 0, 0, 0, 0, 0 };
00088 
00089       get_user_flagrec(u, &fr, dcc[idx].u.chat->con_chan);
00090       if (!(glob_master(fr) || glob_owner(fr))) {
00091         dprintf(idx, NOTES_IGN_OTHERS, handle);
00092         nfree(buf);
00093         return;
00094       }
00095     }
00096     if (!u2) {
00097       dprintf(idx, NOTES_UNKNOWN_USER, handle);
00098       nfree(buf);
00099       return;
00100     }
00101   } else {
00102     u2 = u;
00103     mask = handle;
00104   }
00105 
00106   if (del_note_ignore(u2, mask))
00107     dprintf(idx, NOTES_IGN_REM, mask);
00108   else
00109     dprintf(idx, NOTES_IGN_NOTFOUND, mask);
00110   nfree(buf);
00111   return;
00112 }

Here is the call graph for this function:

static void cmd_note ( struct userrec u,
int  idx,
char *  par 
) [static]

Definition at line 219 of file cmdsnote.c.

References add_note, dcc, dprintf, userrec::handle, newsplit, NOTES_USAGE, rmspace, splitc, and STAT_ECHO.

00220 {
00221   char handle[512], *p;
00222   int echo;
00223 
00224   p = newsplit(&par);
00225   if (!par[0]) {
00226     dprintf(idx, "%s: note <to-whom> <message>\n", NOTES_USAGE);
00227     return;
00228   }
00229   while ((*par == ' ') || (*par == '<') || (*par == '>'))
00230     par++; /* These are now illegal *starting* notes characters */
00231   echo = (dcc[idx].status & STAT_ECHO);
00232   splitc(handle, p, ',');
00233   while (handle[0]) {
00234     rmspace(handle);
00235     add_note(handle, dcc[idx].nick, par, idx, echo);
00236     splitc(handle, p, ',');
00237   }
00238   rmspace(p);
00239   add_note(p, dcc[idx].nick, par, idx, echo);
00240 }

static void cmd_noteigns ( struct userrec u,
int  idx,
char *  par 
) [static]

Definition at line 114 of file cmdsnote.c.

References dcc, dprintf, FR_CHAN, FR_GLOBAL, get_note_ignores(), get_user_by_handle, get_user_flagrec, glob_master, glob_owner, userrec::handle, LOG_CMDS, nfree, NOTES_IGN_FOR, NOTES_IGN_NONE, NOTES_IGN_OTHERS, NOTES_UNKNOWN_USER, putlog, and userlist.

00115 {
00116   struct userrec *u2;
00117   char **ignores;
00118   int ignoresn, i;
00119 
00120   if (par[0]) {
00121     u2 = get_user_by_handle(userlist, par);
00122     if (u != u2) {
00123       struct flag_record fr = { FR_GLOBAL | FR_CHAN, 0, 0, 0, 0, 0 };
00124 
00125       get_user_flagrec(u, &fr, dcc[idx].u.chat->con_chan);
00126       if (!(glob_master(fr) || glob_owner(fr))) {
00127         dprintf(idx, NOTES_IGN_OTHERS, par);
00128         return;
00129       }
00130     }
00131     if (!u2) {
00132       dprintf(idx, NOTES_UNKNOWN_USER, par);
00133       return;
00134     }
00135   } else
00136     u2 = u;
00137 
00138   ignoresn = get_note_ignores(u2, &ignores);
00139   if (!ignoresn) {
00140     dprintf(idx, "%s", NOTES_IGN_NONE);
00141     return;
00142   }
00143   putlog(LOG_CMDS, "*", "#%s# noteigns %s", dcc[idx].nick, par);
00144   dprintf(idx, NOTES_IGN_FOR, u2->handle);
00145   for (i = 0; i < ignoresn; i++)
00146     dprintf(idx, " %s", ignores[i]);
00147   dprintf(idx, "\n");
00148   nfree(ignores[0]);            /* Free the string buffer       */
00149   nfree(ignores);               /* Free the ptr array           */
00150 }

Here is the call graph for this function:

static void cmd_notes ( struct userrec u,
int  idx,
char *  par 
) [static]

Definition at line 187 of file cmdsnote.c.

References dcc, dprintf, egg_strcasecmp, LOG_CMDS, newsplit, notes_del(), NOTES_MAYBE, NOTES_MUSTBE, notes_read(), NOTES_USAGE, and putlog.

00188 {
00189   char *fcn;
00190 
00191   if (!par[0]) {
00192     dprintf(idx, "%s: notes index\n", NOTES_USAGE);
00193     dprintf(idx, "       notes read <# or ALL>\n");
00194     dprintf(idx, "       notes erase <# or ALL>\n");
00195     dprintf(idx, "       %s\n", NOTES_MAYBE);
00196     dprintf(idx, "       ex: notes erase 2-4;8;16-\n");
00197     return;
00198   }
00199   fcn = newsplit(&par);
00200   if (!egg_strcasecmp(fcn, "index"))
00201     notes_read(dcc[idx].nick, "", "+", idx);
00202   else if (!egg_strcasecmp(fcn, "read")) {
00203     if (!egg_strcasecmp(par, "all"))
00204       notes_read(dcc[idx].nick, "", "-", idx);
00205     else
00206       notes_read(dcc[idx].nick, "", par, idx);
00207   } else if (!egg_strcasecmp(fcn, "erase")) {
00208     if (!egg_strcasecmp(par, "all"))
00209       notes_del(dcc[idx].nick, "", "-", idx);
00210     else
00211       notes_del(dcc[idx].nick, "", par, idx);
00212   } else {
00213     dprintf(idx, "%s\n", NOTES_MUSTBE);
00214     return;
00215   }
00216   putlog(LOG_CMDS, "*", "#%s# notes %s %s", dcc[idx].nick, fcn, par);
00217 }

Here is the call graph for this function:

static void cmd_pls_noteign ( struct userrec u,
int  idx,
char *  par 
) [static]

Definition at line 26 of file cmdsnote.c.

References add_note_ignore(), dcc, dprintf, FR_CHAN, FR_GLOBAL, get_user_by_handle, get_user_flagrec, glob_master, glob_owner, userrec::handle, LOG_CMDS, newsplit, nfree, nmalloc, NOTES_IGN_ALREADY, NOTES_IGN_NEW, NOTES_IGN_OTHERS, NOTES_UNKNOWN_USER, NOTES_USAGE, putlog, and userlist.

00027 {
00028   struct userrec *u2;
00029   char *handle, *mask, *buf, *p;
00030 
00031   if (!par[0]) {
00032     dprintf(idx, "%s: +noteign [handle] <ignoremask>\n", NOTES_USAGE);
00033     return;
00034   }
00035   putlog(LOG_CMDS, "*", "#%s# +noteign %s", dcc[idx].nick, par);
00036 
00037   p = buf = nmalloc(strlen(par) + 1);
00038   strcpy(p, par);
00039   handle = newsplit(&p);
00040   mask = newsplit(&p);
00041   if (mask[0]) {
00042     u2 = get_user_by_handle(userlist, handle);
00043     if (u != u2) {
00044       struct flag_record fr = { FR_GLOBAL | FR_CHAN, 0, 0, 0, 0, 0 };
00045 
00046       get_user_flagrec(u, &fr, dcc[idx].u.chat->con_chan);
00047       if (!(glob_master(fr) || glob_owner(fr))) {
00048         dprintf(idx, NOTES_IGN_OTHERS, handle);
00049         nfree(buf);
00050         return;
00051       }
00052     }
00053     if (!u2) {
00054       dprintf(idx, NOTES_UNKNOWN_USER, handle);
00055       nfree(buf);
00056       return;
00057     }
00058   } else {
00059     u2 = u;
00060     mask = handle;
00061   }
00062   if (add_note_ignore(u2, mask))
00063     dprintf(idx, NOTES_IGN_NEW, mask);
00064   else
00065     dprintf(idx, NOTES_IGN_ALREADY, mask);
00066   nfree(buf);
00067   return;
00068 }

Here is the call graph for this function:


Variable Documentation

cmd_t notes_cmds[] [static]
Initial value:
 {
  {"fwd",      "m",  (IntFunc) cmd_fwd,          0 },
  {"notes",    "",   (IntFunc) cmd_notes,        0 },
  {"+noteign", "",   (IntFunc) cmd_pls_noteign,  0 },
  {"-noteign", "",   (IntFunc) cmd_mns_noteign,  0 },
  {"noteigns", "",   (IntFunc) cmd_noteigns,     0 },
  {"note",     "",   (IntFunc) cmd_note,         0 },
  { 0 ,        0 ,  0 ,                        0 }
}

Definition at line 242 of file cmdsnote.c.

Referenced by notes_close(), and notes_start().


Generated on 7 Sep 2016 for Eggdrop by  doxygen 1.6.1