]>
git.ipfire.org Git - thirdparty/bird.git/blob - client/birdcl.c
2 * BIRD Client - Light variant I/O
4 * (c) 1999--2004 Martin Mares <mj@ucw.cz>
5 * (c) 2013 Tomas Hlavacek <tomas.hlavacek@nic.cz>
7 * Can be freely distributed and used under the terms of the GNU GPL.
16 #include <sys/ioctl.h>
19 #include "nest/bird.h"
20 #include "lib/resource.h"
21 #include "lib/string.h"
22 #include "client/client.h"
23 #include "sysdep/unix/unix.h"
25 #define INPUT_BUF_LEN 2048
27 struct termios tty_save
;
30 input_start_list(void)
32 /* Empty in non-ncurses version. */
38 /* Empty in non-ncurses version. */
42 input_notify(int prompt
)
44 /* No ncurses -> no status to reveal/hide, print prompt manually. */
54 lastnb(char *str
, int i
)
57 if ((str
[i
] != ' ') && (str
[i
] != '\t'))
66 char buf
[INPUT_BUF_LEN
];
68 if ((fgets(buf
, INPUT_BUF_LEN
, stdin
) == NULL
) || (buf
[0] == 0))
76 if ((l
+1) == INPUT_BUF_LEN
)
78 printf("Input too long.\n");
91 if (lastnb(buf
, l
) == '?')
93 cmd_help(buf
, strlen(buf
));
100 static struct termios stored_tty
;
101 static int more_active
= 0;
106 static struct termios tty
;
109 tty
.c_lflag
&= (~ECHO
);
110 tty
.c_lflag
&= (~ICANON
);
112 if (tcsetattr (0, TCSANOW
, &tty
) < 0)
123 if (tcsetattr (0, TCSANOW
, &stored_tty
) < 0)
128 sig_handler(int signal
)
140 if (tcgetattr(0, &stored_tty
) < 0)
143 if (signal(SIGINT
, sig_handler
) == SIG_IGN
)
144 signal(SIGINT
, SIG_IGN
);
145 if (signal(SIGTERM
, sig_handler
) == SIG_IGN
)
146 signal(SIGTERM
, SIG_IGN
);
149 if (ioctl(0, TIOCGWINSZ
, &tws
) == 0)
151 term_lns
= tws
.ws_row
;
152 term_cls
= tws
.ws_col
;