コード例 #1
0
ファイル: console.c プロジェクト: Estella/wraith
static bool
console_unpack(struct userrec *u, struct user_entry *e)
{
  struct console_info *ci = (struct console_info *) my_calloc(1, sizeof(struct console_info));
  char *par = e->u.list->extra, *arg = NULL;

  arg = newsplit(&par);
  ci->channel = strdup(arg);
  arg = newsplit(&par);
  ci->conflags = logmodes(arg);
  arg = newsplit(&par);
  ci->stripflags = stripmodes(arg);
  arg = newsplit(&par);
  ci->echoflags = (arg[0] == '1') ? 1 : 0;
  arg = newsplit(&par);
  ci->page = atoi(arg);
  arg = newsplit(&par);
  ci->conchan = atoi(arg);
  arg = newsplit(&par);
  ci->color = atoi(arg);
  arg = newsplit(&par);
  ci->banner = atoi(arg);
  arg = newsplit(&par);
  ci->channels = atoi(arg);
  arg = newsplit(&par);
  ci->bots = atoi(arg);
  arg = newsplit(&par);
  ci->whom = atoi(arg);

  list_type_kill(e->u.list);
  e->u.extra = ci;
  return 1;
}
コード例 #2
0
ファイル: console.c プロジェクト: nawawi/eggdrop1.5.4
static int console_unpack(struct userrec *u, struct user_entry *e)
{
  struct console_info *ci = user_malloc(sizeof(struct console_info));
  char *par, *arg;

  Context;
  Assert(e);
  Assert(e->name);
  par = e->u.list->extra;
  arg = newsplit(&par);
  ci->channel = user_malloc(strlen(arg) + 1);
  strcpy(ci->channel, arg);
  arg = newsplit(&par);
  ci->conflags = logmodes(arg);
  arg = newsplit(&par);
  ci->stripflags = stripmodes(arg);
  arg = newsplit(&par);
  ci->echoflags = (arg[0] == '1') ? 1 : 0;
  arg = newsplit(&par);
  ci->page = atoi(arg);
  arg = newsplit(&par);
  ci->conchan = atoi(arg);
  list_type_kill(e->u.list);
  e->u.extra = ci;
  return 1;
}
コード例 #3
0
ファイル: tcldcc.c プロジェクト: Estella/eggdrop-1.7
static int tcl_console(ClientData cd, Tcl_Interp *irp,
                       int argc, char *argv[])
{
  int i, j, pls, arg;
  module_entry *me;

  BADARGS(2, 4, " idx ?channel? ?console-modes?");

  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] && ((strchr(CHANMETA, argv[arg][0]) != NULL) ||
        (argv[arg][0] == '*'))) {
      if ((argv[arg][0] != '*') && (!findchan_by_dname(argv[arg]))) {
        /* If we dont find the channel, and it starts with a +, assume it
         * should be the console flags to set. */
        if (argv[arg][0] == '+')
          goto do_console_flags;
        Tcl_AppendResult(irp, "invalid channel", NULL);
        return TCL_ERROR;
      }
      strncpyz(dcc[i].u.chat->con_chan, argv[arg], 81);
    } else {
      if ((argv[arg][0] != '+') && (argv[arg][0] != '-'))
        dcc[i].u.chat->con_flags = 0;
    do_console_flags:
      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->con_flags |= logmodes(s);
          else
            dcc[i].u.chat->con_flags &= ~logmodes(s);
        }
      }
    }
  }
  Tcl_AppendElement(irp, dcc[i].u.chat->con_chan);
  Tcl_AppendElement(irp, masktype(dcc[i].u.chat->con_flags));
  /* Console autosave. */
  if (argc > 2 && (me = module_find("console", 1, 1))) {
    Function *func = me->funcs;

    (func[CONSOLE_DOSTORE]) (i);
  }
  return TCL_OK;
}
コード例 #4
0
ファイル: console.c プロジェクト: ArNz8o8/Fr3shness
static int console_tcl_set(Tcl_Interp *irp, struct userrec *u,
                           struct user_entry *e, int argc, char **argv)
{
  struct console_info *i = e->u.extra;
  int l;

