1 /* vdagent.c xorg-client to vdagentd (daemon).
3 Copyright 2010 Red Hat, Inc.
6 Hans de Goede <hdegoede@redhat.com>
8 This program is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
27 #include <sys/select.h>
30 #include "vdagentd-proto.h"
31 #include "vdagent-x11.h"
33 int daemon_read_complete(struct udscs_connection
*conn
,
34 struct udscs_message_header
*header
, const uint8_t *data
)
39 static void usage(FILE *fp
)
42 "vdagent -- spice agent xorg client\n"
44 " -h print this text\n"
45 " -d print debug messages\n");
48 int main(int argc
, char *argv
[])
50 struct udscs_connection
*client
;
51 struct vdagent_x11
*x11
;
52 fd_set readfds
, writefds
;
53 int c
, n
, nfds
, x11_fd
;
57 if (-1 == (c
= getopt(argc
, argv
, "dh")))
72 client
= udscs_connect(VDAGENTD_SOCKET
, daemon_read_complete
, NULL
);
76 x11
= vdagent_x11_create(client
, verbose
);
78 udscs_destroy_connection(&client
);
86 nfds
= udscs_client_fill_fds(client
, &readfds
, &writefds
);
87 x11_fd
= vdagent_x11_get_fd(x11
);
88 FD_SET(x11_fd
, &readfds
);
92 n
= select(nfds
, &readfds
, &writefds
, NULL
, NULL
);
100 if (FD_SET(x11_fd
, &readfds
))
101 vdagent_x11_do_read(x11
);
102 udscs_client_handle_fds(&client
, &readfds
, &writefds
);
105 vdagent_x11_destroy(x11
);