Пример #1
0
void sdprintf (const char *format, ...)
{
  if (sdebug) {
    char s[2001] = "";
    va_list va;

    va_start(va, format);
    egg_vsnprintf(s, sizeof(s), format, va);
    va_end(va);
    
    remove_crlf(s);

    if (!backgrd)
      dprintf(DP_STDOUT, "[D:%d] %s%s%s\n", mypid, BOLD(-1), s, BOLD_END(-1));
    else
      printf("[D:%d] %s%s%s\n", mypid, BOLD(-1), s, BOLD_END(-1));
  }
}
Пример #2
0
void sdprintf (const char *format, ...)
{
  char s[2001] = "";
  va_list va;

  va_start(va, format);
  egg_vsnprintf(s, sizeof(s), format, va);
  va_end(va);

  remove_crlf(s);

  ContextNote("dbg", s);

  if (sdebug) {
    if (!backgrd)
      dprintf(DP_STDOUT, "[D:%lu] %s%s%s\n", (unsigned long) mypid, BOLD(-1), s, BOLD_END(-1));
    else
      printf("[D:%lu] %s%s%s\n", (unsigned long) mypid, BOLD(-1), s, BOLD_END(-1));
  }
#ifdef DEBUG
  logfile(LOG_DEBUG, s);
#endif
}
Пример #3
0
/* show motd to dcc chatter */
void show_motd(int idx)
{
  if (motd[0]) {
    char *who = NULL, *buf = NULL, *buf_ptr = NULL, date[50] = "";
    time_t when;

    buf = buf_ptr = strdup(motd);
    who = newsplit(&buf);
    when = atoi(newsplit(&buf));
    strftime(date, sizeof date, "%c %Z", gmtime(&when));
    dprintf(idx, "Motd set by %s%s%s (%s)\n", BOLD(idx), who, BOLD_END(idx), date);
    dumplots(idx, "* ", replace(buf, "\\n", "\n"));
    dprintf(idx, " \n");
    free(buf_ptr);
  } else
    dprintf(idx, "Motd: none\n");
}
Пример #4
0
static void show_int(int idx, char *work, int *cnt, const char *desc, int state, const char *yes, const char *no, size_t worksiz)
{
  char tmp[101] = "", chr_state[101] = "";

  simple_snprintf(chr_state, sizeof chr_state, "%d", state);  
  /* empty buffer if no (char *) name */
  if (((*cnt) < (INT_COLS - 1)) && (!desc || (desc && !desc[0]))) (*cnt) = (INT_COLS - 1);
  (*cnt)++;
  if (*cnt > INT_COLS) {
    *cnt = 1;
    work[0] = 0;
  }
  if (!work[0])
    strlcpy(work, "  ", 3);
  /* need to make next line all one char, and then put it into %-30s */
  if (desc && desc[0]) {
    char tmp2[50] = "", tmp3[50] = "";

    strlcat(tmp2, BOLD(idx), sizeof(tmp2));
    if (state && yes) {
      strlcat(tmp2, yes, sizeof(tmp2));
      strlcat(tmp3, " (", sizeof(tmp3));
      strlcat(tmp3, chr_state, sizeof(tmp3));
      strlcat(tmp3, ")", sizeof(tmp3));
    } else if (!state && no) {
      strlcat(tmp2, no, sizeof(tmp2));
      strlcat(tmp3, " (", sizeof(tmp3));
      strlcat(tmp3, chr_state, sizeof(tmp3));
      strlcat(tmp3, ")", sizeof(tmp3));
    } else if ((state && !yes) || (!state && !no)) {
      strlcat(tmp2, chr_state, sizeof(tmp2));
    }
    strlcat(tmp2, BOLD_END(idx), sizeof(tmp2));
    simple_snprintf(tmp, sizeof tmp, "%-30s %-20s %s", desc, tmp2, tmp3[0] ? tmp3 : "");
    strlcat(work, tmp, worksiz);
  }
  if (*cnt >= INT_COLS)
    dprintf(idx, "%s\n", work);
}
Пример #5
0
static void cmd_chaninfo(int idx, char *par)
{
  char *chname = NULL, work[512] = "";
  struct chanset_t *chan = NULL;
  int cnt = 0;

  if (!par[0]) {
    chname = dcc[idx].u.chat->con_chan;
    if (chname[0] == '*') {
      dprintf(idx, "Your console channel is invalid.\n");
      return;
    }
  } else {
    chname = newsplit(&par);
    get_user_flagrec(dcc[idx].user, &user, chname);
    if (!glob_master(user) && !chan_master(user)) {
      dprintf(idx, "You don't have access to %s.\n", chname);
      return;
    }
  }
  if (!strcasecmp(chname, "default"))
    chan = chanset_default;
  else
    chan = findchan_by_dname(chname);
  if (!chan || (chan && privchan(user, chan, PRIV_OP))) {
    dprintf(idx, "No such channel.\n");
    return;
  } else {
    char nick[HANDLEN + 1] = "", date[81] = "";
    int deflag = 0;

    if (chan->added_ts) {
      strftime(date, sizeof date, "%c %Z", gmtime(&(chan->added_ts)));
    } else
      date[0] = 0;
    if (chan->added_by && chan->added_by[0])
      strlcpy(nick, chan->added_by, sizeof(nick));
    else
      nick[0] = 0;
    putlog(LOG_CMDS, "*", "#%s# chaninfo %s", dcc[idx].nick, chname);
    if (nick[0] && date[0])
      dprintf(idx, "Settings for channel %s (Added %s by %s%s%s):\n", chan->dname, date, BOLD(idx), nick, BOLD_END(idx));
    else
      dprintf(idx, "Settings for channel %s:\n", chan->dname);
/* FIXME: SHOW_CHAR() here */
    get_mode_protect(chan, work, sizeof(work));
    dprintf(idx, "Protect modes (chanmode): %s\n", work[0] ? work : "None");
    dprintf(idx, "Groups: %s\n", chan->groups && chan->groups->length() ? static_cast<bd::String>(chan->groups->join(" ")).c_str() : "None");
    dprintf(idx, "FiSH Key: %s\n", chan->fish_key[0] ? chan->fish_key : "not set");
//    dprintf(idx, "Protect topic (topic)   : %s\n", chan->topic[0] ? chan->topic : "");
/* Chanchar template
 *  dprintf(idx, "String temp: %s\n", chan->temp[0] ? chan->temp : "NULL");
 */
    dprintf(idx, "Channel flags:\n");
    work[0] = 0;
    SHOW_FLAG("autoop",		channel_autoop(chan));
    SHOW_FLAG("backup",		channel_backup(chan));
    SHOW_FLAG("bitch",		channel_bitch(chan));
    SHOW_FLAG("botbitch",       channel_botbitch(chan));
    SHOW_FLAG("closed",		channel_closed(chan));
    SHOW_FLAG("cycle",		channel_cycle(chan));
    SHOW_FLAG("enforcebans", 	channel_enforcebans(chan));
    SHOW_FLAG("fastop",		channel_fastop(chan));
    SHOW_FLAG("floodban", channel_floodban(chan));
    SHOW_FLAG("inactive",	channel_inactive(chan));
    SHOW_FLAG("nodesynch",	channel_nodesynch(chan));
    SHOW_FLAG("private",	channel_privchan(chan));
    SHOW_FLAG("protect",	channel_protect(chan));
    SHOW_FLAG("rbl",		channel_rbl(chan));
    if (HAVE_TAKE)
      SHOW_FLAG("take",		channel_take(chan));
    SHOW_FLAG("voice",		channel_voice(chan));
    SHOW_FLAG("voicebitch",		channel_voicebitch(chan));
    SHOW_FLAG("", 0);
    SHOW_FLAG("dynamicbans",	channel_dynamicbans(chan));
    SHOW_FLAG("userbans",	!channel_nouserbans(chan));
    SHOW_FLAG("dynamicexempts",	channel_dynamicexempts(chan));
    SHOW_FLAG("userexempts",	!channel_nouserexempts(chan));
    SHOW_FLAG("dynamicinvites",	channel_dynamicinvites(chan));
    SHOW_FLAG("userinvites",	!channel_nouserinvites(chan));
    SHOW_FLAG("", 0);
    work[0] = 0;

/* Chanflag template
 *  SHOW_FLAG("template", channel_template(chan));
 * also include %ctemp in dprintf.
 */

    work[0] = cnt = 0;
/* Chanint template
 * SHOW_INT("Desc: ", integer, "YES", "NO");
 */
    dprintf(idx, "Channel settings:\n");
    deflag = chan->bad_cookie;
    SHOW_INT("Auto-delay: ", chan->auto_delay, NULL, "None");
    SHOW_INT("Bad-cookie:" , chan->bad_cookie, DEFLAG_STR, "Ignore");
    SHOW_INT("Ban-time: ", chan->ban_time, NULL, "Forever");
    SHOW_INT("Ban-type: ", chan->ban_type, NULL, "3");
    SHOW_INT("Closed-ban: ", chan->closed_ban, NULL, "Don't!");
    SHOW_INT("Closed-invite:", chan->closed_invite, NULL, "Don't!");
    SHOW_INT("Closed-Private:", chan->closed_private, NULL, "Don't!");
    SHOW_INT("Closed-Exempt:", chan->closed_exempt_mode, F_STR(chan->closed_exempt_mode), "None");
    SHOW_INT("Exempt-time: ", chan->exempt_time, NULL, "Forever");
    SHOW_INT("Flood-exempt: ", chan->flood_exempt_mode, F_STR(chan->flood_exempt_mode), "None");
    SHOW_INT("Flood-lock-time: ", chan->flood_lock_time, NULL, "Don't");
    SHOW_INT("Caps-Limit(%): ", chan->capslimit, NULL, "None");
    SHOW_INT("Color-Limit: ", chan->colorlimit, NULL, "None");
    SHOW_INT("Invite-time: ", chan->invite_time, NULL, "Forever");
    SHOW_INT("Knock: ", chan->knock_flags, F_STR(chan->knock_flags), "None");
    SHOW_INT("Limit raise (limit): ", chan->limitraise, NULL, "Disabled");
    deflag = chan->manop;
    SHOW_INT("Manop: ", chan->manop, DEFLAG_STR, "Ignore");
    deflag = chan->mdop;
    SHOW_INT("Mdop: ", chan->mdop, DEFLAG_STR, "Ignore");
    deflag = chan->mop;
    SHOW_INT("Mop: ", chan->mop, DEFLAG_STR, "Ignore");
    deflag = chan->revenge;
    SHOW_INT("Revenge: ", chan->revenge, DEFLAG_STR, "Ignore");
    SHOW_INT("Protect-backup: ", chan->protect_backup, "Do!", "Don't!");
    SHOW_INT("Voice-non-ident: ", chan->voice_non_ident, "Do!", "Don't!");
    SHOW_INT("Voice-moderate:", chan->voice_moderate, "Do!", "Don't!");

    dprintf(idx, "Flood settings:   chan bytes ctcp join kick deop nick mjoin mpub mbytes mctcp\n");
    dprintf(idx, "  number:          %3d  %4d  %3d  %3d  %3d  %3d  %3d   %3d  %3d   %4d   %3d\n",
	    chan->flood_pub_thr, chan->flood_bytes_thr, chan->flood_ctcp_thr,
	    chan->flood_join_thr, chan->flood_kick_thr,
	    chan->flood_deop_thr, chan->flood_nick_thr,
            chan->flood_mjoin_thr, chan->flood_mpub_thr,
            chan->flood_mbytes_thr, chan->flood_mctcp_thr);
    dprintf(idx, "  time  :          %3u  %4u  %3u  %3u  %3u  %3u  %3u   %3u  %3u   %4u  %4u\n",
	    chan->flood_pub_time, chan->flood_bytes_time, chan->flood_ctcp_time,
	    chan->flood_join_time, chan->flood_kick_time,
	    chan->flood_deop_time, chan->flood_nick_time,
            chan->flood_mjoin_time, chan->flood_mpub_time,
            chan->flood_mbytes_time, chan->flood_mctcp_time);
  }
}