Working input/output.

This commit is contained in:
Michael Jumper 2013-05-17 22:53:13 -07:00
parent 5009d1c280
commit a53a5e2e1b
2 changed files with 44 additions and 4 deletions

View File

@ -294,7 +294,7 @@ int ssh_guac_client_key_handler(guac_client* client, int keysym, int pressed) {
if (keysym == 0xFF08) { data = "\x08"; length = 1; }
else if (keysym == 0xFF09) { data = "\x09"; length = 1; }
else if (keysym == 0xFF0D) { data = "\x0D"; length = 1; }
else if (keysym == 0xFF0D) { data = "\x0A"; length = 1; }
else if (keysym == 0xFF1B) { data = "\x1B"; length = 1; }
/* Arrow keys */

View File

@ -37,16 +37,56 @@
* ***** END LICENSE BLOCK ***** */
#include <stdio.h>
#include <string.h>
#include <guacamole/client.h>
#include "client.h"
/**
* Similar to fgets(), reads a single line from STDIN. Unlike fgets(), this
* function does not include the trailing newline character, although the
* character is removed from the input stream.
*
* @param title The title of the prompt to display.
* @param str The buffer to read the result into.
* @param size The number of bytes available in the buffer.
* @return str, or NULL if the prompt failed.
*/
static char* prompt(const char* title, char* str, int size) {
/* Print title */
printf("%s", title);
fflush(stdout);
/* Read input */
str = fgets(str, size, stdin);
/* Remove trailing newline, if any */
if (str != NULL) {
int length = strlen(str);
if (str[length-1] == '\n')
str[length-1] = 0;
}
return str;
}
void* ssh_client_thread(void* data) {
/* STUB */
printf("--- STUB! ---\n");
fflush(stdout);
char username[1024];
char password[1024];
/* Get username */
if (prompt("Login as: ", username, sizeof(username)) == NULL)
return NULL;
/* Get password */
if (prompt("Password: ", password, sizeof(password)) == NULL)
return NULL;
guac_client_log_info((guac_client*) data, "got: %s ... %s", username, password);
return NULL;