0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-26 15:33:54 +01:00

ircd: Improve/refactor version.cc -> info.cc related.

This commit is contained in:
Jason Volk 2016-08-15 16:21:01 -07:00
parent 5420a29830
commit 3f6d567285
14 changed files with 279 additions and 258 deletions

53
include/ircd/info.h Normal file
View file

@ -0,0 +1,53 @@
/*
* Copyright (C) 2016 Charybdis Development Team
* Copyright (C) 2016 Jason Volk <jason@zemos.net>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice is present in all copies.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#pragma once
#define HAVE_IRCD_INFO_H
#ifdef __cplusplus
namespace ircd {
namespace info {
struct line
{
std::string key;
std::string valstr;
uint64_t valnum;
std::string desc;
};
extern const std::vector<info::line> myinfo;
extern const std::vector<std::string> credits;
extern const std::string serno;
extern const std::string version;
extern const char *const ircd_version; // legacy (version.c_str() is not safe to hold)
extern const time_t configured_time;
extern const time_t compiled_time;
extern const time_t startup_time;
extern const std::string compiled;
extern const std::string configured;
extern const std::string startup;
} // namespace info
} // namespace ircd
#endif // __cplusplus

View file

@ -63,12 +63,6 @@ struct Counter
extern struct SetOptions GlobalSetOptions; /* defined in ircd.c */ extern struct SetOptions GlobalSetOptions; /* defined in ircd.c */
extern const char *creation;
extern const char *generation;
extern const char *infotext[];
extern const char *serno;
extern const time_t datecode;
extern const char *ircd_version;
extern const char *logFileName; extern const char *logFileName;
extern const char *pidFileName; extern const char *pidFileName;
extern volatile sig_atomic_t dorehash; extern volatile sig_atomic_t dorehash;
@ -85,8 +79,6 @@ extern struct Client *local[];
extern struct Counter Count; extern struct Counter Count;
extern int default_server_capabs; extern int default_server_capabs;
extern time_t startup_time;
extern int splitmode; extern int splitmode;
extern int splitchecking; extern int splitchecking;
extern int split_users; extern int split_users;

View file

