src/map.cpp src/map.h \
src/net.cpp src/net.h \
src/netpoll.cpp src/netpoll.h \
- src/netsock.h \
src/passwd.cpp src/passwd.h \
src/util.cpp src/util.h \
src/main.cpp
// Copyright (c) 2023-2025 Egor
// SPDX-License-Identifier: GPL-2.0-or-later
+#include "common.h"
#ifdef HAVE_LUA
#include "admin.h"
#include "irc.h"
-// Copyright (c) 2023-2024 Egor
+// Copyright (c) 2023-2025 Egor
// SPDX-License-Identifier: GPL-2.0-or-later
#ifndef ADMIN_H_
#define ADMIN_H_
#ifdef HAVE_LUA
-#include "common.h"
void admin_init(void);
void admin_fini(void);
int admin_command(struct client_data *client, char *source, char *command, int argc, char *args[]);
// SPDX-License-Identifier: GPL-2.0-or-later
#ifndef COMMON_H_
#define COMMON_H_
-#include "netsock.h"
-#include "netpoll.h"
-#include "map.h"
+
+/* C standard */
+#include <errno.h>
+#include <locale.h>
+#include <signal.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
#include <time.h>
+
+/* POSIX */
+#include <arpa/inet.h>
+#include <fcntl.h>
+#include <netdb.h>
+#include <netinet/in.h>
+#include <sys/socket.h>
+#include <sys/time.h>
+#include <sys/wait.h>
+#include <unistd.h>
+
+/* C++ standard */
+#include <algorithm>
+#include <deque>
+#include <iterator>
+#include <utility>
+#include <vector>
+
+/* libraries */
#ifdef HAVE_LIBTLS
#include <tls.h>
#else
struct tls;
#endif
+#include <uv.h>
+
+#include "netpoll.h"
+#include "map.h"
#define MAX_NICKLEN 32
#define MAX_CHANLEN 33
// Copyright (c) 2022, 2024 Sam Smith
// Copyright (c) 2022-2025 Egor
// SPDX-License-Identifier: GPL-2.0-or-later
+#include "common.h"
#include "irc.h"
#include "ircfmt.h"
#include "passwd.h"
// Copyright (c) 2022 Sam Smith
-// Copyright (c) 2022-2024 Egor
+// Copyright (c) 2022-2025 Egor
// SPDX-License-Identifier: GPL-2.0-or-later
#ifndef IRC_H_
#define IRC_H_
-
-#include "common.h"
#include "net.h"
#include "util.h"
-
#define is_registered(cl) ((cl)->regstate == REG_REGISTERED)
void sendbuf_monitor(const char *nick, int cookie, int positive, int negative);
const char *format_umodes(struct client_data *cl);
// Copyright (c) 2022-2025 Egor
// SPDX-License-Identifier: GPL-2.0-or-later
+#include "common.h"
#include "ircfmt.h"
static const char *format_prefixes(struct client_data *client, struct client_data *cl, struct channel *chan) {
if (!chan) return "";
#include "common.h"
#include "job.h"
#include "passwd.h"
-#include <unistd.h>
-#include <signal.h>
-#include <sys/wait.h>
-#include <uv.h>
-#include <deque>
struct jobent {
struct client_data *client;
#include "net.h"
#include "irc.h"
#include "job.h"
-#include <locale.h>
-#include <vector>
static int is_running = 1;
// SPDX-License-Identifier: GPL-2.0-or-later
#include "common.h"
#include "map.h"
-#include <stdlib.h>
-#include <string.h>
-#include <algorithm>
static int ent_find(map_base *root, const char *key, int *found)
{
auto it = std::partition_point(root->ptr, root->ptr + root->len,
// SPDX-License-Identifier: GPL-2.0-or-later
#ifndef MAP_H_
#define MAP_H_
-#include <stdlib.h>
-#include <utility>
-#include <iterator>
#include "util.h"
/* A map abstract data type with following properties:
// Copyright (c) 2022 Sam Smith
// Copyright (c) 2022-2025 Egor
// SPDX-License-Identifier: GPL-2.0-or-later
-#include <stdarg.h>
+#include "common.h"
#include "net.h"
#include "irc.h"
#include "ircfmt.h"
// SPDX-License-Identifier: GPL-2.0-or-later
#ifndef NET_H_
#define NET_H_
-#include "common.h"
-
void sendbuf(struct client_data *client);
void sendbuf_visible(struct client_data *client);
void update_poll_reg(struct client_data *cl);
void killConnectionPart2(struct client_data *cl);
void read_proc(struct client_data *cl);
void sendClient(struct client_data *cl, const char *buf, size_t len);
-
#endif
// Copyright (c) 2023-2025 Egor
// SPDX-License-Identifier: GPL-2.0-or-later
+#include "common.h"
#include "netpoll.h"
#include "util.h"
-#include <algorithm>
-#include <vector>
-
#define container_of(ptr, type, member) ((type *)((char *)(ptr) - offsetof(type, member)))
namespace netpoll {
// SPDX-License-Identifier: GPL-2.0-or-later
#ifndef NETPOLL_H_
#define NETPOLL_H_
-#include "netsock.h"
-#include <uv.h>
namespace netpoll {
struct event {
void *assoc;
void begin(void);
bool get(event &out);
}
-
#define SOCKTYPE_LISTENER 0
#define SOCKTYPE_CLIENT 1
#define SOCKTYPE_DYING 2
#define SOCKTYPE_MAX 3
-
#endif
+++ /dev/null
-// Copyright (c) 2022 Sam Smith
-// Copyright (c) 2022-2025 Egor
-// SPDX-License-Identifier: GPL-2.0-or-later
-#ifndef NETSOCK_H_
-#define NETSOCK_H_
-
-/* API comparision table
- * | POSIX | Win32 | NetSock |
- * |--------------------|-------------------|------------------|
- * | int | SOCKET | SOCKET |
- * | "%d" | (complicated) | "%"PRISocket |
- * | -1 | INVALID_SOCKET | INVALID_SOCKET |
- * | errno | WSAGetLastError() | net_errno() |
- * | strerror | (complicated) | net_strerror() |
- * | perror | (complicated) | net_perror() |
- * | EAGAIN | WSAEWOULDBLOCK | net_wouldblock() |
- * | (none) | WSAStartup() | net_init() |
- * | (none) | WSACleanup() | net_cleanup() |
- * | close() | closesocket() | closesocket() |
- * | ioctl() | ioctlsocket() | ioctlsocket() |
- * | SHUT_RD | SD_RECEIVE | SHUT_RD |
- * | SHUT_WR | SD_SEND | SHUT_WR |
- * | SHUT_RDWR | SD_BOTH | SHUT_RDWR |
- * | O_NONBLOCK/FIONBIO | FIONBIO | net_nonblock() |
- * | read/recv | recv | recv |
- * | write/send | send | send |
- * | accept4 | accept | accept4 |
- * | SOCK_CLOEXEC | (none) | SOCK_CLOEXEC |
- * | "e" | (none) | FOPEN_CLOEXEC |
- */
-
-/* Standard headers */
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-
-/* POSIX */
-#include <unistd.h>
-#include <netinet/in.h>
-#include <sys/socket.h>
-#include <sys/time.h>
-#include <sys/select.h>
-#include <arpa/inet.h>
-#include <netdb.h>
-#include <fcntl.h>
-#include <signal.h>
-#endif
// Copyright (c) 2022 Sam Smith
// Copyright (c) 2022-2025 Egor
// SPDX-License-Identifier: GPL-2.0-or-later
+#include "common.h"
#include "util.h"
#include <stdio.h>
#include <string.h>
// SPDX-License-Identifier: GPL-2.0-or-later
#ifndef UTIL_H_
#define UTIL_H_
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-#include <vector>
void append_str(std::vector<char> *v, const char *s);
void append_strf(std::vector<char> *v, const char *s, ...);
#define copy_strf(d, ...) append_strf(((d)->clear(), (d)), __VA_ARGS__)