Commit Diff
Diff:
588af510a35b5b28cb8c1063ac865f86c65d7a8a
f68aa02272d05ffbceea9e0188984d9bf9b83dd1
Commit:
f68aa02272d05ffbceea9e0188984d9bf9b83dd1
Tree:
62fa6c43f46112e86acdbdf653696fab3a9c4793
Author:
Alexander Barton <alex@barton.de>
Committer:
Alexander Barton <alex@barton.de>
Date:
Mon Dec 31 18:29:52 2012 UTC
Message:
Implement new configuration option "HelpFile" This new configuration option allows to specify a specially formatted text file which can be used by the HELP command to provide information about the commands and their syntaxes.
blob - 423221cbbb108262e10de17e37b8e66a82712e2b
blob + fa1bfba1da4d0872d39e016da6aa71982174216d
--- src/ngircd/conf.c
+++ src/ngircd/conf.c
@@ -54,6 +54,7 @@ static CONF_SERVER New_Server;
static int New_Server_Idx;
static char Conf_MotdFile[FNAME_LEN];
+static char Conf_HelpFile[FNAME_LEN];
static void Set_Defaults PARAMS(( bool InitServers ));
static bool Read_Config PARAMS(( bool TestOnly, bool IsStarting ));
@@ -316,6 +317,7 @@ Conf_Test( void )
printf(" AdminInfo1 = %s\n", Conf_ServerAdmin1);
printf(" AdminInfo2 = %s\n", Conf_ServerAdmin2);
printf(" AdminEMail = %s\n", Conf_ServerAdminMail);
+ printf(" HelpFile = %s\n", Conf_HelpFile);
printf(" Info = %s\n", Conf_ServerInfo);
printf(" Listen = %s\n", Conf_ListenAddress);
if (Using_MotdFile) {
@@ -701,8 +703,11 @@ Set_Defaults(bool InitServers)
Conf_ListenAddress = NULL;
array_free(&Conf_ListenPorts);
array_free(&Conf_Motd);
+ array_free(&Conf_Helptext);
strlcpy(Conf_MotdFile, SYSCONFDIR, sizeof(Conf_MotdFile));
strlcat(Conf_MotdFile, MOTD_FILE, sizeof(Conf_MotdFile));
+ strlcpy(Conf_HelpFile, SYSCONFDIR, sizeof(Conf_HelpFile));
+ strlcat(Conf_HelpFile, HELP_FILE, sizeof(Conf_HelpFile));
strcpy(Conf_ServerPwd, "");
strlcpy(Conf_PidFile, PID_FILE, sizeof(Conf_PidFile));
Conf_UID = Conf_GID = 0;
@@ -1047,6 +1052,12 @@ Read_Config(bool TestOnly, bool IsStarting)
Using_MotdFile = true;
}
+ /* Try to read ngIRCd help text file. */
+ (void)Read_TextFile(Conf_HelpFile, "help text", &Conf_Helptext);
+ if (!array_bytes(&Conf_Helptext))
+ Config_Error(LOG_WARNING,
+ "No help text available, HELP command will be of limited use.");
+
#ifdef SSL_SUPPORT
/* Make sure that all SSL-related files are readable */
CheckFileReadable("CertFile", Conf_SSLOptions.CertFile);
@@ -1312,6 +1323,12 @@ Handle_GLOBAL( int Line, char *Var, char *Arg )
Config_Error_TooLong(Line, Var);
return;
}
+ if (strcasecmp(Var, "HelpFile") == 0) {
+ len = strlcpy(Conf_HelpFile, Arg, sizeof(Conf_HelpFile));
+ if (len >= sizeof(Conf_HelpFile))
+ Config_Error_TooLong(Line, Var);
+ return;
+ }
if (strcasecmp(Var, "Listen") == 0) {
if (Conf_ListenAddress) {
Config_Error(LOG_ERR,
blob - f85a25fa08920a2945c02603d2c8d05cc0dde086
blob + ac42746c3a6872202435084bb55eaae544b7709f
--- src/ngircd/conf.h
+++ src/ngircd/conf.h
@@ -111,6 +111,9 @@ GLOBAL char Conf_ServerAdminMail[CLIENT_INFO_LEN];
/** Message of the day (MOTD) of this server */
GLOBAL array Conf_Motd;
+/** Help text of this server */
+GLOBAL array Conf_Helptext;
+
/** Array of ports this server should listen on */
GLOBAL array Conf_ListenPorts;
blob - ad9716fdefb6f2e807d7567911df146f4a43bfd4
blob + 28a260b86024acabba0530eb79d732ab965d5a56
--- src/ngircd/defines.h
+++ src/ngircd/defines.h
@@ -77,6 +77,9 @@
/** Name of the MOTD file. */
#define MOTD_FILE "/ngircd.motd"
+/** Name of the help file. */
+#define HELP_FILE "/ngircd.help"
+
/** Default chroot() directory. */
#define CHROOT_DIR ""
IRCNow