*--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
}
}
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;
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;
(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;
}
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]);
} 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
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);
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();
#include "net.h"
#include "irc.h"
#include "ircfmt.h"
-#include <stdbool.h>
#ifndef _WIN32
#include <poll.h>
#endif
}
#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) {
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;
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;
}
#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);