int xf_event_action_script_init(xfContext* xfc) { int exitCode; char* xevent; FILE* actionScript; char buffer[1024] = { 0 }; char command[1024] = { 0 }; xfc->xevents = ArrayList_New(TRUE); ArrayList_Object(xfc->xevents)->fnObjectFree = free; sprintf_s(command, sizeof(command), "%s xevent", xfc->actionScript); actionScript = popen(command, "r"); if (actionScript < 0) return -1; while (fgets(buffer, sizeof(buffer), actionScript)) { strtok(buffer, "\n"); xevent = _strdup(buffer); ArrayList_Add(xfc->xevents, xevent); } exitCode = pclose(actionScript); return 1; }
BOOL xf_event_action_script_init(xfContext* xfc) { char* xevent; FILE* actionScript; char buffer[1024] = { 0 }; char command[1024] = { 0 }; xfc->xevents = ArrayList_New(TRUE); if (!xfc->xevents) return FALSE; ArrayList_Object(xfc->xevents)->fnObjectFree = free; sprintf_s(command, sizeof(command), "%s xevent", xfc->actionScript); actionScript = popen(command, "r"); if (!actionScript) return FALSE; while (fgets(buffer, sizeof(buffer), actionScript)) { strtok(buffer, "\n"); xevent = _strdup(buffer); if (!xevent || ArrayList_Add(xfc->xevents, xevent) < 0) { ArrayList_Free(xfc->xevents); xfc->xevents = NULL; return FALSE; } } pclose(actionScript); return TRUE; }
TSMF_PRESENTATION* tsmf_presentation_new(const BYTE* guid, IWTSVirtualChannelCallback* pChannelCallback) { TSMF_PRESENTATION* presentation; if (!guid || !pChannelCallback) return NULL; presentation = (TSMF_PRESENTATION*) calloc(1, sizeof(TSMF_PRESENTATION)); if (!presentation) { WLog_ERR(TAG, "calloc failed"); return NULL; } CopyMemory(presentation->presentation_id, guid, GUID_SIZE); presentation->channel_callback = pChannelCallback; presentation->volume = 5000; /* 50% */ presentation->stream_list = ArrayList_New(TRUE); if (presentation->stream_list) goto error_stream_list; ArrayList_Object(presentation->stream_list)->fnObjectFree = (OBJECT_FREE_FN) _tsmf_stream_free; if (ArrayList_Add(presentation_list, presentation) < 0) goto error_add; return presentation; error_add: ArrayList_Free(presentation->stream_list); error_stream_list: free(presentation); return NULL; }
BOOL xf_keyboard_action_script_init(xfContext* xfc) { FILE* keyScript; char* keyCombination; char buffer[1024] = { 0 }; char command[1024] = { 0 }; if (xfc->actionScript) { free(xfc->actionScript); xfc->actionScript = NULL; } if (PathFileExistsA("/usr/share/freerdp/action.sh")) xfc->actionScript = _strdup("/usr/share/freerdp/action.sh"); if (!xfc->actionScript) return FALSE; xfc->keyCombinations = ArrayList_New(TRUE); if (!xfc->keyCombinations) return FALSE; ArrayList_Object(xfc->keyCombinations)->fnObjectFree = free; sprintf_s(command, sizeof(command), "%s key", xfc->actionScript); keyScript = popen(command, "r"); if (!keyScript) { free(xfc->actionScript); xfc->actionScript = NULL; return FALSE; } while (fgets(buffer, sizeof(buffer), keyScript) != NULL) { strtok(buffer, "\n"); keyCombination = _strdup(buffer); if (!keyCombination || ArrayList_Add(xfc->keyCombinations, keyCombination) < 0) { ArrayList_Free(xfc->keyCombinations); free(xfc->actionScript); xfc->actionScript = NULL; pclose(keyScript); return FALSE; } } pclose(keyScript); return xf_event_action_script_init(xfc); }
void tsmf_media_init(void) { #ifndef _WIN32 struct sigaction sigtrap; sigtrap.sa_handler = tsmf_signal_handler; sigemptyset(&sigtrap.sa_mask); sigtrap.sa_flags = 0; sigaction(SIGINT, &sigtrap, 0); sigaction(SIGUSR1, &sigtrap, 0); #endif if (!presentation_list) { presentation_list = ArrayList_New(TRUE); ArrayList_Object(presentation_list)->fnObjectFree = (OBJECT_FREE_FN) _tsmf_presentation_free; } }
TSMF_PRESENTATION *tsmf_presentation_new(const BYTE *guid, IWTSVirtualChannelCallback *pChannelCallback) { TSMF_PRESENTATION *presentation; assert(guid); assert(pChannelCallback); presentation = (TSMF_PRESENTATION *) calloc(1, sizeof(TSMF_PRESENTATION)); if (!presentation) { CLOG_ERR("calloc failed"); return NULL; } CopyMemory(presentation->presentation_id, guid, GUID_SIZE); presentation->channel_callback = pChannelCallback; presentation->volume = 5000; /* 50% */ presentation->stream_list = ArrayList_New(TRUE); ArrayList_Object(presentation->stream_list)->fnObjectFree = (OBJECT_FREE_FN) _tsmf_stream_free; ArrayList_Add(presentation_list, presentation); return presentation; }
int rpc_client_new(rdpRpc* rpc) { RpcClient* client = NULL; client = (RpcClient*) malloc(sizeof(RpcClient)); if (client) { client->Thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) rpc_client_thread, rpc, CREATE_SUSPENDED, NULL); client->StopEvent = CreateEvent(NULL, TRUE, FALSE, NULL); client->PduSentEvent = CreateEvent(NULL, TRUE, FALSE, NULL); client->SendQueue = Queue_New(TRUE, -1, -1); Queue_Object(client->SendQueue)->fnObjectFree = (OBJECT_FREE_FN) rpc_pdu_free; client->pdu = NULL; client->ReceivePool = Queue_New(TRUE, -1, -1); client->ReceiveQueue = Queue_New(TRUE, -1, -1); Queue_Object(client->ReceivePool)->fnObjectFree = (OBJECT_FREE_FN) rpc_pdu_free; Queue_Object(client->ReceiveQueue)->fnObjectFree = (OBJECT_FREE_FN) rpc_pdu_free; client->RecvFrag = NULL; client->FragmentPool = Queue_New(TRUE, -1, -1); client->FragmentQueue = Queue_New(TRUE, -1, -1); Queue_Object(client->FragmentPool)->fnObjectFree = (OBJECT_FREE_FN) rpc_fragment_free; Queue_Object(client->FragmentQueue)->fnObjectFree = (OBJECT_FREE_FN) rpc_fragment_free; client->ClientCallList = ArrayList_New(TRUE); ArrayList_Object(client->ClientCallList)->fnObjectFree = (OBJECT_FREE_FN) rpc_client_call_free; } rpc->client = client; return 0; }
int rpc_client_new(rdpRpc* rpc) { RpcClient* client; client = (RpcClient*) calloc(1, sizeof(RpcClient)); rpc->client = client; if (!client) return -1; client->StopEvent = CreateEvent(NULL, TRUE, FALSE, NULL); if (!client->StopEvent) return -1; client->PduSentEvent = CreateEvent(NULL, TRUE, FALSE, NULL); if (!client->PduSentEvent) return -1; client->SendQueue = Queue_New(TRUE, -1, -1); if (!client->SendQueue) return -1; Queue_Object(client->SendQueue)->fnObjectFree = (OBJECT_FREE_FN) rpc_pdu_free; client->pdu = NULL; client->ReceivePool = Queue_New(TRUE, -1, -1); if (!client->ReceivePool) return -1; Queue_Object(client->ReceivePool)->fnObjectFree = (OBJECT_FREE_FN) rpc_pdu_free; client->ReceiveQueue = Queue_New(TRUE, -1, -1); if (!client->ReceiveQueue) return -1; Queue_Object(client->ReceiveQueue)->fnObjectFree = (OBJECT_FREE_FN) rpc_pdu_free; client->RecvFrag = NULL; client->FragmentPool = Queue_New(TRUE, -1, -1); if (!client->FragmentPool) return -1; Queue_Object(client->FragmentPool)->fnObjectFree = (OBJECT_FREE_FN) rpc_fragment_free; client->FragmentQueue = Queue_New(TRUE, -1, -1); if (!client->FragmentQueue) return -1; Queue_Object(client->FragmentQueue)->fnObjectFree = (OBJECT_FREE_FN) rpc_fragment_free; client->ClientCallList = ArrayList_New(TRUE); if (!client->ClientCallList) return -1; ArrayList_Object(client->ClientCallList)->fnObjectFree = (OBJECT_FREE_FN) rpc_client_call_free; return 0; }