]> arthur.barton.de Git - ngircd.git/commitdiff
Implement new configuration option "HelpFile"
authorAlexander Barton <alex@barton.de>
Mon, 31 Dec 2012 18:29:52 +0000 (19:29 +0100)
committerAlexander Barton <alex@barton.de>
Mon, 31 Dec 2012 18:29:52 +0000 (19:29 +0100)
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.

src/ngircd/conf.c
src/ngircd/conf.h
src/ngircd/defines.h

index 423221cbbb108262e10de17e37b8e66a82712e2b..fa1bfba1da4d0872d39e016da6aa71982174216d 100644 (file)
@@ -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,
index f85a25fa08920a2945c02603d2c8d05cc0dde086..ac42746c3a6872202435084bb55eaae544b7709f 100644 (file)
@@ -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;
 
index ad9716fdefb6f2e807d7567911df146f4a43bfd4..28a260b86024acabba0530eb79d732ab965d5a56 100644 (file)
@@ -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 ""