@ -1,163 +0,0 @@
/*
* ircd-ratbox: A slightly useful ircd.
* m_info.h: A header for the information sent by /info
*
* Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center
* Copyright (C) 1996-2002 Hybrid Development Team
* Copyright (C) 2002-2004 ircd-ratbox development team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*/
#pragma once
#define HAVE_IRCD_INFO_H
#ifdef __cplusplus
namespace ircd {
typedef struct Information
{
const char *name; /* name of item */
const char *strvalue; /* value of item if it's a boolean */
int intvalue; /* value of item if it's an integer */
const char *desc; /* short description of item */
}
Info;
static
Info MyInformation[] = {
#ifdef CPATH
{"CPATH", CPATH, 0, "Path to Main Configuration File"},
#else
{"CPATH", "NONE", 0, "Path to Main Configuration File"},
#endif /* CPATH */
#ifdef DPATH
{"DPATH", DPATH, 0, "Directory Containing Configuration Files"},
#else
{"DPATH", "NONE", 0, "Directory Containing Configuration Files"},
#endif /* DPATH */
#ifdef HPATH
{"HPATH", HPATH, 0, "Path to Operator Help Files"},
#else
{"HPATH", "NONE", 0, "Path to Operator Help Files"},
#endif /* HPATH */
#ifdef UHPATH
{"UHPATH", UHPATH, 0, "Path to User Help Files"},
#else
{"UHPATH", "NONE", 0, "Path to User Help Files"},
#endif /* UH PATH */
#ifdef SOMAXCONN
{"CHARYBDIS_SOMAXCONN", "", SOMAXCONN,
"Maximum Queue Length of Pending Connections"},
#else
{"CHARYBDIS_SOMAXCONN", "", CHARYBDIS_SOMAXCONN,
"Maximum Queue Length of Pending Connections"},
#endif /* SOMAXCONN */
#ifdef RB_IPV6
{"IPV6", "ON", 0, "IPv6 Support"},
#else
{"IPV6", "OFF", 0, "IPv6 Support"},
#endif
{"JOIN_LEAVE_COUNT_EXPIRE_TIME", "", JOIN_LEAVE_COUNT_EXPIRE_TIME,
"Anti SpamBot Parameter"},
{"KILLCHASETIMELIMIT", "", KILLCHASETIMELIMIT,
"Nick Change Tracker for KILL"},
#ifdef LPATH
{"LPATH", LPATH, 0, "Path to Log File"},
#else
{"LPATH", "NONE", 0, "Path to Log File"},
#endif /* LPATH */
{"MAX_BUFFER", "", MAX_BUFFER, "Maximum Buffer Connections Allowed"},
{"MAX_JOIN_LEAVE_COUNT", "", MAX_JOIN_LEAVE_COUNT,
"Anti SpamBot Parameter"},
{"MIN_JOIN_LEAVE_TIME", "", MIN_JOIN_LEAVE_TIME,
"Anti SpamBot Parameter"},
#ifdef MPATH
{"MPATH", MPATH, 0, "Path to MOTD File"},
#else
{"MPATH", "NONE", 0, "Path to MOTD File"},
#endif /* MPATH */
{"NICKNAMEHISTORYLENGTH", "", NICKNAMEHISTORYLENGTH,
"Size of WHOWAS Array"},
#ifdef OPATH
{"OPATH", OPATH, 0, "Path to Operator MOTD File"},
#else
{"OPATH", "NONE", 0, "Path to Operator MOTD File"},
#endif /* OPATH */
{"OPER_SPAM_COUNTDOWN", "", OPER_SPAM_COUNTDOWN,
"Anti SpamBot Parameter"},
#ifdef HAVE_LIBCRYPTO
{"HAVE_LIBCRYPTO", "ON", 0, "Enable OpenSSL CHALLENGE Support"},
#else
{"HAVE_LIBCRYPTO", "OFF", 0, "Enable OpenSSL CHALLENGE Support"},
#endif /* HAVE_LIBCRYPTO */
#ifdef HAVE_LIBZ
{"HAVE_LIBZ", "YES", 0, "zlib (ziplinks) support"},
#else
{"HAVE_LIBZ", "NO", 0, "zlib (ziplinks) support"},
#endif /* HAVE_LIBZ */
#ifdef PPATH
{"PPATH", PPATH, 0, "Path to Pid File"},
#else
{"PPATH", "NONE", 0, "Path to Pid File"},
#endif /* PPATH */
#ifdef SPATH
{"SPATH", SPATH, 0, "Path to Server Executable"},
#else
{"SPATH", "NONE", 0, "Path to Server Executable"},
#endif /* SPATH */
{"TS_MAX_DELTA_DEFAULT", "", TS_MAX_DELTA_DEFAULT,
"Maximum Allowed TS Delta from another Server"},
{"TS_WARN_DELTA_DEFAULT", "", TS_WARN_DELTA_DEFAULT,
"Maximum TS Delta before Sending Warning"},
#ifdef USE_IODEBUG_HOOKS
{"USE_IODEBUG_HOOKS", "YES", 0, "IO Debugging support"},
#else
{"USE_IODEBUG_HOOKS", "NO", 0, "IO Debugging support"},
#endif
/*
* since we don't want to include the world here, NULL probably
* isn't defined by the time we read this, just use plain 0 instead
* 0 is guaranteed by the language to be assignable to ALL built
* in types with the correct results.
*/
{0, 0, 0, 0}
};
} // namespace ircd
#endif // __cplusplus

View file

