コード例 #1
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;
}
コード例 #2
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;
}
コード例 #3
0
ファイル: userent.c プロジェクト: Mafaioz/wraith
static bool set_unpack(struct userrec *u, struct user_entry *e)
{
  struct list_type *curr = NULL, *head = NULL;

  head = curr = e->u.list;
  e->u.extra = NULL;

  struct xtra_key *t = NULL;
  char *key = NULL, *data = NULL;

  while (curr) {
    t = (struct xtra_key *) my_calloc(1, sizeof(struct xtra_key));
    data = curr->extra;
    key = newsplit(&data);
    if (data[0]) {
      t->key = strdup(key);
      t->data = strdup(data);
      list_insert((struct xtra_key **) (&e->u.extra), t);
    } else
      free(t);
    curr = curr->next;
  }

  list_type_kill(head);
  return 1;
}
コード例 #4
0
ファイル: userent.c プロジェクト: Mafaioz/wraith
bool def_unpack(struct userrec *u, struct user_entry *e)
{
  char *tmp = e->u.list->extra;

  e->u.list->extra = NULL;
  list_type_kill(e->u.list);
  e->u.string = tmp;
  return 1;
}
コード例 #5
0
ファイル: flags.c プロジェクト: Protospace/protobot
static int botfl_unpack(struct userrec *u, struct user_entry *e)
{
  struct flag_record fr = { FR_BOT, 0, 0, 0, 0, 0 };

  break_down_flags(e->u.list->extra, &fr, NULL);
  list_type_kill(e->u.list);
  e->u.ulong = fr.bot;
  return 1;
}
コード例 #6
0
ファイル: userent.c プロジェクト: Mafaioz/wraith
static bool laston_unpack(struct userrec *u, struct user_entry *e)
{
  char *par = e->u.list->extra, *arg = newsplit(&par);
  struct laston_info *li = (struct laston_info *) my_calloc(1, sizeof(struct laston_info));

  if (!par[0])
    par = "???";
  li->laston = atoi(arg);
  li->lastonplace = strdup(par);
  list_type_kill(e->u.list);
  e->u.extra = li;
  return 1;
}
コード例 #7
0
ファイル: userent.c プロジェクト: Mafaioz/wraith
static bool botaddr_unpack(struct userrec *u, struct user_entry *e)
{
  char p[1024] = "", *q1 = NULL, *q2 = NULL;
  struct bot_addr *bi = (struct bot_addr *) my_calloc(1, sizeof(struct bot_addr));

  /* address:port/port:hublevel:uplink */

  strlcpy(p, e->u.list->extra, sizeof(p));
  q1 = strchr(p, ':');
  if (q1)
    *q1++ = 0;
  bi->address = strdup(p);
  if (q1) {
    q2 = strchr(q1, ':');
    if (q2)
      *q2++ = 0;
    bi->telnet_port = atoi(q1);
    q1 = strchr(q1, '/');
    if (q1) {
      q1++;
      bi->relay_port = atoi(q1);
    }
    if (q2) {
      q1 = strchr(q2, ':');
      if (q1) {
        *q1++ = 0;
        bi->uplink = strdup(q1);
      }
      bi->hublevel = atoi(q2);
    }
  }
  if (!bi->telnet_port)
    bi->telnet_port = 3333;
  if (!bi->relay_port)
    bi->relay_port = bi->telnet_port;
  if (!bi->uplink) {
    bi->uplink = (char *) my_calloc(1, 1);
  }
  list_type_kill(e->u.list);
  e->u.extra = bi;
  return 1;

}
コード例 #8
0
ファイル: userent.c プロジェクト: Mafaioz/wraith
static bool hosts_set(struct userrec *u, struct user_entry *e, void *buf)
{
  if (!buf || !strcasecmp((const char *) buf, "none")) {
    /* When the bot crashes, it's in this part, not in the 'else' part */
    list_type_kill(e->u.list);
    e->u.list = NULL;
  } else {
    char *host = (char *) buf, *p = strchr(host, ',');
    struct list_type **t;

    /* Can't have ,'s in hostmasks */
    while (p) {
      *p = '?';
      p = strchr(host, ',');
    }
    /* fred1: check for redundant hostmasks with
     * controversial "superpenis" algorithm ;) */
    /* I'm surprised Raistlin hasn't gotten involved in this controversy */
    t = &(e->u.list);
    while (*t) {
      if (wild_match(host, (*t)->extra)) {
	struct list_type *listu;

	listu = *t;
	*t = (*t)->next;
	if (listu->extra)
	  free(listu->extra);
	free(listu);
      } else
	t = &((*t)->next);
    }
    *t = (struct list_type *) my_calloc(1, sizeof(struct list_type));

    (*t)->next = NULL;
    (*t)->extra = strdup(host);
  }
  return 1;
}
コード例 #9
0
ファイル: userent.c プロジェクト: Mafaioz/wraith
static bool hosts_kill(struct user_entry *e)
{
  list_type_kill(e->u.list);
  free(e);
  return 1;
}