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 1013 by michael, Sun Oct 18 14:26:49 2009 UTC vs.
ircd-hybrid-8/src/ircd.c (file contents), Revision 1176 by michael, Sun Aug 14 11:24:24 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 195 | 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 297 | Line 297 | initialize_global_set_options(void)
297    }
298  
299    GlobalSetOptions.ident_timeout = IDENT_TIMEOUT;
300  GlobalSetOptions.idletime = ConfigFileEntry.idletime;
300    /* End of global set options */
301   }
302  
# Line 331 | Line 330 | initialize_server_capabs(void)
330   {
331    add_capability("QS", CAP_QS, 1);
332    add_capability("EOB", CAP_EOB, 1);
333 <
335 <  if (ServerInfo.sid != NULL)   /* only enable TS6 if we have an SID */
336 <    add_capability("TS6", CAP_TS6, 0);
337 <
333 >  add_capability("TS6", CAP_TS6, 0);
334    add_capability("ZIP", CAP_ZIP, 0);
335    add_capability("CLUSTER", CAP_CLUSTER, 1);
336   #ifdef HALFOPS
# Line 357 | Line 353 | write_pidfile(const char *filename)
353    {
354      char buff[32];
355      unsigned int pid = (unsigned int)getpid();
356 <    size_t nbytes = ircsprintf(buff, "%u\n", pid);
356 >    size_t nbytes = snprintf(buff, sizeof(buff), "%u\n", pid);
357  
358      if ((fbputs(buff, fb, nbytes) == -1))
359        ilog(L_ERROR, "Error writing %u to pid file %s (%s)",
# Line 504 | Line 500 | main(int argc, char *argv[])
500    /* It ain't random, but it ought to be a little harder to guess */
501    init_genrand(SystemTime.tv_sec ^ (SystemTime.tv_usec | (getpid() << 20)));
502  
507  memset(&me, 0, sizeof(me));
508  memset(&meLocalUser, 0, sizeof(meLocalUser));
503    me.localClient = &meLocalUser;
504    dlinkAdd(&me, &me.node, &global_client_list); /* Pointer to beginning
505                                                     of Client list */
512
513  memset(&ServerInfo, 0, sizeof(ServerInfo));
514  memset(&ServerStats, 0, sizeof(ServerStats));
515
506    /* Initialise the channel capability usage counts... */
507    init_chcap_usage_counts();
508  
# Line 583 | Line 573 | main(int argc, char *argv[])
573    init_auth();          /* Initialise the auth code */
574    init_resolver();      /* Needs to be setup before the io loop */
575    read_conf_files(1);   /* cold start init conf files */
586  me.id[0] = '\0';
576    init_uid();
577    initialize_server_capabs();   /* Set up default_server_capabs */
578    initialize_global_set_options();
579    init_channels();
580  
581 <  if (ServerInfo.name == NULL)
581 >  if (EmptyString(ServerInfo.sid))
582    {
583 <    ilog(L_CRIT, "No server name specified in serverinfo block.");
583 >    ilog(L_CRIT, "ERROR: No server id specified in serverinfo block.");
584 >    exit(EXIT_FAILURE);
585 >  }
586 >
587 >  strlcpy(me.id, ServerInfo.sid, sizeof(me.id));
588 >
589 >  if (EmptyString(ServerInfo.name))
590 >  {
591 >    ilog(L_CRIT, "ERROR: No server name specified in serverinfo block.");
592      exit(EXIT_FAILURE);
593    }
594  
595    strlcpy(me.name, ServerInfo.name, sizeof(me.name));
596  
597    /* serverinfo{} description must exist.  If not, error out.*/
598 <  if (ServerInfo.description == NULL)
598 >  if (EmptyString(ServerInfo.description))
599    {
600 <    ilog(L_CRIT,
604 <      "ERROR: No server description specified in serverinfo block.");
600 >    ilog(L_CRIT, "ERROR: No server description specified in serverinfo block.");
601      exit(EXIT_FAILURE);
602    }
603  
604    strlcpy(me.info, ServerInfo.description, sizeof(me.info));
605  
606 <  me.from    = &me;
607 <  me.servptr = &me;
606 >  me.from     = &me;
607 >  me.servptr  = &me;
608 >  me.lasttime = me.since = me.firsttime = CurrentTime;
609  
610    SetMe(&me);
611    make_server(&me);
612  
613 <  me.lasttime = me.since = me.firsttime = CurrentTime;
613 >  hash_add_id(&me);
614    hash_add_client(&me);
615    
616    /* add ourselves to global_serv_list */
617    dlinkAdd(&me, make_dlink_node(), &global_serv_list);
618  
622  check_class();
623
624 #ifndef STATIC_MODULES
619    if (chdir(MODPATH))
620    {
621 <    ilog (L_CRIT, "Could not load core modules. Terminating!");
621 >    ilog(L_CRIT, "Could not load core modules. Terminating!");
622      exit(EXIT_FAILURE);
623    }
624  
625    load_all_modules(1);
626    load_conf_modules();
627    load_core_modules(1);
628 +
629    /* Go back to DPATH after checking to see if we can chdir to MODPATH */
630 <  chdir(ConfigFileEntry.dpath);
631 < #else
632 <  load_all_modules(1);
633 < #endif
630 >  if (chdir(ConfigFileEntry.dpath))
631 >  {
632 >    perror("chdir");
633 >    exit(EXIT_FAILURE);
634 >  }
635 >
636    /*
637     * assemble_umode_buffer() has to be called after
638     * reading conf/loading modules.

Diff Legend

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