@ -60,7 +60,7 @@ namespace ircd
#include "logger.h" #include "logger.h"
#include "match.h" #include "match.h"
#include "messages.h" #include "messages.h"
#include "m_info.h" #include "info.h"
#include "modules.h" #include "modules.h"
#include "monitor.h" #include "monitor.h"
#include "msgbuf.h" #include "msgbuf.h"

View file

@ -52,6 +52,7 @@ libircd_la_SOURCES = \
hash.cc \ hash.cc \
hook.cc \ hook.cc \
hostmask.cc \ hostmask.cc \
info.cc \
ircd.cc \ ircd.cc \
ircd_lexer.cc \ ircd_lexer.cc \
ircd_parser.cc \ ircd_parser.cc \
@ -81,7 +82,6 @@ libircd_la_SOURCES = \
substitution.cc \ substitution.cc \
supported.cc \ supported.cc \
tgchange.cc \ tgchange.cc \
version.cc \
whowas.cc \ whowas.cc \
wsproc.cc wsproc.cc

198
ircd/info.cc Normal file
View file

@ -0,0 +1,198 @@
/*
* Copyright (C) 1990 Chelsea Ashley Dyerman
* Copyright (C) 2008 ircd-ratbox development team
* Copyright (C) 2016 Charybdis Development Team
* Copyright (C) 2016 Jason Volk <jason@zemos.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
using namespace ircd;
const time_t
info::configured_time
{
RB_TIME_CONFIGURED
};
const time_t
info::compiled_time
{
RB_TIME_COMPILED
};
const time_t
info::startup_time
{
std::time(nullptr)
};
const std::string
info::configured
{
ctime(&configured_time)
};
const std::string
info::compiled
{
ctime(&compiled_time)
};
const std::string
info::startup
{
ctime(&startup_time)
};
const std::string
info::serno
{
//TODO: XXX: compile counter?
// RB_SERNO
0
};
const std::string
info::version
{
RB_VERSION
};
const char *const
info::ircd_version
{
RB_VERSION
};
/* XXX: integrate CREDITS text again somehow */
const std::vector<std::string>
info::credits
{{
"charybdis",
"Based on the original code written by Jarkko Oikarinen",
"Copyright (c) 1988-1991 University of Oulu, Computing Center",
"Copyright (c) 1996-2001 Hybrid Development Team",
"Copyright (c) 2002-2009 ircd-ratbox Development Team",
"Copyright (c) 2005-2016 charybdis development team",
" ",
"This program is free software; you can redistribute it and/or",
"modify it under the terms of the GNU General Public License as",
"published by the Free Software Foundation; either version 2, or",
"(at your option) any later version.",
" ",
}};
const std::vector<info::line>
info::myinfo
{{
#ifdef CPATH
{"CPATH", CPATH, 0, "Path to Main Configuration File"},
#else
{"CPATH", "NONE", 0, "Path to Main Configuration File"},
#endif
#ifdef DPATH
{"DPATH", DPATH, 0, "Directory Containing Configuration Files"},
#else
{"DPATH", "NONE", 0, "Directory Containing Configuration Files"},
#endif
#ifdef HPATH
{"HPATH", HPATH, 0, "Path to Operator Help Files"},
#else
{"HPATH", "NONE", 0, "Path to Operator Help Files"},
#endif
#ifdef UHPATH
{"UHPATH", UHPATH, 0, "Path to User Help Files"},
#else
{"UHPATH", "NONE", 0, "Path to User Help Files"},
#endif
#ifdef SOMAXCONN
{"CHARYBDIS_SOMAXCONN", "", SOMAXCONN, "Maximum Queue Length of Pending Connections"},
#else
{"CHARYBDIS_SOMAXCONN", "", CHARYBDIS_SOMAXCONN, "Maximum Queue Length of Pending Connections"},
#endif
#ifdef RB_IPV6
{"IPV6", "ON", 0, "IPv6 Support"},
#else
{"IPV6", "OFF", 0, "IPv6 Support"},
#endif
{"JOIN_LEAVE_COUNT_EXPIRE_TIME", "", JOIN_LEAVE_COUNT_EXPIRE_TIME, "Anti SpamBot Parameter"},
{"KILLCHASETIMELIMIT", "", KILLCHASETIMELIMIT, "Nick Change Tracker for KILL"},
#ifdef LPATH
{"LPATH", LPATH, 0, "Path to Log File"},
#else
{"LPATH", "NONE", 0, "Path to Log File"},
#endif
{"MAX_BUFFER", "", MAX_BUFFER, "Maximum Buffer Connections Allowed"},
{"MAX_JOIN_LEAVE_COUNT", "", MAX_JOIN_LEAVE_COUNT, "Anti SpamBot Parameter"},
{"MIN_JOIN_LEAVE_TIME", "", MIN_JOIN_LEAVE_TIME, "Anti SpamBot Parameter"},
#ifdef MPATH
{"MPATH", MPATH, 0, "Path to MOTD File"},
#else
{"MPATH", "NONE", 0, "Path to MOTD File"},
#endif
{"NICKNAMEHISTORYLENGTH", "", NICKNAMEHISTORYLENGTH, "Size of WHOWAS Array"},
#ifdef OPATH
{"OPATH", OPATH, 0, "Path to Operator MOTD File"},
#else
{"OPATH", "NONE", 0, "Path to Operator MOTD File"},
#endif
{"OPER_SPAM_COUNTDOWN", "", OPER_SPAM_COUNTDOWN, "Anti SpamBot Parameter"},
#ifdef HAVE_LIBCRYPTO
{"HAVE_LIBCRYPTO", "ON", 0, "Enable OpenSSL CHALLENGE Support"},
#else
{"HAVE_LIBCRYPTO", "OFF", 0, "Enable OpenSSL CHALLENGE Support"},
#endif
#ifdef HAVE_LIBZ
{"HAVE_LIBZ", "YES", 0, "zlib (ziplinks) support"},
#else
{"HAVE_LIBZ", "NO", 0, "zlib (ziplinks) support"},
#endif
#ifdef PPATH
{"PPATH", PPATH, 0, "Path to Pid File"},
#else
{"PPATH", "NONE", 0, "Path to Pid File"},
#endif
#ifdef SPATH
{"SPATH", SPATH, 0, "Path to Server Executable"},
#else
{"SPATH", "NONE", 0, "Path to Server Executable"},
#endif
{"TS_MAX_DELTA_DEFAULT", "", TS_MAX_DELTA_DEFAULT, "Maximum Allowed TS Delta from another Server"},
{"TS_WARN_DELTA_DEFAULT", "", TS_WARN_DELTA_DEFAULT, "Maximum TS Delta before Sending Warning"},
#ifdef USE_IODEBUG_HOOKS
{"USE_IODEBUG_HOOKS", "YES", 0, "IO Debugging support"},
#else
{"USE_IODEBUG_HOOKS", "NO", 0, "IO Debugging support"},
#endif
}};

