summaryrefslogtreecommitdiffstats
path: root/client_examples
diff options
context:
space:
mode:
authorChristian Beier <dontmind@freeshell.org>2018-07-25 14:22:00 +0200
committerChristian Beier <dontmind@freeshell.org>2018-07-25 14:22:00 +0200
commit436a047f56cf5f5c92d946faa6b08e3ed7aa2309 (patch)
tree847fea003aec91c06a8c98416cc232e97392accb /client_examples
parent1781ecda341fb06fd414a4d84bb363b070958ea4 (diff)
downloadlibtdevnc-436a047f56cf5f5c92d946faa6b08e3ed7aa2309.tar.gz
libtdevnc-436a047f56cf5f5c92d946faa6b08e3ed7aa2309.zip
SDLvncviewer: add a very simple GetCredentials callback
Diffstat (limited to 'client_examples')
-rw-r--r--client_examples/SDLvncviewer.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/client_examples/SDLvncviewer.c b/client_examples/SDLvncviewer.c
index 8fe6f57..6dce992 100644
--- a/client_examples/SDLvncviewer.c
+++ b/client_examples/SDLvncviewer.c
@@ -475,6 +475,30 @@ static void got_selection(rfbClient *cl, const char *text, int len)
}
+static rfbCredential* get_credential(rfbClient* cl, int credentialType){
+ rfbCredential *c = malloc(sizeof(rfbCredential));
+ c->userCredential.username = malloc(RFB_BUF_SIZE);
+ c->userCredential.password = malloc(RFB_BUF_SIZE);
+
+ if(credentialType != rfbCredentialTypeUser) {
+ rfbClientErr("something else than username and password required for authentication\n");
+ return NULL;
+ }
+
+ rfbClientLog("username and password required for authentication!\n");
+ printf("user: ");
+ fgets(c->userCredential.username, RFB_BUF_SIZE, stdin);
+ printf("pass: ");
+ fgets(c->userCredential.password, RFB_BUF_SIZE, stdin);
+
+ /* remove trailing newlines */
+ c->userCredential.username[strcspn(c->userCredential.username, "\n")] = 0;
+ c->userCredential.password[strcspn(c->userCredential.password, "\n")] = 0;
+
+ return c;
+}
+
+
#ifdef mac
#define main SDLmain
#endif
@@ -523,6 +547,7 @@ int main(int argc,char** argv) {
cl->HandleKeyboardLedState=kbd_leds;
cl->HandleTextChat=text_chat;
cl->GotXCutText = got_selection;
+ cl->GetCredential = get_credential;
cl->listenPort = LISTEN_PORT_OFFSET;
cl->listen6Port = LISTEN_PORT_OFFSET;
if(!rfbInitClient(cl,&argc,argv))