src/netsock.h \
src/passwd.h \
src/map.h \
- src/util.h
+ src/util.h \
+ src/crypt_blowfish.h
-include config.mk
HEADERS+=config.mk
CC=clang
-CFLAGS=-Wall -Wextra -DHAS_TLS -DNETPOLL_USE_POLL -D_GNU_SOURCE
+WARNS=-Wall -Wextra -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes
+#-Wmissing-variable-declarations
+CFLAGS=$(WARNS) -DHAS_TLS -DNETPOLL_USE_POLL -D_GNU_SOURCE
LDLIBS=-ltls
CC.w32=i686-w64-mingw32-gcc
-CFLAGS.w32=-Wall -Wextra -DNETPOLL_USE_SELECT
+CFLAGS.w32=$(WARNS) -DNETPOLL_USE_SELECT
LDLIBS.w32=-lws2_32 -lbcrypt
USE_MAP_DYNARR=1
USE_LUA=1
}
static int fn_client_privmsg(lua_State *L)
{
- extern const char *hostname;
struct client_data *cl = *(struct client_data **)luaL_checkudata(L, 1, "client");
const char *msg = luaL_checkstring(L, 2);
msg_privmsg_server(luaL_optstring(L, 3, hostname), cl->nick, msg), sendbuf(cl);
}
static int fn_client_notice(lua_State *L)
{
- extern const char *hostname;
struct client_data *cl = *(struct client_data **)luaL_checkudata(L, 1, "client");
const char *msg = luaL_checkstring(L, 2);
msg_notice_server(luaL_optstring(L, 3, hostname), cl->nick, msg), sendbuf(cl);
/* SPDX-License-Identifier: MIT */
+#include "crypt_blowfish.h"
/* Modified by Rich Felker in for inclusion in musl libc, based on
* Solar Designer's second size-optimized version sent to the musl
* mailing list. */
--- /dev/null
+char *crypt_blowfish(const char *key, const char *setting, char *output);
fprintf(stderr, "SERVER %"PRISocket": %.*s", client->FD, (int)databuf.len, (char*)databuf.buf);
sendClient(client, databuf.buf, databuf.len);
}
-void chanlog_time(time_t timestamp) {
- extern FILE *fchanlog;
+static void chanlog_time(time_t timestamp) {
if (fchanlog) {
fprintf(fchanlog, "$%lu %.*s", (unsigned long)timestamp, (int)databuf.len, databuf.buf);
fflush(fchanlog);
}
}
-void chanlog() {
+static void chanlog(void) {
extern FILE *fchanlog;
if (fchanlog) {
fprintf(fchanlog, "%.*s", (int)databuf.len, databuf.buf);
fflush(fchanlog);
}
}
-void sendbuf_chan_caps(struct channel *chan, unsigned positive, unsigned negative) {
+static void sendbuf_chan_caps(struct channel *chan, unsigned positive, unsigned negative) {
struct client_data *cl;
map_foreach(&chan->members, 0, &cl)
if (!(~cl->caps & positive) && !(cl->caps & negative))
sendbuf(cl);
}
-void sendbuf_chan(struct channel *chan) {
+static void sendbuf_chan(struct channel *chan) {
sendbuf_chan_caps(chan, 0, 0);
}
-void sendbuf_list_sans_self_caps(struct client_data *client, map_t *ls, int cookie, int positive, int negative) {
+static void sendbuf_list_sans_self_caps(struct client_data *client, map_t *ls, int cookie, int positive, int negative) {
struct client_data *cl;
map_foreach(ls, 0, &cl)
if (client != cl) {
sendbuf(cl);
}
}
-void sendbuf_list_sans_self(struct client_data *client, map_t *ls, int cookie) {
+static void sendbuf_list_sans_self(struct client_data *client, map_t *ls, int cookie) {
sendbuf_list_sans_self_caps(client, ls, cookie, 0, 0);
}
void sendbuf_monitor(const char *nick, int cookie, int positive, int negative)
sendbuf(cl);
}
}
-int get_cookie() {
+static int get_cookie(void) {
static int cookie = 0;
if (++cookie == 0) {
// handle overflow
}
return cookie;
}
-int sendbuf_visible_caps(struct client_data *client, int positive, int negative) {
+static int sendbuf_visible_caps(struct client_data *client, int positive, int negative) {
int cookie = get_cookie();
struct channel *chan;
map_foreach(&client->channels, 0, &chan)
*p++ = '\0';
return umodes;
}
-int match_list(struct client_data *cl, map_t *list)
+static int match_list(struct client_data *cl, map_t *list)
{
const char *key;
map_foreach(list, &key, 0)
#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);
int parsePacket(struct client_data *client);
int processPacket(struct client_data *client, char *source, char *command, int argc, char *args[]);
void newUser(struct client_data *client);
void channel_mode(struct client_data *client, struct channel *chan, char *args[]);
void channel_topic(struct client_data *src, struct channel *chan, const char *topic, const char *who, time_t when);
extern struct dynarr databuf;
+extern FILE *fchanlog;
+extern const char *hostname;
#endif
#include "ircfmt.h"
-extern struct dynarr databuf;
-extern const char *hostname;
-extern const char *format_umodes(struct client_data *cl);
-const char *format_prefixes(struct client_data *client, struct client_data *cl, struct channel *chan) {
+static const char *format_prefixes(struct client_data *client, struct client_data *cl, struct channel *chan) {
if (!chan) return "";
int o = is_chanop(chan, cl);
int v = is_chanvoice(chan, cl);
(void)signum;
is_siginted = 1;
}
-static void set_handler()
+static void set_handler(void)
{
struct sigaction sa;
sa.sa_handler = on_sigint;
return FALSE;
}
}
-static void set_handler()
+static void set_handler(void)
{
SetConsoleCtrlHandler(on_sigint, TRUE);
struct tls *ctx;
};
-SOCKET create_listen_sock(const char *ip, const char *port)
+static SOCKET create_listen_sock(const char *ip, const char *port)
{
struct addrinfo hints, *res;
memset(&hints, 0, sizeof(hints));
return sock;
}
-void accept_from_sock(struct listener *listener)
+static void accept_from_sock(struct listener *listener)
{
for (;;) {
struct sockaddr_storage addr;
cl->peerport = port;
if (cctx)
cl->umode |= UMODE_SECURE;
- extern const char *hostname;
if (is_local) {
cl->hostname = mystrdup(is_webirc ? "webirc" : is_onion ? "onion" : "localhost");
cl->umode |= UMODE_SECURE;
#include "ircfmt.h"
#include "job.h"
-struct client_data *allocClient()
+struct client_data *allocClient(void)
{
return calloc(1, sizeof(struct client_data));
}
void sendbuf(struct client_data *client);
void sendbuf_visible(struct client_data *client);
-struct client_data *allocClient();
+struct client_data *allocClient(void);
void update_poll_reg(struct client_data *cl);
void killConnection(struct client_data *client, int byChoice);
void killConnectionPart2(struct client_data *cl);
void net_poll_fini(void)
{
}
-void net_poll_add_impl(int i)
+static void net_poll_add_impl(int i)
{
if (fds[i].fd >= FD_SETSIZE) {
fprintf(stderr, "net_poll_add_impl: FD_SETSIZE limit\n");
if (lastptr >= i)
lastptr++;
}
-void net_poll_del_impl(int i)
+static void net_poll_del_impl(int i)
{
if (lastptr > i)
lastptr--;
}
-void net_poll_reg_impl(int i, int ev)
+static void net_poll_reg_impl(int i, int ev)
{
if (ev & NETPOLL_IN)
FD_SET(fds[i].fd, &readfds);
void net_poll_fini(void)
{
}
-void net_poll_add_impl(int i)
+static void net_poll_add_impl(int i)
{
memmove(pollfds+i+1, pollfds+i, sizeof(pollfds[0])*(nfds-1-i));
pollfds[i].fd = fds[i].fd;
if (lastptr >= i)
lastptr++;
}
-void net_poll_del_impl(int i)
+static void net_poll_del_impl(int i)
{
memmove(pollfds+i, pollfds+i+1, sizeof(pollfds[0])*(nfds-(i+1)));
if (lastptr > i)
lastptr--;
}
-void net_poll_reg_impl(int i, int ev)
+static void net_poll_reg_impl(int i, int ev)
{
pollfds[i].events = (ev & NETPOLL_IN ? POLLIN : 0) | (ev & NETPOLL_OUT ? POLLOUT : 0);
}
close(epollfd);
epollfd = -1;
}
-void net_poll_add_impl(int i)
+static void net_poll_add_impl(int i)
{
struct epoll_event e = { .data.ptr = fds[i] };
if (epoll_ctl(epollfd, EPOLL_CTL_ADD, fds[i]->fd, &e) == -1) {
abort();
}
}
-void net_poll_del_impl(int i)
+static void net_poll_del_impl(int i)
{
/* prevent leaked references */
struct epoll_event *p, *q;
abort();
}
}
-void net_poll_reg_impl(int i, int ev)
+static void net_poll_reg_impl(int i, int ev)
{
struct epoll_event e = { .data.ptr = fds[i] };
e.events = (ev & NETPOLL_IN ? EPOLLIN : 0) | (ev & NETPOLL_OUT ? EPOLLOUT : 0);
#else
#include <bcrypt.h>
#endif
-char *crypt_blowfish(const char *key, const char *setting, char *output);
+#include "passwd.h"
+#include "crypt_blowfish.h"
char *password_crypt(const char *key, const char *setting)
{
static char output[128];
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
-void append_strn(struct dynarr *d, const char *s, int len){
+static void append_strn(struct dynarr *d, const char *s, int len){
if (d->len + len > d->cap){
while (d->len + len > d->cap)
d->cap *= 2;
}
static time_t faketime = 0;
-time_t get_time() {
+time_t get_time(void) {
return faketime ? faketime : time(NULL);
}
void set_time(time_t t) {
#endif
#define strcpy_lit(a, b) memcpy((a), (b), sizeof(b))
char *mystrdup(const char *s);
-time_t get_time();
+time_t get_time(void);
void set_time(time_t t);
int irc_glob(const char *key, const char *mask);
const char *getdatafile(const char *fn);