"Fossies" - the Fresh Open Source Software Archive

Member "bahamut-2.1.5/src/s_debug.c" (28 May 2020, 6973 Bytes) of package /linux/privat/bahamut-2.1.5.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "s_debug.c" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 2.1.4_vs_2.1.5.

    1 /************************************************************************
    2  *   IRC - Internet Relay Chat, src/s_debug.c
    3  *   Copyright (C) 1990 Jarkko Oikarinen and
    4  *                      University of Oulu, Computing Center
    5  *
    6  *   This program is free software; you can redistribute it and/or modify
    7  *   it under the terms of the GNU General Public License as published by
    8  *   the Free Software Foundation; either version 1, or (at your option)
    9  *   any later version.
   10  *
   11  *   This program is distributed in the hope that it will be useful,
   12  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
   13  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   14  *   GNU General Public License for more details.
   15  *
   16  *   You should have received a copy of the GNU General Public License
   17  *   along with this program; if not, write to the Free Software
   18  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
   19  */
   20 
   21 #include "struct.h"
   22 #include "common.h"
   23 #include "sys.h"
   24 #include "h.h"
   25 #include "patchlevel.h"
   26 #include "numeric.h"
   27 #include "channel.h"
   28 
   29 /* This file is hereby declared the nexus of all things ugly and preprocessed */
   30 
   31 static char rplisupport1[BUFSIZE];
   32 static char rplisupport2[BUFSIZE];
   33 static char rplisupportoper[BUFSIZE];
   34 static char rplversion[BUFSIZE];
   35 static char scratchbuf[BUFSIZE];
   36 
   37 /* send cached RPL_ISUPPORT */
   38 void send_rplisupport(aClient *acptr)
   39 {
   40     sendto_one(acptr, rplisupport1, acptr->name);
   41     sendto_one(acptr, rplisupport2, acptr->name);
   42 }
   43 
   44 /* send cached RPL_ISUPPORT for oper limits */
   45 void send_rplisupportoper(aClient *acptr)
   46 {
   47     sendto_one(acptr, rplisupportoper, acptr->name);
   48 }
   49 
   50 /* send cached RPL_VERSION */
   51 void send_rplversion(aClient *acptr)
   52 {
   53     sendto_one(acptr, rplversion, acptr->name);
   54 }
   55 
   56 
   57 /* build and cache complex strings */
   58 void build_rplcache(void)
   59 {
   60     char *s;
   61 
   62     /* build RPL_ISUPPORT */
   63 
   64     /* Most of this tracks draft-brocklesby-irc-isupport-03, with a
   65     * few differences:
   66     * STD is not sent since there is no RFC
   67     * MAXCHANNELS and MAXBANS are sent for compatibility with old clients
   68     * SILENCE WATCH and ELIST are sent but not documented
   69     */
   70 
   71     /* put MAXBANS and MAXCHANNELS first so better tokens override them */
   72     ircsprintf(scratchbuf,"NETWORK=%s SAFELIST MAXBANS=%i MAXCHANNELS=%i "
   73                "CHANNELLEN=%i KICKLEN=%i NICKLEN=%i TOPICLEN=%i MODES=%i "
   74                "CHANTYPES=# CHANLIMIT=#:%i "
   75 #ifdef USE_HALFOPS
   76                "PREFIX=(ohv)@%%%%+ STATUSMSG=@%%%%+",
   77 #else
   78                "PREFIX=(ov)@+ STATUSMSG=@+",
   79 #endif
   80                Network_Name, MAXBANS, maxchannelsperuser, CHANNELLEN,
   81                TOPICLEN, NICKLEN, TOPICLEN, MAXMODEPARAMSUSER,
   82                maxchannelsperuser);
   83 
   84     ircsprintf(rplisupport1, rpl_str(RPL_ISUPPORT), me.name, "%s", scratchbuf);
   85 
   86     ircsprintf(scratchbuf,"WATCH=65535 MAXCHANNELS=%i CHANLIMIT=#:%i",
   87                (maxchannelsperuser * 3), (maxchannelsperuser * 3));
   88     ircsprintf(rplisupportoper, rpl_str(RPL_ISUPPORT), me.name, "%s", scratchbuf);
   89 
   90     s = scratchbuf;
   91     s += ircsprintf(s, "CASEMAPPING=ascii WATCH=%i SILENCE=%i ELIST=cmntu",
   92                     MAXWATCH, MAXSILES);
   93 #ifdef EXEMPT_LISTS
   94     s += ircsprintf(s, " EXCEPTS");
   95 #endif
   96 #ifdef INVITE_LISTS
   97     s += ircsprintf(s, " INVEX");
   98 #endif
   99     s += ircsprintf(s, " CHANMODES=b");
  100 #ifdef EXEMPT_LISTS
  101     *s++ = 'e';
  102 #endif
  103 #ifdef INVITE_LISTS
  104     *s++ = 'I';
  105 #endif
  106     s += ircsprintf(s, ",k,jl,ci");
  107 #ifdef USE_CHANMODE_L
  108     *s++ = 'L';
  109 #endif
  110 #ifdef SPAMFILTER
  111     *s++ = 'P';
  112 #endif
  113     s += ircsprintf(s, "AmMnOprRsSt MAXLIST=b:%i", MAXBANS);
  114 #ifdef EXEMPT_LISTS
  115     s += ircsprintf(s, ",e:%i", MAXEXEMPTLIST);
  116 #endif
  117 #ifdef INVITE_LISTS
  118     s += ircsprintf(s, ",I:%i", MAXINVITELIST);
  119 #endif
  120     s += ircsprintf(s, " TARGMAX=DCCALLOW:,JOIN:,KICK:4,KILL:20,NOTICE:%i,"
  121                     "PART:,PRIVMSG:%i,WHOIS:,WHOWAS:", MAXRECIPIENTS,
  122                     MAXRECIPIENTS);
  123 
  124     ircsprintf(rplisupport2, rpl_str(RPL_ISUPPORT), me.name, "%s", scratchbuf);
  125 
  126 
  127     /* build RPL_VERSION */
  128     s = scratchbuf;
  129 
  130 #ifdef ANTI_SPAMBOT
  131     *s++ = 'a';
  132 #endif
  133 #ifdef ALWAYS_SEND_DURING_SPLIT
  134     *s++ = 'A';
  135 #endif
  136 #ifdef MAXBUFFERS
  137     *s++ = 'B';
  138 #endif
  139 #ifdef CMDLINE_CONFIG
  140     *s++ = 'C';
  141 #endif
  142 #ifdef DO_IDENTD
  143     *s++ = 'd';
  144 #endif
  145 #ifdef DEBUGMODE
  146     *s++ = 'D';
  147 #endif
  148 #ifdef HAVE_ENCRYPTION_ON
  149     *s++ = 'E';
  150 #endif
  151 #ifdef FLUD
  152     *s++ = 'F';
  153 #endif
  154 #ifdef SHOW_HEADERS
  155     *s++ = 'h';
  156 #endif
  157 #ifdef SHOW_INVISIBLE_LUSERS
  158     *s++ = 'i';
  159 #endif
  160 #ifdef NO_DEFAULT_INVISIBLE
  161     *s++ = 'I';
  162 #endif
  163 #ifdef NO_DEFAULT_JOINRATE
  164     *s++ = 'J';
  165 #endif
  166 #ifdef USE_HOOKMODULES
  167     *s++ = 'M';
  168 #endif
  169 #ifdef DNS_DEBUG
  170     *s++ = 'N';
  171 #endif
  172 #ifdef DENY_SERVICES_MSGS
  173     *s++ = 'r';
  174 #endif
  175 #ifdef SUPER_TARGETS_ONLY
  176     *s++ = 's';
  177 #endif
  178 #ifdef MSG_TARGET_LIMIT
  179     *s++ = 't';
  180 #endif
  181 #ifdef THROTTLE_ENABLE
  182     *s++ = 'T';
  183 #endif
  184 #ifdef IRCII_KLUDGE
  185     *s++ = 'u';
  186 #endif
  187 #ifdef USE_SYSLOG
  188     *s++ = 'Y';
  189 #endif
  190     *s++ = '/';
  191     if (confopts & FLAGS_HUB)
  192         *s++ = 'H';
  193     if (confopts & FLAGS_SMOTD)
  194         *s++ = 'm';
  195     if (confopts & FLAGS_SPLITOPOK)
  196         *s++ = 'o';
  197     if (confopts & FLAGS_CRYPTPASS)
  198         *s++ = 'p';
  199     if (confopts & FLAGS_SERVHUB)
  200         *s++ = 'S';
  201     if ((confopts & FLAGS_WGMON) == FLAGS_WGMON)
  202         *s++ = 'w';
  203     
  204     s += ircsprintf(s, " TS%iow", TS_CURRENT);
  205 
  206 #ifdef RIDICULOUS_PARANOIA_LEVEL
  207     s += ircsprintf(s, " RPL%i", RIDICULOUS_PARANOIA_LEVEL);
  208 #endif
  209 
  210     s += ircsprintf(s, " NP[");
  211 #ifdef FORCE_EVERYONE_HIDDEN
  212     *s++ = 'A';
  213 #endif
  214 #ifdef ALLOW_HIDDEN_OPERS
  215     *s++ = 'I';
  216 #endif
  217 #ifdef HIDE_KILL_ORIGINS
  218     *s++ = 'K';
  219 #endif
  220 #ifdef NO_USER_SERVERKILLS
  221     *s++ = 'k';
  222 #endif
  223     if (!(confopts & FLAGS_SHOWLINKS))
  224         *s++ = 'L';
  225 #ifdef HIDE_SERVERMODE_ORIGINS
  226     *s++ = 'M';
  227 #endif
  228 #ifdef HIDE_NUMERIC_SOURCE
  229     *s++ = 'N';
  230 #endif
  231 #ifdef NO_USER_OPERTARGETED_COMMANDS
  232     *s++ = 'O';
  233 #endif
  234 #ifdef HIDE_SPLIT_SERVERS
  235     *s++ = 'P';
  236 #endif
  237 #ifdef NO_USER_STATS
  238     *s++ = 'S';
  239 #endif
  240 #ifdef NO_USER_OPERKILLS
  241     *s++ = 's';
  242 #endif
  243 #ifdef NO_USER_TRACE
  244     *s++ = 'T';
  245 #endif
  246 #ifdef HIDEULINEDSERVS
  247     *s++ = 'U';
  248 #endif
  249     *s++ = ']';
  250     *s++ = 0;
  251 
  252     ircsprintf(rplversion, rpl_str(RPL_VERSION), me.name, "%s", version,
  253                     debugmode, me.name, scratchbuf);
  254 }
  255 
  256 
  257 #if defined(DNS_DEBUG) || defined(DEBUGMODE)
  258 static char debugbuf[1024];
  259 
  260 void debug(int level, char *pattern, ...)
  261 {
  262     va_list      vl;
  263     int         err = errno;
  264     
  265     va_start(vl, pattern);
  266     (void) vsprintf(debugbuf, pattern, vl);
  267     va_end(vl);
  268 
  269 #ifdef USE_SYSLOG
  270     if (level == DEBUG_ERROR)
  271         syslog(LOG_ERR, "%s", debugbuf);
  272 #endif
  273 
  274     if ((debuglevel >= 0) && (level <= debuglevel)) {
  275 
  276         if (local[2]) {
  277             local[2]->sendM++;
  278             local[2]->sendB += strlen(debugbuf);
  279         }
  280         (void) fprintf(stderr, "%s", debugbuf);
  281         (void) fputc('\n', stderr);
  282     }
  283     errno = err;
  284 }
  285 
  286 #endif