Use libvncclient options, parse password from command line.

This commit is contained in:
Michael Jumper
2010-10-02 08:34:48 +00:00
parent f94ea16b1f
commit 1b07316b0e

View File

@@ -31,7 +31,7 @@
#include <guacamole/protocol.h> #include <guacamole/protocol.h>
#include <guacamole/client.h> #include <guacamole/client.h>
char __guac_password[] = "potato"; char __guac_password[256] = "";
static char* __GUAC_CLIENT = "GUAC_CLIENT"; static char* __GUAC_CLIENT = "GUAC_CLIENT";
@@ -276,8 +276,7 @@ int vnc_guac_client_free_handler(guac_client* client) {
int guac_client_init(guac_client* client, int argc, char** argv) { int guac_client_init(guac_client* client, int argc, char** argv) {
char* hostname_copy; char** rfb_argv;
rfbClient* rfb_client; rfbClient* rfb_client;
png_byte** png_buffer; png_byte** png_buffer;
@@ -302,17 +301,31 @@ int guac_client_init(guac_client* client, int argc, char** argv) {
/* Password */ /* Password */
rfb_client->GetPassword = guac_vnc_get_password; rfb_client->GetPassword = guac_vnc_get_password;
/* Connect */ /* Parse password from args if provided */
hostname_copy = malloc(1024); if (argc >= 2 && strncmp(argv[0], "-passwd=", 8) == 0) {
strncpy(hostname_copy, argv[0], 1024);
rfb_client->serverHost = hostname_copy; strncpy(__guac_password, &((argv[0])[8]), sizeof(__guac_password));
rfb_client->serverPort = atoi(argv[1]);
if (!rfbInitClient(rfb_client, NULL, NULL)) { /* Continue with next argument */
argc--;
argv = &(argv[1]);
}
/* Set up argc/argv for libvncclient (expects progname) */
rfb_argv = malloc((argc+1) * sizeof(char*));
rfb_argv[0] = "guac-client-vnc";
memcpy(&(rfb_argv[1]), argv, argc*sizeof(char*));
argc++;
/* Parse remaining args, connect */
if (!rfbInitClient(rfb_client, &argc, rfb_argv)) {
return 1; return 1;
} }
free(rfb_argv);
/* Allocate buffers */ /* Allocate buffers */
png_buffer = guac_alloc_png_buffer(rfb_client->width, rfb_client->height, 3); /* No-alpha */ png_buffer = guac_alloc_png_buffer(rfb_client->width, rfb_client->height, 3); /* No-alpha */
png_buffer_alpha = guac_alloc_png_buffer(rfb_client->width, rfb_client->height, 4); /* With alpha */ png_buffer_alpha = guac_alloc_png_buffer(rfb_client->width, rfb_client->height, 4); /* With alpha */