aboutsummaryrefslogtreecommitdiff
path: root/src/ccapi/common/win/win-utils.c
blob: b49cca85f037bf19cb904aa739fe947521bf98e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/* ccapi/common/win/win-utils.c */
/*
 * Copyright 2008 Massachusetts Institute of Technology.
 * All Rights Reserved.
 *
 * Export of this software from the United States of America may
 * require a specific license from the United States Government.
 * It is the responsibility of any person or organization contemplating
 * export to obtain such a license before exporting.
 *
 * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
 * distribute this software and its documentation for any purpose and
 * without fee is hereby granted, provided that the above copyright
 * notice appear in all copies and that both that copyright notice and
 * this permission notice appear in supporting documentation, and that
 * the name of M.I.T. not be used in advertising or publicity pertaining
 * to distribution of the software without specific, written prior
 * permission.  Furthermore if you modify this software you must label
 * your software as modified software and not distribute it in such a
 * fashion that it might be confused with the original M.I.T. software.
 * M.I.T. makes no representations about the suitability of
 * this software for any purpose.  It is provided "as is" without express
 * or implied warranty.
 */

#include <stdio.h>
#include <string.h>
#include <time.h>
#include "windows.h"
#include <stdlib.h>
#include <malloc.h>


#include "win-utils.h"
#include "cci_debugging.h"

#pragma warning (disable : 4996)

#define UUID_SIZE   128

char*           clientPrefix        = "CCAPI_CLIENT_";
char*           serverPrefix        = "CCS_LISTEN_";
unsigned char*  pszProtocolSequence = "ncalrpc";

#define         MAX_TIMESTAMP   40
char            _ts[MAX_TIMESTAMP];

char* clientEndpoint(const char* UUID) {
    char* _clientEndpoint   = (char*)malloc(strlen(UUID) + strlen(clientPrefix) + 2);
    strcpy(_clientEndpoint, clientPrefix);
    strncat(_clientEndpoint, UUID, UUID_SIZE);
//    cci_debug_printf("%s returning %s", __FUNCTION__, _clientEndpoint);
    return _clientEndpoint;
    }

char* serverEndpoint(const char* user) {
    char* _serverEndpoint   = (char*)malloc(strlen(user) + strlen(serverPrefix) + 2);
    strcpy(_serverEndpoint, serverPrefix);
    strncat(_serverEndpoint, user, UUID_SIZE);
    return _serverEndpoint;
    }

char* timestamp() {
    SYSTEMTIME  _stime;
    GetSystemTime(&_stime);
    GetTimeFormat(LOCALE_SYSTEM_DEFAULT, 0, &_stime, "HH:mm:ss", _ts, sizeof(_ts)-1);
    return _ts;
    }