aboutsummaryrefslogtreecommitdiffstats
path: root/kirc.c
diff options
context:
space:
mode:
authormcpcpc <michaelczigler@icloud.com>2020-08-10 07:18:23 -0400
committermcpcpc <michaelczigler@icloud.com>2020-08-11 22:26:05 -0400
commit5e54e4f51dbb781ae5cb7c57b20affde3dbe1e9e (patch)
tree8a6684a94f6e2da78e8e84443840985c8b629104 /kirc.c
parentfixed child process u[BUFF] to u[CMAX] (diff)
downloadkirc-5e54e4f51dbb781ae5cb7c57b20affde3dbe1e9e.tar.gz
kirc-5e54e4f51dbb781ae5cb7c57b20affde3dbe1e9e.tar.bz2
kirc-5e54e4f51dbb781ae5cb7c57b20affde3dbe1e9e.tar.xz
kirc-5e54e4f51dbb781ae5cb7c57b20affde3dbe1e9e.tar.zst
kirc-5e54e4f51dbb781ae5cb7c57b20affde3dbe1e9e.zip
possible fix for garbage printing with ':m'
README: fix usage for password 2nd attempt to fix garbage printing fix typo 2nd fix cleanup guard against accidental WAIT_SIG read move WAIT_SIG check after garbage cleanup experiment with disabling echo update update update enable backspace in stdin from virtual terminal update
Diffstat (limited to 'kirc.c')
-rw-r--r--kirc.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/kirc.c b/kirc.c
index 820cc05..457173d 100644
--- a/kirc.c
+++ b/kirc.c
@@ -29,9 +29,10 @@ kbhit(void) {
int byteswaiting;
struct termios term;
+ term.c_cc[VERASE] = 127;
+ tcgetattr(0, &term);
fd_set fds;
struct timespec ts = {0};
- tcgetattr(0, &term);
struct termios term2 = term;
@@ -54,7 +55,7 @@ raw(char *fmt, ...) {
vsnprintf(sbuf, BUFF, fmt, ap);
va_end(ap);
- if (verb) printf("<< %s", sbuf);
+ if (verb) printf("<< \x1b[33m%s\x1b[0m", sbuf);
write(conn, sbuf, strlen(sbuf));
}
@@ -127,7 +128,7 @@ pars(int sl, char *buf) {
buf_c[o + 1] = '\0';
o = -1;
- if (verb) printf(">> %s", buf_c);
+ if (verb) printf(">> \x1b[33m%s\x1b[0m", buf_c);
if (!strncmp(buf_c, "PING", 4)) {
buf_c[1] = 'O';
@@ -164,7 +165,7 @@ main(int argc, char **argv) {
while ((cval = getopt(argc, argv, "s:p:n:k:c:vV")) != -1) {
switch (cval) {
- case 'v' : printf("kirc 0.0.1\n"); break;
+ case 'v' : puts("kirc 0.0.1"); break;
case 'V' : verb = 1; break;
case 's' : host = optarg; break;
case 'p' : port = optarg; break;
@@ -188,15 +189,17 @@ main(int argc, char **argv) {
pid_t pid = fork();
if (pid == 0) {
- int sl;
+ int sl, i, j;
char u[CMAX];
con();
while ((sl = read(conn, sbuf, BUFF))) {
pars(sl, sbuf);
- if ((read(fd[0], u, CMAX) > 0) && !strstr(u, "WAIT_SIG")) {
- raw("%s\r\n", u);
+ if (read(fd[0], u, CMAX) > 0) {
+ for (i = 0; u[i] != '\n'; i++) continue;
+ for (j = i; j < CMAX; j++) u[j] = ' ';
+ if (!strstr(u, "WAIT_SIG")) raw("%-*.*s\r\n", i, i, u);
}
}
printf("(press <ENTER> to quit)\n");
@@ -216,12 +219,11 @@ main(int argc, char **argv) {
switch (usrin[1]) {
case 'q':
- write(fd[1], "quit", sizeof("quit"));
+ dprintf(fd[1],"quit\n");
break;
case 'm':
while (isspace(*cmd_val)) cmd_val++;
- dprintf(fd[1], "privmsg #%s :%-*s", \
- chan, CMAX - strlen(chan) - 11, cmd_val);
+ dprintf(fd[1], "privmsg #%s :%s", chan, cmd_val);
break;
}
}