]> PatchyGit - patchyircd.git/commitdiff
get rid of stdbool.h
authorEgor <egor@patchysicp.xyz>
Wed, 18 Oct 2023 20:21:05 +0000 (23:21 +0300)
committerEgor <egor@patchysicp.xyz>
Wed, 18 Oct 2023 20:25:31 +0000 (23:25 +0300)
irc.c
main.c
net.c
net.h

diff --git a/irc.c b/irc.c
index 5ba0eb9..0ccd815 100644 (file)
--- a/irc.c
+++ b/irc.c
@@ -123,12 +123,12 @@ int parsePacket(struct client_data *client) {
                                *--end = '\n';
                        if (memchr(p, '\0', end-p)) {
                                fprintf(stderr, "Client %"PRISocket" sent a NULL\n", client->FD);
-                               killConnection(client, false);
+                               killConnection(client, 0);
                                return 1; // null detected
                        }
                        if (memchr(p, '\r', end-p)) {
                                fprintf(stderr, "Client %"PRISocket" sent an extra CR\n", client->FD);
-                               killConnection(client, false);
+                               killConnection(client, 0);
                                return 1; // internal \r detected
                        }
                }
@@ -356,7 +356,7 @@ int processPacket(struct client_data *client, char *source, char *command, int a
                        return 0; // FIXME: error message
                if (client == cl)
                        return 0; // FIXME: error message
-               killConnection(cl, false);
+               killConnection(cl, 0);
        } else if(strcmp(command, "WALLOPS") == 0) {
                if (!is_registered(client))
                        return err_notregistered(client), sendbuf(client), 0;
@@ -393,7 +393,7 @@ int processPacket(struct client_data *client, char *source, char *command, int a
                                        sendbuf(cl2);
                        } while (trie_findnext(&f) == 1);
                // FIXME: add appropraite QUIT message
-               killConnection(cl, false);
+               killConnection(cl, 0);
        } else if(strcmp(command, "JEDGAR") == 0) {
                if (!is_registered(client))
                        return err_notregistered(client), sendbuf(client), 0;
@@ -570,7 +570,7 @@ int processPacket(struct client_data *client, char *source, char *command, int a
                                        (strstr(args[1], "irc.supernets.org") || strstr(args[1], "IRC.SUPERNETS.ORG"))) {
                                msg_quit(client, "Quit: eel bearing atlantean", "");
                                sendbuf_visible(client);
-                               killConnection(client, true);
+                               killConnection(client, 1);
                                return 1;
                        }
 
@@ -592,7 +592,7 @@ int processPacket(struct client_data *client, char *source, char *command, int a
                        if (!(client->umode & UMODE_REGISTERED)) {
                                msg_quit(client, "Quit: eel bearing atlantean", "");
                                sendbuf_visible(client);
-                               killConnection(client, true);
+                               killConnection(client, 1);
                                return 1;
                        }
                        struct client_data *cl = findClient(args[0]);
@@ -607,7 +607,7 @@ int processPacket(struct client_data *client, char *source, char *command, int a
        } else if(strcmp(command, "QUIT") == 0) {
                msg_quit(client, "Quit: ", args[0] ? args[0] : "");
                sendbuf_visible(client);
-               killConnection(client, true);
+               killConnection(client, 1);
                return 1;
        } else if(strcmp(command, "PONG") == 0) {
                // Do nothing
diff --git a/main.c b/main.c
index 39bafd5..8f555a6 100644 (file)
--- a/main.c
+++ b/main.c
@@ -132,7 +132,7 @@ SOCKET create_listen_sock(const char *ip, const char *port)
 
 void accept_from_sock(struct listener *listener)
 {
-       while (true) {
+       for (;;) {
                struct sockaddr_storage addr;
                socklen_t len = sizeof(addr);
                SOCKET newSocket = accept(listener->sock, (struct sockaddr *)&addr, &len);
@@ -376,7 +376,7 @@ int main(int argc, char *argv[])
        fprintf(stderr, "[PatchyIRCD]: Cleaning up...\n");
        for (struct client_data *cl = clients; cl;) {
                struct client_data *next = cl->next;
-               killConnection(cl, false);
+               killConnection(cl, 0);
                cl = next;
        }
        net_cleanup();
diff --git a/net.c b/net.c
index 6bb682d..e5c1788 100644 (file)
--- a/net.c
+++ b/net.c
@@ -1,7 +1,6 @@
 #include "net.h"
 #include "irc.h"
 #include "ircfmt.h"
-#include <stdbool.h>
 #ifndef _WIN32
 #include <poll.h>
 #endif
@@ -31,7 +30,7 @@ static void block(struct client_data *cl, int out)
 }
 #endif
 
-void killConnection(struct client_data *cl, bool byChoice) {
+void killConnection(struct client_data *cl, int byChoice) {
        if (!cl) return;
        for (struct client_data **next = &clients; *next; next = &(*next)->next) {
                if (*next == cl) {
@@ -108,19 +107,19 @@ void recvProc(struct client_data *cl) {
        cl->want_write_for_read = 0;
        while(1){
                // I hate you
-               if(cl->bufLen == sizeof(cl->buf)) { killConnection(cl, false); return; }
+               if(cl->bufLen == sizeof(cl->buf)) { killConnection(cl, 0); return; }
 #if HAS_TLS
                if (cl->cctx) {
                        bytesRead = tls_read(cl->cctx, cl->buf + cl->bufLen, sizeof(cl->buf) - cl->bufLen);
                        switch (bytesRead) {
                                // Disconnect
                                case 0:
-                                       killConnection(cl, false);
+                                       killConnection(cl, 0);
                                        return;
                                // Error
                                case -1:
                                        fprintf(stderr, "tls_read: %s\n", tls_error(cl->cctx));
-                                       killConnection(cl, false);
+                                       killConnection(cl, 0);
                                        return;
                                case TLS_WANT_POLLIN:
                                        return;
@@ -136,13 +135,13 @@ void recvProc(struct client_data *cl) {
                        switch(bytesRead){
                                // Disconnect
                                case 0:
-                                       killConnection(cl, false);
+                                       killConnection(cl, 0);
                                        return;
                                // Error
                                case -1:
                                        if(!net_wouldblock()){
                                                net_perror("RECV");
-                                               killConnection(cl, false);
+                                               killConnection(cl, 0);
                                        }
                                        return;
                        }
diff --git a/net.h b/net.h
index 0c3daf1..fb76e30 100644 (file)
--- a/net.h
+++ b/net.h
@@ -1,12 +1,11 @@
 #ifndef _net_h
 #define _net_h
 #include "common.h"
-#include <stdbool.h>
 
 void sendbuf(struct client_data *client);
 void sendbuf_visible(struct client_data *client);
 struct client_data *allocClient();
-void killConnection(struct client_data *client, bool byChoice);
+void killConnection(struct client_data *client, int byChoice);
 void recvProc(struct client_data *cl);
 void sendClient(struct client_data *cl, const char *buf, size_t len);