Exemple #1
0
static int
console_store(int idx, char *par, bool displaySave)
{
  struct console_info *i = (struct console_info *) get_user(&USERENTRY_CONSOLE, dcc[idx].user);

  if (!i) 
    i = (struct console_info *) my_calloc(1, sizeof(struct console_info));
  
  if (i->channel)
    free(i->channel);
  i->channel = strdup(dcc[idx].u.chat->con_chan);
  i->conflags = dcc[idx].u.chat->con_flags;
  i->stripflags = dcc[idx].u.chat->strip_flags;
  i->echoflags = (dcc[idx].status & STAT_ECHO) ? 1 : 0;
  if (dcc[idx].status & STAT_PAGE)
    i->page = dcc[idx].u.chat->max_line;
  else
    i->page = 0;
  if (dcc[idx].status & STAT_COLOR)
    i->color = 1;
  else
    i->color = 0;
  if (dcc[idx].status & STAT_BANNER)
    i->banner = 1;
  else
    i->banner = 0;
  if (dcc[idx].status & STAT_CHANNELS)
    i->channels = 1;
  else
    i->channels = 0;
  if (dcc[idx].status & STAT_BOTS)
    i->bots = 1;
  else
    i->bots = 0;
  if (dcc[idx].status & STAT_WHOM)
    i->whom = 1;
  else
    i->whom = 0;

  i->conchan = dcc[idx].u.chat->channel;
  if (par) {
    dprintf(idx, "%s\n", "Saved your Console Settings:");
    dprintf(idx, "  %s %s\n", "Channel:", i->channel);
    dprintf(idx, "  %s %s, %s %s, %s %s\n", "Console flags:",
            masktype(i->conflags), "",
            stripmasktype(i->stripflags), "Echo:", i->echoflags ? "yes" : "no");
    dprintf(idx, "  %s %d, %s %d\n", "Page setting:", i->page, "Console channel:", i->conchan);
    dprintf(idx, "    Color: $b%s$b\n", i->color ? "on" : "off");
    dprintf(idx, "    Login settings:\n");
    dprintf(idx, "    Login settings:\n");
    dprintf(idx, "     Banner:   $b%-3s$b   Bots: $b%-3s$b\n", i->banner ? "on" : "off", i->bots ? "on" : "off");
    dprintf(idx, "     Channels: $b%-3s$b   Whom: $b%-3s$b\n", i->channels ? "on" : "off", i->whom ? "on" : "off");

  }
  set_user(&USERENTRY_CONSOLE, dcc[idx].user, i);
  dprintf(idx, "Console setting stored.\n");
  if (conf.bot->hub)
    write_userfile(displaySave ? idx : -1);
  return 0;
}
Exemple #2
0
static bool
console_set(struct userrec *u, struct user_entry *e, void *buf)
{
  struct console_info *ci = (struct console_info *) e->u.extra;

  if (!ci && !buf)
    return 1;

  if (ci != buf) {
    if (ci) {
      free(ci->channel);
      free(ci);
    }
    ci = (struct console_info *) buf;
    e->u.extra = (struct console_info *) buf;
  }

  if (!noshare && !u->bot) {
    char string[501] = "";

    simple_snprintf(string, sizeof string, "%s %s %s %d %d %d %d %d %d %d %d", ci->channel,
                 masktype(ci->conflags), stripmasktype(ci->stripflags), ci->echoflags, ci->page, ci->conchan,
                 ci->color, ci->banner, ci->channels, ci->bots, ci->whom);
    /* shareout("c %s %s %s\n", e->type->name, u->handle, string); */
    shareout("c CONSOLE %s %s\n", u->handle, string);
  }
  return 1;
}
Exemple #3
0
static int console_pack(struct userrec *u, struct user_entry *e)
{
  char work[1024];
  struct console_info *ci;
  int l;

  Assert(e);
  Assert(e->u.extra);
  Assert(!e->name);

  ci = (struct console_info *) e->u.extra;

  l = simple_sprintf(work, "%s %s %s %d %d %d",
		     ci->channel, masktype(ci->conflags),
		     stripmasktype(ci->stripflags), ci->echoflags,
		     ci->page, ci->conchan);

  e->u.list = user_malloc(sizeof(struct list_type));
  e->u.list->next = NULL;
  e->u.list->extra = user_malloc(l + 1);
  strcpy(e->u.list->extra, work);

  nfree(ci->channel);
  nfree(ci);
  return 1;
}
Exemple #4
0
static int console_write_userfile(FILE *f, struct userrec *u,
                                  struct user_entry *e)
{
  struct console_info *i = e->u.extra;

  if (fprintf(f, "--CONSOLE %s %s %s %d %d %d\n",
              i->channel, masktype(i->conflags),
              stripmasktype(i->stripflags), i->echoflags,
              i->page, i->conchan) == EOF)
    return 0;
  return 1;
}
Exemple #5
0
static int console_tcl_get(Tcl_Interp *irp, struct userrec *u,
			   struct user_entry *e, int argc, char **argv)
{
  char work[1024];
  struct console_info *i = e->u.extra;

