"Fossies" - the Fresh Open Source Software Archive

Member "ircd-hybrid-8.2.26/modules/m_encap.c" (31 May 2019, 3235 Bytes) of package /linux/privat/ircd-hybrid-8.2.26.tgz:


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 "m_encap.c" see the Fossies "Dox" file reference documentation and the last Fossies "Diffs" side-by-side code changes report: 8.2.24_vs_8.2.25.

    1 /*
    2  *  ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
    3  *
    4  *  Copyright (c) 2003-2019 ircd-hybrid development team
    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 2 of the License, or
    9  *  (at your option) 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
   19  *  USA
   20  */
   21 
   22 /*! \file m_encap.c
   23  * \brief Includes required functions for processing the ENCAP command.
   24  * \version $Id: m_encap.c 8751 2019-01-01 11:06:50Z michael $
   25  */
   26 
   27 #include "stdinc.h"
   28 #include "client.h"
   29 #include "parse.h"
   30 #include "server_capab.h"
   31 #include "send.h"
   32 #include "modules.h"
   33 #include "irc_string.h"
   34 
   35 
   36 /*
   37  * ms_encap()
   38  *
   39  * inputs   - destination server, subcommand, parameters
   40  * output   - none
   41  * side effects - propagates subcommand to locally connected servers
   42  */
   43 static int
   44 ms_encap(struct Client *source_p, int parc, char *parv[])
   45 {
   46   char buffer[IRCD_BUFSIZE] = "", *ptr = buffer;
   47   unsigned int cur_len = 0, len, i;
   48 #ifdef NOT_USED_YET
   49   int paramcount, mpara = 0;
   50 #endif
   51   struct Message *mptr = NULL;
   52 
   53   for (i = 1; i < (unsigned int)parc - 1; ++i)
   54   {
   55     len = strlen(parv[i]) + 1;  /* +1 for the space */
   56 
   57     /* Drop the whole command if this parameter would be truncated */
   58     if ((cur_len + len) >= sizeof(buffer))
   59       return 0;
   60 
   61     snprintf(ptr, sizeof(buffer) - cur_len, "%s ", parv[i]);
   62     cur_len += len;
   63     ptr += len;
   64   }
   65 
   66   /* If it's a command without parameters, don't prepend a ':' */
   67   if (parc == 3)
   68     snprintf(ptr, sizeof(buffer) - cur_len, "%s", parv[2]);
   69   else
   70     snprintf(ptr, sizeof(buffer) - cur_len, ":%s", parv[parc - 1]);
   71 
   72   sendto_match_servs(source_p, parv[1], CAPAB_ENCAP,
   73                      "ENCAP %s", buffer);
   74 
   75   if (match(parv[1], me.name))
   76     return 0;
   77 
   78   if ((mptr = find_command(parv[2])) == NULL)
   79     return 0;
   80 
   81 #ifdef NOT_USED_YET
   82   paramcount = mptr->parameters;
   83   mpara      = mptr->maxpara;
   84 #endif
   85   mptr->bytes += strlen(buffer);
   86 
   87   parv += 2;
   88   parc -= 2;
   89 
   90   if ((unsigned int)parc >= mptr->args_min)
   91     mptr->handlers[ENCAP_HANDLER](source_p, parc, parv);
   92   return 0;
   93 }
   94 
   95 static struct Message encap_msgtab =
   96 {
   97   .cmd = "ENCAP",
   98   .args_min = 3,
   99   .args_max = MAXPARA,
  100   .handlers[UNREGISTERED_HANDLER] = m_ignore,
  101   .handlers[CLIENT_HANDLER] = m_ignore,
  102   .handlers[SERVER_HANDLER] = ms_encap,
  103   .handlers[ENCAP_HANDLER] = m_ignore,
  104   .handlers[OPER_HANDLER] = m_ignore
  105 };
  106 
  107 static void
  108 module_init(void)
  109 {
  110   mod_add_cmd(&encap_msgtab);
  111   capab_add("ENCAP", CAPAB_ENCAP);
  112 }
  113 
  114 static void
  115 module_exit(void)
  116 {
  117   mod_del_cmd(&encap_msgtab);
  118   capab_del("ENCAP");
  119 }
  120 
  121 struct module module_entry =
  122 {
  123   .version = "$Revision: 8751 $",
  124   .modinit = module_init,
  125   .modexit = module_exit,
  126 };