2020-02-01 06:18:01 +00:00
|
|
|
/* Copyright (C) 2020 C. McEnroe <june@causal.agency>
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2020-06-08 21:48:07 +00:00
|
|
|
*
|
|
|
|
* Additional permission under GNU GPL version 3 section 7:
|
|
|
|
*
|
|
|
|
* If you modify this Program, or any covered work, by linking or
|
2020-08-04 16:19:14 +00:00
|
|
|
* combining it with OpenSSL (or a modified version of that library),
|
2020-06-08 21:48:07 +00:00
|
|
|
* containing parts covered by the terms of the OpenSSL License and the
|
|
|
|
* original SSLeay license, the licensors of this Program grant you
|
|
|
|
* additional permission to convey the resulting work. Corresponding
|
|
|
|
* Source for a non-source form of such a combination shall include the
|
2020-08-04 16:19:14 +00:00
|
|
|
* source code for the parts of OpenSSL used as well as that of the
|
2020-06-08 21:48:07 +00:00
|
|
|
* covered work.
|
2020-02-01 06:18:01 +00:00
|
|
|
*/
|
|
|
|
|
2020-02-17 00:12:19 +00:00
|
|
|
#include <assert.h>
|
2020-09-01 22:05:17 +00:00
|
|
|
#include <ctype.h>
|
2020-02-01 07:33:17 +00:00
|
|
|
#include <err.h>
|
2020-02-06 03:49:56 +00:00
|
|
|
#include <getopt.h>
|
2020-02-17 00:12:19 +00:00
|
|
|
#include <stdarg.h>
|
2020-02-01 06:18:01 +00:00
|
|
|
#include <stdbool.h>
|
2020-02-02 07:31:20 +00:00
|
|
|
#include <stdint.h>
|
2020-02-17 00:12:19 +00:00
|
|
|
#include <stdio.h>
|
2020-02-01 07:33:17 +00:00
|
|
|
#include <string.h>
|
2021-08-26 16:59:57 +00:00
|
|
|
#include <strings.h>
|
2020-02-01 07:33:17 +00:00
|
|
|
#include <sysexits.h>
|
|
|
|
#include <time.h>
|
2020-02-05 05:20:39 +00:00
|
|
|
#include <wchar.h>
|
2020-02-01 06:18:01 +00:00
|
|
|
|
|
|
|
#define ARRAY_LEN(a) (sizeof(a) / sizeof(a[0]))
|
|
|
|
#define BIT(x) x##Bit, x = 1 << x##Bit, x##Bit_ = x##Bit
|
|
|
|
|
2020-02-16 03:19:55 +00:00
|
|
|
typedef unsigned uint;
|
2020-02-01 06:18:01 +00:00
|
|
|
typedef unsigned char byte;
|
|
|
|
|
2021-06-07 04:08:59 +00:00
|
|
|
static inline char *seprintf(char *ptr, char *end, const char *fmt, ...)
|
|
|
|
__attribute__((format(printf, 3, 4)));
|
|
|
|
static inline char *seprintf(char *ptr, char *end, const char *fmt, ...) {
|
|
|
|
va_list ap;
|
|
|
|
va_start(ap, fmt);
|
|
|
|
int n = vsnprintf(ptr, end - ptr, fmt, ap);
|
|
|
|
va_end(ap);
|
|
|
|
if (n < 0) return NULL;
|
2021-06-09 21:34:57 +00:00
|
|
|
if (n > end - ptr) return end;
|
|
|
|
return ptr + n;
|
2021-06-07 04:08:59 +00:00
|
|
|
}
|
|
|
|
|
2020-09-01 22:05:17 +00:00
|
|
|
enum Attr {
|
|
|
|
BIT(Bold),
|
|
|
|
BIT(Reverse),
|
|
|
|
BIT(Italic),
|
|
|
|
BIT(Underline),
|
|
|
|
};
|
2020-02-02 08:27:50 +00:00
|
|
|
enum Color {
|
|
|
|
White, Black, Blue, Green, Red, Brown, Magenta, Orange,
|
|
|
|
Yellow, LightGreen, Cyan, LightCyan, LightBlue, Pink, Gray, LightGray,
|
|
|
|
Default = 99,
|
2020-02-11 22:43:36 +00:00
|
|
|
ColorCap,
|
2020-02-02 08:27:50 +00:00
|
|
|
};
|
2020-09-01 22:05:17 +00:00
|
|
|
struct Style {
|
|
|
|
enum Attr attr;
|
|
|
|
enum Color fg, bg;
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct Style StyleDefault = { 0, Default, Default };
|
|
|
|
enum { B = '\2', C = '\3', O = '\17', R = '\26', I = '\35', U = '\37' };
|
|
|
|
|
|
|
|
static inline size_t styleParse(struct Style *style, const char **str) {
|
|
|
|
switch (**str) {
|
|
|
|
break; case B: (*str)++; style->attr ^= Bold;
|
|
|
|
break; case O: (*str)++; *style = StyleDefault;
|
|
|
|
break; case R: (*str)++; style->attr ^= Reverse;
|
|
|
|
break; case I: (*str)++; style->attr ^= Italic;
|
|
|
|
break; case U: (*str)++; style->attr ^= Underline;
|
|
|
|
break; case C: {
|
|
|
|
(*str)++;
|
|
|
|
if (!isdigit(**str)) {
|
|
|
|
style->fg = Default;
|
|
|
|
style->bg = Default;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
style->fg = *(*str)++ - '0';
|
|
|
|
if (isdigit(**str)) style->fg = style->fg * 10 + *(*str)++ - '0';
|
|
|
|
if ((*str)[0] != ',' || !isdigit((*str)[1])) break;
|
|
|
|
(*str)++;
|
|
|
|
style->bg = *(*str)++ - '0';
|
|
|
|
if (isdigit(**str)) style->bg = style->bg * 10 + *(*str)++ - '0';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return strcspn(*str, (const char[]) { B, C, O, R, I, U, '\0' });
|
|
|
|
}
|
2020-02-02 08:27:50 +00:00
|
|
|
|
2021-06-07 04:09:58 +00:00
|
|
|
static inline void styleStrip(char *buf, size_t cap, const char *str) {
|
|
|
|
*buf = '\0';
|
|
|
|
char *ptr = buf, *end = &buf[cap];
|
2020-10-09 22:45:52 +00:00
|
|
|
struct Style style = StyleDefault;
|
|
|
|
while (*str) {
|
|
|
|
size_t len = styleParse(&style, &str);
|
2021-06-07 04:09:58 +00:00
|
|
|
ptr = seprintf(ptr, end, "%.*s", (int)len, str);
|
2020-10-09 22:45:52 +00:00
|
|
|
str += len;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-01 07:33:17 +00:00
|
|
|
enum { None, Debug, Network, IDCap = 256 };
|
|
|
|
extern char *idNames[IDCap];
|
2020-02-02 08:27:50 +00:00
|
|
|
extern enum Color idColors[IDCap];
|
2020-02-16 03:19:55 +00:00
|
|
|
extern uint idNext;
|
2020-02-01 07:33:17 +00:00
|
|
|
|
2020-02-16 03:19:55 +00:00
|
|
|
static inline uint idFind(const char *name) {
|
|
|
|
for (uint id = 0; id < idNext; ++id) {
|
2021-08-26 16:59:57 +00:00
|
|
|
if (!strcasecmp(idNames[id], name)) return id;
|
2020-02-01 07:33:17 +00:00
|
|
|
}
|
|
|
|
return None;
|
|
|
|
}
|
2020-02-02 08:27:50 +00:00
|
|
|
|
2020-02-16 03:19:55 +00:00
|
|
|
static inline uint idFor(const char *name) {
|
|
|
|
uint id = idFind(name);
|
2020-02-01 07:33:17 +00:00
|
|
|
if (id) return id;
|
2020-02-08 06:14:41 +00:00
|
|
|
if (idNext == IDCap) return Network;
|
2020-02-01 07:33:17 +00:00
|
|
|
idNames[idNext] = strdup(name);
|
2020-02-06 09:19:56 +00:00
|
|
|
idColors[idNext] = Default;
|
2020-02-17 04:05:43 +00:00
|
|
|
if (!idNames[idNext]) err(EX_OSERR, "strdup");
|
2020-02-01 07:33:17 +00:00
|
|
|
return idNext++;
|
|
|
|
}
|
|
|
|
|
2020-02-11 22:41:06 +00:00
|
|
|
extern uint32_t hashInit;
|
2021-01-09 22:58:29 +00:00
|
|
|
extern uint32_t hashBound;
|
2021-05-27 15:45:47 +00:00
|
|
|
static inline uint32_t _hash(const char *str) {
|
2020-02-11 22:41:06 +00:00
|
|
|
if (*str == '~') str++;
|
|
|
|
uint32_t hash = hashInit;
|
|
|
|
for (; *str; ++str) {
|
|
|
|
hash = (hash << 5) | (hash >> 27);
|
|
|
|
hash ^= *str;
|
|
|
|
hash *= 0x27220A95;
|
|
|
|
}
|
2021-05-27 15:45:47 +00:00
|
|
|
return hash;
|
|
|
|
}
|
|
|
|
static inline enum Color hash(const char *str) {
|
|
|
|
if (hashBound < Blue) return Default;
|
|
|
|
return Blue + _hash(str) % (hashBound + 1 - Blue);
|
2020-02-11 22:41:06 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 04:05:43 +00:00
|
|
|
extern struct Network {
|
|
|
|
char *name;
|
2020-03-23 17:13:43 +00:00
|
|
|
uint userLen;
|
|
|
|
uint hostLen;
|
2020-02-17 04:05:43 +00:00
|
|
|
char *chanTypes;
|
2021-04-02 21:03:10 +00:00
|
|
|
char *statusmsg;
|
2020-02-17 04:05:43 +00:00
|
|
|
char *prefixes;
|
|
|
|
char *prefixModes;
|
|
|
|
char *listModes;
|
|
|
|
char *paramModes;
|
|
|
|
char *setParamModes;
|
|
|
|
char *channelModes;
|
|
|
|
char excepts;
|
|
|
|
char invex;
|
|
|
|
} network;
|
|
|
|
|
2020-02-01 06:18:01 +00:00
|
|
|
#define ENUM_CAP \
|
2020-02-29 06:03:46 +00:00
|
|
|
X("causal.agency/consumer", CapConsumer) \
|
2020-03-22 18:32:20 +00:00
|
|
|
X("chghost", CapChghost) \
|
2020-02-09 05:53:55 +00:00
|
|
|
X("extended-join", CapExtendedJoin) \
|
2020-02-15 02:36:58 +00:00
|
|
|
X("invite-notify", CapInviteNotify) \
|
2021-05-04 19:34:27 +00:00
|
|
|
X("message-tags", CapMessageTags) \
|
2020-02-15 09:59:50 +00:00
|
|
|
X("multi-prefix", CapMultiPrefix) \
|
2020-02-01 06:18:01 +00:00
|
|
|
X("sasl", CapSASL) \
|
|
|
|
X("server-time", CapServerTime) \
|
2020-12-30 04:49:16 +00:00
|
|
|
X("setname", CapSetname) \
|
2021-09-21 00:25:11 +00:00
|
|
|
X("userhost-in-names", CapUserhostInNames) \
|
|
|
|
X("znc.in/self-message", CapSelfMessage)
|
2020-02-01 06:18:01 +00:00
|
|
|
|
|
|
|
enum Cap {
|
|
|
|
#define X(name, id) BIT(id),
|
|
|
|
ENUM_CAP
|
|
|
|
#undef X
|
|
|
|
};
|
|
|
|
|
|
|
|
extern struct Self {
|
2020-02-01 07:26:35 +00:00
|
|
|
bool debug;
|
2021-01-23 05:03:58 +00:00
|
|
|
bool kiosk;
|
2020-02-12 03:39:29 +00:00
|
|
|
bool restricted;
|
2020-02-29 06:03:46 +00:00
|
|
|
size_t pos;
|
2020-02-01 06:18:01 +00:00
|
|
|
enum Cap caps;
|
2022-02-12 18:26:38 +00:00
|
|
|
char *plainUser;
|
|
|
|
char *plainPass;
|
2021-06-18 16:28:09 +00:00
|
|
|
char *mode;
|
2020-02-17 04:05:43 +00:00
|
|
|
char *join;
|
2020-02-01 06:18:01 +00:00
|
|
|
char *nick;
|
2020-02-05 05:40:24 +00:00
|
|
|
char *user;
|
2020-03-22 18:32:20 +00:00
|
|
|
char *host;
|
2020-02-05 01:23:55 +00:00
|
|
|
enum Color color;
|
2021-07-02 19:24:11 +00:00
|
|
|
char *invited;
|
2020-02-06 02:57:23 +00:00
|
|
|
char *quit;
|
2020-02-01 06:18:01 +00:00
|
|
|
} self;
|
|
|
|
|
2020-02-02 22:37:36 +00:00
|
|
|
static inline void set(char **field, const char *value) {
|
|
|
|
free(*field);
|
|
|
|
*field = strdup(value);
|
|
|
|
if (!*field) err(EX_OSERR, "strdup");
|
|
|
|
}
|
|
|
|
|
2020-02-01 06:18:01 +00:00
|
|
|
#define ENUM_TAG \
|
2021-05-04 19:34:27 +00:00
|
|
|
X("+draft/reply", TagReply) \
|
2020-02-29 06:03:46 +00:00
|
|
|
X("causal.agency/pos", TagPos) \
|
2021-05-04 19:34:27 +00:00
|
|
|
X("msgid", TagMsgID) \
|
2020-02-01 06:18:01 +00:00
|
|
|
X("time", TagTime)
|
|
|
|
|
|
|
|
enum Tag {
|
|
|
|
#define X(name, id) id,
|
|
|
|
ENUM_TAG
|
|
|
|
#undef X
|
|
|
|
TagCap,
|
|
|
|
};
|
|
|
|
|
2020-06-24 17:36:24 +00:00
|
|
|
enum { ParamCap = 254 };
|
2020-02-01 06:18:01 +00:00
|
|
|
struct Message {
|
|
|
|
char *tags[TagCap];
|
|
|
|
char *nick;
|
|
|
|
char *user;
|
|
|
|
char *host;
|
|
|
|
char *cmd;
|
|
|
|
char *params[ParamCap];
|
|
|
|
};
|
|
|
|
|
2021-01-10 00:11:57 +00:00
|
|
|
void ircConfig(
|
|
|
|
bool insecure, const char *trust, const char *cert, const char *priv
|
|
|
|
);
|
2020-02-12 01:02:37 +00:00
|
|
|
int ircConnect(const char *bind, const char *host, const char *port);
|
2021-06-29 13:34:03 +00:00
|
|
|
void ircHandshake(void);
|
2021-01-10 23:00:41 +00:00
|
|
|
void ircPrintCert(void);
|
2020-02-01 06:18:01 +00:00
|
|
|
void ircRecv(void);
|
|
|
|
void ircSend(const char *ptr, size_t len);
|
|
|
|
void ircFormat(const char *format, ...)
|
|
|
|
__attribute__((format(printf, 1, 2)));
|
2020-02-13 06:01:23 +00:00
|
|
|
void ircClose(void);
|
2020-02-01 06:18:01 +00:00
|
|
|
|
2020-05-07 23:47:40 +00:00
|
|
|
extern uint execID;
|
|
|
|
extern int execPipe[2];
|
|
|
|
extern int utilPipe[2];
|
2020-02-14 02:57:55 +00:00
|
|
|
|
2020-02-13 01:12:34 +00:00
|
|
|
enum { UtilCap = 16 };
|
|
|
|
struct Util {
|
2020-02-16 03:19:55 +00:00
|
|
|
uint argc;
|
2020-02-13 01:12:34 +00:00
|
|
|
const char *argv[UtilCap];
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline void utilPush(struct Util *util, const char *arg) {
|
|
|
|
if (1 + util->argc < UtilCap) {
|
|
|
|
util->argv[util->argc++] = arg;
|
|
|
|
} else {
|
|
|
|
errx(EX_CONFIG, "too many utility arguments");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-30 21:49:55 +00:00
|
|
|
enum Reply {
|
|
|
|
ReplyAway = 1,
|
|
|
|
ReplyBan,
|
|
|
|
ReplyExcepts,
|
|
|
|
ReplyHelp,
|
|
|
|
ReplyInvex,
|
|
|
|
ReplyJoin,
|
|
|
|
ReplyList,
|
|
|
|
ReplyMode,
|
|
|
|
ReplyNames,
|
2021-02-21 19:23:17 +00:00
|
|
|
ReplyNamesAuto,
|
2020-12-30 21:49:55 +00:00
|
|
|
ReplyTopic,
|
2021-02-21 19:23:17 +00:00
|
|
|
ReplyTopicAuto,
|
2020-12-30 21:49:55 +00:00
|
|
|
ReplyWho,
|
|
|
|
ReplyWhois,
|
|
|
|
ReplyWhowas,
|
|
|
|
ReplyCap,
|
|
|
|
};
|
|
|
|
|
|
|
|
extern uint replies[ReplyCap];
|
2020-02-17 04:05:43 +00:00
|
|
|
|
2020-06-24 17:36:24 +00:00
|
|
|
void handle(struct Message *msg);
|
2020-02-17 04:05:43 +00:00
|
|
|
void command(uint id, char *input);
|
|
|
|
const char *commandIsPrivmsg(uint id, const char *input);
|
|
|
|
const char *commandIsNotice(uint id, const char *input);
|
|
|
|
const char *commandIsAction(uint id, const char *input);
|
2021-03-17 17:34:33 +00:00
|
|
|
size_t commandWillSplit(uint id, const char *input);
|
2020-03-30 18:56:26 +00:00
|
|
|
void commandCompleteAdd(void);
|
2020-02-17 04:05:43 +00:00
|
|
|
|
2022-02-19 23:28:45 +00:00
|
|
|
enum Heat {
|
|
|
|
Ice,
|
|
|
|
Cold,
|
|
|
|
Warm,
|
|
|
|
Hot,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
TitleCap = 256,
|
|
|
|
StatusLines = 1,
|
|
|
|
MarkerLines = 1,
|
|
|
|
SplitLines = 5,
|
|
|
|
InputLines = 1,
|
|
|
|
InputCols = 1024,
|
|
|
|
};
|
|
|
|
extern char uiTitle[TitleCap];
|
|
|
|
extern struct _win_st *uiStatus;
|
|
|
|
extern struct _win_st *uiMain;
|
2022-02-20 01:20:19 +00:00
|
|
|
extern struct _win_st *uiInput;
|
|
|
|
extern bool uiSpoilerReveal;
|
2020-02-13 01:12:34 +00:00
|
|
|
extern struct Util uiNotifyUtil;
|
2022-02-20 01:20:19 +00:00
|
|
|
void uiInit(void);
|
2022-02-19 23:28:45 +00:00
|
|
|
uint uiAttr(struct Style style);
|
|
|
|
short uiPair(struct Style style);
|
2020-02-03 04:20:19 +00:00
|
|
|
void uiShow(void);
|
|
|
|
void uiHide(void);
|
2020-02-02 00:37:48 +00:00
|
|
|
void uiDraw(void);
|
2022-02-20 01:20:19 +00:00
|
|
|
void uiResize(void);
|
2020-02-16 03:19:55 +00:00
|
|
|
void uiWrite(uint id, enum Heat heat, const time_t *time, const char *str);
|
2020-02-02 00:37:48 +00:00
|
|
|
void uiFormat(
|
2020-02-16 03:19:55 +00:00
|
|
|
uint id, enum Heat heat, const time_t *time, const char *format, ...
|
2020-02-02 00:37:48 +00:00
|
|
|
) __attribute__((format(printf, 4, 5)));
|
2020-02-11 00:40:13 +00:00
|
|
|
void uiLoad(const char *name);
|
2021-06-11 12:30:58 +00:00
|
|
|
int uiSave(void);
|
2020-02-02 00:37:48 +00:00
|
|
|
|
2022-02-20 01:20:19 +00:00
|
|
|
void inputInit(void);
|
|
|
|
void inputWait(void);
|
|
|
|
void inputUpdate(void);
|
|
|
|
void inputRead(void);
|
2022-02-20 01:37:48 +00:00
|
|
|
void inputCompleteAdd(void);
|
2022-02-20 01:20:19 +00:00
|
|
|
|
2022-02-19 23:28:45 +00:00
|
|
|
enum Scroll {
|
|
|
|
ScrollOne,
|
|
|
|
ScrollPage,
|
|
|
|
ScrollAll,
|
|
|
|
ScrollUnread,
|
|
|
|
ScrollHot,
|
|
|
|
};
|
|
|
|
extern struct Time {
|
|
|
|
bool enable;
|
|
|
|
const char *format;
|
|
|
|
int width;
|
|
|
|
} windowTime;
|
|
|
|
extern enum Heat windowThreshold;
|
|
|
|
void windowInit(void);
|
|
|
|
void windowUpdate(void);
|
|
|
|
void windowResize(void);
|
|
|
|
bool windowWrite(uint id, enum Heat heat, const time_t *time, const char *str);
|
|
|
|
void windowBare(void);
|
|
|
|
uint windowID(void);
|
|
|
|
uint windowNum(void);
|
|
|
|
uint windowFor(uint id);
|
|
|
|
void windowShow(uint num);
|
|
|
|
void windowAuto(void);
|
|
|
|
void windowSwap(void);
|
|
|
|
void windowMove(uint from, uint to);
|
|
|
|
void windowClose(uint num);
|
|
|
|
void windowList(void);
|
|
|
|
void windowMark(void);
|
|
|
|
void windowUnmark(void);
|
|
|
|
void windowToggleMute(void);
|
|
|
|
void windowToggleTime(void);
|
|
|
|
void windowToggleThresh(int n);
|
|
|
|
bool windowTimeEnable(void);
|
|
|
|
void windowScroll(enum Scroll by, int n);
|
|
|
|
void windowSearch(const char *str, int dir);
|
|
|
|
int windowSave(FILE *file);
|
|
|
|
void windowLoad(FILE *file, size_t version);
|
|
|
|
|
2020-09-02 00:35:17 +00:00
|
|
|
enum { BufferCap = 1024 };
|
|
|
|
struct Buffer;
|
|
|
|
struct Line {
|
2021-01-27 03:14:12 +00:00
|
|
|
uint num;
|
2020-09-02 00:35:17 +00:00
|
|
|
enum Heat heat;
|
|
|
|
time_t time;
|
|
|
|
char *str;
|
|
|
|
};
|
|
|
|
struct Buffer *bufferAlloc(void);
|
|
|
|
void bufferFree(struct Buffer *buffer);
|
|
|
|
const struct Line *bufferSoft(const struct Buffer *buffer, size_t i);
|
|
|
|
const struct Line *bufferHard(const struct Buffer *buffer, size_t i);
|
2020-09-02 02:54:26 +00:00
|
|
|
int bufferPush(
|
2021-01-16 17:58:16 +00:00
|
|
|
struct Buffer *buffer, int cols, enum Heat thresh,
|
2020-09-02 00:35:17 +00:00
|
|
|
enum Heat heat, time_t time, const char *str
|
|
|
|
);
|
2021-01-16 17:58:16 +00:00
|
|
|
int bufferReflow(
|
|
|
|
struct Buffer *buffer, int cols, enum Heat thresh, size_t tail
|
|
|
|
);
|
2020-09-02 00:35:17 +00:00
|
|
|
|
2020-02-16 03:19:55 +00:00
|
|
|
const char *complete(uint id, const char *prefix);
|
2021-06-17 22:43:26 +00:00
|
|
|
const char *completeSubstr(uint id, const char *substr);
|
2020-02-08 02:30:25 +00:00
|
|
|
void completeAccept(void);
|
|
|
|
void completeReject(void);
|
2020-02-16 03:19:55 +00:00
|
|
|
void completeAdd(uint id, const char *str, enum Color color);
|
|
|
|
void completeTouch(uint id, const char *str, enum Color color);
|
|
|
|
void completeReplace(uint id, const char *old, const char *new);
|
|
|
|
void completeRemove(uint id, const char *str);
|
|
|
|
void completeClear(uint id);
|
|
|
|
uint completeID(const char *str);
|
|
|
|
enum Color completeColor(uint id, const char *str);
|
2020-02-08 02:30:25 +00:00
|
|
|
|
2020-02-12 05:48:43 +00:00
|
|
|
extern struct Util urlOpenUtil;
|
|
|
|
extern struct Util urlCopyUtil;
|
2020-02-16 03:19:55 +00:00
|
|
|
void urlScan(uint id, const char *nick, const char *mesg);
|
|
|
|
void urlOpenCount(uint id, uint count);
|
|
|
|
void urlOpenMatch(uint id, const char *str);
|
|
|
|
void urlCopyMatch(uint id, const char *str);
|
2021-01-11 23:05:22 +00:00
|
|
|
int urlSave(FILE *file);
|
|
|
|
void urlLoad(FILE *file, size_t version);
|
2020-02-08 23:29:01 +00:00
|
|
|
|
2021-01-16 18:30:59 +00:00
|
|
|
enum { FilterCap = 64 };
|
|
|
|
extern struct Filter {
|
|
|
|
enum Heat heat;
|
2021-01-02 01:09:10 +00:00
|
|
|
char *mask;
|
|
|
|
char *cmd;
|
|
|
|
char *chan;
|
|
|
|
char *mesg;
|
2021-01-16 18:30:59 +00:00
|
|
|
} filters[FilterCap];
|
|
|
|
struct Filter filterParse(enum Heat heat, char *pattern);
|
|
|
|
struct Filter filterAdd(enum Heat heat, const char *pattern);
|
|
|
|
bool filterRemove(struct Filter filter);
|
|
|
|
enum Heat filterCheck(enum Heat heat, uint id, const struct Message *msg);
|
2020-03-31 18:30:42 +00:00
|
|
|
|
2021-06-24 20:58:28 +00:00
|
|
|
void logOpen(void);
|
2020-03-25 22:56:09 +00:00
|
|
|
void logFormat(uint id, const time_t *time, const char *format, ...)
|
|
|
|
__attribute__((format(printf, 3, 4)));
|
|
|
|
void logClose(void);
|
|
|
|
|
2021-10-16 21:03:31 +00:00
|
|
|
char *configPath(char *buf, size_t cap, const char *path, int i);
|
|
|
|
char *dataPath(char *buf, size_t cap, const char *path, int i);
|
2020-02-06 03:49:56 +00:00
|
|
|
FILE *configOpen(const char *path, const char *mode);
|
2020-02-11 00:57:10 +00:00
|
|
|
FILE *dataOpen(const char *path, const char *mode);
|
|
|
|
|
2020-02-06 03:49:56 +00:00
|
|
|
int getopt_config(
|
|
|
|
int argc, char *const *argv,
|
|
|
|
const char *optstring, const struct option *longopts, int *longindex
|
|
|
|
);
|