@@ -29,9 +29,10 @@ kbhit(void) {
29
29
30
30
int byteswaiting ;
31
31
struct termios term ;
32
+ term .c_cc [VERASE ] = 127 ;
33
+ tcgetattr (0 , & term );
32
34
fd_set fds ;
33
35
struct timespec ts = {0 };
34
- tcgetattr (0 , & term );
35
36
36
37
struct termios term2 = term ;
37
38
@@ -54,7 +55,7 @@ raw(char *fmt, ...) {
54
55
vsnprintf (sbuf , BUFF , fmt , ap );
55
56
va_end (ap );
56
57
57
- if (verb ) printf ("<< %s " , sbuf );
58
+ if (verb ) printf ("<< \x1b[33m%s\x1b[0m " , sbuf );
58
59
59
60
write (conn , sbuf , strlen (sbuf ));
60
61
}
@@ -127,7 +128,7 @@ pars(int sl, char *buf) {
127
128
buf_c [o + 1 ] = '\0' ;
128
129
o = -1 ;
129
130
130
- if (verb ) printf (">> %s " , buf_c );
131
+ if (verb ) printf (">> \x1b[33m%s\x1b[0m " , buf_c );
131
132
132
133
if (!strncmp (buf_c , "PING" , 4 )) {
133
134
buf_c [1 ] = 'O' ;
@@ -164,7 +165,7 @@ main(int argc, char **argv) {
164
165
165
166
while ((cval = getopt (argc , argv , "s:p:n:k:c:vV" )) != -1 ) {
166
167
switch (cval ) {
167
- case 'v' : printf ("kirc 0.0.1\n " ); break ;
168
+ case 'v' : puts ("kirc 0.0.1" ); break ;
168
169
case 'V' : verb = 1 ; break ;
169
170
case 's' : host = optarg ; break ;
170
171
case 'p' : port = optarg ; break ;
@@ -188,15 +189,17 @@ main(int argc, char **argv) {
188
189
pid_t pid = fork ();
189
190
190
191
if (pid == 0 ) {
191
- int sl ;
192
+ int sl , i , j ;
192
193
char u [CMAX ];
193
194
194
195
con ();
195
196
196
197
while ((sl = read (conn , sbuf , BUFF ))) {
197
198
pars (sl , sbuf );
198
- if ((read (fd [0 ], u , CMAX ) > 0 ) && !strstr (u , "WAIT_SIG" )) {
199
- raw ("%s\r\n" , u );
199
+ if (read (fd [0 ], u , CMAX ) > 0 ) {
200
+ for (i = 0 ; u [i ] != '\n' ; i ++ ) continue ;
201
+ for (j = i ; j < CMAX ; j ++ ) u [j ] = ' ' ;
202
+ if (!strstr (u , "WAIT_SIG" )) raw ("%-*.*s\r\n" , i , i , u );
200
203
}
201
204
}
202
205
printf ("(press <ENTER> to quit)\n" );
@@ -216,12 +219,11 @@ main(int argc, char **argv) {
216
219
217
220
switch (usrin [1 ]) {
218
221
case 'q' :
219
- write (fd [1 ], "quit" , sizeof ( "quit" ) );
222
+ dprintf (fd [1 ],"quit\n" );
220
223
break ;
221
224
case 'm' :
222
225
while (isspace (* cmd_val )) cmd_val ++ ;
223
- dprintf (fd [1 ], "privmsg #%s :%-*s" , \
224
- chan , CMAX - strlen (chan ) - 11 , cmd_val );
226
+ dprintf (fd [1 ], "privmsg #%s :%s" , chan , cmd_val );
225
227
break ;
226
228
}
227
229
}
0 commit comments