ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/branches/8.2.x/src/conf_pseudo.c
(Generate patch)

Comparing ircd-hybrid/branches/8.2.x/src/conf_pseudo.c (file contents):
Revision 5880 by michael, Sun May 3 16:01:42 2015 UTC vs.
Revision 9383 by michael, Sun May 10 08:58:47 2020 UTC

# Line 1 | Line 1
1   /*
2   *  ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3   *
4 < *  Copyright (c) 1997-2015 ircd-hybrid development team
4 > *  Copyright (c) 2014-2020 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
# Line 21 | Line 21
21  
22   /*! \file conf_pseudo.c
23   * \brief Handles with pseudo commands/service aliases.
24 < * \version $Id: conf_pseudo.c 4299 2014-07-20 13:51:28Z michael $
24 > * \version $Id$
25   */
26  
27   #include "stdinc.h"
# Line 38 | Line 38
38   #include "server.h"
39   #include "conf_pseudo.h"
40  
41 struct pseudo_cmd
42 {
43  dlink_node node;
44  struct Message msg;
45  char *name;
46  char *nick;
47  char *serv;
48  char *prep;
49  char *command;
50 };
41  
42 < static dlink_list pseudo_cmd_list;
42 > static dlink_list pseudo_list;
43 >
44 >
45 > const dlink_list *
46 > pseudo_get_list(void)
47 > {
48 >  return &pseudo_list;
49 > }
50  
51 < static int
52 < m_pseudo(struct Client *source_p, int parc, char *parv[])
51 > static void
52 > pseudo_message_handler(struct Client *source_p, int parc, char *parv[])
53   {
54    char buffer[IRCD_BUFSIZE] = "";
55 <  const struct pseudo_cmd *const pseudo = (const struct pseudo_cmd *)parv[1];
55 >  const struct PseudoItem *const pseudo = (const struct PseudoItem *)parv[1];
56    struct Client *target_p = NULL;
57    struct Client *server_p = NULL;
58    const char *msg = parv[parc - 1];
# Line 63 | Line 60 | m_pseudo(struct Client *source_p, int pa
60    if (parc < 3 || EmptyString(msg))
61    {
62      sendto_one_numeric(source_p, &me, ERR_NOTEXTTOSEND);
63 <    return 0;
63 >    return;
64    }
65  
66 <  if (!EmptyString(pseudo->prep))
66 >  if (pseudo->prepend)
67    {
68 <    snprintf(buffer, sizeof(buffer), "%s%s", pseudo->prep, msg);
68 >    snprintf(buffer, sizeof(buffer), "%s%s", pseudo->prepend, msg);
69      msg = buffer;
70    }
71  
# Line 76 | Line 73 | m_pseudo(struct Client *source_p, int pa
73    server_p = hash_find_server(pseudo->serv);
74  
75    if (target_p && server_p && (target_p->servptr == server_p) && !IsMe(server_p))
76 <  {
77 <    sendto_one(target_p, ":%s PRIVMSG %s :%s",
78 <               source_p->id, target_p->id, msg);
82 <    return 0;
83 <  }
84 <
85 <  sendto_one_numeric(source_p, &me, ERR_SERVICESDOWN, pseudo->name);
86 <  return 0;
76 >    sendto_one(target_p, ":%s PRIVMSG %s :%s", source_p->id, target_p->id, msg);
77 >  else
78 >    sendto_one_numeric(source_p, &me, ERR_SERVICESDOWN, pseudo->name);
79   }
80  
81   void
82 < pseudo_register(const char *name, const char *nick,
83 <                const char *serv, const char *prep,
82 > pseudo_register(const char *name, const char *nick, const char *serv,
83 >                const char *prepend,
84                  const char *command)
85   {
94  struct pseudo_cmd *cmd = NULL;
95
86    if (find_command(command))
87      return;
88  
89 <  cmd = MyCalloc(sizeof(*cmd));
90 <  cmd->name = xstrdup(name);
91 <  cmd->nick = xstrdup(nick);
92 <  cmd->serv = xstrdup(serv);
93 <  cmd->prep = xstrdup(prep);
94 <  cmd->command = xstrdup(command);
95 <
96 <  cmd->msg.cmd = cmd->command;
97 <  cmd->msg.args_max = 2;
98 <  cmd->msg.flags = MFLG_EXTRA;
99 <  cmd->msg.extra = cmd;
100 <  cmd->msg.handlers[UNREGISTERED_HANDLER] = m_unregistered;
101 <  cmd->msg.handlers[CLIENT_HANDLER] = m_pseudo;
102 <  cmd->msg.handlers[SERVER_HANDLER] = m_ignore;
103 <  cmd->msg.handlers[ENCAP_HANDLER] = m_ignore;
104 <  cmd->msg.handlers[OPER_HANDLER] = m_pseudo;
115 <  dlinkAdd(cmd, &cmd->node, &pseudo_cmd_list);
89 >  struct PseudoItem *pseudo = xcalloc(sizeof(*pseudo));
90 >  pseudo->name = xstrdup(name);
91 >  pseudo->nick = xstrdup(nick);
92 >  pseudo->serv = xstrdup(serv);
93 >  pseudo->command = xstrdup(command);
94 >  if (!EmptyString(prepend))
95 >    pseudo->prepend = xstrdup(prepend);
96 >
97 >  pseudo->msg.cmd = pseudo->command;
98 >  pseudo->msg.extra = pseudo;
99 >  pseudo->msg.handlers[UNREGISTERED_HANDLER] = (struct MessageHandler) { .handler = m_unregistered };
100 >  pseudo->msg.handlers[CLIENT_HANDLER] = (struct MessageHandler) { .handler = pseudo_message_handler, .args_max = 2 };
101 >  pseudo->msg.handlers[SERVER_HANDLER] = (struct MessageHandler) { .handler = m_ignore };
102 >  pseudo->msg.handlers[ENCAP_HANDLER] = (struct MessageHandler) { .handler = m_ignore };
103 >  pseudo->msg.handlers[OPER_HANDLER] = (struct MessageHandler) { .handler = pseudo_message_handler, .args_max = 2 };
104 >  dlinkAdd(pseudo, &pseudo->node, &pseudo_list);
105  
106 <  mod_add_cmd(&cmd->msg);
106 >  mod_add_cmd(&pseudo->msg);
107   }
108  
109   void
110   pseudo_clear(void)
111   {
112 <  dlink_node *node = NULL, *node_next = NULL;
124 <
125 <  DLINK_FOREACH_SAFE(node, node_next, pseudo_cmd_list.head)
112 >  while (pseudo_list.head)
113    {
114 <    struct pseudo_cmd *cmd = node->data;
115 <    assert(find_command(cmd->msg.cmd));
114 >    struct PseudoItem *pseudo = pseudo_list.head->data;
115 >    assert(find_command(pseudo->msg.cmd));
116  
117 <    mod_del_cmd(&cmd->msg);
118 <    dlinkDelete(&cmd->node, &pseudo_cmd_list);
117 >    mod_del_cmd(&pseudo->msg);
118 >    dlinkDelete(&pseudo->node, &pseudo_list);
119  
120 <    MyFree(cmd->name);
121 <    MyFree(cmd->nick);
122 <    MyFree(cmd->serv);
123 <    MyFree(cmd->prep);
124 <    MyFree(cmd->command);
125 <    MyFree(cmd);
120 >    xfree(pseudo->name);
121 >    xfree(pseudo->nick);
122 >    xfree(pseudo->serv);
123 >    xfree(pseudo->prepend);
124 >    xfree(pseudo->command);
125 >    xfree(pseudo);
126    }
127   }

Comparing ircd-hybrid/branches/8.2.x/src/conf_pseudo.c (property svn:eol-style):
Revision 5880 by michael, Sun May 3 16:01:42 2015 UTC vs.
Revision 9383 by michael, Sun May 10 08:58:47 2020 UTC

# Line 0 | Line 1
1 + native

Comparing ircd-hybrid/branches/8.2.x/src/conf_pseudo.c (property svn:keywords):
Revision 5880 by michael, Sun May 3 16:01:42 2015 UTC vs.
Revision 9383 by michael, Sun May 10 08:58:47 2020 UTC

# Line 0 | Line 1
1 + Id

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)