diff options
author | Ken Raeburn <raeburn@mit.edu> | 2008-02-05 18:25:28 +0000 |
---|---|---|
committer | Ken Raeburn <raeburn@mit.edu> | 2008-02-05 18:25:28 +0000 |
commit | 54383345ad77587fa4eaf765eb77d20439500482 (patch) | |
tree | dbf052f9df6b3024a7ec18888c741c8efb8fea7a /src/ccapi/server | |
parent | 23378da7704a0c1dfd58ab46289036b509ee4d9f (diff) | |
download | krb5-54383345ad77587fa4eaf765eb77d20439500482.tar.gz krb5-54383345ad77587fa4eaf765eb77d20439500482.tar.xz krb5-54383345ad77587fa4eaf765eb77d20439500482.zip |
set eol-style
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@20217 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/ccapi/server')
-rw-r--r-- | src/ccapi/server/win/WorkQueue.h | 90 | ||||
-rw-r--r-- | src/ccapi/server/win/ccs_os_pipe.c | 128 | ||||
-rw-r--r-- | src/ccapi/server/win/ccs_request_proc.c | 230 | ||||
-rw-r--r-- | src/ccapi/server/win/ccs_win_pipe.c | 326 | ||||
-rw-r--r-- | src/ccapi/server/win/ccs_win_pipe.h | 136 | ||||
-rw-r--r-- | src/ccapi/server/win/workitem.h | 94 |
6 files changed, 502 insertions, 502 deletions
diff --git a/src/ccapi/server/win/WorkQueue.h b/src/ccapi/server/win/WorkQueue.h index 106f9acb9c..eb46780196 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 69dcec4748..95af378e7e 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 40713fb502..a1c082da03 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 <stdlib.h>
-#include <stdio.h>
-
-#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 <stdlib.h> +#include <stdio.h> + +#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 4d121aaeac..a8fea2f384 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 afabe12fed..3600d12af4 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 a9d1c0e299..df1d7794a4 100644 --- a/src/ccapi/server/win/workitem.h +++ b/src/ccapi/server/win/workitem.h @@ -1,48 +1,48 @@ -#ifndef __WorkItem
-#define __WorkItem
-
-#include <list>
-#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 <WorkItem*> wl;
- CRITICAL_SECTION cs;
-public:
- WorkList();
- ~WorkList();
- int add(WorkItem*);
- int remove(WorkItem**);
- bool isEmpty() {return wl.empty();}
- };
-
+#ifndef __WorkItem +#define __WorkItem + +#include <list> +#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 <WorkItem*> 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 |