From 54383345ad77587fa4eaf765eb77d20439500482 Mon Sep 17 00:00:00 2001 From: Ken Raeburn Date: Tue, 5 Feb 2008 18:25:28 +0000 Subject: set eol-style git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@20217 dc483132-0cff-0310-8789-dd5450dbe970 --- src/ccapi/common/win/OldCC/ccutils.c | 270 +++++++++++++++---------------- src/ccapi/common/win/OldCC/ccutils.h | 98 +++++------ src/ccapi/common/win/OldCC/name.h | 74 ++++----- src/ccapi/common/win/OldCC/util.h | 178 ++++++++++---------- src/ccapi/common/win/cci_os_debugging.c | 78 ++++----- src/ccapi/common/win/cci_os_identifier.c | 114 ++++++------- src/ccapi/common/win/tls.c | 142 ++++++++-------- src/ccapi/common/win/tls.h | 140 ++++++++-------- src/ccapi/common/win/win-utils.c | 130 +++++++-------- src/ccapi/common/win/win-utils.h | 108 ++++++------- 10 files changed, 666 insertions(+), 666 deletions(-) (limited to 'src/ccapi/common/win') diff --git a/src/ccapi/common/win/OldCC/ccutils.c b/src/ccapi/common/win/OldCC/ccutils.c index 1db00b480..bfe138997 100644 --- a/src/ccapi/common/win/OldCC/ccutils.c +++ b/src/ccapi/common/win/OldCC/ccutils.c @@ -1,136 +1,136 @@ -/* - * $Header$ - * - * 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 - -#include "cci_debugging.h" -#include "util.h" - -BOOL isNT() { - OSVERSIONINFO osvi; - DWORD status = 0; - BOOL bSupportedVersion = FALSE; - BOOL bIsNT = FALSE; - - memset(&osvi, 0, sizeof(osvi)); - osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); - - status = !GetVersionEx(&osvi); // Returns a boolean. Invert to 0 is OK. - - if (!status) { - switch(osvi.dwPlatformId) { - case VER_PLATFORM_WIN32_WINDOWS: - bIsNT = FALSE; - bSupportedVersion = TRUE; - break; - case VER_PLATFORM_WIN32_NT: - bIsNT = TRUE; - bSupportedVersion = TRUE; - break; - case VER_PLATFORM_WIN32s: - default: - bIsNT = FALSE; - break; - } - - if (!bSupportedVersion) { - cci_debug_printf("%s Running on an unsupported version of Windows", __FUNCTION__); - status = 1; - } - } - - return (!status && bIsNT && bSupportedVersion); - } - -char* allocEventName(char* uuid_string, char* suffix) { - LPSTR event_name = NULL; - cc_int32 err = ccNoError; - - event_name = malloc(strlen(uuid_string) + strlen(suffix) + 3); - if (!event_name) err = cci_check_error(ccErrNoMem); - - if (!err) { - strcpy(event_name, uuid_string); - strcat(event_name, "_"); - strcat(event_name, suffix); - } - - return event_name; - } - -HANDLE createThreadEvent(char* uuid, char* suffix) { - LPSTR event_name = NULL; - HANDLE hEvent = NULL; - PSECURITY_ATTRIBUTES psa = 0; // Everything having to do with - SECURITY_ATTRIBUTES sa = { 0 }; // sa, psa, security is copied - DWORD status = 0; // from the previous implementation. - - psa = isNT() ? &sa : 0; - - if (isNT()) { - sa.nLength = sizeof(sa); - status = alloc_own_security_descriptor_NT(&sa.lpSecurityDescriptor); - cci_check_error(status); - } - - if (!status) { - event_name = allocEventName(uuid, suffix); - if (!event_name) status = cci_check_error(ccErrNoMem); - } - cci_debug_printf("%s event_name:%s", __FUNCTION__, event_name); - - if (!status) { - hEvent = CreateEvent(psa, FALSE, FALSE, event_name); - if (!hEvent) status = cci_check_error(GetLastError()); - } - - if (!status) ResetEvent(hEvent); - - - if (event_name) free(event_name); - if (isNT()) free(sa.lpSecurityDescriptor); - - return hEvent; - } - -HANDLE openThreadEvent(char* uuid, char* suffix) { - LPSTR event_name = NULL; - HANDLE hEvent = NULL; - DWORD status = 0; - - event_name = allocEventName(uuid, suffix); - if (!event_name) status = cci_check_error(ccErrNoMem); - cci_debug_printf("%s event_name:%s", __FUNCTION__, event_name); - - if (!status) { - hEvent = OpenEvent(EVENT_MODIFY_STATE, FALSE, event_name); - if (!hEvent) status = cci_check_error(GetLastError()); - } - - if (event_name) free(event_name); - - return hEvent; +/* + * $Header$ + * + * 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 + +#include "cci_debugging.h" +#include "util.h" + +BOOL isNT() { + OSVERSIONINFO osvi; + DWORD status = 0; + BOOL bSupportedVersion = FALSE; + BOOL bIsNT = FALSE; + + memset(&osvi, 0, sizeof(osvi)); + osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); + + status = !GetVersionEx(&osvi); // Returns a boolean. Invert to 0 is OK. + + if (!status) { + switch(osvi.dwPlatformId) { + case VER_PLATFORM_WIN32_WINDOWS: + bIsNT = FALSE; + bSupportedVersion = TRUE; + break; + case VER_PLATFORM_WIN32_NT: + bIsNT = TRUE; + bSupportedVersion = TRUE; + break; + case VER_PLATFORM_WIN32s: + default: + bIsNT = FALSE; + break; + } + + if (!bSupportedVersion) { + cci_debug_printf("%s Running on an unsupported version of Windows", __FUNCTION__); + status = 1; + } + } + + return (!status && bIsNT && bSupportedVersion); + } + +char* allocEventName(char* uuid_string, char* suffix) { + LPSTR event_name = NULL; + cc_int32 err = ccNoError; + + event_name = malloc(strlen(uuid_string) + strlen(suffix) + 3); + if (!event_name) err = cci_check_error(ccErrNoMem); + + if (!err) { + strcpy(event_name, uuid_string); + strcat(event_name, "_"); + strcat(event_name, suffix); + } + + return event_name; + } + +HANDLE createThreadEvent(char* uuid, char* suffix) { + LPSTR event_name = NULL; + HANDLE hEvent = NULL; + PSECURITY_ATTRIBUTES psa = 0; // Everything having to do with + SECURITY_ATTRIBUTES sa = { 0 }; // sa, psa, security is copied + DWORD status = 0; // from the previous implementation. + + psa = isNT() ? &sa : 0; + + if (isNT()) { + sa.nLength = sizeof(sa); + status = alloc_own_security_descriptor_NT(&sa.lpSecurityDescriptor); + cci_check_error(status); + } + + if (!status) { + event_name = allocEventName(uuid, suffix); + if (!event_name) status = cci_check_error(ccErrNoMem); + } + cci_debug_printf("%s event_name:%s", __FUNCTION__, event_name); + + if (!status) { + hEvent = CreateEvent(psa, FALSE, FALSE, event_name); + if (!hEvent) status = cci_check_error(GetLastError()); + } + + if (!status) ResetEvent(hEvent); + + + if (event_name) free(event_name); + if (isNT()) free(sa.lpSecurityDescriptor); + + return hEvent; + } + +HANDLE openThreadEvent(char* uuid, char* suffix) { + LPSTR event_name = NULL; + HANDLE hEvent = NULL; + DWORD status = 0; + + event_name = allocEventName(uuid, suffix); + if (!event_name) status = cci_check_error(ccErrNoMem); + cci_debug_printf("%s event_name:%s", __FUNCTION__, event_name); + + if (!status) { + hEvent = OpenEvent(EVENT_MODIFY_STATE, FALSE, event_name); + if (!hEvent) status = cci_check_error(GetLastError()); + } + + if (event_name) free(event_name); + + return hEvent; } \ No newline at end of file diff --git a/src/ccapi/common/win/OldCC/ccutils.h b/src/ccapi/common/win/OldCC/ccutils.h index 77cafb11e..073412893 100644 --- a/src/ccapi/common/win/OldCC/ccutils.h +++ b/src/ccapi/common/win/OldCC/ccutils.h @@ -1,49 +1,49 @@ -/* - * $Header$ - * - * 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. - */ - -#ifndef __CCUTILS_H__ -#define __CCUTILS_H__ - -#ifdef __cplusplus -extern "C" { -#endif -#if 0 -} -#endif - -#define REPLY_SUFFIX (char*)"reply" -#define LISTEN_SUFFIX (char*)"listen" - -BOOL isNT(); -char* allocEventName (char* uuid, char* suffix); -HANDLE createThreadEvent(char* uuid, char* suffix); -HANDLE openThreadEvent (char* uuid, char* suffix); - -#ifdef __cplusplus -} -#endif - -#endif /* __CCUTILS_H__ */ +/* + * $Header$ + * + * 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. + */ + +#ifndef __CCUTILS_H__ +#define __CCUTILS_H__ + +#ifdef __cplusplus +extern "C" { +#endif +#if 0 +} +#endif + +#define REPLY_SUFFIX (char*)"reply" +#define LISTEN_SUFFIX (char*)"listen" + +BOOL isNT(); +char* allocEventName (char* uuid, char* suffix); +HANDLE createThreadEvent(char* uuid, char* suffix); +HANDLE openThreadEvent (char* uuid, char* suffix); + +#ifdef __cplusplus +} +#endif + +#endif /* __CCUTILS_H__ */ diff --git a/src/ccapi/common/win/OldCC/name.h b/src/ccapi/common/win/OldCC/name.h index e0172d673..7b442e09c 100644 --- a/src/ccapi/common/win/OldCC/name.h +++ b/src/ccapi/common/win/OldCC/name.h @@ -1,38 +1,38 @@ -/* - * $Header$ - * - * 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. - */ - -#pragma once - -#ifdef _WIN64 -#define CCAPI_MODULE "krbcc64" -#else -#define CCAPI_MODULE "krbcc32" -#endif -#define CCAPI_DLL CCAPI_MODULE ".dll" -#define CCAPI_EXE CCAPI_MODULE "s.exe" - -#define CCAPI_DLL "ccapi.dll" +/* + * $Header$ + * + * 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. + */ + +#pragma once + +#ifdef _WIN64 +#define CCAPI_MODULE "krbcc64" +#else +#define CCAPI_MODULE "krbcc32" +#endif +#define CCAPI_DLL CCAPI_MODULE ".dll" +#define CCAPI_EXE CCAPI_MODULE "s.exe" + +#define CCAPI_DLL "ccapi.dll" #define CCAPI_EXE "ccapiserver.exe" \ No newline at end of file diff --git a/src/ccapi/common/win/OldCC/util.h b/src/ccapi/common/win/OldCC/util.h index a51858cd2..4a83c644a 100644 --- a/src/ccapi/common/win/OldCC/util.h +++ b/src/ccapi/common/win/OldCC/util.h @@ -1,89 +1,89 @@ -/* - * $Header$ - * - * 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. - */ - -#ifndef __UTIL_H__ -#define __UTIL_H__ - -#ifdef __cplusplus -extern "C" { -#endif -#if 0 -} -#endif - -BOOL isNT(); - -void* -user_allocate( - size_t size - ); - -void -user_free( - void* ptr - ); - -void -free_alloc_p( - void* pptr - ); - -DWORD -alloc_name( - LPSTR* pname, - LPSTR postfix, - BOOL isNT - ); - -DWORD -alloc_own_security_descriptor_NT( - PSECURITY_DESCRIPTOR* ppsd - ); - -DWORD -alloc_module_dir_name( - char* module, - char** pname - ); - -DWORD -alloc_module_dir_name_with_file( - char* module, - char* file, - char** pname - ); - -DWORD alloc_cmdline_2_args( - char* prog, - char* arg1, - char* arg2, - char** pname); - -#ifdef __cplusplus -} -#endif - -#endif /* __UTIL_H__ */ +/* + * $Header$ + * + * 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. + */ + +#ifndef __UTIL_H__ +#define __UTIL_H__ + +#ifdef __cplusplus +extern "C" { +#endif +#if 0 +} +#endif + +BOOL isNT(); + +void* +user_allocate( + size_t size + ); + +void +user_free( + void* ptr + ); + +void +free_alloc_p( + void* pptr + ); + +DWORD +alloc_name( + LPSTR* pname, + LPSTR postfix, + BOOL isNT + ); + +DWORD +alloc_own_security_descriptor_NT( + PSECURITY_DESCRIPTOR* ppsd + ); + +DWORD +alloc_module_dir_name( + char* module, + char** pname + ); + +DWORD +alloc_module_dir_name_with_file( + char* module, + char* file, + char** pname + ); + +DWORD alloc_cmdline_2_args( + char* prog, + char* arg1, + char* arg2, + char** pname); + +#ifdef __cplusplus +} +#endif + +#endif /* __UTIL_H__ */ diff --git a/src/ccapi/common/win/cci_os_debugging.c b/src/ccapi/common/win/cci_os_debugging.c index f1fbb2816..6e6a7158d 100644 --- a/src/ccapi/common/win/cci_os_debugging.c +++ b/src/ccapi/common/win/cci_os_debugging.c @@ -1,39 +1,39 @@ -/* - * $Header$ - * - * 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 -#include - -#include "cci_os_debugging.h" -#include "win-utils.h" - -/* ------------------------------------------------------------------------ */ - -void cci_os_debug_vprintf (const char *in_format, va_list in_args) { - printf ( "%s %ld ", timestamp(), GetCurrentThreadId() ); - vprintf ( in_format, in_args ); - printf ( "\n" ); - } +/* + * $Header$ + * + * 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 +#include + +#include "cci_os_debugging.h" +#include "win-utils.h" + +/* ------------------------------------------------------------------------ */ + +void cci_os_debug_vprintf (const char *in_format, va_list in_args) { + printf ( "%s %ld ", timestamp(), GetCurrentThreadId() ); + vprintf ( in_format, in_args ); + printf ( "\n" ); + } diff --git a/src/ccapi/common/win/cci_os_identifier.c b/src/ccapi/common/win/cci_os_identifier.c index 7b44fe3e9..34659e097 100644 --- a/src/ccapi/common/win/cci_os_identifier.c +++ b/src/ccapi/common/win/cci_os_identifier.c @@ -1,58 +1,58 @@ -/* - * $Header$ - * - * 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 "cci_common.h" -#include "cci_os_identifier.h" - -#include - -/* ------------------------------------------------------------------------ */ - -cc_int32 cci_os_identifier_new_uuid (cci_uuid_string_t *out_uuid_string) { - cc_int32 err = ccNoError; - UUID uuid; - char* uuidStringTemp; - - err = UuidCreate(&uuid); - - if (!err) { - err = UuidToString(&uuid, &uuidStringTemp); - } - - if (!err) { - *out_uuid_string = malloc(1+strlen(uuidStringTemp)); - - if (*out_uuid_string) { - strcpy(*out_uuid_string, uuidStringTemp); - } - - RpcStringFree(&uuidStringTemp); - } - - cci_debug_printf("cci_os_identifier_new_uuid returning %s", *out_uuid_string); - - return cci_check_error (err); +/* + * $Header$ + * + * 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 "cci_common.h" +#include "cci_os_identifier.h" + +#include + +/* ------------------------------------------------------------------------ */ + +cc_int32 cci_os_identifier_new_uuid (cci_uuid_string_t *out_uuid_string) { + cc_int32 err = ccNoError; + UUID uuid; + char* uuidStringTemp; + + err = UuidCreate(&uuid); + + if (!err) { + err = UuidToString(&uuid, &uuidStringTemp); + } + + if (!err) { + *out_uuid_string = malloc(1+strlen(uuidStringTemp)); + + if (*out_uuid_string) { + strcpy(*out_uuid_string, uuidStringTemp); + } + + RpcStringFree(&uuidStringTemp); + } + + cci_debug_printf("cci_os_identifier_new_uuid returning %s", *out_uuid_string); + + return cci_check_error (err); } \ No newline at end of file diff --git a/src/ccapi/common/win/tls.c b/src/ccapi/common/win/tls.c index 411d709aa..cf8daa3b2 100644 --- a/src/ccapi/common/win/tls.c +++ b/src/ccapi/common/win/tls.c @@ -1,71 +1,71 @@ -/* - * $Header$ - * - * 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 "string.h" - -#include "tls.h" - -struct tspdata* new_tspdata(char* uuid, time_t sst) { - struct tspdata* p = (struct tspdata*)malloc(sizeof(struct tspdata)); - if (p) { - memset(p, 0, sizeof(struct tspdata)); - p->_sst = sst; - if (uuid) {strncpy(p->_uuid, uuid, UUID_SIZE-1);} - } - return p; - } - -void delete_tspdata(struct tspdata* p) { - if (p) free(p); - } - -void tspdata_setUUID(struct tspdata* p, unsigned char __RPC_FAR* uuidString) { - strncpy(p->_uuid, uuidString, UUID_SIZE-1); - }; - -void tspdata_setConnected (struct tspdata* p, BOOL b) {p->_CCAPI_Connected = b;} - -void tspdata_setReplyEvent(struct tspdata* p, HANDLE h) {p->_replyEvent = h;} - -void tspdata_setRpcAState (struct tspdata* p, RPC_ASYNC_STATE* rpcState) { - p->_rpcState = rpcState;} - -void tspdata_setSST (struct tspdata* p, time_t t) {p->_sst = t;} - -void tspdata_setStream (struct tspdata* p, cci_stream_t s) {p->_stream = s;} - - -BOOL tspdata_getConnected (struct tspdata* p) {return p->_CCAPI_Connected;} - -HANDLE tspdata_getReplyEvent(struct tspdata* p) {return p->_replyEvent;} - -time_t tspdata_getSST (const struct tspdata* p) {return p->_sst;} - -cci_stream_t tspdata_getStream (const struct tspdata* p) {return p->_stream;} - -char* tspdata_getUUID (const struct tspdata* p) {return p->_uuid;} - -RPC_ASYNC_STATE* tspdata_getRpcAState (const struct tspdata* p) {return p->_rpcState;} +/* + * $Header$ + * + * 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 "string.h" + +#include "tls.h" + +struct tspdata* new_tspdata(char* uuid, time_t sst) { + struct tspdata* p = (struct tspdata*)malloc(sizeof(struct tspdata)); + if (p) { + memset(p, 0, sizeof(struct tspdata)); + p->_sst = sst; + if (uuid) {strncpy(p->_uuid, uuid, UUID_SIZE-1);} + } + return p; + } + +void delete_tspdata(struct tspdata* p) { + if (p) free(p); + } + +void tspdata_setUUID(struct tspdata* p, unsigned char __RPC_FAR* uuidString) { + strncpy(p->_uuid, uuidString, UUID_SIZE-1); + }; + +void tspdata_setConnected (struct tspdata* p, BOOL b) {p->_CCAPI_Connected = b;} + +void tspdata_setReplyEvent(struct tspdata* p, HANDLE h) {p->_replyEvent = h;} + +void tspdata_setRpcAState (struct tspdata* p, RPC_ASYNC_STATE* rpcState) { + p->_rpcState = rpcState;} + +void tspdata_setSST (struct tspdata* p, time_t t) {p->_sst = t;} + +void tspdata_setStream (struct tspdata* p, cci_stream_t s) {p->_stream = s;} + + +BOOL tspdata_getConnected (struct tspdata* p) {return p->_CCAPI_Connected;} + +HANDLE tspdata_getReplyEvent(struct tspdata* p) {return p->_replyEvent;} + +time_t tspdata_getSST (const struct tspdata* p) {return p->_sst;} + +cci_stream_t tspdata_getStream (const struct tspdata* p) {return p->_stream;} + +char* tspdata_getUUID (const struct tspdata* p) {return p->_uuid;} + +RPC_ASYNC_STATE* tspdata_getRpcAState (const struct tspdata* p) {return p->_rpcState;} diff --git a/src/ccapi/common/win/tls.h b/src/ccapi/common/win/tls.h index b18705e84..3d988cd69 100644 --- a/src/ccapi/common/win/tls.h +++ b/src/ccapi/common/win/tls.h @@ -1,70 +1,70 @@ -/* - * $Header$ - * - * 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. - */ - -/* Thread local storage for client threads. */ - -#ifndef _tls_h -#define _tls_h - -#include "windows.h" -#include "time.h" - -#include "cci_stream.h" - -#define UUID_SIZE 128 - -/* The client code can be run in any client thread. The thread-specific data - is defined here. - */ - -struct tspdata { - BOOL _CCAPI_Connected; - RPC_ASYNC_STATE* _rpcState; - HANDLE _replyEvent; - time_t _sst; - cci_stream_t _stream; - char _uuid[UUID_SIZE]; - }; - -struct tspdata* new_tspdata (char* uuid, time_t sst); -void delete_tspdata (struct tspdata* p); - -void tspdata_setConnected (struct tspdata* p, BOOL b); -void tspdata_setReplyEvent(struct tspdata* p, HANDLE h); -void tspdata_setRpcAState (struct tspdata* p, RPC_ASYNC_STATE* rpcState); -void tspdata_setSST (struct tspdata* p, time_t t); -void tspdata_setStream (struct tspdata* p, cci_stream_t s); -void tspdata_setUUID (struct tspdata* p, unsigned char __RPC_FAR* uuidString); -HANDLE tspdata_getReplyEvent(const struct tspdata* p); - -BOOL tspdata_getConnected(const struct tspdata* p); -RPC_ASYNC_STATE* tspdata_getRpcAState(const struct tspdata* p); -time_t tspdata_getSST (const struct tspdata* p); -cci_stream_t tspdata_getStream (const struct tspdata* p); -char* tspdata_getUUID (const struct tspdata* p); - - -#endif _tls_h +/* + * $Header$ + * + * 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. + */ + +/* Thread local storage for client threads. */ + +#ifndef _tls_h +#define _tls_h + +#include "windows.h" +#include "time.h" + +#include "cci_stream.h" + +#define UUID_SIZE 128 + +/* The client code can be run in any client thread. The thread-specific data + is defined here. + */ + +struct tspdata { + BOOL _CCAPI_Connected; + RPC_ASYNC_STATE* _rpcState; + HANDLE _replyEvent; + time_t _sst; + cci_stream_t _stream; + char _uuid[UUID_SIZE]; + }; + +struct tspdata* new_tspdata (char* uuid, time_t sst); +void delete_tspdata (struct tspdata* p); + +void tspdata_setConnected (struct tspdata* p, BOOL b); +void tspdata_setReplyEvent(struct tspdata* p, HANDLE h); +void tspdata_setRpcAState (struct tspdata* p, RPC_ASYNC_STATE* rpcState); +void tspdata_setSST (struct tspdata* p, time_t t); +void tspdata_setStream (struct tspdata* p, cci_stream_t s); +void tspdata_setUUID (struct tspdata* p, unsigned char __RPC_FAR* uuidString); +HANDLE tspdata_getReplyEvent(const struct tspdata* p); + +BOOL tspdata_getConnected(const struct tspdata* p); +RPC_ASYNC_STATE* tspdata_getRpcAState(const struct tspdata* p); +time_t tspdata_getSST (const struct tspdata* p); +cci_stream_t tspdata_getStream (const struct tspdata* p); +char* tspdata_getUUID (const struct tspdata* p); + + +#endif _tls_h diff --git a/src/ccapi/common/win/win-utils.c b/src/ccapi/common/win/win-utils.c index c082142b0..4cba153a9 100644 --- a/src/ccapi/common/win/win-utils.c +++ b/src/ccapi/common/win/win-utils.c @@ -1,66 +1,66 @@ -/* - * $Header$ - * - * 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 -#include -#include -#include "windows.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; +/* + * $Header$ + * + * 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 +#include +#include +#include "windows.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; } \ No newline at end of file diff --git a/src/ccapi/common/win/win-utils.h b/src/ccapi/common/win/win-utils.h index 97226e90b..5dbb192fa 100644 --- a/src/ccapi/common/win/win-utils.h +++ b/src/ccapi/common/win/win-utils.h @@ -1,55 +1,55 @@ -/* - * $Header$ - * - * 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. - */ - -#ifndef _win_utils_h -#define _win_utils_h - -#ifndef TRUE -#define TRUE (1==1) -#endif - -#ifndef FALSE -#define FALSE (1==0) -#endif - -static enum ccapiMsgType { - CCMSG_INVALID = 0, - CCMSG_CONNECT, - CCMSG_REQUEST, - CCMSG_CONNECT_REPLY, - CCMSG_REQUEST_REPLY, - CCMSG_DISCONNECT, - CCMSG_LISTEN, - CCMSG_PING - }; - -char* clientEndpoint(const char* UUID); -char* serverEndpoint(const char* UUID); -extern unsigned char* pszProtocolSequence; - -char* timestamp(); - +/* + * $Header$ + * + * 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. + */ + +#ifndef _win_utils_h +#define _win_utils_h + +#ifndef TRUE +#define TRUE (1==1) +#endif + +#ifndef FALSE +#define FALSE (1==0) +#endif + +static enum ccapiMsgType { + CCMSG_INVALID = 0, + CCMSG_CONNECT, + CCMSG_REQUEST, + CCMSG_CONNECT_REPLY, + CCMSG_REQUEST_REPLY, + CCMSG_DISCONNECT, + CCMSG_LISTEN, + CCMSG_PING + }; + +char* clientEndpoint(const char* UUID); +char* serverEndpoint(const char* UUID); +extern unsigned char* pszProtocolSequence; + +char* timestamp(); + #endif // _win_utils_h \ No newline at end of file -- cgit