View file

@ -67,7 +67,7 @@ bool ircd_ssl_ok = false;
bool ircd_zlib_ok = true; bool ircd_zlib_ok = true;
int testing_conf = 0; int testing_conf = 0;
time_t startup_time; //time_t startup_time;
int default_server_capabs; int default_server_capabs;
@ -573,7 +573,7 @@ charybdis_main(int argc, char * const argv[])
if(printVersion) if(printVersion)
{ {
printf("ircd: version %s(%s)\n", ircd_version, serno); printf("ircd: version %s(%s)\n", info::version.c_str(), info::serno.c_str());
#ifdef CUSTOM_BRANDING #ifdef CUSTOM_BRANDING
printf("ircd: based on %s-%s\n", PACKAGE_NAME, PACKAGE_VERSION); printf("ircd: based on %s-%s\n", PACKAGE_NAME, PACKAGE_VERSION);
#endif #endif
@ -605,7 +605,7 @@ charybdis_main(int argc, char * const argv[])
if(!server_state_foreground) if(!server_state_foreground)
make_daemon(); make_daemon();
inotice("starting %s ...", ircd_version); inotice("starting %s ...", info::version.c_str());
inotice("%s", rb_lib_version()); inotice("%s", rb_lib_version());
} }
@ -707,7 +707,6 @@ charybdis_main(int argc, char * const argv[])
me.servptr = &me; me.servptr = &me;
SetMe(&me); SetMe(&me);
make_server(&me); make_server(&me);
startup_time = rb_current_time();
add_to_client_hash(me.name, &me); add_to_client_hash(me.name, &me);
add_to_id_hash(me.id, &me); add_to_id_hash(me.id, &me);
me.serv->nameinfo = scache_connect(me.name, me.info, 0); me.serv->nameinfo = scache_connect(me.name, me.info, 0);

