1 /* ccapi/common/win/win-utils.c */
2 /*
3 * Copyright 2008 Massachusetts Institute of Technology.
4 * All Rights Reserved.
5 *
6 * Export of this software from the United States of America may
7 * require a specific license from the United States Government.
8 * It is the responsibility of any person or organization contemplating
9 * export to obtain such a license before exporting.
10 *
11 * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
12 * distribute this software and its documentation for any purpose and
13 * without fee is hereby granted, provided that the above copyright
14 * notice appear in all copies and that both that copyright notice and
15 * this permission notice appear in supporting documentation, and that
16 * the name of M.I.T. not be used in advertising or publicity pertaining
17 * to distribution of the software without specific, written prior
18 * permission. Furthermore if you modify this software you must label
19 * your software as modified software and not distribute it in such a
20 * fashion that it might be confused with the original M.I.T. software.
21 * M.I.T. makes no representations about the suitability of
22 * this software for any purpose. It is provided "as is" without express
23 * or implied warranty.
24 */
25
26 #include <stdio.h>
27 #include <string.h>
28 #include <time.h>
29 #include "windows.h"
30 #include <stdlib.h>
31 #include <malloc.h>
32
33
34 #include "win-utils.h"
35 #include "cci_debugging.h"
36
37 #pragma warning (disable : 4996)
38
39 #define UUID_SIZE 128
40
41 char* clientPrefix = "CCAPI_CLIENT_";
42 char* serverPrefix = "CCS_LISTEN_";
43 unsigned char* pszProtocolSequence = "ncalrpc";
44
45 #define MAX_TIMESTAMP 40
46 char _ts[MAX_TIMESTAMP];
47
clientEndpoint(const char * UUID)48 char* clientEndpoint(const char* UUID) {
49 char* _clientEndpoint = (char*)malloc(strlen(UUID) + strlen(clientPrefix) + 2);
50 strcpy(_clientEndpoint, clientPrefix);
51 strncat(_clientEndpoint, UUID, UUID_SIZE);
52 // cci_debug_printf("%s returning %s", __FUNCTION__, _clientEndpoint);
53 return _clientEndpoint;
54 }
55
serverEndpoint(const char * user)56 char* serverEndpoint(const char* user) {
57 char* _serverEndpoint = (char*)malloc(strlen(user) + strlen(serverPrefix) + 2);
58 strcpy(_serverEndpoint, serverPrefix);
59 strncat(_serverEndpoint, user, UUID_SIZE);
60 return _serverEndpoint;
61 }
62
timestamp(void)63 char* timestamp(void) {
64 SYSTEMTIME _stime;
65 GetSystemTime(&_stime);
66 GetTimeFormat(LOCALE_SYSTEM_DEFAULT, 0, &_stime, "HH:mm:ss", _ts, sizeof(_ts)-1);
67 return _ts;
68 }
69