  simple_sprintf(work, "%s %s %s %d %d %d",
		 i->channel, masktype(i->conflags),
		 stripmasktype(i->stripflags), i->echoflags,
		 i->page, i->conchan);
  Tcl_AppendResult(irp, work, NULL);
  return TCL_OK;
}
Exemple #6
0
static bool
console_write_userfile(FILE * f, struct userrec *u, struct user_entry *e, int idx)
{
  if (u->bot)
    return 1;

  struct console_info *i = (struct console_info *) e->u.extra;

  if (lfprintf(f, "--CONSOLE %s %s %s %d %d %d %d %d %d %d %d\n",
               i->channel, masktype(i->conflags),
               stripmasktype(i->stripflags), i->echoflags,
               i->page, i->conchan, i->color, i->banner, i->channels, i->bots, i->whom) == EOF)
    return 0;
  return 1;
}
Exemple #7
0
void console_display(int idx, struct user_entry *e)
{
  struct console_info *i = e->u.extra;

  Context;
  if (dcc[idx].user && (dcc[idx].user->flags & USER_MASTER)) {
    dprintf(idx, "  Saved Console Settings:\n");
    dprintf(idx, "    Channel: %s\n", i->channel);
    dprintf(idx, "    Console flags: %s, Strip flags: %s, Echo: %s\n",
	    masktype(i->conflags), stripmasktype(i->stripflags),
	    i->echoflags ? "yes" : "no");
    dprintf(idx, "    Page setting: %d, Console channel: %s%d\n",
	    i->page, (i->conchan < 100000) ? "" : "*", i->conchan % 100000);
  }
}
Exemple #8
0
static void console_display(int idx, struct user_entry *e)
{
  struct console_info *i = e->u.extra;

  if (dcc[idx].user && (dcc[idx].user->flags & USER_MASTER)) {
    dprintf(idx, "  %s\n", CONSOLE_SAVED_SETTINGS);
    dprintf(idx, "    %s %s\n", CONSOLE_CHANNEL, i->channel);
    dprintf(idx, "    %s %s, %s %s, %s %s\n", CONSOLE_FLAGS,
            masktype(i->conflags), CONSOLE_STRIPFLAGS,
            stripmasktype(i->stripflags), CONSOLE_ECHO,
            i->echoflags ? CONSOLE_YES : CONSOLE_NO);
    dprintf(idx, "    %s %d, %s %s%d\n", CONSOLE_PAGE_SETTING, i->page,
            CONSOLE_CHANNEL2, (i->conchan < GLOBAL_CHANS) ? "" : "*",
            i->conchan % GLOBAL_CHANS);
  }
}
Exemple #9
0
static int tcl_strip(ClientData cd, Tcl_Interp *irp,
                     int argc, char *argv[])
{
  int i, j, pls, arg;
  module_entry *me;

  BADARGS(2, 4, " idx ?strip-flags?");

  i = findidx(atoi(argv[1]));
  if (i < 0 || dcc[i].type != &DCC_CHAT) {
    Tcl_AppendResult(irp, "invalid idx", NULL);
    return TCL_ERROR;
  }
  pls = 1;

  for (arg = 2; arg < argc; arg++) {
    if ((argv[arg][0] != '+') && (argv[arg][0] != '-'))
      dcc[i].u.chat->strip_flags = 0;
    for (j = 0; j < strlen(argv[arg]); j++) {
      if (argv[arg][j] == '+')
        pls = 1;
      else if (argv[arg][j] == '-')
        pls = -1;
      else {
        char s[2];

        s[0] = argv[arg][j];
        s[1] = 0;
        if (pls == 1)
          dcc[i].u.chat->strip_flags |= stripmodes(s);
        else
          dcc[i].u.chat->strip_flags &= ~stripmodes(s);
      }
    }
  }
  Tcl_AppendElement(irp, stripmasktype(dcc[i].u.chat->strip_flags));
  /* Console autosave. */
  if (argc > 2 && (me = module_find("console", 1, 1))) {
    Function *func = me->funcs;

    (func[CONSOLE_DOSTORE]) (i);
  }
  return TCL_OK;
}
Exemple #10
0
static void
console_display(int idx, struct user_entry *e, struct userrec *u)
{
  struct console_info *i = (struct console_info *) e->u.extra;

  if (dcc[idx].user && (dcc[idx].user->flags & USER_MASTER)) {
    dprintf(idx, "  %s\n", "Saved Console Settings:");
    dprintf(idx, "    %s %s\n", "Channel:", i->channel);
    dprintf(idx, "    %s %s, %s %s, %s %s\n", "Console flags:",
            masktype(i->conflags), "",
            stripmasktype(i->stripflags), "Echo:", i->echoflags ? "yes" : "no");
    dprintf(idx, "    %s %d, %s %s%d\n", "Page setting:", i->page,
            "Console channel:", (i->conchan < GLOBAL_CHANS) ? "" : "*", i->conchan % GLOBAL_CHANS);
    dprintf(idx, "    Color: $b%s$b\n", i->color ? "on" : "off");
    dprintf(idx, "    Login settings:\n");
    dprintf(idx, "     Banner:   $b%-3s$b   Bots: $b%-3s$b\n", i->banner ? "on" : "off", i->bots ? "on" : "off");
    dprintf(idx, "     Channels: $b%-3s$b   Whom: $b%-3s$b\n", i->channels ? "on" : "off", i->whom ? "on" : "off");
  }
}