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

Comparing:
ircd-hybrid/src/modules.c (file contents), Revision 32 by knight, Sun Oct 2 20:41:23 2005 UTC vs.
ircd-hybrid-8/src/modules.c (file contents), Revision 1156 by michael, Tue Aug 9 20:29:20 2011 UTC

# Line 23 | Line 23
23   */
24  
25   #include "stdinc.h"
26 < #include "tools.h"
26 > #include "list.h"
27   #include "modules.h"
28   #include "s_log.h"
29   #include "ircd.h"
# Line 36 | Line 36
36   #include "ircd_defs.h"
37   #include "irc_string.h"
38   #include "memory.h"
39 #include "list.h"
40
41 /* -TimeMr14C:
42 * I have moved the dl* function definitions and
43 * the two functions (load_a_module / unload_a_module) to the
44 * file dynlink.c
45 * And also made the necessary changes to those functions
46 * to comply with shl_load and friends.
47 * In this file, to keep consistency with the makefile,
48 * I added the ability to load *.sl files, too.
49 * 27/02/2002
50 */
39  
52 #ifndef STATIC_MODULES
40  
41   dlink_list mod_list = { NULL, NULL, 0 };
42  
43   static const char *core_module_table[] =
44   {
45 <  "m_die",
46 <  "m_join",
47 <  "m_kick",
48 <  "m_kill",
49 <  "m_message",
50 <  "m_mode",
51 <  "m_nick",
52 <  "m_part",
53 <  "m_quit",
54 <  "m_server",
55 <  "m_sjoin",
56 <  "m_squit",
45 >  "m_die.la",
46 >  "m_error.la",
47 >  "m_join.la",
48 >  "m_kick.la",
49 >  "m_kill.la",
50 >  "m_message.la",
51 >  "m_mode.la",
52 >  "m_nick.la",
53 >  "m_part.la",
54 >  "m_quit.la",
55 >  "m_server.la",
56 >  "m_sjoin.la",
57 >  "m_squit.la",
58    NULL
59   };
60  
# Line 105 | Line 93 | struct Message modrestart_msgtab = {
93   };
94  
95  
108 extern struct Message error_msgtab;
109
96   /*
97   * modules_init
98   *
# Line 117 | Line 103 | extern struct Message error_msgtab;
103   void
104   modules_init(void)
105   {
106 +  dynlink_init();
107 +
108    mod_add_cmd(&modload_msgtab);
109    mod_add_cmd(&modunload_msgtab);
110    mod_add_cmd(&modreload_msgtab);
111    mod_add_cmd(&modlist_msgtab);
112    mod_add_cmd(&modrestart_msgtab);
125  mod_add_cmd(&error_msgtab);
113   }
114  
115   /* mod_find_path()
# Line 231 | Line 218 | findmodule_byname(const char *name)
218    {
219      modp = ptr->data;
220  
221 <    if (!irccmp(modp->name, name))
221 >    if (strcmp(modp->name, name) == 0)
222        return ptr;
223    }
224  
# Line 262 | Line 249 | load_all_modules(int warn)
249  
250    while ((ldirent = readdir(system_module_dir)) != NULL)
251    {
252 <    const char *offset = strrchr(ldirent->d_name, '.');
266 <
267 <    if (offset && !strcmp(offset, SHARED_SUFFIX))
252 >    if (modules_valid_suffix(ldirent->d_name))
253      {
254         snprintf(module_fq_name, sizeof(module_fq_name), "%s/%s",
255                  AUTOMODPATH, ldirent->d_name);
# Line 310 | Line 295 | load_core_modules(int warn)
295  
296    for (; core_module_table[i]; ++i)
297    {
298 <    snprintf(module_name, sizeof(module_name), "%s%s%s", MODPATH,
299 <             core_module_table[i], SHARED_SUFFIX);
298 >    snprintf(module_name, sizeof(module_name), "%s%s",
299 >             MODPATH, core_module_table[i]);
300  
301      if (load_a_module(module_name, warn, 1) == -1)
302      {
303 <      ilog(L_CRIT, "Error loading core module %s%s: terminating ircd",
304 <           core_module_table[i], SHARED_SUFFIX);
303 >      ilog(L_CRIT, "Error loading core module %s: terminating ircd",
304 >           core_module_table[i]);
305        exit(EXIT_FAILURE);
306      }
307    }
# Line 330 | Line 315 | load_core_modules(int warn)
315   * side effects - module is loaded if found.
316   */
317   int
318 < load_one_module(char *path, int coremodule)
318 > load_one_module(const char *path, int coremodule)
319   {
320    dlink_node *ptr = NULL;
321    char modpath[PATH_MAX + 1];
# Line 342 | Line 327 | load_one_module(char *path, int coremodu
327  
328      snprintf(modpath, sizeof(modpath), "%s/%s", mpath->path, path);
329  
330 +    if (!modules_valid_suffix(path))
331 +      continue;
332 +
333      if (strstr(modpath, "../") == NULL &&
334          strstr(modpath, "/..") == NULL)
335      {
# Line 367 | Line 355 | static void
355   mo_modload(struct Client *client_p, struct Client *source_p,
356             int parc, char *parv[])
357   {
358 <  char *m_bn;
358 >  const char *m_bn = NULL;
359  
360    if (!IsAdmin(source_p))
361    {
# Line 376 | Line 364 | mo_modload(struct Client *client_p, stru
364      return;
365    }
366  
367 <  m_bn = basename(parv[1]);
367 >  m_bn = libio_basename(parv[1]);
368  
369    if (findmodule_byname(m_bn) != NULL)
370    {
# Line 393 | Line 381 | static void
381   mo_modunload(struct Client *client_p, struct Client *source_p,
382               int parc, char *parv[])
383   {
384 <  char *m_bn;
384 >  const char *m_bn = NULL;
385    dlink_node *ptr;
386    struct module *modp;
387  
# Line 404 | Line 392 | mo_modunload(struct Client *client_p, st
392      return;
393    }
394  
395 <  m_bn = basename(parv[1]);
395 >  m_bn = libio_basename(parv[1]);
396  
397    if ((ptr = findmodule_byname(m_bn)) == NULL)
398    {
# Line 437 | Line 425 | static void
425   mo_modreload(struct Client *client_p, struct Client *source_p,
426               int parc, char *parv[])
427   {
428 <  char *m_bn;
428 >  const char *m_bn = NULL;
429    dlink_node *ptr;
430    struct module *modp;
431    int check_core;
# Line 449 | Line 437 | mo_modreload(struct Client *client_p, st
437      return;
438    }
439  
440 <  m_bn = basename(parv[1]);
440 >  m_bn = libio_basename(parv[1]);
441  
442    if ((ptr = findmodule_byname(m_bn)) == NULL)
443    {
# Line 482 | Line 470 | static void
470   mo_modlist(struct Client *client_p, struct Client *source_p,
471             int parc, char *parv[])
472   {
473 <  dlink_node *ptr;
486 <  struct module *modp;
473 >  const dlink_node *ptr = NULL;
474  
475    if (!IsAdmin(source_p))
476    {
# Line 494 | Line 481 | mo_modlist(struct Client *client_p, stru
481  
482    DLINK_FOREACH(ptr, mod_list.head)
483    {
484 <    modp = ptr->data;
484 >    const struct module *modp = ptr->data;
485  
486 <    if (parc > 1)
487 <    {
488 <      if (match(parv[1], modp->name))
489 <      {
490 <        sendto_one(source_p, form_str(RPL_MODLIST), me.name, parv[0],
491 <                   modp->name, modp->address,
505 <                   modp->version, modp->core?"(core)":"");
506 <      }
507 <    }
508 <    else
509 <    {
510 <      sendto_one(source_p, form_str(RPL_MODLIST), me.name, parv[0],
511 <                 modp->name, modp->address,
512 <                 modp->version, modp->core?"(core)":"");
513 <    }
486 >    if (parc > 1 && !match(parv[1], modp->name))
487 >      continue;
488 >
489 >    sendto_one(source_p, form_str(RPL_MODLIST), me.name, parv[0],
490 >               modp->name, modp->handle,
491 >               modp->version, modp->core?"(core)":"");
492    }
493  
494    sendto_one(source_p, form_str(RPL_ENDOFMODLIST),
# Line 523 | Line 501 | mo_modrestart(struct Client *client_p, s
501                int parc, char *parv[])
502   {
503    unsigned int modnum = 0;
504 <  dlink_node *ptr;
505 <  dlink_node *tptr;
528 <  struct module *modp;
529 <  
504 >  dlink_node *ptr = NULL, *ptr_next = NULL;
505 >
506    if (!IsAdmin(source_p))
507    {
508      sendto_one(source_p, form_str(ERR_NOPRIVILEGES),
# Line 539 | Line 515 | mo_modrestart(struct Client *client_p, s
515  
516    modnum = dlink_list_length(&mod_list);
517  
518 <  DLINK_FOREACH_SAFE(ptr, tptr, mod_list.head)
518 >  DLINK_FOREACH_SAFE(ptr, ptr_next, mod_list.head)
519    {
520 <    modp = ptr->data;
520 >    struct module *modp = ptr->data;
521      unload_one_module(modp->name, 0);
522    }
523  
# Line 550 | Line 526 | mo_modrestart(struct Client *client_p, s
526    load_core_modules(0);
527  
528    sendto_realops_flags(UMODE_ALL, L_ALL,
529 <              "Module Restart: %u modules unloaded, %lu modules loaded",
529 >              "Module Restart: %u modules unloaded, %u modules loaded",
530                          modnum, dlink_list_length(&mod_list));
531 <  ilog(L_WARN, "Module Restart: %u modules unloaded, %lu modules loaded",
531 >  ilog(L_WARN, "Module Restart: %u modules unloaded, %u modules loaded",
532         modnum, dlink_list_length(&mod_list));
533   }
558
559 #else /* STATIC_MODULES */
560 #include "s_serv.h"
561
562 /* load_all_modules()
563 *
564 * input        - warn flag
565 * output       - NONE
566 * side effects - all the msgtabs are added for static modules
567 */
568 void
569 load_all_modules(int warn)
570 {
571  mod_add_cmd(&error_msgtab);
572  mod_add_cmd(&accept_msgtab);
573  mod_add_cmd(&admin_msgtab);
574  mod_add_cmd(&away_msgtab);
575  mod_add_cmd(&capab_msgtab);
576  mod_add_cmd(&cburst_msgtab);
577  mod_add_cmd(&close_msgtab);
578  mod_add_cmd(&connect_msgtab);
579 #ifdef HAVE_LIBCRYPTO
580  mod_add_cmd(&challenge_msgtab);
581  mod_add_cmd(&cryptlink_msgtab);
582 #endif
583  mod_add_cmd(&die_msgtab);
584  mod_add_cmd(&drop_msgtab);
585  mod_add_cmd(&eob_msgtab);
586  mod_add_cmd(&etrace_msgtab);
587  mod_add_cmd(&gline_msgtab);
588  add_capability("GLN", CAP_GLN, 1);
589  mod_add_cmd(&hash_msgtab);
590  mod_add_cmd(&ungline_msgtab);
591  mod_add_cmd(&info_msgtab);
592  mod_add_cmd(&invite_msgtab);
593  mod_add_cmd(&ison_msgtab);
594  mod_add_cmd(&join_msgtab);
595  mod_add_cmd(&kick_msgtab);
596  mod_add_cmd(&kill_msgtab);
597  mod_add_cmd(&kline_msgtab);
598  add_capability("KLN", CAP_KLN, 1);
599  mod_add_cmd(&dline_msgtab);
600  mod_add_cmd(&unkline_msgtab);
601  mod_add_cmd(&undline_msgtab);
602  mod_add_cmd(&knock_msgtab);
603  add_capability("KNOCK", CAP_KNOCK, 1);
604  mod_add_cmd(&knockll_msgtab);
605  mod_add_cmd(&links_msgtab);
606  mod_add_cmd(&list_msgtab);
607  mod_add_cmd(&lljoin_msgtab);
608  mod_add_cmd(&llnick_msgtab);
609  mod_add_cmd(&locops_msgtab);
610  mod_add_cmd(&lusers_msgtab);
611  mod_add_cmd(&privmsg_msgtab);
612  mod_add_cmd(&notice_msgtab);
613  mod_add_cmd(&map_msgtab);
614  mod_add_cmd(&mode_msgtab);
615  mod_add_cmd(&motd_msgtab);
616  mod_add_cmd(&names_msgtab);
617  mod_add_cmd(&nburst_msgtab);
618  mod_add_cmd(&nick_msgtab);
619  mod_add_cmd(&omotd_msgtab);
620  mod_add_cmd(&oper_msgtab);
621  mod_add_cmd(&operwall_msgtab);
622  mod_add_cmd(&part_msgtab);
623  mod_add_cmd(&pass_msgtab);
624  mod_add_cmd(&ping_msgtab);
625  mod_add_cmd(&pong_msgtab);
626  mod_add_cmd(&post_msgtab);
627  mod_add_cmd(&get_msgtab);
628  mod_add_cmd(&put_msgtab);
629  mod_add_cmd(&quit_msgtab);
630  mod_add_cmd(&rehash_msgtab);
631  mod_add_cmd(&restart_msgtab);
632  mod_add_cmd(&resv_msgtab);
633  mod_add_cmd(&rkline_msgtab);
634  mod_add_cmd(&rxline_msgtab);
635  mod_add_cmd(&server_msgtab);
636  mod_add_cmd(&set_msgtab);
637  mod_add_cmd(&sid_msgtab);
638  mod_add_cmd(&sjoin_msgtab);
639  mod_add_cmd(&squit_msgtab);
640  mod_add_cmd(&stats_msgtab);
641  mod_add_cmd(&svinfo_msgtab);
642  mod_add_cmd(&tb_msgtab);
643  add_capability("TB", CAP_TB, 1);
644  mod_add_cmd(&testline_msgtab);
645  mod_add_cmd(&testgecos_msgtab);
646  mod_add_cmd(&testmask_msgtab);
647  mod_add_cmd(&time_msgtab);
648  mod_add_cmd(&topic_msgtab);
649  mod_add_cmd(&trace_msgtab);
650  add_capability("UNKLN", CAP_UNKLN, 1);
651  mod_add_cmd(&uid_msgtab);
652  mod_add_cmd(&unresv_msgtab);
653  mod_add_cmd(&unxline_msgtab);
654  mod_add_cmd(&user_msgtab);
655  mod_add_cmd(&userhost_msgtab);
656  mod_add_cmd(&users_msgtab);
657  mod_add_cmd(&version_msgtab);
658  mod_add_cmd(&wallops_msgtab);
659  mod_add_cmd(&who_msgtab);
660  mod_add_cmd(&whois_msgtab);
661  mod_add_cmd(&whowas_msgtab);
662  mod_add_cmd(&xline_msgtab);
663  mod_add_cmd(&help_msgtab);
664  mod_add_cmd(&uhelp_msgtab);
665 #ifdef BUILD_CONTRIB
666  mod_add_cmd(&botserv_msgtab);
667  mod_add_cmd(&capture_msgtab);
668  mod_add_cmd(&chanserv_msgtab);
669  mod_add_cmd(&chghost_msgtab);
670  mod_add_cmd(&chgident_msgtab);
671  mod_add_cmd(&chgname_msgtab);
672  mod_add_cmd(&classlist_msgtab);
673  mod_add_cmd(&clearchan_msgtab);
674  mod_add_cmd(&cs_msgtab);
675  mod_add_cmd(&ctrace_msgtab);
676  mod_add_cmd(&delspoof_msgtab);
677  mod_add_cmd(&flags_msgtab);
678  mod_add_cmd(&forcejoin_msgtab);
679  mod_add_cmd(&forcepart_msgtab);
680  mod_add_cmd(&global_msgtab);
681  mod_add_cmd(&help_msgtab);
682  mod_add_cmd(&uhelp_msgtab);
683  mod_add_cmd(&helpserv_msgtab);
684  mod_add_cmd(&hostserv_msgtab);
685  mod_add_cmd(&identify_msgtab);
686  mod_add_cmd(&jupe_msgtab);
687  mod_add_cmd(&killhost_msgtab);
688  mod_add_cmd(&ltrace_msgtab);
689  mod_add_cmd(&memoserv_msgtab);
690  mod_add_cmd(&mkpasswd_msgtab);
691  mod_add_cmd(&ms_msgtab);
692  mod_add_cmd(&nickserv_msgtab);
693  mod_add_cmd(&ns_msgtab);
694  mod_add_cmd(&ojoin_msgtab);
695  mod_add_cmd(&operserv_msgtab);
696  mod_add_cmd(&operspy_msgtab);
697  mod_add_cmd(&opme_msgtab);
698  mod_add_cmd(&os_msgtab);
699  mod_add_cmd(&seenserv_msgtab);
700  mod_add_cmd(&spoof_msgtab);
701  mod_add_cmd(&statserv_msgtab);
702  mod_add_cmd(&svsnick_msgtab);
703  mod_add_cmd(&uncapture_msgtab);
704  /* FIXME: what about spy*? */
705 #endif
706 }
707 #endif /* STATIC_MODULES */

Comparing:
ircd-hybrid/src/modules.c (property svn:keywords), Revision 32 by knight, Sun Oct 2 20:41:23 2005 UTC vs.
ircd-hybrid-8/src/modules.c (property svn:keywords), Revision 1156 by michael, Tue Aug 9 20:29:20 2011 UTC

# Line 1 | Line 1
1 < Revision
1 > Id Revision

Diff Legend

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