2 * fbvnc - A small linux framebuffer vnc viewer
4 * Copyright (C) 1999 Milan Pikula
5 * Copyright (C) 2009 Ali Gholami Rudi
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License, as published by the
9 * Free Software Foundation.
16 #include <sys/types.h>
22 static void term_setup(struct termios
*ti
)
24 struct termios termios
;
25 char *hide
= "\x1b[?25l";
26 char *clear
= "\x1b[2J\x1b[H";
27 char *msg
= "\t\t\t*** fbvnc ***\r\n";
29 write(STDIN_FILENO
, hide
, strlen(hide
));
30 write(STDOUT_FILENO
, clear
, strlen(clear
));
31 write(STDOUT_FILENO
, msg
, strlen(msg
));
32 tcgetattr (0, &termios
);
35 tcsetattr(0, TCSANOW
, &termios
);
38 static void term_cleanup(struct termios
*ti
)
40 char *show
= "\x1b[?25h";
41 tcsetattr(0, TCSANOW
, ti
);
42 write(STDIN_FILENO
, show
, strlen(show
));
45 static void mainloop(int fd
)
56 if (redraw
|| ((update
|| !retval
) && !pending
)) {
57 if (request_vnc_refresh(fd
, !redraw
) == -1)
68 retval
= select(fd
+ 1, &sel_in
, NULL
, NULL
, &tv
);
71 if (FD_ISSET(0, &sel_in
)) {
72 if (parse_kbd_in(0, fd
) == -1)
76 if (FD_ISSET(fd
, &sel_in
)) {
77 if (parse_vnc_in(fd
) == -1)
84 int main(int argc
, char * argv
[])
87 char * host
= "127.0.0.1";
94 if ((fd
= vncproto_init(host
, port
)) == -1)