added cmd_netinfo
[NeonServV5.git] / ChanNode.c
index 4568e63faf51d22a1873c976c80f50ee764c40de..6869a954fb7e9833ae82971a4a74c9a6e05b84e6 100644 (file)
@@ -60,7 +60,8 @@ void init_ChanNode() {
      ---------------------------
      = 47
     */
-    chanList = calloc(47, sizeof(*chanList));
+    #define CHANNEL_LIST_SIZE 47
+    chanList = calloc(CHANNEL_LIST_SIZE, sizeof(*chanList));
     unsigned int *mode, flag = 1;
     modes_with_strarg = 0;
     modes_with_intarg = 0;
@@ -83,7 +84,7 @@ void free_ChanNode() {
     int i;
     struct ChanNode *chan, *next;
     struct ChanUser *chanuser, *next_chanuser;
-    for(i = 0; i < 47; i++) {
+    for(i = 0; i < CHANNEL_LIST_SIZE; i++) {
         for(chan = chanList[i]; chan; chan = next) {
             next = chan->next;
             for(chanuser = getChannelUsers(chan, NULL); chanuser; chanuser = next_chanuser) {
@@ -173,6 +174,28 @@ struct ChanNode* addChannel(const char *name) {
     return chan;
 }
 
+int getChannelCount() {
+    int i, count = 0;
+    struct ChanNode *chan;
+    for(i = 0; i < CHANNEL_LIST_SIZE; i++) {
+        for(chan = chanList[i]; chan; chan = chan->next) {
+            count++;
+        }
+    }
+    return count;
+}
+
+int getChanUserCount() {
+    int i, count = 0;
+    struct ChanNode *chan;
+    for(i = 0; i < CHANNEL_LIST_SIZE; i++) {
+        for(chan = chanList[i]; chan; chan = chan->next) {
+            count += chan->usercount;
+        }
+    }
+    return count;
+}
+
 void delChannel(struct ChanNode* chan, int freeChan) {
     int chanListIndex = get_chanlist_entry(chan->name[1]);
     if(chanListIndex == -1) return;