]> arthur.barton.de Git - ngircd-alex.git/blobdiff - src/ngircd/conf.c
Block nicknames that are reserved for services
[ngircd-alex.git] / src / ngircd / conf.c
index b09113730ef185dff831ca6a0392c4a8d757ddcf..41b5469a8140f4c5a07d1874dd6d048fcbf6ae3b 100644 (file)
@@ -636,16 +636,42 @@ Conf_AddServer(const char *Name, UINT16 Port, const char *Host,
 }
 
 /**
- * Check if the given nick name is an service.
+ * Check if the given nick name is reserved for services on a particular server.
  *
+ * @param ConfServer The server index to check.
+ * @param Nick The nick name to check.
  * @returns true if the given nick name belongs to an "IRC service".
  */
 GLOBAL bool
-Conf_IsService(int ConfServer, const char *Nick)
+Conf_NickIsService(int ConfServer, const char *Nick)
 {
+       assert (ConfServer >= 0);
+       assert (ConfServer < MAX_SERVERS);
+
        return MatchCaseInsensitive(Conf_Server[ConfServer].svs_mask, Nick);
 }
 
+/**
+ * Check if the given nick name is blocked for "normal client" use.
+ *
+ * @param ConfServer The server index or NONE to check all configured servers.
+ * @param Nick The nick name to check.
+ * @returns true if the given nick name belongs to an "IRC service".
+ */
+GLOBAL bool
+Conf_NickIsBlocked(const char *Nick)
+{
+       int i;
+
+       for(i = 0; i < MAX_SERVERS; i++) {
+               if (!Conf_Server[i].name[0])
+                       continue;
+               if (Conf_NickIsService(i, Nick))
+                       return true;
+       }
+       return false;
+}
+
 /**
  * Initialize configuration settings with their default values.
  */
@@ -653,7 +679,7 @@ static void
 Set_Defaults(bool InitServers)
 {
        int i;
-       char random[RANDOM_SALT_LEN];
+       char random[RANDOM_SALT_LEN + 1];
 
        /* Global */
        strcpy(Conf_ServerName, "");