Path: blob/main/crypto/krb5/src/ccapi/common/win/win-utils.c
39566 views
/* ccapi/common/win/win-utils.c */1/*2* Copyright 2008 Massachusetts Institute of Technology.3* All Rights Reserved.4*5* Export of this software from the United States of America may6* require a specific license from the United States Government.7* It is the responsibility of any person or organization contemplating8* export to obtain such a license before exporting.9*10* WITHIN THAT CONSTRAINT, permission to use, copy, modify, and11* distribute this software and its documentation for any purpose and12* without fee is hereby granted, provided that the above copyright13* notice appear in all copies and that both that copyright notice and14* this permission notice appear in supporting documentation, and that15* the name of M.I.T. not be used in advertising or publicity pertaining16* to distribution of the software without specific, written prior17* permission. Furthermore if you modify this software you must label18* your software as modified software and not distribute it in such a19* fashion that it might be confused with the original M.I.T. software.20* M.I.T. makes no representations about the suitability of21* this software for any purpose. It is provided "as is" without express22* or implied warranty.23*/2425#include <stdio.h>26#include <string.h>27#include <time.h>28#include "windows.h"29#include <stdlib.h>30#include <malloc.h>313233#include "win-utils.h"34#include "cci_debugging.h"3536#pragma warning (disable : 4996)3738#define UUID_SIZE 1283940char* clientPrefix = "CCAPI_CLIENT_";41char* serverPrefix = "CCS_LISTEN_";42unsigned char* pszProtocolSequence = "ncalrpc";4344#define MAX_TIMESTAMP 4045char _ts[MAX_TIMESTAMP];4647char* clientEndpoint(const char* UUID) {48char* _clientEndpoint = (char*)malloc(strlen(UUID) + strlen(clientPrefix) + 2);49strcpy(_clientEndpoint, clientPrefix);50strncat(_clientEndpoint, UUID, UUID_SIZE);51// cci_debug_printf("%s returning %s", __FUNCTION__, _clientEndpoint);52return _clientEndpoint;53}5455char* serverEndpoint(const char* user) {56char* _serverEndpoint = (char*)malloc(strlen(user) + strlen(serverPrefix) + 2);57strcpy(_serverEndpoint, serverPrefix);58strncat(_serverEndpoint, user, UUID_SIZE);59return _serverEndpoint;60}6162char* timestamp(void) {63SYSTEMTIME _stime;64GetSystemTime(&_stime);65GetTimeFormat(LOCALE_SYSTEM_DEFAULT, 0, &_stime, "HH:mm:ss", _ts, sizeof(_ts)-1);66return _ts;67}686970