View file

@ -420,9 +420,9 @@ bool init_module_v2(struct module *const mod)
* Later on if there are major API changes we can add fatal checks. * Later on if there are major API changes we can add fatal checks.
* -- Elizafox * -- Elizafox
*/ */
if(mheader->mapi_datecode != datecode && mheader->mapi_datecode > 0) if(mheader->mapi_datecode != info::configured_time && mheader->mapi_datecode > 0)
{ {
long int delta = datecode - mheader->mapi_datecode; long int delta = info::configured_time - mheader->mapi_datecode;
if (delta > MOD_WARN_DELTA) if (delta > MOD_WARN_DELTA)
{ {
delta /= 86400; delta /= 86400;
@ -456,7 +456,7 @@ bool init_module_v2(struct module *const mod)
} }
/* New in MAPI v2 - version replacement */ /* New in MAPI v2 - version replacement */
mod->version = mheader->mapi_module_version? mheader->mapi_module_version : ircd_version; mod->version = mheader->mapi_module_version? mheader->mapi_module_version : info::ircd_version;
mod->description = mheader->mapi_module_description; mod->description = mheader->mapi_module_description;
if(mheader->mapi_cap_list) if(mheader->mapi_cap_list)

View file

@ -1311,9 +1311,9 @@ user_welcome(struct Client *source_p)
{ {
sendto_one_numeric(source_p, RPL_WELCOME, form_str(RPL_WELCOME), ServerInfo.network_name, source_p->name); sendto_one_numeric(source_p, RPL_WELCOME, form_str(RPL_WELCOME), ServerInfo.network_name, source_p->name);
sendto_one_numeric(source_p, RPL_YOURHOST, form_str(RPL_YOURHOST), sendto_one_numeric(source_p, RPL_YOURHOST, form_str(RPL_YOURHOST),
get_listener_name(source_p->localClient->listener), ircd_version); get_listener_name(source_p->localClient->listener), info::version.c_str());
sendto_one_numeric(source_p, RPL_CREATED, form_str(RPL_CREATED), creation); sendto_one_numeric(source_p, RPL_CREATED, form_str(RPL_CREATED), info::compiled.c_str());
sendto_one_numeric(source_p, RPL_MYINFO, form_str(RPL_MYINFO), me.name, ircd_version, umodebuf, chmode_arity[0], chmode_arity[1]); sendto_one_numeric(source_p, RPL_MYINFO, form_str(RPL_MYINFO), me.name, info::version.c_str(), umodebuf, chmode_arity[0], chmode_arity[1]);
show_isupport(source_p); show_isupport(source_p);

View file

@ -1,51 +0,0 @@
/*
* librb: a library used by charybdis and other things
* src/version.c
*
* Copyright (C) 1990 Chelsea Ashley Dyerman
* Copyright (C) 2008 ircd-ratbox development team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
namespace ircd {
const char *ircd_version = RB_VERSION;
const char *ircd_datestr = RB_DATESTR;
const time_t ircd_datecode = RB_DATECODE;
const char *creation = RB_DATESTR;
const char *serno = RB_DATESTR;
const time_t datecode = RB_DATECODE;
/* XXX: integrate CREDITS text again somehow */
const char *infotext[] =
{
"charybdis",
"Based on the original code written by Jarkko Oikarinen",
"Copyright (c) 1988-1991 University of Oulu, Computing Center",
"Copyright (c) 1996-2001 Hybrid Development Team",
"Copyright (c) 2002-2009 ircd-ratbox Development Team",
"Copyright (c) 2005-2016 charybdis development team",
" ",
"This program is free software; you can redistribute it and/or",
"modify it under the terms of the GNU General Public License as",
"published by the Free Software Foundation; either version 2, or",
"(at your option) any later version.",
"",
NULL,
};
}

View file

@ -713,12 +713,8 @@ mo_info(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_
static void static void
send_info_text(struct Client *source_p) send_info_text(struct Client *source_p)
{ {
const char **text = infotext; for (const auto &text : info::credits)
sendto_one_numeric(source_p, RPL_INFO, form_str(RPL_INFO), text.c_str());
while (*text)
{
sendto_one_numeric(source_p, RPL_INFO, form_str(RPL_INFO), *text++);
}
sendto_one_numeric(source_p, RPL_INFO, form_str(RPL_INFO), ""); sendto_one_numeric(source_p, RPL_INFO, form_str(RPL_INFO), "");
} }
@ -736,11 +732,11 @@ send_birthdate_online_time(struct Client *source_p)
char tbuf[26]; /* this needs to be 26 - see ctime_r manpage */ char tbuf[26]; /* this needs to be 26 - see ctime_r manpage */
sendto_one(source_p, ":%s %d %s :Birth Date: %s (%ld)", sendto_one(source_p, ":%s %d %s :Birth Date: %s (%ld)",
get_id(&me, source_p), RPL_INFO, get_id(&me, source_p), RPL_INFO,
get_id(source_p, source_p), creation, datecode); get_id(source_p, source_p), info::compiled.c_str(), info::compiled_time);
sendto_one(source_p, ":%s %d %s :On-line since %s", sendto_one(source_p, ":%s %d %s :On-line since %s",
get_id(&me, source_p), RPL_INFO, get_id(&me, source_p), RPL_INFO,
get_id(source_p, source_p), rb_ctime(startup_time, tbuf, sizeof(tbuf))); get_id(source_p, source_p), info::startup.c_str());
} }
/* /*
@ -753,37 +749,34 @@ send_birthdate_online_time(struct Client *source_p)
static void static void
send_conf_options(struct Client *source_p) send_conf_options(struct Client *source_p)
{ {
Info *infoptr;
int i = 0;
/* /*
* Now send them a list of all our configuration options * Now send them a list of all our configuration options
* (mostly from defaults.h) * (mostly from defaults.h)
*/ */
for (infoptr = MyInformation; infoptr->name; infoptr++) for (const auto &line : info::myinfo)
{ {
if(infoptr->intvalue) if (line.valnum)
{ {
sendto_one(source_p, ":%s %d %s :%-30s %-16d [%s]", sendto_one(source_p, ":%s %d %s :%-30s %-16d [%s]",
get_id(&me, source_p), RPL_INFO, get_id(&me, source_p), RPL_INFO,
get_id(source_p, source_p), get_id(source_p, source_p),
infoptr->name, infoptr->intvalue, line.key.c_str(), line.valnum,
infoptr->desc); line.desc.c_str());
} }
else else
{ {
sendto_one(source_p, ":%s %d %s :%-30s %-16s [%s]", sendto_one(source_p, ":%s %d %s :%-30s %-16s [%s]",
get_id(&me, source_p), RPL_INFO, get_id(&me, source_p), RPL_INFO,
get_id(source_p, source_p), get_id(source_p, source_p),
infoptr->name, infoptr->strvalue, line.key.c_str(), line.valstr.c_str(),
infoptr->desc); line.desc.c_str());
} }
} }
/* /*
* Parse the info_table[] and do the magic. * Parse the info_table[] and do the magic.
*/ */
for (i = 0; info_table[i].name; i++) for (int i(0); info_table[i].name; i++)
{ {
switch (info_table[i].output_type) switch (info_table[i].output_type)
{ {

View file

@ -964,7 +964,7 @@ stats_usage (struct Client *source_p)
if(0 == secs) if(0 == secs)
secs = 1; secs = 1;
rup = (rb_current_time() - startup_time) * hzz; rup = (rb_current_time() - info::startup_time) * hzz;
if(0 == rup) if(0 == rup)
rup = 1; rup = 1;
@ -1082,7 +1082,7 @@ stats_uptime (struct Client *source_p)
{ {
time_t now; time_t now;
now = rb_current_time() - startup_time; now = rb_current_time() - info::startup_time;
sendto_one_numeric(source_p, RPL_STATSUPTIME, sendto_one_numeric(source_p, RPL_STATSUPTIME,
form_str (RPL_STATSUPTIME), form_str (RPL_STATSUPTIME),
(int)(now / 86400), (int)((now / 3600) % 24), (int)(now / 86400), (int)((now / 3600) % 24),
@ -1575,7 +1575,7 @@ stats_servlinks (struct Client *source_p)
"? :Recv total : %s %s", "? :Recv total : %s %s",
buf, _GMKs (receiveK)); buf, _GMKs (receiveK));
uptime = (rb_current_time() - startup_time); uptime = rb_current_time() - info::startup_time;
snprintf(buf, sizeof buf, "%7.2f %s (%4.1f K/s)", snprintf(buf, sizeof buf, "%7.2f %s (%4.1f K/s)",
_GMKv (me.localClient->sendK), _GMKv (me.localClient->sendK),
_GMKs (me.localClient->sendK), _GMKs (me.localClient->sendK),

View file

@ -114,7 +114,7 @@ m_trace(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_
!ConfigServerHide.flatten_links) !ConfigServerHide.flatten_links)
sendto_one_numeric(source_p, RPL_TRACELINK, sendto_one_numeric(source_p, RPL_TRACELINK,
form_str(RPL_TRACELINK), form_str(RPL_TRACELINK),
ircd_version, info::version.c_str(),
ac2ptr ? ac2ptr->name : tname, ac2ptr ? ac2ptr->name : tname,
ac2ptr ? ac2ptr->from->name : "EEK!"); ac2ptr ? ac2ptr->from->name : "EEK!");

View file

@ -67,7 +67,7 @@ m_version(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sourc
} }
sendto_one_numeric(source_p, RPL_VERSION, form_str(RPL_VERSION), sendto_one_numeric(source_p, RPL_VERSION, form_str(RPL_VERSION),
ircd_version, serno, info::version.c_str(), info::serno.c_str(),
#ifdef CUSTOM_BRANDING #ifdef CUSTOM_BRANDING
PACKAGE_NAME "-" PACKAGE_VERSION, PACKAGE_NAME "-" PACKAGE_VERSION,
#endif #endif
@ -87,7 +87,7 @@ mo_version(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sour
if(hunt_server(client_p, source_p, ":%s VERSION :%s", 1, parc, parv) == HUNTED_ISME) if(hunt_server(client_p, source_p, ":%s VERSION :%s", 1, parc, parv) == HUNTED_ISME)
{ {
sendto_one_numeric(source_p, RPL_VERSION, form_str(RPL_VERSION), sendto_one_numeric(source_p, RPL_VERSION, form_str(RPL_VERSION),
ircd_version, serno, info::version.c_str(), info::serno.c_str(),
#ifdef CUSTOM_BRANDING #ifdef CUSTOM_BRANDING
PACKAGE_NAME "-" PACKAGE_VERSION, PACKAGE_NAME "-" PACKAGE_VERSION,
#endif #endif