Commit 71f2ec79 authored by runge's avatar runge

x11vnc: the big split.

parent def30126
2006-01-08 Karl Runge <runge@karlrunge.com>
* x11vnc: the big split. (and -afteraccept and -passwdfile read:..)
* examples/pnmshow24.c: fix typo.
2006-01-08 Karl Runge <runge@karlrunge.com> 2006-01-08 Karl Runge <runge@karlrunge.com>
* libvncclient/vncviewer.c: fix non-jpeg/libz builds. * libvncclient/vncviewer.c: fix non-jpeg/libz builds.
* examples/pnmshow24.c: fix non-ALLOW24BPP builds. * examples/pnmshow24.c: fix non-ALLOW24BPP builds.
......
...@@ -4,7 +4,8 @@ ...@@ -4,7 +4,8 @@
#ifndef LIBVNCSERVER_ALLOW24BPP #ifndef LIBVNCSERVER_ALLOW24BPP
int main() { int main() {
printf("I need the ALLOW24BPP LibVNCSever flag to work\n"); printf("I need the ALLOW24BPP LibVNCServer flag to work\n");
exit(1);
} }
#else #else
......
2006-01-08 Karl Runge <runge@karlrunge.com>
* x11vnc: the big split. opts: -afteraccept and -passwdfile read:
2005-12-24 Karl Runge <runge@karlrunge.com> 2005-12-24 Karl Runge <runge@karlrunge.com>
* x11vnc: enhance -passwdfile features, filetransfer on by default, * x11vnc: enhance -passwdfile features, filetransfer on by default,
call rfbRegisterTightVNCFileTransferExtension() earlier. call rfbRegisterTightVNCFileTransferExtension() earlier.
......
...@@ -13,7 +13,7 @@ endif ...@@ -13,7 +13,7 @@ endif
if HAVE_X if HAVE_X
bin_PROGRAMS=x11vnc bin_PROGRAMS=x11vnc
x11vnc_SOURCES=x11vnc.c tkx11vnc.h x11vnc_SOURCES = cleanup.c connections.c cursor.c gui.c help.c inet.c keyboard.c options.c pointer.c rates.c remote.c scan.c screen.c selection.c solid.c user.c userinput.c util.c win_utils.c x11vnc.c x11vnc_defs.c xdamage.c xevents.c xinerama.c xkb_bell.c xrandr.c xrecord.c xwrappers.c allowed_input_t.h blackout_t.h cleanup.h connections.h cursor.h enums.h gui.h help.h inet.h keyboard.h options.h params.h pointer.h rates.h remote.h scan.h screen.h scrollevent_t.h selection.h solid.h tkx11vnc.h user.h userinput.h util.h win_utils.h winattr_t.h x11vnc.h xdamage.h xevents.h xinerama.h xkb_bell.h xrandr.h xrecord.h xwrappers.h
INCLUDES=@X_CFLAGS@ INCLUDES=@X_CFLAGS@
x11vnc_LDADD=@X_LIBS@ $(LD_CYGIPC) $(LDADD) x11vnc_LDADD=@X_LIBS@ $(LD_CYGIPC) $(LDADD)
endif endif
......
This diff is collapsed.
#ifndef _X11VNC_ALLOWED_INPUT_T_H
#define _X11VNC_ALLOWED_INPUT_T_H
/* -- allowed_input_t.h -- */
typedef struct allowed_input {
int keystroke;
int motion;
int button;
} allowed_input_t;
#endif /* _X11VNC_ALLOWED_INPUT_T_H */
#ifndef _X11VNC_BLACKOUT_T_H
#define _X11VNC_BLACKOUT_T_H
/* -- blackout_t.h -- */
typedef struct bout {
int x1, y1, x2, y2;
} blackout_t;
#define BO_MAX 32
typedef struct tbout {
blackout_t bo[BO_MAX]; /* hardwired max rectangles. */
int cover;
int count;
} tile_blackout_t;
#endif /* _X11VNC_BLACKOUT_T_H */
/* -- cleanup.c -- */
#include "x11vnc.h"
#include "xwrappers.h"
#include "xdamage.h"
#include "remote.h"
#include "keyboard.h"
#include "scan.h"
#include "gui.h"
#include "solid.h"
/*
* Exiting and error handling routines
*/
int trapped_xerror = 0;
int trapped_xioerror = 0;
int trapped_getimage_xerror = 0;
int trapped_record_xerror = 0;
XErrorEvent *trapped_xerror_event;
/* XXX CHECK BEFORE RELEASE */
int crash_debug = 0;
void clean_shm(int quick);
void clean_up_exit (int ret);
int trap_xerror(Display *d, XErrorEvent *error);
int trap_xioerror(Display *d);
int trap_getimage_xerror(Display *d, XErrorEvent *error);
char *xerror_string(XErrorEvent *error);
void initialize_crash_handler(void);
void initialize_signals(void);
int known_sigpipe_mode(char *s);
static int exit_flag = 0;
static int exit_sig = 0;
static void clean_icon_mode(void);
static int Xerror(Display *d, XErrorEvent *error);
static int XIOerr(Display *d);
static void crash_shell_help(void);
static void crash_shell(void);
static void interrupted (int sig);
void clean_shm(int quick) {
int i, cnt = 0;
if (raw_fb) quick = 1; /* raw_fb hack */
/*
* to avoid deadlock, etc, under quick=1 we just delete the shm
* areas and leave the X stuff hanging.
*/
if (quick) {
shm_delete(&scanline_shm);
shm_delete(&fullscreen_shm);
shm_delete(&snaprect_shm);
} else {
shm_clean(&scanline_shm, scanline);
shm_clean(&fullscreen_shm, fullscreen);
shm_clean(&snaprect_shm, snaprect);
}
/*
* Here we have to clean up quite a few shm areas for all
* the possible tile row runs (40 for 1280), not as robust
* as one might like... sometimes need to run ipcrm(1).
*/
for(i=1; i<=ntiles_x; i++) {
if (i > tile_shm_count) {
break;
}
if (quick) {
shm_delete(&tile_row_shm[i]);
} else {
shm_clean(&tile_row_shm[i], tile_row[i]);
}
cnt++;
if (single_copytile_count && i >= single_copytile_count) {
break;
}
}
if (!quiet) {
rfbLog("deleted %d tile_row polling images.\n", cnt);
}
}
static void clean_icon_mode(void) {
if (icon_mode && icon_mode_fh) {
fprintf(icon_mode_fh, "quit\n");
fflush(icon_mode_fh);
fclose(icon_mode_fh);
icon_mode_fh = NULL;
if (icon_mode_file) {
unlink(icon_mode_file);
icon_mode_file = NULL;
}
}
}
/*
* Normal exiting
*/
void clean_up_exit (int ret) {
exit_flag = 1;
if (icon_mode) {
clean_icon_mode();
}
/* remove the shm areas: */
clean_shm(0);
if (! dpy) exit(ret); /* raw_rb hack */
/* X keyboard cleanups */
delete_added_keycodes(0);
if (clear_mods == 1) {
clear_modifiers(0);
} else if (clear_mods == 2) {
clear_keys();
}
if (no_autorepeat) {
autorepeat(1, 0);
}
if (use_solid_bg) {
solid_bg(1);
}
X_LOCK;
XTestDiscard_wr(dpy);
#if LIBVNCSERVER_HAVE_LIBXDAMAGE
if (xdamage) {
XDamageDestroy(dpy, xdamage);
}
#endif
#if LIBVNCSERVER_HAVE_LIBXTRAP
if (trap_ctx) {
XEFreeTC(trap_ctx);
}
#endif
/* XXX rdpy_ctrl, etc. cannot close w/o blocking */
XCloseDisplay(dpy);
X_UNLOCK;
fflush(stderr);
exit(ret);
}
/* X11 error handlers */
static XErrorHandler Xerror_def;
static XIOErrorHandler XIOerr_def;
int trap_xerror(Display *d, XErrorEvent *error) {
trapped_xerror = 1;
trapped_xerror_event = error;
if (d) {} /* unused vars warning: */
return 0;
}
int trap_xioerror(Display *d) {
trapped_xioerror = 1;
if (d) {} /* unused vars warning: */
return 0;
}
int trap_getimage_xerror(Display *d, XErrorEvent *error) {
trapped_getimage_xerror = 1;
trapped_xerror_event = error;
if (d) {} /* unused vars warning: */
return 0;
}
static int Xerror(Display *d, XErrorEvent *error) {
X_UNLOCK;
interrupted(0);
if (d) {} /* unused vars warning: */
return (*Xerror_def)(d, error);
}
static int XIOerr(Display *d) {
X_UNLOCK;
interrupted(-1);
if (d) {} /* unused vars warning: */
return (*XIOerr_def)(d);
}
static char *xerrors[] = {
"Success",
"BadRequest",
"BadValue",
"BadWindow",
"BadPixmap",
"BadAtom",
"BadCursor",
"BadFont",
"BadMatch",
"BadDrawable",
"BadAccess",
"BadAlloc",
"BadColor",
"BadGC",
"BadIDChoice",
"BadName",
"BadLength",
"BadImplementation",
"unknown"
};
static int xerrors_max = BadImplementation;
char *xerror_string(XErrorEvent *error) {
int index = -1;
if (error) {
index = (int) error->error_code;
}
if (0 <= index && index <= xerrors_max) {
return xerrors[index];
} else {
return xerrors[xerrors_max+1];
}
}
static char *crash_stack_command1 = NULL;
static char *crash_stack_command2 = NULL;
static char *crash_debug_command = NULL;
void initialize_crash_handler(void) {
int pid = program_pid;
crash_stack_command1 = (char *) malloc(1000);
crash_stack_command2 = (char *) malloc(1000);
crash_debug_command = (char *) malloc(1000);
snprintf(crash_stack_command1, 500, "echo where > /tmp/gdb.%d;"
" env PATH=$PATH:/usr/local/bin:/usr/sfw/bin:/usr/bin"
" gdb -x /tmp/gdb.%d -batch -n %s %d;"
" rm -f /tmp/gdb.%d", pid, pid, program_name, pid, pid);
snprintf(crash_stack_command2, 500, "pstack %d", program_pid);
snprintf(crash_debug_command, 500, "gdb %s %d", program_name, pid);
}
static void crash_shell_help(void) {
int pid = program_pid;
fprintf(stderr, "\n");
fprintf(stderr, " *** Welcome to the x11vnc crash shell! ***\n");
fprintf(stderr, "\n");
fprintf(stderr, "PROGRAM: %s PID: %d\n", program_name, pid);
fprintf(stderr, "\n");
fprintf(stderr, "POSSIBLE DEBUGGER COMMAND:\n");
fprintf(stderr, "\n");
fprintf(stderr, " %s\n", crash_debug_command);
fprintf(stderr, "\n");
fprintf(stderr, "Press \"q\" to quit.\n");
fprintf(stderr, "Press \"h\" or \"?\" for this help.\n");
fprintf(stderr, "Press \"s\" to try to run some commands to"
" show a stack trace (gdb/pstack).\n");
fprintf(stderr, "\n");
fprintf(stderr, "Anything else is passed to -Q query function.\n");
fprintf(stderr, "\n");
}
static void crash_shell(void) {
char qry[1000], cmd[1000], line[1000];
char *str, *p;
crash_shell_help();
fprintf(stderr, "\ncrash> ");
while (fgets(line, 1000, stdin) != NULL) {
str = lblanks(line);
p = str;
while(*p) {
if (*p == '\n') {
*p = '\0';
}
p++;
}
if (*str == 'q' && *(str+1) == '\0') {
fprintf(stderr, "quiting.\n");
return;
} else if (*str == 'h' && *(str+1) == '\0') {
crash_shell_help();
} else if (*str == '?' && *(str+1) == '\0') {
crash_shell_help();
} else if (*str == 's' && *(str+1) == '\0') {
sprintf(cmd, "sh -c '(%s) &'", crash_stack_command1);
fprintf(stderr, "\nrunning:\n\t%s\n\n",
crash_stack_command1);
system(cmd);
usleep(1000*1000);
sprintf(cmd, "sh -c '(%s) &'", crash_stack_command2);
fprintf(stderr, "\nrunning:\n\t%s\n\n",
crash_stack_command2);
system(cmd);
usleep(1000*1000);
} else {
snprintf(qry, 1000, "qry=%s", str);
p = process_remote_cmd(qry, 1);
fprintf(stderr, "\n\nresult:\n%s\n", p);
free(p);
}
fprintf(stderr, "crash> ");
}
}
/*
* General problem handler
*/
static void interrupted (int sig) {
exit_sig = sig;
if (exit_flag) {
exit_flag++;
if (use_threads) {
usleep2(250 * 1000);
} else if (exit_flag <= 2) {
return;
}
exit(4);
}
exit_flag++;
if (sig == 0) {
fprintf(stderr, "caught X11 error:\n");
} else if (sig == -1) {
fprintf(stderr, "caught XIO error:\n");
} else {
fprintf(stderr, "caught signal: %d\n", sig);
}
if (sig == SIGINT) {
shut_down = 1;
return;
}
X_UNLOCK;
if (icon_mode) {
clean_icon_mode();
}
/* remove the shm areas with quick=1: */
clean_shm(1);
if (sig == -1) {
/* not worth trying any more cleanup, X server probably gone */
exit(3);
}
/* X keyboard cleanups */
delete_added_keycodes(0);
if (clear_mods == 1) {
clear_modifiers(0);
} else if (clear_mods == 2) {
clear_keys();
}
if (no_autorepeat) {
autorepeat(1, 0);
}
if (use_solid_bg) {
solid_bg(1);
}
if (crash_debug) {
crash_shell();
}
if (sig) {
exit(2);
}
}
/* signal handlers */
void initialize_signals(void) {
signal(SIGHUP, interrupted);
signal(SIGINT, interrupted);
signal(SIGQUIT, interrupted);
signal(SIGABRT, interrupted);
signal(SIGTERM, interrupted);
signal(SIGBUS, interrupted);
signal(SIGSEGV, interrupted);
signal(SIGFPE, interrupted);
if (!sigpipe || *sigpipe == '\0' || !strcmp(sigpipe, "skip")) {
;
} else if (!strcmp(sigpipe, "ignore")) {
#ifdef SIG_IGN
signal(SIGPIPE, SIG_IGN);
#endif
} else if (!strcmp(sigpipe, "exit")) {
rfbLog("initialize_signals: will exit on SIGPIPE\n");
signal(SIGPIPE, interrupted);
}
X_LOCK;
Xerror_def = XSetErrorHandler(Xerror);
XIOerr_def = XSetIOErrorHandler(XIOerr);
X_UNLOCK;
}
int known_sigpipe_mode(char *s) {
/*
* skip, ignore, exit
*/
if (strcmp(s, "skip") && strcmp(s, "ignore") &&
strcmp(s, "exit")) {
return 0;
} else {
return 1;
}
}
#ifndef _X11VNC_CLEANUP_H
#define _X11VNC_CLEANUP_H
/* -- cleanup.h -- */
extern int trapped_xerror;
extern int trapped_xioerror;
extern int trapped_getimage_xerror;
extern int trapped_record_xerror;
extern XErrorEvent *trapped_xerror_event;
extern int crash_debug;
extern void clean_shm(int quick);
extern void clean_up_exit (int ret);
extern int trap_xerror(Display *d, XErrorEvent *error);
extern int trap_xioerror(Display *d);
extern int trap_getimage_xerror(Display *d, XErrorEvent *error);
extern char *xerror_string(XErrorEvent *error);
extern void initialize_crash_handler(void);
extern void initialize_signals(void);
extern int known_sigpipe_mode(char *s);
#endif /* _X11VNC_CLEANUP_H */
This diff is collapsed.
#ifndef _X11VNC_CONNECTIONS_H
#define _X11VNC_CONNECTIONS_H
/* -- connections.h -- */
extern char vnc_connect_str[];
extern Atom vnc_connect_prop;
extern int all_clients_initialized(void);
extern char *list_clients(void);
extern int new_fb_size_clients(rfbScreenInfoPtr s);
extern void close_all_clients(void);
extern void close_clients(char *str);
extern void set_client_input(char *str);
extern void set_child_info(void);
extern void reverse_connect(char *str);
extern void set_vnc_connect_prop(char *str);
extern void read_vnc_connect_prop(void);
extern void check_connect_inputs(void);
extern void check_gui_inputs(void);
extern enum rfbNewClientAction new_client(rfbClientPtr client);
extern void start_client_info_sock(char *host_port_cookie);
extern void send_client_info(char *str);
extern void check_new_clients(void);
#endif /* _X11VNC_CONNECTIONS_H */
This diff is collapsed.
#ifndef _X11VNC_CURSOR_H
#define _X11VNC_CURSOR_H
/* -- cursor.h -- */
extern int xfixes_present;
extern int use_xfixes;
extern int got_xfixes_cursor_notify;
extern int cursor_changes;
extern int alpha_threshold;
extern double alpha_frac;
extern int alpha_remove;
extern int alpha_blend;
extern int alt_arrow;
extern int alt_arrow_max;
extern void first_cursor(void);
extern void setup_cursors_and_push(void);
extern void initialize_xfixes(void);
extern int known_cursors_mode(char *s);
extern void initialize_cursors_mode(void);
extern int get_which_cursor(void);
extern void restore_cursor_shape_updates(rfbScreenInfoPtr s);
extern void disable_cursor_shape_updates(rfbScreenInfoPtr s);
extern int cursor_shape_updates_clients(rfbScreenInfoPtr s);
extern int cursor_pos_updates_clients(rfbScreenInfoPtr s);
extern void cursor_position(int x, int y);
extern void set_no_cursor(void);
extern int set_cursor(int x, int y, int which);
extern int check_x11_pointer(void);
#endif /* _X11VNC_CURSOR_H */
#ifndef _X11VNC_ENUMS_H
#define _X11VNC_ENUMS_H
/* -- enums.h -- */
enum {
LR_UNSET = 0,
LR_UNKNOWN,
LR_DIALUP,
LR_BROADBAND,
LR_LAN
};
enum scroll_types {
SCR_NONE = 0,
SCR_MOUSE,
SCR_KEY,
SCR_FAIL,
SCR_SUCCESS
};
#endif /* _X11VNC_ENUMS_H */
This diff is collapsed.
#ifndef _X11VNC_GUI_H
#define _X11VNC_GUI_H
/* -- gui.h -- */
extern int icon_mode;
extern char *icon_mode_file;
extern FILE *icon_mode_fh;
extern int icon_mode_socks[];
extern int tray_manager_ok;
extern Window tray_request;
extern Window tray_window;
extern int tray_unembed;
extern char *get_gui_code(void);
extern int tray_embed(Window iconwin, int remove);
extern void do_gui(char *opts, int sleep);
#endif /* _X11VNC_GUI_H */
This diff is collapsed.
#ifndef _X11VNC_HELP_H
#define _X11VNC_HELP_H
/* -- help.h -- */
extern void print_help(int mode);
extern void xopen_display_fail_message(char *disp);
extern void nopassword_warning_msg(int gotloc);
#endif /* _X11VNC_HELP_H */
/* -- inet.c -- */
#include "x11vnc.h"
/*
* Simple utility to map host name to dotted IP address. Ignores aliases.
* Up to caller to free returned string.
*/
char *host2ip(char *host);
char *raw2host(char *raw, int len);
char *raw2ip(char *raw);
char *ip2host(char *ip);
int dotted_ip(char *host);
int get_remote_port(int sock);
int get_local_port(int sock);
char *get_remote_host(int sock);
char *get_local_host(int sock);
char *ident_username(rfbClientPtr client);
static int get_port(int sock, int remote);
static char *get_host(int sock, int remote);
char *host2ip(char *host) {
struct hostent *hp;
struct sockaddr_in addr;
char *str;
if (! host_lookup) {
return NULL;
}
hp = gethostbyname(host);
if (!hp) {
return NULL;
}
memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET;
addr.sin_addr.s_addr = *(unsigned long *)hp->h_addr;
str = strdup(inet_ntoa(addr.sin_addr));
return str;
}
char *raw2host(char *raw, int len) {
char *str;
#if LIBVNCSERVER_HAVE_NETDB_H && LIBVNCSERVER_HAVE_NETINET_IN_H
struct hostent *hp;
if (! host_lookup) {
return strdup("unknown");
}
hp = gethostbyaddr(raw, len, AF_INET);
if (!hp) {
return strdup(inet_ntoa(*((struct in_addr *)raw)));
}
str = strdup(hp->h_name);
#else
str = strdup("unknown");
#endif
return str;
}
char *raw2ip(char *raw) {
return strdup(inet_ntoa(*((struct in_addr *)raw)));
}
char *ip2host(char *ip) {
char *str;
#if LIBVNCSERVER_HAVE_NETDB_H && LIBVNCSERVER_HAVE_NETINET_IN_H
struct hostent *hp;
in_addr_t iaddr;
if (! host_lookup) {
return strdup("unknown");
}
iaddr = inet_addr(ip);
if (iaddr == htonl(INADDR_NONE)) {
return strdup("unknown");
}
hp = gethostbyaddr((char *)&iaddr, sizeof(in_addr_t), AF_INET);
if (!hp) {
return strdup("unknown");
}
str = strdup(hp->h_name);
#else
str = strdup("unknown");
#endif
return str;
}
int dotted_ip(char *host) {
char *p = host;
while (*p != '\0') {
if (*p == '.' || isdigit(*p)) {
p++;
continue;
}
return 0;
}
return 1;
}
static int get_port(int sock, int remote) {
struct sockaddr_in saddr;
unsigned int saddr_len;
int saddr_port;
saddr_len = sizeof(saddr);
memset(&saddr, 0, sizeof(saddr));
saddr_port = -1;
if (remote) {
if (!getpeername(sock, (struct sockaddr *)&saddr, &saddr_len)) {
saddr_port = ntohs(saddr.sin_port);
}
} else {
if (!getsockname(sock, (struct sockaddr *)&saddr, &saddr_len)) {
saddr_port = ntohs(saddr.sin_port);
}
}
return saddr_port;
}
int get_remote_port(int sock) {
return get_port(sock, 1);
}
int get_local_port(int sock) {
return get_port(sock, 0);
}
static char *get_host(int sock, int remote) {
struct sockaddr_in saddr;
unsigned int saddr_len;
int saddr_port;
char *saddr_ip_str = NULL;
saddr_len = sizeof(saddr);
memset(&saddr, 0, sizeof(saddr));
saddr_port = -1;
#if LIBVNCSERVER_HAVE_NETINET_IN_H
if (remote) {
if (!getpeername(sock, (struct sockaddr *)&saddr, &saddr_len)) {
saddr_ip_str = inet_ntoa(saddr.sin_addr);
}
} else {
if (!getsockname(sock, (struct sockaddr *)&saddr, &saddr_len)) {
saddr_ip_str = inet_ntoa(saddr.sin_addr);
}
}
#endif
if (! saddr_ip_str) {
saddr_ip_str = "unknown";
}
return strdup(saddr_ip_str);
}
char *get_remote_host(int sock) {
return get_host(sock, 1);
}
char *get_local_host(int sock) {
return get_host(sock, 0);
}
char *ident_username(rfbClientPtr client) {
ClientData *cd = (ClientData *) client->clientData;
char *str, *newhost, *user = NULL, *newuser = NULL;
int len;
if (cd) {
user = cd->username;
}
if (!user || *user == '\0') {
char msg[128];
int n, sock, ok = 0;
if ((sock = rfbConnectToTcpAddr(client->host, 113)) < 0) {
rfbLog("could not connect to ident: %s:%d\n",
client->host, 113);
} else {
int ret;
fd_set rfds;
struct timeval tv;
int rport = get_remote_port(client->sock);
int lport = get_local_port(client->sock);
sprintf(msg, "%d, %d\r\n", rport, lport);
n = write(sock, msg, strlen(msg));
FD_ZERO(&rfds);
FD_SET(sock, &rfds);
tv.tv_sec = 4;
tv.tv_usec = 0;
ret = select(sock+1, &rfds, NULL, NULL, &tv);
if (ret > 0) {
int i;
char *q, *p;
for (i=0; i<128; i++) {
msg[i] = '\0';
}
usleep(250*1000);
n = read(sock, msg, 127);
close(sock);
if (n <= 0) goto badreply;
/* 32782 , 6000 : USERID : UNIX :runge */
q = strstr(msg, "USERID");
if (!q) goto badreply;
q = strstr(q, ":");
if (!q) goto badreply;
q++;
q = strstr(q, ":");
if (!q) goto badreply;
q++;
q = lblanks(q);
p = q;
while (*p) {
if (*p == '\r' || *p == '\n') {
*p = '\0';
}
p++;
}
ok = 1;
if (strlen(q) > 24) {
*(q+24) = '\0';
}
newuser = strdup(q);
badreply:
n = 0; /* avoid syntax error */
} else {
close(sock);
}
}
if (! ok || !newuser) {
newuser = strdup("unknown-user");
}
if (cd) {
if (cd->username) {
free(cd->username);
}
cd->username = newuser;
}
user = newuser;
}
newhost = ip2host(client->host);
len = strlen(user) + 1 + strlen(newhost) + 1;
str = (char *) malloc(len);
sprintf(str, "%s@%s", user, newhost);
free(newhost);
return str;
}
#ifndef _X11VNC_INET_H
#define _X11VNC_INET_H
/* -- inet.h -- */
extern char *host2ip(char *host);
extern char *raw2host(char *raw, int len);
extern char *raw2ip(char *raw);
extern char *ip2host(char *ip);
extern int dotted_ip(char *host);
extern int get_remote_port(int sock);
extern int get_local_port(int sock);
extern char *get_remote_host(int sock);
extern char *get_local_host(int sock);
extern char *ident_username(rfbClientPtr client);
#endif /* _X11VNC_INET_H */
This diff is collapsed.
#ifndef _X11VNC_KEYBOARD_H
#define _X11VNC_KEYBOARD_H
/* -- keyboard.h -- */
#include "allowed_input_t.h"
extern void get_keystate(int *keystate);
extern void clear_modifiers(int init);
extern int track_mod_state(rfbKeySym keysym, rfbBool down, rfbBool set);
extern void clear_keys(void);
extern int get_autorepeat_state(void);
extern int get_initial_autorepeat_state(void);
extern void autorepeat(int restore, int bequiet);
extern void check_add_keysyms(void);
extern int add_keysym(KeySym keysym);
extern void delete_added_keycodes(int bequiet);
extern void initialize_remap(char *infile);
extern int sloppy_key_check(int key, rfbBool down, rfbKeySym keysym, int *new);
extern void switch_to_xkb_if_better(void);
extern char *short_kmb(char *str);
extern void initialize_allowed_input(void);
extern void initialize_modtweak(void);
extern void initialize_keyboard_and_pointer(void);
extern void get_allowed_input(rfbClientPtr client, allowed_input_t *input);
extern double typing_rate(double time_window, int *repeating);
extern int skip_cr_when_scaling(char *mode);
extern void keyboard(rfbBool down, rfbKeySym keysym, rfbClientPtr client);
#endif /* _X11VNC_KEYBOARD_H */
This diff is collapsed.
This diff is collapsed.
#ifndef _X11VNC_PARAMS_H
#define _X11VNC_PARAMS_H
/* -- params.h -- */
#define ICON_MODE_SOCKS 16
#ifndef WIREFRAME_PARMS
#define WIREFRAME_PARMS "0xff,3,0,32+8+8+8,all,0.15+0.30+5.0+0.125"
#endif
#ifndef SCROLL_COPYRECT_PARMS
#define SCROLL_COPYRECT_PARMS "0+64+32+32,0.02+0.10+0.9,0.03+0.06+0.5+0.1+5.0"
#endif
#define LATENCY0 20 /* 20ms */
#define NETRATE0 20 /* 20KB/sec */
#define POINTER_MODE_NOFB 2
/* scan pattern jitter from x0rfbserver */
#define NSCAN 32
#define FB_COPY 0x1
#define FB_MOD 0x2
#define FB_REQ 0x4
#define VNC_CONNECT_MAX 16384
#define PROP_MAX (131072L)
#define MAXN 256
#endif /* _X11VNC_PARAMS_H */
This diff is collapsed.
#ifndef _X11VNC_POINTER_H
#define _X11VNC_POINTER_H
/* -- pointer.h -- */
extern int pointer_queued_sent;
extern void initialize_pointer_map(char *pointer_remap);
extern void do_button_mask_change(int mask, int button);
extern void pointer(int mask, int x, int y, rfbClientPtr client);
extern int check_pipeinput(void);
extern void initialize_pipeinput(void);
#endif /* _X11VNC_POINTER_H */
This diff is collapsed.
#ifndef _X11VNC_RATES_H
#define _X11VNC_RATES_H
/* -- rates.h -- */
extern int measure_speeds;
extern int speeds_net_rate;
extern int speeds_net_rate_measured;
extern int speeds_net_latency;
extern int speeds_net_latency_measured;
extern int speeds_read_rate;
extern int speeds_read_rate_measured;
extern int get_cmp_rate(void);
extern int get_raw_rate(void);
extern void initialize_speeds(void);
extern int get_read_rate(void);
extern int link_rate(int *latency, int *netrate);
extern int get_net_rate(void);
extern int get_net_latency(void);
extern void measure_send_rates(int init);
#endif /* _X11VNC_RATES_H */
This diff is collapsed.
#ifndef _X11VNC_REMOTE_H
#define _X11VNC_REMOTE_H
/* -- remote.h -- */
extern int send_remote_cmd(char *cmd, int query, int wait);
extern int do_remote_query(char *remote_cmd, char *query_cmd, int remote_sync,
int qdefault);
extern void check_black_fb(void);
extern int check_httpdir(void);
extern void http_connections(int on);
extern int remote_control_access_ok(void);
extern char *process_remote_cmd(char *cmd, int stringonly);
#endif /* _X11VNC_REMOTE_H */
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
#ifndef _X11VNC_SOLID_H
#define _X11VNC_SOLID_H
/* -- solid.h -- */
extern char *guess_desktop(void);
extern void solid_bg(int restore);
#endif /* _X11VNC_SOLID_H */
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment