/[svn]/branches/newio/modules/m_module.c
ViewVC logotype

Diff of /branches/newio/modules/m_module.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2381 by michael, Sat Jul 6 16:22:05 2013 UTC revision 2417 by michael, Sun Jul 21 18:11:50 2013 UTC
# Line 54  Line 54 
54   *      - parv[1] = action [LOAD, UNLOAD, RELOAD, LIST]   *      - parv[1] = action [LOAD, UNLOAD, RELOAD, LIST]
55   *      - parv[2] = module name   *      - parv[2] = module name
56   */   */
57  static void  static int
58  mo_module(struct Client *client_p, struct Client *source_p,  mo_module(struct Client *client_p, struct Client *source_p,
59            int parc, char *parv[])            int parc, char *parv[])
60  {  {
# Line 66  mo_module(struct Client *client_p, struc Line 66  mo_module(struct Client *client_p, struc
66    {    {
67      sendto_one(source_p, form_str(ERR_NOPRIVILEGES),      sendto_one(source_p, form_str(ERR_NOPRIVILEGES),
68                 me.name, source_p->name);                 me.name, source_p->name);
69      return;      return 0;
70    }    }
71    
72    if (EmptyString(parv[1]))    if (EmptyString(parv[1]))
73    {    {
74      sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),      sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
75                 me.name, source_p->name, "MODULE");                 me.name, source_p->name, "MODULE");
76      return;      return 0;
77    }    }
78    
79    if (!irccmp(parv[1], "LOAD"))    if (!irccmp(parv[1], "LOAD"))
# Line 82  mo_module(struct Client *client_p, struc Line 82  mo_module(struct Client *client_p, struc
82      {      {
83        sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),        sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
84                   me.name, source_p->name, "MODULE");                   me.name, source_p->name, "MODULE");
85        return;        return 0;
86      }      }
87    
88      if (findmodule_byname((m_bn = libio_basename(parv[2]))) != NULL)      if (findmodule_byname((m_bn = libio_basename(parv[2]))) != NULL)
89      {      {
90        sendto_one(source_p, ":%s NOTICE %s :Module %s is already loaded",        sendto_one(source_p, ":%s NOTICE %s :Module %s is already loaded",
91                   me.name, source_p->name, m_bn);                   me.name, source_p->name, m_bn);
92        return;        return 0;
93      }      }
94    
95      load_one_module(parv[2]);      load_one_module(parv[2]);
96      return;      return 0;
97    }    }
98    
99    if (!irccmp(parv[1], "UNLOAD"))    if (!irccmp(parv[1], "UNLOAD"))
# Line 102  mo_module(struct Client *client_p, struc Line 102  mo_module(struct Client *client_p, struc
102      {      {
103        sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),        sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
104                   me.name, source_p->name, "MODULE");                   me.name, source_p->name, "MODULE");
105        return;        return 0;
106      }      }
107    
108      if ((modp = findmodule_byname((m_bn = libio_basename(parv[2])))) == NULL)      if ((modp = findmodule_byname((m_bn = libio_basename(parv[2])))) == NULL)
109      {      {
110        sendto_one(source_p, ":%s NOTICE %s :Module %s is not loaded",        sendto_one(source_p, ":%s NOTICE %s :Module %s is not loaded",
111                   me.name, source_p->name, m_bn);                   me.name, source_p->name, m_bn);
112        return;        return 0;
113      }      }
114    
115      if (modp->flags & MODULE_FLAG_CORE)      if (modp->flags & MODULE_FLAG_CORE)
# Line 117  mo_module(struct Client *client_p, struc Line 117  mo_module(struct Client *client_p, struc
117        sendto_one(source_p,        sendto_one(source_p,
118                   ":%s NOTICE %s :Module %s is a core module and may not be unloaded",                   ":%s NOTICE %s :Module %s is a core module and may not be unloaded",
119                   me.name, source_p->name, m_bn);                   me.name, source_p->name, m_bn);
120        return;        return 0;
121      }      }
122    
123      if (modp->flags & MODULE_FLAG_NOUNLOAD)      if (modp->flags & MODULE_FLAG_NOUNLOAD)
# Line 125  mo_module(struct Client *client_p, struc Line 125  mo_module(struct Client *client_p, struc
125        sendto_one(source_p,        sendto_one(source_p,
126                   ":%s NOTICE %s :Module %s is a resident module and may not be unloaded",                   ":%s NOTICE %s :Module %s is a resident module and may not be unloaded",
127                   me.name, source_p->name, m_bn);                   me.name, source_p->name, m_bn);
128        return;        return 0;
129      }      }
130    
131      if (unload_one_module(m_bn, 1) == -1)      if (unload_one_module(m_bn, 1) == -1)
132        sendto_one(source_p, ":%s NOTICE %s :Module %s is not loaded",        sendto_one(source_p, ":%s NOTICE %s :Module %s is not loaded",
133                   me.name, source_p->name, m_bn);                   me.name, source_p->name, m_bn);
134      return;      return 0;
135    }    }
136    
137    if (!irccmp(parv[1], "RELOAD"))    if (!irccmp(parv[1], "RELOAD"))
# Line 140  mo_module(struct Client *client_p, struc Line 140  mo_module(struct Client *client_p, struc
140      {      {
141        sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),        sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
142                   me.name, source_p->name, "MODULE");                   me.name, source_p->name, "MODULE");
143        return;        return 0;
144      }      }
145    
146      if (!strcmp(parv[2], "*"))      if (!strcmp(parv[2], "*"))
# Line 170  mo_module(struct Client *client_p, struc Line 170  mo_module(struct Client *client_p, struc
170                             modnum, dlink_list_length(&modules_list));                             modnum, dlink_list_length(&modules_list));
171        ilog(LOG_TYPE_IRCD, "Module Restart: %u modules unloaded, %u modules loaded",        ilog(LOG_TYPE_IRCD, "Module Restart: %u modules unloaded, %u modules loaded",
172             modnum, dlink_list_length(&modules_list));             modnum, dlink_list_length(&modules_list));
173        return;        return 0;
174      }      }
175    
176      if ((modp = findmodule_byname((m_bn = libio_basename(parv[2])))) == NULL)      if ((modp = findmodule_byname((m_bn = libio_basename(parv[2])))) == NULL)
177      {      {
178        sendto_one(source_p, ":%s NOTICE %s :Module %s is not loaded",        sendto_one(source_p, ":%s NOTICE %s :Module %s is not loaded",
179                 me.name, source_p->name, m_bn);                 me.name, source_p->name, m_bn);
180        return;        return 0;
181      }      }
182    
183      if (modp->flags & MODULE_FLAG_NOUNLOAD)      if (modp->flags & MODULE_FLAG_NOUNLOAD)
# Line 185  mo_module(struct Client *client_p, struc Line 185  mo_module(struct Client *client_p, struc
185        sendto_one(source_p,        sendto_one(source_p,
186                   ":%s NOTICE %s :Module %s is a resident module and may not be unloaded",                   ":%s NOTICE %s :Module %s is a resident module and may not be unloaded",
187                   me.name, source_p->name, m_bn);                   me.name, source_p->name, m_bn);
188        return;        return 0;
189      }      }
190    
191      check_core = (modp->flags & MODULE_FLAG_CORE) != 0;      check_core = (modp->flags & MODULE_FLAG_CORE) != 0;
# Line 194  mo_module(struct Client *client_p, struc Line 194  mo_module(struct Client *client_p, struc
194      {      {
195        sendto_one(source_p, ":%s NOTICE %s :Module %s is not loaded",        sendto_one(source_p, ":%s NOTICE %s :Module %s is not loaded",
196                   me.name, source_p->name, m_bn);                   me.name, source_p->name, m_bn);
197        return;        return 0;
198      }      }
199    
200      if ((load_one_module(parv[2]) == -1) && check_core)      if ((load_one_module(parv[2]) == -1) && check_core)
# Line 206  mo_module(struct Client *client_p, struc Line 206  mo_module(struct Client *client_p, struc
206        exit(0);        exit(0);
207      }      }
208    
209      return;      return 0;
210    }    }
211    
212    if (!irccmp(parv[1], "LIST"))    if (!irccmp(parv[1], "LIST"))
# Line 227  mo_module(struct Client *client_p, struc Line 227  mo_module(struct Client *client_p, struc
227    
228      sendto_one(source_p, form_str(RPL_ENDOFMODLIST),      sendto_one(source_p, form_str(RPL_ENDOFMODLIST),
229                 me.name, source_p->name);                 me.name, source_p->name);
230      return;      return 0;
231    }    }
232    
233    sendto_one(source_p, ":%s NOTICE %s :%s is not a valid option. "    sendto_one(source_p, ":%s NOTICE %s :%s is not a valid option. "
234               "Choose from LOAD, UNLOAD, RELOAD, LIST",               "Choose from LOAD, UNLOAD, RELOAD, LIST",
235               me.name, source_p->name, parv[1]);               me.name, source_p->name, parv[1]);
236      return 0;
237  }  }
238    
239    static struct Message module_msgtab =
240  static struct Message module_msgtab = {  {
241   "MODULE", 0, 0, 2, MAXPARA, MFLG_SLOW, 0,    "MODULE", 0, 0, 2, MAXPARA, MFLG_SLOW, 0,
242    {m_unregistered, m_not_oper, m_ignore, m_ignore, mo_module, m_ignore}    {m_unregistered, m_not_oper, m_ignore, m_ignore, mo_module, m_ignore}
243  };  };
244    
# Line 253  module_exit(void) Line 254  module_exit(void)
254    mod_del_cmd(&module_msgtab);    mod_del_cmd(&module_msgtab);
255  }  }
256    
257  struct module module_entry = {  struct module module_entry =
258    {
259    .node    = { NULL, NULL, NULL },    .node    = { NULL, NULL, NULL },
260    .name    = NULL,    .name    = NULL,
261    .version = "$Revision$",    .version = "$Revision$",

Legend:
Removed from v.2381  
changed lines
  Added in v.2417

svnadmin@ircd-hybrid.org
ViewVC Help
Powered by ViewVC 1.1.28