From 54383345ad77587fa4eaf765eb77d20439500482 Mon Sep 17 00:00:00 2001 From: Ken Raeburn Date: Tue, 5 Feb 2008 18:25:28 +0000 Subject: [PATCH] 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 ++--- src/ccapi/lib/win/OldCC/ccapi.h | 568 +++++++++++------------ src/ccapi/lib/win/OldCC/client.h | 122 ++--- src/ccapi/lib/win/ccs_reply_proc.c | 196 ++++---- src/ccapi/lib/win/dllmain.h | 88 ++-- src/ccapi/server/win/WorkQueue.h | 90 ++-- src/ccapi/server/win/ccs_os_pipe.c | 128 ++--- src/ccapi/server/win/ccs_request_proc.c | 230 ++++----- src/ccapi/server/win/ccs_win_pipe.c | 326 ++++++------- src/ccapi/server/win/ccs_win_pipe.h | 136 +++--- src/ccapi/server/win/workitem.h | 94 ++-- src/ccapi/test/pingtest.c | 216 ++++----- 21 files changed, 1763 insertions(+), 1763 deletions(-) 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 diff --git a/src/ccapi/lib/win/OldCC/ccapi.h b/src/ccapi/lib/win/OldCC/ccapi.h index 65a72edb4..c40bd1158 100644 --- a/src/ccapi/lib/win/OldCC/ccapi.h +++ b/src/ccapi/lib/win/OldCC/ccapi.h @@ -1,284 +1,284 @@ - - -/* this ALWAYS GENERATED file contains the definitions for the interfaces */ - - - /* File created by MIDL compiler version 6.00.0366 */ -/* at Fri Nov 30 10:06:16 2007 - */ -/* Compiler settings for ccapi.idl: - Oic, W1, Zp8, env=Win32 (32b run) - protocol : dce , ms_ext, c_ext, oldnames - error checks: allocation ref bounds_check enum stub_data - VC __declspec() decoration level: - __declspec(uuid()), __declspec(selectany), __declspec(novtable) - DECLSPEC_UUID(), MIDL_INTERFACE() -*/ -//@@MIDL_FILE_HEADING( ) - -#pragma warning( disable: 4049 ) /* more than 64k source lines */ - - -/* verify that the version is high enough to compile this file*/ -#ifndef __REQUIRED_RPCNDR_H_VERSION__ -#define __REQUIRED_RPCNDR_H_VERSION__ 440 -#endif - -#include "rpc.h" -#include "rpcndr.h" - -#ifndef __ccapi_h__ -#define __ccapi_h__ - -#if defined(_MSC_VER) && (_MSC_VER >= 1020) -#pragma once -#endif - -/* Forward Declarations */ - -#ifdef __cplusplus -extern "C"{ -#endif - -void * __RPC_USER MIDL_user_allocate(size_t); -void __RPC_USER MIDL_user_free( void * ); - -#ifndef __ccapi_INTERFACE_DEFINED__ -#define __ccapi_INTERFACE_DEFINED__ - -/* interface ccapi */ -/* [implicit_handle][unique][version][uuid] */ - -typedef /* [context_handle] */ struct opaque_handle_CTX *HCTX; - -typedef /* [context_handle] */ struct opaque_handle_CACHE *HCACHE; - -typedef /* [context_handle] */ struct opaque_handle_CACHE_ITER *HCACHE_ITER; - -typedef /* [context_handle] */ struct opaque_handle_CRED_ITER *HCRED_ITER; - -typedef unsigned char CC_CHAR; - -typedef unsigned char CC_UCHAR; - -typedef int CC_INT32; - -typedef unsigned int CC_UINT32; - -typedef CC_INT32 CC_TIME_T; - - -enum __MIDL_ccapi_0001 - { STK_AFS = 0, - STK_DES = 1 - } ; - -enum __MIDL_ccapi_0002 - { CC_API_VER_1 = 1, - CC_API_VER_2 = 2 - } ; - -enum __MIDL_ccapi_0003 - { KRB_NAME_SZ = 40, - KRB_INSTANCE_SZ = 40, - KRB_REALM_SZ = 40, - MAX_V4_CRED_LEN = 1250 - } ; -typedef struct _NC_INFO - { - /* [string] */ CC_CHAR *name; - /* [string] */ CC_CHAR *principal; - CC_INT32 vers; - } NC_INFO; - -typedef struct _NC_INFO_LIST - { - CC_UINT32 length; - /* [size_is] */ NC_INFO *info; - } NC_INFO_LIST; - -typedef struct _V4_CRED - { - CC_UCHAR kversion; - CC_CHAR principal[ 41 ]; - CC_CHAR principal_instance[ 41 ]; - CC_CHAR service[ 41 ]; - CC_CHAR service_instance[ 41 ]; - CC_CHAR realm[ 41 ]; - CC_UCHAR session_key[ 8 ]; - CC_INT32 kvno; - CC_INT32 str_to_key; - CC_INT32 issue_date; - CC_INT32 lifetime; - CC_UINT32 address; - CC_INT32 ticket_sz; - CC_UCHAR ticket[ 1250 ]; - } V4_CRED; - -typedef struct _CC_DATA - { - CC_UINT32 type; - CC_UINT32 length; - /* [size_is] */ CC_UCHAR *data; - } CC_DATA; - -typedef struct _CC_DATA_LIST - { - CC_UINT32 count; - /* [size_is] */ CC_DATA *data; - } CC_DATA_LIST; - -typedef struct _V5_CRED - { - /* [string] */ CC_CHAR *client; - /* [string] */ CC_CHAR *server; - CC_DATA keyblock; - CC_TIME_T authtime; - CC_TIME_T starttime; - CC_TIME_T endtime; - CC_TIME_T renew_till; - CC_UINT32 is_skey; - CC_UINT32 ticket_flags; - CC_DATA_LIST addresses; - CC_DATA ticket; - CC_DATA second_ticket; - CC_DATA_LIST authdata; - } V5_CRED; - -typedef /* [switch_type] */ union _CRED_PTR_UNION - { - /* [case()] */ V4_CRED *pV4Cred; - /* [case()] */ V5_CRED *pV5Cred; - } CRED_PTR_UNION; - -typedef struct _CRED_UNION - { - CC_INT32 cred_type; - /* [switch_is] */ CRED_PTR_UNION cred; - } CRED_UNION; - -CC_INT32 rcc_initialize( - /* [out] */ HCTX *pctx); - -CC_INT32 rcc_shutdown( - /* [out][in] */ HCTX *pctx); - -CC_INT32 rcc_get_change_time( - /* [in] */ HCTX ctx, - /* [out] */ CC_TIME_T *time); - -CC_INT32 rcc_create( - /* [in] */ HCTX ctx, - /* [string][in] */ const CC_CHAR *name, - /* [string][in] */ const CC_CHAR *principal, - /* [in] */ CC_INT32 vers, - /* [in] */ CC_UINT32 flags, - /* [out] */ HCACHE *pcache); - -CC_INT32 rcc_open( - /* [in] */ HCTX ctx, - /* [string][in] */ const CC_CHAR *name, - /* [in] */ CC_INT32 vers, - /* [in] */ CC_UINT32 flags, - /* [out] */ HCACHE *pcache); - -CC_INT32 rcc_close( - /* [out][in] */ HCACHE *pcache); - -CC_INT32 rcc_destroy( - /* [out][in] */ HCACHE *pcache); - -CC_INT32 rcc_seq_fetch_NCs_begin( - /* [in] */ HCTX ctx, - /* [out] */ HCACHE_ITER *piter); - -CC_INT32 rcc_seq_fetch_NCs_end( - /* [out][in] */ HCACHE_ITER *piter); - -CC_INT32 rcc_seq_fetch_NCs_next( - /* [in] */ HCACHE_ITER iter, - /* [out] */ HCACHE *pcache); - -CC_INT32 rcc_seq_fetch_NCs( - /* [in] */ HCTX ctx, - /* [out][in] */ HCACHE_ITER *piter, - /* [out] */ HCACHE *pcache); - -CC_INT32 rcc_get_NC_info( - /* [in] */ HCTX ctx, - /* [out] */ NC_INFO_LIST **info_list); - -CC_INT32 rcc_get_name( - /* [in] */ HCACHE cache, - /* [string][out] */ CC_CHAR **name); - -CC_INT32 rcc_set_principal( - /* [in] */ HCACHE cache, - /* [in] */ CC_INT32 vers, - /* [string][in] */ const CC_CHAR *principal); - -CC_INT32 rcc_get_principal( - /* [in] */ HCACHE cache, - /* [string][out] */ CC_CHAR **principal); - -CC_INT32 rcc_get_cred_version( - /* [in] */ HCACHE cache, - /* [out] */ CC_INT32 *vers); - -CC_INT32 rcc_lock_request( - /* [in] */ HCACHE cache, - /* [in] */ CC_INT32 lock_type); - -CC_INT32 rcc_store( - /* [in] */ HCACHE cache, - /* [in] */ CRED_UNION cred); - -CC_INT32 rcc_remove_cred( - /* [in] */ HCACHE cache, - /* [in] */ CRED_UNION cred); - -CC_INT32 rcc_seq_fetch_creds( - /* [in] */ HCACHE cache, - /* [out][in] */ HCRED_ITER *piter, - /* [out] */ CRED_UNION **cred); - -CC_INT32 rcc_seq_fetch_creds_begin( - /* [in] */ HCACHE cache, - /* [out] */ HCRED_ITER *piter); - -CC_INT32 rcc_seq_fetch_creds_end( - /* [out][in] */ HCRED_ITER *piter); - -CC_INT32 rcc_seq_fetch_creds_next( - /* [in] */ HCRED_ITER iter, - /* [out] */ CRED_UNION **cred); - -CC_UINT32 Connect( - /* [string][in] */ CC_CHAR *name); - -void Shutdown( void); - - -extern handle_t ccapi_IfHandle; - - -extern RPC_IF_HANDLE ccapi_ClientIfHandle; -extern RPC_IF_HANDLE ccapi_ServerIfHandle; -#endif /* __ccapi_INTERFACE_DEFINED__ */ - -/* Additional Prototypes for ALL interfaces */ - -void __RPC_USER HCTX_rundown( HCTX ); -void __RPC_USER HCACHE_rundown( HCACHE ); -void __RPC_USER HCACHE_ITER_rundown( HCACHE_ITER ); -void __RPC_USER HCRED_ITER_rundown( HCRED_ITER ); - -/* end of Additional Prototypes */ - -#ifdef __cplusplus -} -#endif - -#endif - - + + +/* this ALWAYS GENERATED file contains the definitions for the interfaces */ + + + /* File created by MIDL compiler version 6.00.0366 */ +/* at Fri Nov 30 10:06:16 2007 + */ +/* Compiler settings for ccapi.idl: + Oic, W1, Zp8, env=Win32 (32b run) + protocol : dce , ms_ext, c_ext, oldnames + error checks: allocation ref bounds_check enum stub_data + VC __declspec() decoration level: + __declspec(uuid()), __declspec(selectany), __declspec(novtable) + DECLSPEC_UUID(), MIDL_INTERFACE() +*/ +//@@MIDL_FILE_HEADING( ) + +#pragma warning( disable: 4049 ) /* more than 64k source lines */ + + +/* verify that the version is high enough to compile this file*/ +#ifndef __REQUIRED_RPCNDR_H_VERSION__ +#define __REQUIRED_RPCNDR_H_VERSION__ 440 +#endif + +#include "rpc.h" +#include "rpcndr.h" + +#ifndef __ccapi_h__ +#define __ccapi_h__ + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +#pragma once +#endif + +/* Forward Declarations */ + +#ifdef __cplusplus +extern "C"{ +#endif + +void * __RPC_USER MIDL_user_allocate(size_t); +void __RPC_USER MIDL_user_free( void * ); + +#ifndef __ccapi_INTERFACE_DEFINED__ +#define __ccapi_INTERFACE_DEFINED__ + +/* interface ccapi */ +/* [implicit_handle][unique][version][uuid] */ + +typedef /* [context_handle] */ struct opaque_handle_CTX *HCTX; + +typedef /* [context_handle] */ struct opaque_handle_CACHE *HCACHE; + +typedef /* [context_handle] */ struct opaque_handle_CACHE_ITER *HCACHE_ITER; + +typedef /* [context_handle] */ struct opaque_handle_CRED_ITER *HCRED_ITER; + +typedef unsigned char CC_CHAR; + +typedef unsigned char CC_UCHAR; + +typedef int CC_INT32; + +typedef unsigned int CC_UINT32; + +typedef CC_INT32 CC_TIME_T; + + +enum __MIDL_ccapi_0001 + { STK_AFS = 0, + STK_DES = 1 + } ; + +enum __MIDL_ccapi_0002 + { CC_API_VER_1 = 1, + CC_API_VER_2 = 2 + } ; + +enum __MIDL_ccapi_0003 + { KRB_NAME_SZ = 40, + KRB_INSTANCE_SZ = 40, + KRB_REALM_SZ = 40, + MAX_V4_CRED_LEN = 1250 + } ; +typedef struct _NC_INFO + { + /* [string] */ CC_CHAR *name; + /* [string] */ CC_CHAR *principal; + CC_INT32 vers; + } NC_INFO; + +typedef struct _NC_INFO_LIST + { + CC_UINT32 length; + /* [size_is] */ NC_INFO *info; + } NC_INFO_LIST; + +typedef struct _V4_CRED + { + CC_UCHAR kversion; + CC_CHAR principal[ 41 ]; + CC_CHAR principal_instance[ 41 ]; + CC_CHAR service[ 41 ]; + CC_CHAR service_instance[ 41 ]; + CC_CHAR realm[ 41 ]; + CC_UCHAR session_key[ 8 ]; + CC_INT32 kvno; + CC_INT32 str_to_key; + CC_INT32 issue_date; + CC_INT32 lifetime; + CC_UINT32 address; + CC_INT32 ticket_sz; + CC_UCHAR ticket[ 1250 ]; + } V4_CRED; + +typedef struct _CC_DATA + { + CC_UINT32 type; + CC_UINT32 length; + /* [size_is] */ CC_UCHAR *data; + } CC_DATA; + +typedef struct _CC_DATA_LIST + { + CC_UINT32 count; + /* [size_is] */ CC_DATA *data; + } CC_DATA_LIST; + +typedef struct _V5_CRED + { + /* [string] */ CC_CHAR *client; + /* [string] */ CC_CHAR *server; + CC_DATA keyblock; + CC_TIME_T authtime; + CC_TIME_T starttime; + CC_TIME_T endtime; + CC_TIME_T renew_till; + CC_UINT32 is_skey; + CC_UINT32 ticket_flags; + CC_DATA_LIST addresses; + CC_DATA ticket; + CC_DATA second_ticket; + CC_DATA_LIST authdata; + } V5_CRED; + +typedef /* [switch_type] */ union _CRED_PTR_UNION + { + /* [case()] */ V4_CRED *pV4Cred; + /* [case()] */ V5_CRED *pV5Cred; + } CRED_PTR_UNION; + +typedef struct _CRED_UNION + { + CC_INT32 cred_type; + /* [switch_is] */ CRED_PTR_UNION cred; + } CRED_UNION; + +CC_INT32 rcc_initialize( + /* [out] */ HCTX *pctx); + +CC_INT32 rcc_shutdown( + /* [out][in] */ HCTX *pctx); + +CC_INT32 rcc_get_change_time( + /* [in] */ HCTX ctx, + /* [out] */ CC_TIME_T *time); + +CC_INT32 rcc_create( + /* [in] */ HCTX ctx, + /* [string][in] */ const CC_CHAR *name, + /* [string][in] */ const CC_CHAR *principal, + /* [in] */ CC_INT32 vers, + /* [in] */ CC_UINT32 flags, + /* [out] */ HCACHE *pcache); + +CC_INT32 rcc_open( + /* [in] */ HCTX ctx, + /* [string][in] */ const CC_CHAR *name, + /* [in] */ CC_INT32 vers, + /* [in] */ CC_UINT32 flags, + /* [out] */ HCACHE *pcache); + +CC_INT32 rcc_close( + /* [out][in] */ HCACHE *pcache); + +CC_INT32 rcc_destroy( + /* [out][in] */ HCACHE *pcache); + +CC_INT32 rcc_seq_fetch_NCs_begin( + /* [in] */ HCTX ctx, + /* [out] */ HCACHE_ITER *piter); + +CC_INT32 rcc_seq_fetch_NCs_end( + /* [out][in] */ HCACHE_ITER *piter); + +CC_INT32 rcc_seq_fetch_NCs_next( + /* [in] */ HCACHE_ITER iter, + /* [out] */ HCACHE *pcache); + +CC_INT32 rcc_seq_fetch_NCs( + /* [in] */ HCTX ctx, + /* [out][in] */ HCACHE_ITER *piter, + /* [out] */ HCACHE *pcache); + +CC_INT32 rcc_get_NC_info( + /* [in] */ HCTX ctx, + /* [out] */ NC_INFO_LIST **info_list); + +CC_INT32 rcc_get_name( + /* [in] */ HCACHE cache, + /* [string][out] */ CC_CHAR **name); + +CC_INT32 rcc_set_principal( + /* [in] */ HCACHE cache, + /* [in] */ CC_INT32 vers, + /* [string][in] */ const CC_CHAR *principal); + +CC_INT32 rcc_get_principal( + /* [in] */ HCACHE cache, + /* [string][out] */ CC_CHAR **principal); + +CC_INT32 rcc_get_cred_version( + /* [in] */ HCACHE cache, + /* [out] */ CC_INT32 *vers); + +CC_INT32 rcc_lock_request( + /* [in] */ HCACHE cache, + /* [in] */ CC_INT32 lock_type); + +CC_INT32 rcc_store( + /* [in] */ HCACHE cache, + /* [in] */ CRED_UNION cred); + +CC_INT32 rcc_remove_cred( + /* [in] */ HCACHE cache, + /* [in] */ CRED_UNION cred); + +CC_INT32 rcc_seq_fetch_creds( + /* [in] */ HCACHE cache, + /* [out][in] */ HCRED_ITER *piter, + /* [out] */ CRED_UNION **cred); + +CC_INT32 rcc_seq_fetch_creds_begin( + /* [in] */ HCACHE cache, + /* [out] */ HCRED_ITER *piter); + +CC_INT32 rcc_seq_fetch_creds_end( + /* [out][in] */ HCRED_ITER *piter); + +CC_INT32 rcc_seq_fetch_creds_next( + /* [in] */ HCRED_ITER iter, + /* [out] */ CRED_UNION **cred); + +CC_UINT32 Connect( + /* [string][in] */ CC_CHAR *name); + +void Shutdown( void); + + +extern handle_t ccapi_IfHandle; + + +extern RPC_IF_HANDLE ccapi_ClientIfHandle; +extern RPC_IF_HANDLE ccapi_ServerIfHandle; +#endif /* __ccapi_INTERFACE_DEFINED__ */ + +/* Additional Prototypes for ALL interfaces */ + +void __RPC_USER HCTX_rundown( HCTX ); +void __RPC_USER HCACHE_rundown( HCACHE ); +void __RPC_USER HCACHE_ITER_rundown( HCACHE_ITER ); +void __RPC_USER HCRED_ITER_rundown( HCRED_ITER ); + +/* end of Additional Prototypes */ + +#ifdef __cplusplus +} +#endif + +#endif + + diff --git a/src/ccapi/lib/win/OldCC/client.h b/src/ccapi/lib/win/OldCC/client.h index f263ce1c0..52be2edfb 100644 --- a/src/ccapi/lib/win/OldCC/client.h +++ b/src/ccapi/lib/win/OldCC/client.h @@ -1,61 +1,61 @@ -/* - * $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 __DLL_CLIENT_H__ -#define __DLL_CLIENT_H__ - -#include "autolock.hxx" -#include "init.hxx" - -class Client { -public: - static DWORD Initialize(char* ep OPTIONAL); - static DWORD Cleanup(); - static DWORD Reconnect(char* ep OPTIONAL); - - static bool Initialized() { return s_init; } - - static CcOsLock sLock; - -private: - static bool s_init; - - static DWORD Disconnect(); - static DWORD Connect(char* ep OPTIONAL); - }; - -#define CLIENT_INIT_EX(trap, error) \ -do \ -{ \ - INIT_INIT_EX(trap, error); \ - if (!Client::Initialized()) \ - { \ - DWORD status = Client::Initialize(0); \ - if (status) return (trap) ? (error) : status; \ - } \ -} while(0) - -#endif +/* + * $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 __DLL_CLIENT_H__ +#define __DLL_CLIENT_H__ + +#include "autolock.hxx" +#include "init.hxx" + +class Client { +public: + static DWORD Initialize(char* ep OPTIONAL); + static DWORD Cleanup(); + static DWORD Reconnect(char* ep OPTIONAL); + + static bool Initialized() { return s_init; } + + static CcOsLock sLock; + +private: + static bool s_init; + + static DWORD Disconnect(); + static DWORD Connect(char* ep OPTIONAL); + }; + +#define CLIENT_INIT_EX(trap, error) \ +do \ +{ \ + INIT_INIT_EX(trap, error); \ + if (!Client::Initialized()) \ + { \ + DWORD status = Client::Initialize(0); \ + if (status) return (trap) ? (error) : status; \ + } \ +} while(0) + +#endif diff --git a/src/ccapi/lib/win/ccs_reply_proc.c b/src/ccapi/lib/win/ccs_reply_proc.c index ebac6e3cf..f9eef87ff 100644 --- a/src/ccapi/lib/win/ccs_reply_proc.c +++ b/src/ccapi/lib/win/ccs_reply_proc.c @@ -1,98 +1,98 @@ -/* - * $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 "cci_debugging.h" -#include "ccs_reply.h" /* generated by MIDL compiler */ -#include "ccutils.h" -#include "tls.h" -#include "win-utils.h" - - -void ccs_rpc_request_reply( - const long rpcmsg, /* Message type */ - const char tspHandle[], /* Client's tspdata* */ - const char* uuid, /* uuid for making thread-specific event name */ - const long srvStartTime, /* Server Start Time */ - const long cbIn, /* Length of buffer */ - const char* chIn, /* Data buffer */ - long* ret_status ) { /* Return code */ - - HANDLE hEvent = openThreadEvent(uuid, REPLY_SUFFIX); - DWORD* p = (DWORD*)(tspHandle); - struct tspdata* tsp = (struct tspdata*)*p; - cci_stream_t stream; - long status = 0; - - cci_debug_printf("%s! msg#:%d SST:%ld uuid:%s", __FUNCTION__, rpcmsg, srvStartTime, uuid); - cci_debug_printf(" payload:<%s>", chIn); - cci_debug_printf(" uuid from handle:<%s>", tspdata_getUUID(tsp)); - - if (!status) { - status = cci_stream_new (&stream); /* Create a stream for the request data */ - } - - if (!status) { /* Put the data into the stream */ - status = cci_stream_write (stream, chIn, cbIn); - } - - if (!status) { /* Put the data into the stream */ - tspdata_setStream(tsp, stream); - } - - SetEvent(hEvent); - CloseHandle(hEvent); - *ret_status = status; - } - -void ccs_rpc_connect_reply( - const long rpcmsg, /* Message type */ - const char tspHandle[], /* Client's tspdata* */ - const char* uuid, /* uuid for making thread-specific event name */ - const long srvStartTime, /* Server Start Time */ - long* status ) { /* Return code */ - - HANDLE hEvent = openThreadEvent(uuid, REPLY_SUFFIX); - DWORD* p = (DWORD*)(tspHandle); - - cci_debug_printf("%s! msg#:%d SST:%ld uuid:%s", __FUNCTION__, rpcmsg, srvStartTime, uuid); - - SetEvent(hEvent); - CloseHandle(hEvent); - } - -void ccapi_listen( - RPC_ASYNC_STATE* rpcState, - handle_t hBinding, - const long rpcmsg, /* Message type */ - long* status ) { /* Return code */ - - cci_debug_printf("%s %s!", __FUNCTION__, rpcState->UserInfo); - *status = 0; - } +/* + * $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 "cci_debugging.h" +#include "ccs_reply.h" /* generated by MIDL compiler */ +#include "ccutils.h" +#include "tls.h" +#include "win-utils.h" + + +void ccs_rpc_request_reply( + const long rpcmsg, /* Message type */ + const char tspHandle[], /* Client's tspdata* */ + const char* uuid, /* uuid for making thread-specific event name */ + const long srvStartTime, /* Server Start Time */ + const long cbIn, /* Length of buffer */ + const char* chIn, /* Data buffer */ + long* ret_status ) { /* Return code */ + + HANDLE hEvent = openThreadEvent(uuid, REPLY_SUFFIX); + DWORD* p = (DWORD*)(tspHandle); + struct tspdata* tsp = (struct tspdata*)*p; + cci_stream_t stream; + long status = 0; + + cci_debug_printf("%s! msg#:%d SST:%ld uuid:%s", __FUNCTION__, rpcmsg, srvStartTime, uuid); + cci_debug_printf(" payload:<%s>", chIn); + cci_debug_printf(" uuid from handle:<%s>", tspdata_getUUID(tsp)); + + if (!status) { + status = cci_stream_new (&stream); /* Create a stream for the request data */ + } + + if (!status) { /* Put the data into the stream */ + status = cci_stream_write (stream, chIn, cbIn); + } + + if (!status) { /* Put the data into the stream */ + tspdata_setStream(tsp, stream); + } + + SetEvent(hEvent); + CloseHandle(hEvent); + *ret_status = status; + } + +void ccs_rpc_connect_reply( + const long rpcmsg, /* Message type */ + const char tspHandle[], /* Client's tspdata* */ + const char* uuid, /* uuid for making thread-specific event name */ + const long srvStartTime, /* Server Start Time */ + long* status ) { /* Return code */ + + HANDLE hEvent = openThreadEvent(uuid, REPLY_SUFFIX); + DWORD* p = (DWORD*)(tspHandle); + + cci_debug_printf("%s! msg#:%d SST:%ld uuid:%s", __FUNCTION__, rpcmsg, srvStartTime, uuid); + + SetEvent(hEvent); + CloseHandle(hEvent); + } + +void ccapi_listen( + RPC_ASYNC_STATE* rpcState, + handle_t hBinding, + const long rpcmsg, /* Message type */ + long* status ) { /* Return code */ + + cci_debug_printf("%s %s!", __FUNCTION__, rpcState->UserInfo); + *status = 0; + } diff --git a/src/ccapi/lib/win/dllmain.h b/src/ccapi/lib/win/dllmain.h index 3ce2ac230..8c585721c 100644 --- a/src/ccapi/lib/win/dllmain.h +++ b/src/ccapi/lib/win/dllmain.h @@ -1,45 +1,45 @@ -/* - * $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 _dll_h -#define _dll_h - -#include "windows.h" - -enum EndpointType {EPT_SERVER=0, EPT_CLIENT}; - -#ifdef __cplusplus // If used by C++ code, -extern "C" { // we need to export the C interface -#endif -__declspec(dllexport) BOOL WINAPI PutTspData(struct tspdata* p); -__declspec(dllexport) BOOL WINAPI GetTspData(struct tspdata** p); - -//__declspec(dllexport) char* WINAPI getEndpoint(enum EndpointType); -#ifdef __cplusplus -} -#endif - +/* + * $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 _dll_h +#define _dll_h + +#include "windows.h" + +enum EndpointType {EPT_SERVER=0, EPT_CLIENT}; + +#ifdef __cplusplus // If used by C++ code, +extern "C" { // we need to export the C interface +#endif +__declspec(dllexport) BOOL WINAPI PutTspData(struct tspdata* p); +__declspec(dllexport) BOOL WINAPI GetTspData(struct tspdata** p); + +//__declspec(dllexport) char* WINAPI getEndpoint(enum EndpointType); +#ifdef __cplusplus +} +#endif + #endif _dll_h \ No newline at end of file diff --git a/src/ccapi/server/win/WorkQueue.h b/src/ccapi/server/win/WorkQueue.h index 106f9acb9..eb4678019 100644 --- a/src/ccapi/server/win/WorkQueue.h +++ b/src/ccapi/server/win/WorkQueue.h @@ -1,46 +1,46 @@ -/* - * $Header$ - * - * Copyright 2007 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 _work_queue_h -#define _work_queue_h - -#include "windows.h" -#include "cci_stream.h" -#include "ccs_pipe.h" - -EXTERN_C BOOL worklist_isEmpty(); - -EXTERN_C void worklist_add( const long rpcmsg, - const ccs_pipe_t pipe, - const cci_stream_t stream, - const time_t serverStartTime); - -EXTERN_C int worklist_remove(long* rpcmsg, - ccs_pipe_t* pipe, - cci_stream_t* stream, - time_t* serverStartTime); - +/* + * $Header$ + * + * Copyright 2007 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 _work_queue_h +#define _work_queue_h + +#include "windows.h" +#include "cci_stream.h" +#include "ccs_pipe.h" + +EXTERN_C BOOL worklist_isEmpty(); + +EXTERN_C void worklist_add( const long rpcmsg, + const ccs_pipe_t pipe, + const cci_stream_t stream, + const time_t serverStartTime); + +EXTERN_C int worklist_remove(long* rpcmsg, + ccs_pipe_t* pipe, + cci_stream_t* stream, + time_t* serverStartTime); + #endif // _work_queue_h \ No newline at end of file diff --git a/src/ccapi/server/win/ccs_os_pipe.c b/src/ccapi/server/win/ccs_os_pipe.c index 69dcec474..95af378e7 100644 --- a/src/ccapi/server/win/ccs_os_pipe.c +++ b/src/ccapi/server/win/ccs_os_pipe.c @@ -1,64 +1,64 @@ -/* - * $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 "ccs_common.h" -#include "ccs_os_pipe.h" -#include "ccs_win_pipe.h" - -/* ------------------------------------------------------------------------ */ - -/* On Windows, a pipe is a struct. See ccs_win_pipe.h for details. */ - - -/* ------------------------------------------------------------------------ */ - -cc_int32 ccs_os_pipe_valid (ccs_pipe_t in_pipe) { - return ccs_win_pipe_valid(in_pipe); - } - -/* ------------------------------------------------------------------------ */ - -cc_int32 ccs_os_pipe_copy (ccs_pipe_t* out_pipe, ccs_pipe_t in_pipe) { - return ccs_win_pipe_copy( - out_pipe, - in_pipe); - } - -/* ------------------------------------------------------------------------ */ - -cc_int32 ccs_os_pipe_release (ccs_pipe_t io_pipe) { - return ccs_win_pipe_release(io_pipe); - } - -/* ------------------------------------------------------------------------ */ - -cc_int32 ccs_os_pipe_compare (ccs_pipe_t pipe_1, - ccs_pipe_t pipe_2, - cc_uint32 *out_equal) { - - return ccs_win_pipe_compare(pipe_1, pipe_2, out_equal); - } - +/* + * $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 "ccs_common.h" +#include "ccs_os_pipe.h" +#include "ccs_win_pipe.h" + +/* ------------------------------------------------------------------------ */ + +/* On Windows, a pipe is a struct. See ccs_win_pipe.h for details. */ + + +/* ------------------------------------------------------------------------ */ + +cc_int32 ccs_os_pipe_valid (ccs_pipe_t in_pipe) { + return ccs_win_pipe_valid(in_pipe); + } + +/* ------------------------------------------------------------------------ */ + +cc_int32 ccs_os_pipe_copy (ccs_pipe_t* out_pipe, ccs_pipe_t in_pipe) { + return ccs_win_pipe_copy( + out_pipe, + in_pipe); + } + +/* ------------------------------------------------------------------------ */ + +cc_int32 ccs_os_pipe_release (ccs_pipe_t io_pipe) { + return ccs_win_pipe_release(io_pipe); + } + +/* ------------------------------------------------------------------------ */ + +cc_int32 ccs_os_pipe_compare (ccs_pipe_t pipe_1, + ccs_pipe_t pipe_2, + cc_uint32 *out_equal) { + + return ccs_win_pipe_compare(pipe_1, pipe_2, out_equal); + } + diff --git a/src/ccapi/server/win/ccs_request_proc.c b/src/ccapi/server/win/ccs_request_proc.c index 40713fb50..a1c082da0 100644 --- a/src/ccapi/server/win/ccs_request_proc.c +++ b/src/ccapi/server/win/ccs_request_proc.c @@ -1,116 +1,116 @@ -/* - * $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 "ccs_request.h" // header file generated by MIDL compiler -#include "cci_debugging.h" -#include "WorkQueue.h" -#include "win-utils.h" -#include "ccs_win_pipe.h" - -void ccs_rpc_request( - const long rpcmsg, /* Message type */ - const char tspHandle[], /* Client's tspdata* */ - const char* pszUUID, /* Where client will listen for the reply */ - const long lenRequest, /* Length of buffer */ - const char pbRequest[], /* Data buffer */ - const long serverStartTime, /* Which server session we're talking to */ - long* return_status ) { /* Return code */ - - cc_int32 status = 0; - cci_stream_t stream; - DWORD* p = (DWORD*)(tspHandle); - WIN_PIPE* pipe = NULL; - - cci_debug_printf("%s rpcmsg:%d; UUID:<%s> SST:<%s>", - __FUNCTION__, rpcmsg, pszUUID, serverStartTime); - - status = (rpcmsg != CCMSG_REQUEST) && (rpcmsg != CCMSG_PING); - - if (!status) { - status = cci_stream_new (&stream); /* Create a stream for the request data */ - } - - if (!status) { /* Put the data into the stream */ - status = cci_stream_write (stream, pbRequest, lenRequest); - } - - pipe = ccs_win_pipe_new(pszUUID, *p); - worklist_add(rpcmsg, pipe, stream, serverStartTime); - *return_status = status; - } - - -void ccs_rpc_connect( - const long rpcmsg, /* Message type */ - const char tspHandle[], /* Client's tspdata* */ - const char* pszUUID, /* Data buffer */ - long* return_status ) { /* Return code */ - - DWORD* p = (DWORD*)(tspHandle); - WIN_PIPE* pipe = ccs_win_pipe_new(pszUUID, *p); - - cci_debug_printf("%s; rpcmsg:%d; UUID: <%s>", __FUNCTION__, rpcmsg, pszUUID); - - worklist_add( rpcmsg, - pipe, - NULL, /* No payload with connect request */ - (const time_t)0 ); /* No server session number with connect request */ - } - - -// 'Authentication' is client setting a value in a file and the server -// returning that value plus one. -CC_UINT32 ccs_authenticate(const CC_CHAR* name) { - HANDLE hMap = 0; - PDWORD pvalue = 0; - CC_UINT32 result = 0; - DWORD status = 0; - - cci_debug_printf("%s ( %s )", __FUNCTION__, name); - - hMap = OpenFileMapping(FILE_MAP_ALL_ACCESS, FALSE, (LPSTR)name); - status = !hMap; - - if (!status) { - pvalue = (PDWORD)MapViewOfFile(hMap, FILE_MAP_WRITE, 0, 0, 0); - status = !pvalue; - } - - if (!status) { - *pvalue += 1; - result = *pvalue; - } - - if (pvalue) { - UnmapViewOfFile(pvalue); - } - - if (hMap) CloseHandle(hMap); - return result; +/* + * $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 "ccs_request.h" // header file generated by MIDL compiler +#include "cci_debugging.h" +#include "WorkQueue.h" +#include "win-utils.h" +#include "ccs_win_pipe.h" + +void ccs_rpc_request( + const long rpcmsg, /* Message type */ + const char tspHandle[], /* Client's tspdata* */ + const char* pszUUID, /* Where client will listen for the reply */ + const long lenRequest, /* Length of buffer */ + const char pbRequest[], /* Data buffer */ + const long serverStartTime, /* Which server session we're talking to */ + long* return_status ) { /* Return code */ + + cc_int32 status = 0; + cci_stream_t stream; + DWORD* p = (DWORD*)(tspHandle); + WIN_PIPE* pipe = NULL; + + cci_debug_printf("%s rpcmsg:%d; UUID:<%s> SST:<%s>", + __FUNCTION__, rpcmsg, pszUUID, serverStartTime); + + status = (rpcmsg != CCMSG_REQUEST) && (rpcmsg != CCMSG_PING); + + if (!status) { + status = cci_stream_new (&stream); /* Create a stream for the request data */ + } + + if (!status) { /* Put the data into the stream */ + status = cci_stream_write (stream, pbRequest, lenRequest); + } + + pipe = ccs_win_pipe_new(pszUUID, *p); + worklist_add(rpcmsg, pipe, stream, serverStartTime); + *return_status = status; + } + + +void ccs_rpc_connect( + const long rpcmsg, /* Message type */ + const char tspHandle[], /* Client's tspdata* */ + const char* pszUUID, /* Data buffer */ + long* return_status ) { /* Return code */ + + DWORD* p = (DWORD*)(tspHandle); + WIN_PIPE* pipe = ccs_win_pipe_new(pszUUID, *p); + + cci_debug_printf("%s; rpcmsg:%d; UUID: <%s>", __FUNCTION__, rpcmsg, pszUUID); + + worklist_add( rpcmsg, + pipe, + NULL, /* No payload with connect request */ + (const time_t)0 ); /* No server session number with connect request */ + } + + +// 'Authentication' is client setting a value in a file and the server +// returning that value plus one. +CC_UINT32 ccs_authenticate(const CC_CHAR* name) { + HANDLE hMap = 0; + PDWORD pvalue = 0; + CC_UINT32 result = 0; + DWORD status = 0; + + cci_debug_printf("%s ( %s )", __FUNCTION__, name); + + hMap = OpenFileMapping(FILE_MAP_ALL_ACCESS, FALSE, (LPSTR)name); + status = !hMap; + + if (!status) { + pvalue = (PDWORD)MapViewOfFile(hMap, FILE_MAP_WRITE, 0, 0, 0); + status = !pvalue; + } + + if (!status) { + *pvalue += 1; + result = *pvalue; + } + + if (pvalue) { + UnmapViewOfFile(pvalue); + } + + if (hMap) CloseHandle(hMap); + return result; } \ No newline at end of file diff --git a/src/ccapi/server/win/ccs_win_pipe.c b/src/ccapi/server/win/ccs_win_pipe.c index 4d121aaea..a8fea2f38 100644 --- a/src/ccapi/server/win/ccs_win_pipe.c +++ b/src/ccapi/server/win/ccs_win_pipe.c @@ -1,163 +1,163 @@ -/* - * $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 "assert.h" - -#include "ccs_win_pipe.h" -#include "cci_debugging.h" - -/* Ref: -struct ccs_win_pipe_t { - char* uuid; - HANDLE clientHandle; - } - */ - -/* ------------------------------------------------------------------------ */ - -struct ccs_win_pipe_t* ccs_win_pipe_new (const char* uuid, const HANDLE h) { - - cc_int32 err = ccNoError; - struct ccs_win_pipe_t* out_pipe = NULL; - char* uuidCopy = NULL; - - if (!err) { - if (!uuid) {err = cci_check_error(ccErrBadParam);} - } - - if (!err) { - uuidCopy = (char*)malloc(1+strlen(uuid)); - if (!uuidCopy) {err = cci_check_error(ccErrBadParam);} - strcpy(uuidCopy, uuid); - } - - if (!err) { - out_pipe = (struct ccs_win_pipe_t*)malloc(sizeof(struct ccs_win_pipe_t)); - if (!out_pipe) {err = cci_check_error(ccErrBadParam);} - out_pipe->uuid = uuidCopy; - out_pipe->clientHandle = h; - } - - cci_debug_printf("0x%X = %s(%s, 0x%X)", out_pipe, __FUNCTION__, uuid, h); - - return out_pipe; - } - -/* ------------------------------------------------------------------------ */ - -cc_int32 ccs_win_pipe_copy (WIN_PIPE** out_pipe, - const WIN_PIPE* in_pipe) { - - *out_pipe = - ccs_win_pipe_new( - ccs_win_pipe_getUuid (in_pipe), - ccs_win_pipe_getHandle(in_pipe) ); - - return (*out_pipe) ? ccNoError : ccErrBadParam; - } - -/* ------------------------------------------------------------------------ */ - -cc_int32 ccs_win_pipe_release(const WIN_PIPE* in_pipe) { - - cc_int32 err = ccNoError; - - if (!ccs_win_pipe_valid(in_pipe)) {err = cci_check_error(ccErrBadParam);} - - if (!err) { - if (!in_pipe->uuid) free(in_pipe->uuid); - if (!in_pipe) free(in_pipe); - } - - return err; - } - -/* ------------------------------------------------------------------------ */ - -cc_int32 ccs_win_pipe_valid (const WIN_PIPE* in_pipe) { - - if (!in_pipe) { - cci_check_error(ccErrBadParam); - return FALSE; - } - - if (!in_pipe->uuid) { - cci_check_error(ccErrBadParam); - return FALSE; - } - - return TRUE; - } - -/* ------------------------------------------------------------------------ */ - -cc_int32 ccs_win_pipe_compare (const WIN_PIPE* in_pipe_1, - const WIN_PIPE* in_pipe_2, - cc_uint32 *out_equal) { - - cc_int32 err = ccNoError; - int seq = 0; - *out_equal = FALSE; - - if (!ccs_win_pipe_valid(in_pipe_1)) {err = cci_check_error(ccErrBadParam);} - if (!ccs_win_pipe_valid(in_pipe_2)) {err = cci_check_error(ccErrBadParam);} - if (!out_equal) {err = cci_check_error(ccErrBadParam);} - - /* A disconnect doesn't have a tls* with it -- only the uuid. SO only - compare the uuids. - */ - if (!err) { - seq = strcmp( ccs_win_pipe_getUuid(in_pipe_1), - ccs_win_pipe_getUuid(in_pipe_2) ); - *out_equal = (seq == 0); - } - - return err; - } - -/* ------------------------------------------------------------------------ */ - -char* ccs_win_pipe_getUuid (const WIN_PIPE* in_pipe) { - - char* result = NULL; - - if (!ccs_win_pipe_valid(in_pipe)) {cci_check_error(ccErrBadParam);} - else {result = in_pipe->uuid;} - - return result; - } - -/* ------------------------------------------------------------------------ */ - -HANDLE ccs_win_pipe_getHandle (const WIN_PIPE* in_pipe) { - - HANDLE result = NULL; - - if (!ccs_win_pipe_valid(in_pipe)) {cci_check_error(ccErrBadParam);} - else {result = in_pipe->clientHandle;} - - return result; - } +/* + * $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 "assert.h" + +#include "ccs_win_pipe.h" +#include "cci_debugging.h" + +/* Ref: +struct ccs_win_pipe_t { + char* uuid; + HANDLE clientHandle; + } + */ + +/* ------------------------------------------------------------------------ */ + +struct ccs_win_pipe_t* ccs_win_pipe_new (const char* uuid, const HANDLE h) { + + cc_int32 err = ccNoError; + struct ccs_win_pipe_t* out_pipe = NULL; + char* uuidCopy = NULL; + + if (!err) { + if (!uuid) {err = cci_check_error(ccErrBadParam);} + } + + if (!err) { + uuidCopy = (char*)malloc(1+strlen(uuid)); + if (!uuidCopy) {err = cci_check_error(ccErrBadParam);} + strcpy(uuidCopy, uuid); + } + + if (!err) { + out_pipe = (struct ccs_win_pipe_t*)malloc(sizeof(struct ccs_win_pipe_t)); + if (!out_pipe) {err = cci_check_error(ccErrBadParam);} + out_pipe->uuid = uuidCopy; + out_pipe->clientHandle = h; + } + + cci_debug_printf("0x%X = %s(%s, 0x%X)", out_pipe, __FUNCTION__, uuid, h); + + return out_pipe; + } + +/* ------------------------------------------------------------------------ */ + +cc_int32 ccs_win_pipe_copy (WIN_PIPE** out_pipe, + const WIN_PIPE* in_pipe) { + + *out_pipe = + ccs_win_pipe_new( + ccs_win_pipe_getUuid (in_pipe), + ccs_win_pipe_getHandle(in_pipe) ); + + return (*out_pipe) ? ccNoError : ccErrBadParam; + } + +/* ------------------------------------------------------------------------ */ + +cc_int32 ccs_win_pipe_release(const WIN_PIPE* in_pipe) { + + cc_int32 err = ccNoError; + + if (!ccs_win_pipe_valid(in_pipe)) {err = cci_check_error(ccErrBadParam);} + + if (!err) { + if (!in_pipe->uuid) free(in_pipe->uuid); + if (!in_pipe) free(in_pipe); + } + + return err; + } + +/* ------------------------------------------------------------------------ */ + +cc_int32 ccs_win_pipe_valid (const WIN_PIPE* in_pipe) { + + if (!in_pipe) { + cci_check_error(ccErrBadParam); + return FALSE; + } + + if (!in_pipe->uuid) { + cci_check_error(ccErrBadParam); + return FALSE; + } + + return TRUE; + } + +/* ------------------------------------------------------------------------ */ + +cc_int32 ccs_win_pipe_compare (const WIN_PIPE* in_pipe_1, + const WIN_PIPE* in_pipe_2, + cc_uint32 *out_equal) { + + cc_int32 err = ccNoError; + int seq = 0; + *out_equal = FALSE; + + if (!ccs_win_pipe_valid(in_pipe_1)) {err = cci_check_error(ccErrBadParam);} + if (!ccs_win_pipe_valid(in_pipe_2)) {err = cci_check_error(ccErrBadParam);} + if (!out_equal) {err = cci_check_error(ccErrBadParam);} + + /* A disconnect doesn't have a tls* with it -- only the uuid. SO only + compare the uuids. + */ + if (!err) { + seq = strcmp( ccs_win_pipe_getUuid(in_pipe_1), + ccs_win_pipe_getUuid(in_pipe_2) ); + *out_equal = (seq == 0); + } + + return err; + } + +/* ------------------------------------------------------------------------ */ + +char* ccs_win_pipe_getUuid (const WIN_PIPE* in_pipe) { + + char* result = NULL; + + if (!ccs_win_pipe_valid(in_pipe)) {cci_check_error(ccErrBadParam);} + else {result = in_pipe->uuid;} + + return result; + } + +/* ------------------------------------------------------------------------ */ + +HANDLE ccs_win_pipe_getHandle (const WIN_PIPE* in_pipe) { + + HANDLE result = NULL; + + if (!ccs_win_pipe_valid(in_pipe)) {cci_check_error(ccErrBadParam);} + else {result = in_pipe->clientHandle;} + + return result; + } diff --git a/src/ccapi/server/win/ccs_win_pipe.h b/src/ccapi/server/win/ccs_win_pipe.h index afabe12fe..3600d12af 100644 --- a/src/ccapi/server/win/ccs_win_pipe.h +++ b/src/ccapi/server/win/ccs_win_pipe.h @@ -1,69 +1,69 @@ -/* - * $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 _ccs_win_pipe_h_ -#define _ccs_win_pipe_h_ - -#include "windows.h" - -#include "CredentialsCache.h" - -/* ------------------------------------------------------------------------ */ - -/* On Windows, a pipe is a struct containing a UUID and a handle. Both the - UUID and handle are supplied by the client. - - The UUID is used to build the client's reply endpoint. - - The handle is to the requesting client thread's thread local storage struct, - so that the client's one and only reply handler can put reply data where - the requesting thread will be able to see it. - */ - -struct ccs_win_pipe_t { - char* uuid; - HANDLE clientHandle; - }; - -typedef struct ccs_win_pipe_t WIN_PIPE; - -struct ccs_win_pipe_t* ccs_win_pipe_new(const char* uuid, const HANDLE h); - -cc_int32 ccs_win_pipe_release (const WIN_PIPE* io_pipe); - -cc_int32 ccs_win_pipe_compare (const WIN_PIPE* win_pipe_1, - const WIN_PIPE* win_pipe_2, - cc_uint32 *out_equal); - -cc_int32 ccs_win_pipe_copy (WIN_PIPE** out_pipe, - const WIN_PIPE* in_pipe); - -cc_int32 ccs_win_pipe_valid (const WIN_PIPE* in_pipe); - -char* ccs_win_pipe_getUuid (const WIN_PIPE* in_pipe); -HANDLE ccs_win_pipe_getHandle (const WIN_PIPE* in_pipe); - +/* + * $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 _ccs_win_pipe_h_ +#define _ccs_win_pipe_h_ + +#include "windows.h" + +#include "CredentialsCache.h" + +/* ------------------------------------------------------------------------ */ + +/* On Windows, a pipe is a struct containing a UUID and a handle. Both the + UUID and handle are supplied by the client. + + The UUID is used to build the client's reply endpoint. + + The handle is to the requesting client thread's thread local storage struct, + so that the client's one and only reply handler can put reply data where + the requesting thread will be able to see it. + */ + +struct ccs_win_pipe_t { + char* uuid; + HANDLE clientHandle; + }; + +typedef struct ccs_win_pipe_t WIN_PIPE; + +struct ccs_win_pipe_t* ccs_win_pipe_new(const char* uuid, const HANDLE h); + +cc_int32 ccs_win_pipe_release (const WIN_PIPE* io_pipe); + +cc_int32 ccs_win_pipe_compare (const WIN_PIPE* win_pipe_1, + const WIN_PIPE* win_pipe_2, + cc_uint32 *out_equal); + +cc_int32 ccs_win_pipe_copy (WIN_PIPE** out_pipe, + const WIN_PIPE* in_pipe); + +cc_int32 ccs_win_pipe_valid (const WIN_PIPE* in_pipe); + +char* ccs_win_pipe_getUuid (const WIN_PIPE* in_pipe); +HANDLE ccs_win_pipe_getHandle (const WIN_PIPE* in_pipe); + #endif // _ccs_win_pipe_h_ \ No newline at end of file diff --git a/src/ccapi/server/win/workitem.h b/src/ccapi/server/win/workitem.h index a9d1c0e29..df1d7794a 100644 --- a/src/ccapi/server/win/workitem.h +++ b/src/ccapi/server/win/workitem.h @@ -1,48 +1,48 @@ -#ifndef __WorkItem -#define __WorkItem - -#include -#include "windows.h" - -extern "C" { - #include "cci_stream.h" - #include "ccs_pipe.h" - } - -class WorkItem { -private: - cci_stream_t _buf; - WIN_PIPE* _pipe; - const long _rpcmsg; - const long _sst; -public: - WorkItem( cci_stream_t buf, - WIN_PIPE* pipe, - const long type, - const long serverStartTime); - WorkItem( const WorkItem&); - WorkItem(); - ~WorkItem(); - - const cci_stream_t payload() const {return _buf;} - const cci_stream_t take_payload(); - WIN_PIPE* take_pipe(); - WIN_PIPE* pipe() const {return _pipe;} - const long type() const {return _rpcmsg;} - const long sst() const {return _sst;} - char* print(char* buf); - }; - -class WorkList { -private: - std::list wl; - CRITICAL_SECTION cs; -public: - WorkList(); - ~WorkList(); - int add(WorkItem*); - int remove(WorkItem**); - bool isEmpty() {return wl.empty();} - }; - +#ifndef __WorkItem +#define __WorkItem + +#include +#include "windows.h" + +extern "C" { + #include "cci_stream.h" + #include "ccs_pipe.h" + } + +class WorkItem { +private: + cci_stream_t _buf; + WIN_PIPE* _pipe; + const long _rpcmsg; + const long _sst; +public: + WorkItem( cci_stream_t buf, + WIN_PIPE* pipe, + const long type, + const long serverStartTime); + WorkItem( const WorkItem&); + WorkItem(); + ~WorkItem(); + + const cci_stream_t payload() const {return _buf;} + const cci_stream_t take_payload(); + WIN_PIPE* take_pipe(); + WIN_PIPE* pipe() const {return _pipe;} + const long type() const {return _rpcmsg;} + const long sst() const {return _sst;} + char* print(char* buf); + }; + +class WorkList { +private: + std::list wl; + CRITICAL_SECTION cs; +public: + WorkList(); + ~WorkList(); + int add(WorkItem*); + int remove(WorkItem**); + bool isEmpty() {return wl.empty();} + }; + #endif // __WorkItem \ No newline at end of file diff --git a/src/ccapi/test/pingtest.c b/src/ccapi/test/pingtest.c index 992772586..a2499118f 100644 --- a/src/ccapi/test/pingtest.c +++ b/src/ccapi/test/pingtest.c @@ -1,108 +1,108 @@ -// pingtest.c -// -// Test RPC to server, with PING message, which exists for no other purpose than this test. - -#include -#include - -#include "cci_debugging.h" -#include "CredentialsCache.h" -#include "cci_stream.h" -#include "win-utils.h" - -#include "ccs_request.h" -#define CLIENT_REQUEST_RPC_HANDLE ccs_request_IfHandle - - -extern cc_int32 cci_os_ipc_thread_init (void); -extern cc_int32 cci_os_ipc_msg( cc_int32 in_launch_server, - cci_stream_t in_request_stream, - cc_int32 in_msg, - cci_stream_t* out_reply_stream); - -RPC_STATUS send_test(char* endpoint) { - unsigned char* pszNetworkAddress = NULL; - unsigned char* pszOptions = NULL; - unsigned char* pszStringBinding = NULL; - unsigned char* pszUuid = NULL; - RPC_STATUS status; - - status = RpcStringBindingCompose(pszUuid, - (RPC_CSTR)"ncalrpc", - pszNetworkAddress, - (unsigned char*)endpoint, - pszOptions, - &pszStringBinding); - cci_debug_printf("%s pszStringBinding = %s", __FUNCTION__, pszStringBinding); - if (status) {return cci_check_error(status);} - - /* Set the binding handle that will be used to bind to the RPC server [the 'client']. */ - status = RpcBindingFromStringBinding(pszStringBinding, &CLIENT_REQUEST_RPC_HANDLE); - if (status) {return cci_check_error(status);} - - status = RpcStringFree(&pszStringBinding); // Temp var no longer needed. - - if (!status) { - RpcTryExcept { - cci_debug_printf("%s calling remote procedure 'ccs_authenticate'", __FUNCTION__); - status = ccs_authenticate((CC_CHAR*)"DLLMAIN TEST!"); - cci_debug_printf(" ccs_authenticate returned %d", status); - } - RpcExcept(1) { - status = cci_check_error(RpcExceptionCode()); - } - RpcEndExcept - } - - cci_check_error(RpcBindingFree(&CLIENT_REQUEST_RPC_HANDLE)); - - return (status); - } - -int main( int argc, char *argv[]) { - cc_int32 err = 0; - cc_context_t context = NULL; - cci_stream_t send_stream = NULL; - cci_stream_t reply_stream = NULL; - char* message = "Hello, RPC!"; - - -// send_test("krbcc.229026.0.ep"); - -#if 0 - err = cc_initialize(&context, ccapi_version_7, NULL, NULL); -#endif - - if (!err) { - err = cci_os_ipc_thread_init(); - } - if (!err) { - err = cci_stream_new (&send_stream); - err = cci_stream_write(send_stream, message, 1+strlen(message)); - } - - if (!err) { - err = cci_os_ipc_msg(TRUE, send_stream, CCMSG_PING, &reply_stream); - } - Sleep(10*1000); - cci_debug_printf("Try finishing async call."); - - Sleep(INFINITE); - cci_debug_printf("main: return. err == %d", err); - - return 0; - } - - - -/*********************************************************************/ -/* MIDL allocate and free */ -/*********************************************************************/ - -void __RPC_FAR * __RPC_USER midl_user_allocate(size_t len) { - return(malloc(len)); - } - -void __RPC_USER midl_user_free(void __RPC_FAR * ptr) { - free(ptr); - } +// pingtest.c +// +// Test RPC to server, with PING message, which exists for no other purpose than this test. + +#include +#include + +#include "cci_debugging.h" +#include "CredentialsCache.h" +#include "cci_stream.h" +#include "win-utils.h" + +#include "ccs_request.h" +#define CLIENT_REQUEST_RPC_HANDLE ccs_request_IfHandle + + +extern cc_int32 cci_os_ipc_thread_init (void); +extern cc_int32 cci_os_ipc_msg( cc_int32 in_launch_server, + cci_stream_t in_request_stream, + cc_int32 in_msg, + cci_stream_t* out_reply_stream); + +RPC_STATUS send_test(char* endpoint) { + unsigned char* pszNetworkAddress = NULL; + unsigned char* pszOptions = NULL; + unsigned char* pszStringBinding = NULL; + unsigned char* pszUuid = NULL; + RPC_STATUS status; + + status = RpcStringBindingCompose(pszUuid, + (RPC_CSTR)"ncalrpc", + pszNetworkAddress, + (unsigned char*)endpoint, + pszOptions, + &pszStringBinding); + cci_debug_printf("%s pszStringBinding = %s", __FUNCTION__, pszStringBinding); + if (status) {return cci_check_error(status);} + + /* Set the binding handle that will be used to bind to the RPC server [the 'client']. */ + status = RpcBindingFromStringBinding(pszStringBinding, &CLIENT_REQUEST_RPC_HANDLE); + if (status) {return cci_check_error(status);} + + status = RpcStringFree(&pszStringBinding); // Temp var no longer needed. + + if (!status) { + RpcTryExcept { + cci_debug_printf("%s calling remote procedure 'ccs_authenticate'", __FUNCTION__); + status = ccs_authenticate((CC_CHAR*)"DLLMAIN TEST!"); + cci_debug_printf(" ccs_authenticate returned %d", status); + } + RpcExcept(1) { + status = cci_check_error(RpcExceptionCode()); + } + RpcEndExcept + } + + cci_check_error(RpcBindingFree(&CLIENT_REQUEST_RPC_HANDLE)); + + return (status); + } + +int main( int argc, char *argv[]) { + cc_int32 err = 0; + cc_context_t context = NULL; + cci_stream_t send_stream = NULL; + cci_stream_t reply_stream = NULL; + char* message = "Hello, RPC!"; + + +// send_test("krbcc.229026.0.ep"); + +#if 0 + err = cc_initialize(&context, ccapi_version_7, NULL, NULL); +#endif + + if (!err) { + err = cci_os_ipc_thread_init(); + } + if (!err) { + err = cci_stream_new (&send_stream); + err = cci_stream_write(send_stream, message, 1+strlen(message)); + } + + if (!err) { + err = cci_os_ipc_msg(TRUE, send_stream, CCMSG_PING, &reply_stream); + } + Sleep(10*1000); + cci_debug_printf("Try finishing async call."); + + Sleep(INFINITE); + cci_debug_printf("main: return. err == %d", err); + + return 0; + } + + + +/*********************************************************************/ +/* MIDL allocate and free */ +/*********************************************************************/ + +void __RPC_FAR * __RPC_USER midl_user_allocate(size_t len) { + return(malloc(len)); + } + +void __RPC_USER midl_user_free(void __RPC_FAR * ptr) { + free(ptr); + } -- 2.26.2