15
15
16
16
#define VERSION "0.1.3"
17
17
18
- #define MSG_MAX 512 /* guaranteed max message length */
19
- #define CHA_MAX 200 /* guaranteed max channel length */
20
-
21
- static int conn ; /* connection socket */
22
- static char chan_default [ MSG_MAX ] ; /* default channel for PRIVMSG */
23
- static int verb = 0 ; /* verbose output (e.g. raw stream) */
24
- static int sasl = 0 ; /* SASL method (PLAIN=0, EXTERNAL=1) */
25
- static size_t cmax = 80 ; /* max number of chars per line */
26
- static size_t gutl = 20 ; /* max char width of left column */
27
- static char * host = "irc.freenode.org" ; /* irc host address */
28
- static char * port = "6667" ; /* server port */
29
- static char * chan = NULL ; /* channel(s) */
30
- static char * nick = NULL ; /* nickname */
31
- static char * pass = NULL ; /* server password */
32
- static char * user = NULL ; /* server user name */
33
- static char * auth = NULL ; /* PLAIN SASL authentication token */
34
- static char * real = NULL ; /* server user real name */
35
- static char * olog = NULL ; /* log irc stream path */
36
- static char * inic = NULL ; /* server command after connection */
18
+ #define MSG_MAX 512 /* max message length */
19
+ #define CHA_MAX 200 /* max channel length */
20
+
21
+ static unsigned short cmax ; /* max printed line chars */
22
+ static int conn ; /* connection socket */
23
+ static char chan_default [ MSG_MAX ]; /* default PRIVMSG channel */
24
+ static int verb = 0 ; /* verbose output */
25
+ static int sasl = 0 ; /* SASL method */
26
+ static size_t gutl = 20 ; /* max printed nick chars */
27
+ static char * host = "irc.freenode.org" ; /* host address */
28
+ static char * port = "6667" ; /* port */
29
+ static char * chan = NULL ; /* channel(s) */
30
+ static char * nick = NULL ; /* nickname */
31
+ static char * pass = NULL ; /* password */
32
+ static char * user = NULL ; /* user name */
33
+ static char * auth = NULL ; /* PLAIN SASL token */
34
+ static char * real = NULL ; /* real name */
35
+ static char * olog = NULL ; /* chat log path*/
36
+ static char * inic = NULL ; /* additional server command */
37
37
38
38
static void
39
39
log_append (char * str , char * path ) {
@@ -280,7 +280,7 @@ main(int argc, char **argv) {
280
280
281
281
int cval ;
282
282
283
- while ((cval = getopt (argc , argv , "s:p:o:n:k:c:u:r:x:w:W: a:hevV" )) != -1 ) {
283
+ while ((cval = getopt (argc , argv , "s:p:o:n:k:c:u:r:x:w:a:hevV" )) != -1 ) {
284
284
switch (cval ) {
285
285
case 'V' : ++ verb ; break ;
286
286
case 'e' : ++ sasl ; break ;
@@ -295,7 +295,6 @@ main(int argc, char **argv) {
295
295
case 'c' : chan = optarg ; break ;
296
296
case 'x' : inic = optarg ; break ;
297
297
case 'w' : gutl = atoi (optarg ); break ;
298
- case 'W' : cmax = atoi (optarg ); break ;
299
298
case 'v' : puts ("kirc-" VERSION ); break ;
300
299
case '?' : usage (); break ;
301
300
}
@@ -319,6 +318,8 @@ main(int argc, char **argv) {
319
318
if (pass ) raw ("PASS %s\r\n" , pass );
320
319
if (inic ) raw ("%s\r\n" , inic );
321
320
321
+ struct winsize window_dims ;
322
+
322
323
struct pollfd fds [2 ];
323
324
fds [0 ].fd = STDIN_FILENO ;
324
325
fds [1 ].fd = conn ;
@@ -327,6 +328,8 @@ main(int argc, char **argv) {
327
328
328
329
for (;;) {
329
330
int poll_res = poll (fds , 2 , -1 );
331
+ ioctl (0 , TIOCGWINSZ , & window_dims );
332
+ cmax = window_dims .ws_col ;
330
333
if (poll_res != -1 ) {
331
334
if (fds [0 ].revents & POLLIN ) {
332
335
handle_user_input ();
0 commit comments