  BADARGS(4, 9, " handle CONSOLE channel flags strip echo page conchan");

  if (!i) {
    i = user_malloc(sizeof(struct console_info));
    egg_bzero(i, sizeof(struct console_info));
  }
  if (i->channel)
    nfree(i->channel);
  l = strlen(argv[3]);
  if (l > 80)
    l = 80;
  i->channel = user_malloc(l + 1);
  strncpy(i->channel, argv[3], l);
  i->channel[l] = 0;
  if (argc > 4) {
    i->conflags = logmodes(argv[4]);
    if (argc > 5) {
      i->stripflags = stripmodes(argv[5]);
      if (argc > 6) {
        i->echoflags = (argv[6][0] == '1') ? 1 : 0;
        if (argc > 7) {
          i->page = atoi(argv[7]);
          if (argc > 8)
            i->conchan = atoi(argv[8]);
        }
      }
    }
  }
  set_user(&USERENTRY_CONSOLE, u, i);
  return TCL_OK;
}
コード例 #5
0
ファイル: console.c プロジェクト: Estella/wraith
static bool
console_gotshare(struct userrec *u, struct user_entry *e, char *par, int idx)
{
  struct console_info *ci = (struct console_info *) e->u.extra;
  char *arg = NULL;

  arg = newsplit(&par);
  if (ci) {
    free(ci->channel);
    free(ci);
  }
  ci = (struct console_info *) my_calloc(1, sizeof(struct console_info));
  ci->channel = strdup(arg);
  arg = newsplit(&par);
  ci->conflags = logmodes(arg);
  arg = newsplit(&par);
  ci->stripflags = stripmodes(arg);
  arg = newsplit(&par);
  ci->echoflags = (arg[0] == '1') ? 1 : 0;
  arg = newsplit(&par);
  ci->page = atoi(arg);
  arg = newsplit(&par);
  ci->conchan = atoi(arg);
  arg = newsplit(&par);
  ci->color = atoi(arg);
  arg = newsplit(&par);
  ci->banner = atoi(arg);
  arg = newsplit(&par);
  ci->channels = atoi(arg);
  arg = newsplit(&par);
  ci->bots = atoi(arg);
  arg = newsplit(&par);
  ci->whom = atoi(arg);

  e->u.extra = ci;
  struct chat_info dummy;
  /* now let's propogate to the dcc list */
  for (int i = 0; i < dcc_total; i++) {
    if (dcc[i].type && (dcc[i].type == &DCC_CHAT) && !strcmp(dcc[i].user->handle, u->handle)) {
      if (ci->channel && ci->channel[0])
        strlcpy(dcc[i].u.chat->con_chan, ci->channel, sizeof(dummy.con_chan));
      dcc[i].u.chat->con_flags = ci->conflags;
      dcc[i].u.chat->strip_flags = ci->stripflags;
      if (ci->echoflags)
        dcc[i].status |= STAT_ECHO;
      else
        dcc[i].status &= ~STAT_ECHO;
      if (ci->page) {
        dcc[i].status |= STAT_PAGE;
        dcc[i].u.chat->max_line = ci->page;
        if (!dcc[i].u.chat->line_count)
          dcc[i].u.chat->current_lines = 0;
      }
      if (ci->color)
        dcc[i].status |= STAT_COLOR;
      else
        dcc[i].status &= ~STAT_COLOR;
      if (ci->banner)
        dcc[i].status |= STAT_BANNER;
      else
        dcc[i].status &= ~STAT_BANNER;
      if (ci->channels)
        dcc[i].status |= STAT_CHANNELS;
      else
        dcc[i].status &= ~STAT_CHANNELS;
      if (ci->bots)
        dcc[i].status |= STAT_BOTS;
      else
        dcc[i].status &= ~STAT_BOTS;
      if (ci->whom)
        dcc[i].status |= STAT_WHOM;
      else
        dcc[i].status &= ~STAT_WHOM;
    }
  }
  return 1;
}