commit 5c0cf35e0b54bce9d7e1862165a0a7359b9afdab
parent 732738f4ae42057d98c34ed1e65718994f7e8d41
Author: hhvn <dev@hhvn.uk>
Date: Sun, 24 Oct 2021 12:19:25 +0100
Makefile hirc.h hist.c main.c struct.h ui.c: send raw commands for now
Diffstat:
6 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/Makefile b/Makefile
@@ -1,7 +1,8 @@
PREFIX = /usr/local
BINDIR = $(PREFIX)/bin
BIN = hirc
-OBJ = main.o handle.o hist.o nick.o chan.o serv.o ui.o
+OBJ = main.o handle.o hist.o nick.o \
+ chan.o serv.o ui.o commands.o
# Comment to disable TLS
LDTLS = -ltls
diff --git a/hirc.h b/hirc.h
@@ -5,6 +5,9 @@
#include "config.h"
#define PARAM_MAX 64
#define INPUT_MAX 8192
+#define COMMANDARG_MAX (INPUT_MAX / 5)
+ /* Theoretical max: -a o -b o -c o *
+ * 12345 */
/* main.c */
void * emalloc(size_t size);
@@ -102,6 +105,9 @@ void ui_tls_error_(char *file, int line, struct tls *ctx, char *str);
#define ui_tls_error(ctx, str) ui_tls_error_(__FILE__, __LINE__, ctx, str);
#endif /* TLS */
+/* commands.c */
+void command_eval(char *str);
+
/* main.c */
extern struct HistInfo *main_buf;
diff --git a/hist.c b/hist.c
@@ -72,6 +72,9 @@ hist_add(struct Server *server, struct HistInfo *histinfo, struct Nick *from,
ui_error("HIST_MAIN specified, but history is &main_buf", NULL);
}
+ if (options & HIST_SELF && server)
+ from = server->self;
+
new = hist_create(server, from, msg, params, activity, timestamp, options);
if (histinfo && options & HIST_SHOW && activity > histinfo->activity)
@@ -97,7 +100,7 @@ hist_add(struct Server *server, struct HistInfo *histinfo, struct Nick *from,
// XXX
if (options & HIST_SHOW) {
- wprintw(mainwindow.window, "!%lld :%s %s\n", (long long)timestamp, nick_strprefix(from), msg);
+ wprintw(mainwindow.window, "!%lld :%s %s\n", (long long)new->timestamp, nick_strprefix(new->from), new->raw);
refresh();
}
diff --git a/main.c b/main.c
@@ -190,7 +190,7 @@ main(int argc, char **argv) {
main_buf->history = NULL;
ui_init();
- serv_add(&servers, "hlircnet", "irc.hhvn.uk", "6667", "hhvn", "Fanatic", "gopher://hhvn.uk", 1, 0);
+ selected_server = serv_add(&servers, "hlircnet", "irc.hhvn.uk", "6667", "hhvn", "Fanatic", "gopher://hhvn.uk", 1, 0);
/* serv_add(&servers, "dataswamp", "127.0.0.1", "6697", "hhvn", "Fanatic", "gopher://hhvn.uk", 1, 0); */
for (sp = servers; sp; sp = sp->next)
serv_connect(sp);
diff --git a/struct.h b/struct.h
@@ -20,6 +20,7 @@ struct Nick {
enum Activity {
Activity_ignore,
+ Activity_self = Activity_ignore,
Activity_status,
Activity_notice = Activity_status,
Activity_error,
@@ -31,6 +32,7 @@ enum HistOpt {
HIST_SHOW = 1, /* show in buffer */
HIST_LOG = 2, /* log to server->logfd */
HIST_MAIN = 4, /* copy to &main_buf */
+ HIST_SELF = 8, /* from = self */
HIST_DFL = HIST_SHOW|HIST_LOG
};
diff --git a/ui.c b/ui.c
@@ -141,11 +141,9 @@ ui_read(void) {
}
break;
case '\n':
- if (strcmp(input.string, "/quit") == 0) {
- endwin();
exit(0);
}
- wprintw(mainwindow.window, "%s\n", input.string);
+ command_eval(input.string);
memset(input.string, '\0', sizeof(input.string));
input.counter = 0;
ui_draw_input();