From d630d66c8b956ec511634b5200c09ba8ffdd967d Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Sun, 2 Mar 2014 10:46:38 -0800 Subject: [PATCH] Implement get for SVC. --- src/protocols/rdp/rdp_svc.c | 28 +++++++++++++++++++++++++--- src/protocols/rdp/rdp_svc.h | 2 +- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/protocols/rdp/rdp_svc.c b/src/protocols/rdp/rdp_svc.c index 9bd49f94..24ab9b0a 100644 --- a/src/protocols/rdp/rdp_svc.c +++ b/src/protocols/rdp/rdp_svc.c @@ -63,8 +63,30 @@ void guac_rdp_add_svc(guac_client* client, guac_rdp_svc* svc) { } -guac_rdp_svc* guac_rdp_get_svc(guac_client* client, char* name) { - /* STUB */ - return NULL; +guac_rdp_svc* guac_rdp_get_svc(guac_client* client, const char* name) { + + rdp_guac_client_data* client_data = (rdp_guac_client_data*) client->data; + guac_common_list_element* current; + guac_rdp_svc* found = NULL; + + /* For each available SVC */ + guac_common_list_lock(client_data->available_svc); + current = client_data->available_svc->head; + while (current != NULL) { + + /* If name matches, found */ + guac_rdp_svc* current_svc = (guac_rdp_svc*) current->data; + if (strcmp(current_svc->name, name) == 0) { + found = current_svc; + break; + } + + current = current->next; + + } + guac_common_list_unlock(client_data->available_svc); + + return found; + } diff --git a/src/protocols/rdp/rdp_svc.h b/src/protocols/rdp/rdp_svc.h index 0059df07..2c389bb7 100644 --- a/src/protocols/rdp/rdp_svc.h +++ b/src/protocols/rdp/rdp_svc.h @@ -82,7 +82,7 @@ void guac_rdp_add_svc(guac_client* client, guac_rdp_svc* svc); /** * Retrieve the SVC with the given name from the list stored in the client. */ -guac_rdp_svc* guac_rdp_get_svc(guac_client* client, char* name); +guac_rdp_svc* guac_rdp_get_svc(guac_client* client, const char* name); #endif