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

Comparing:
ircd-hybrid-7.2/src/ircd.c (file contents), Revision 1011 by michael, Fri Sep 18 10:14:09 2009 UTC vs.
ircd-hybrid-8/src/ircd.c (file contents), Revision 1196 by michael, Sun Aug 21 10:09:23 2011 UTC

# Line 34 | Line 34
34   #include "fdlist.h"
35   #include "hash.h"
36   #include "irc_string.h"
37 #include "sprintf_irc.h"
37   #include "ircd_signal.h"
38   #include "s_gline.h"
39   #include "motd.h"
# Line 77 | Line 76 | struct config_file_entry ConfigFileEntry
76   struct server_info ServerInfo;
77   /* admin info set from ircd.conf */
78   struct admin_info AdminInfo = { NULL, NULL, NULL };
79 < struct Counter Count = { 0, 0, 0, 0, 0, 0, 0, 0 };
79 > struct Counter Count = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
80   struct ServerState_t server_state = { 0 };
81   struct logging_entry ConfigLoggingEntry = { 1, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0} };
82   struct ServerStatistics ServerStats;
# Line 93 | Line 92 | char ircd_platform[PLATFORMLEN];
92  
93   int dorehash = 0;
94   int doremotd = 0;
96 time_t nextconnect = 1;       /* time for next try_connections call */
95  
96   /* Set to zero because it should be initialized later using
97   * initialize_server_capabs
# Line 104 | Line 102 | int default_server_capabs = 0;
102   int bio_spare_fd = -1;
103   #endif
104  
105 < int splitmode;
106 < int splitchecking;
107 < int split_users;
105 > unsigned int splitmode;
106 > unsigned int splitchecking;
107 > unsigned int split_users;
108   unsigned int split_servers;
109  
110   /* Do klines the same way hybrid-6 did them, i.e. at the
# Line 196 | Line 194 | set_time(void)
194  
195    if (newtime.tv_sec < CurrentTime)
196    {
197 <    ircsprintf(to_send, "System clock is running backwards - (%lu < %lu)",
198 <               (unsigned long)newtime.tv_sec, (unsigned long)CurrentTime);
197 >    snprintf(to_send, sizeof(to_send),
198 >             "System clock is running backwards - (%lu < %lu)",
199 >             (unsigned long)newtime.tv_sec, (unsigned long)CurrentTime);
200      report_error(L_ALL, to_send, me.name, 0);
201      set_back_events(CurrentTime - newtime.tv_sec);
202    }
# Line 298 | Line 297 | initialize_global_set_options(void)
297    }
298  
299    GlobalSetOptions.ident_timeout = IDENT_TIMEOUT;
301  GlobalSetOptions.idletime = ConfigFileEntry.idletime;
300    /* End of global set options */
301   }
302  
# Line 332 | Line 330 | initialize_server_capabs(void)
330   {
331    add_capability("QS", CAP_QS, 1);
332    add_capability("EOB", CAP_EOB, 1);
333 <
336 <  if (ServerInfo.sid != NULL)   /* only enable TS6 if we have an SID */
337 <    add_capability("TS6", CAP_TS6, 0);
338 <
333 >  add_capability("TS6", CAP_TS6, 0);
334    add_capability("ZIP", CAP_ZIP, 0);
335    add_capability("CLUSTER", CAP_CLUSTER, 1);
336 +  add_capability("SVS", CAP_SVS, 1);
337   #ifdef HALFOPS
338    add_capability("HOPS", CAP_HOPS, 1);
339   #endif
# Line 358 | Line 354 | write_pidfile(const char *filename)
354    {
355      char buff[32];
356      unsigned int pid = (unsigned int)getpid();
357 <    size_t nbytes = ircsprintf(buff, "%u\n", pid);
357 >    size_t nbytes = snprintf(buff, sizeof(buff), "%u\n", pid);
358  
359      if ((fbputs(buff, fb, nbytes) == -1))
360        ilog(L_ERROR, "Error writing %u to pid file %s (%s)",
# Line 505 | Line 501 | main(int argc, char *argv[])
501    /* It ain't random, but it ought to be a little harder to guess */
502    init_genrand(SystemTime.tv_sec ^ (SystemTime.tv_usec | (getpid() << 20)));
503  
508  memset(&me, 0, sizeof(me));
509  memset(&meLocalUser, 0, sizeof(meLocalUser));
504    me.localClient = &meLocalUser;
505    dlinkAdd(&me, &me.node, &global_client_list); /* Pointer to beginning
506                                                     of Client list */
513
514  memset(&ServerInfo, 0, sizeof(ServerInfo));
515  memset(&ServerStats, 0, sizeof(ServerStats));
516
507    /* Initialise the channel capability usage counts... */
508    init_chcap_usage_counts();
509  
# Line 568 | Line 558 | main(int argc, char *argv[])
558    /* Check if there is pidfile and daemon already running */
559    check_pidfile(pidFileName);
560  
571 #ifndef NOBALLOC
561    initBlockHeap();
573 #endif
562    init_dlink_nodes();
563    init_callbacks();
564    initialize_message_files();
# Line 586 | Line 574 | main(int argc, char *argv[])
574    init_auth();          /* Initialise the auth code */
575    init_resolver();      /* Needs to be setup before the io loop */
576    read_conf_files(1);   /* cold start init conf files */
589  me.id[0] = '\0';
577    init_uid();
578    initialize_server_capabs();   /* Set up default_server_capabs */
579    initialize_global_set_options();
580    init_channels();
581  
582 <  if (ServerInfo.name == NULL)
582 >  if (EmptyString(ServerInfo.sid))
583    {
584 <    ilog(L_CRIT, "No server name specified in serverinfo block.");
584 >    ilog(L_CRIT, "ERROR: No server id specified in serverinfo block.");
585 >    exit(EXIT_FAILURE);
586 >  }
587 >
588 >  strlcpy(me.id, ServerInfo.sid, sizeof(me.id));
589 >
590 >  if (EmptyString(ServerInfo.name))
591 >  {
592 >    ilog(L_CRIT, "ERROR: No server name specified in serverinfo block.");
593      exit(EXIT_FAILURE);
594    }
595  
596    strlcpy(me.name, ServerInfo.name, sizeof(me.name));
597  
598    /* serverinfo{} description must exist.  If not, error out.*/
599 <  if (ServerInfo.description == NULL)
599 >  if (EmptyString(ServerInfo.description))
600    {
601 <    ilog(L_CRIT,
607 <      "ERROR: No server description specified in serverinfo block.");
601 >    ilog(L_CRIT, "ERROR: No server description specified in serverinfo block.");
602      exit(EXIT_FAILURE);
603    }
604  
605    strlcpy(me.info, ServerInfo.description, sizeof(me.info));
606  
607 <  me.from    = &me;
608 <  me.servptr = &me;
607 >  me.from     = &me;
608 >  me.servptr  = &me;
609 >  me.lasttime = me.since = me.firsttime = CurrentTime;
610  
611    SetMe(&me);
612    make_server(&me);
613  
614 <  me.lasttime = me.since = me.firsttime = CurrentTime;
614 >  hash_add_id(&me);
615    hash_add_client(&me);
616    
617    /* add ourselves to global_serv_list */
618    dlinkAdd(&me, make_dlink_node(), &global_serv_list);
619  
625  check_class();
626
627 #ifndef STATIC_MODULES
620    if (chdir(MODPATH))
621    {
622 <    ilog (L_CRIT, "Could not load core modules. Terminating!");
622 >    ilog(L_CRIT, "Could not load core modules. Terminating!");
623      exit(EXIT_FAILURE);
624    }
625  
626    load_all_modules(1);
627    load_conf_modules();
628    load_core_modules(1);
629 +
630    /* Go back to DPATH after checking to see if we can chdir to MODPATH */
631 <  chdir(ConfigFileEntry.dpath);
632 < #else
633 <  load_all_modules(1);
634 < #endif
631 >  if (chdir(ConfigFileEntry.dpath))
632 >  {
633 >    perror("chdir");
634 >    exit(EXIT_FAILURE);
635 >  }
636 >
637    /*
638     * assemble_umode_buffer() has to be called after
639     * reading conf/loading modules.

Diff Legend

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