Path: blob/main/crypto/krb5/src/ccapi/common/win/tls.c
39566 views
/* ccapi/common/win/tls.c */1/*2* Copyright 2008 Massachusetts Institute of Technology.3* All Rights Reserved.4*5* Export of this software from the United States of America may6* require a specific license from the United States Government.7* It is the responsibility of any person or organization contemplating8* export to obtain such a license before exporting.9*10* WITHIN THAT CONSTRAINT, permission to use, copy, modify, and11* distribute this software and its documentation for any purpose and12* without fee is hereby granted, provided that the above copyright13* notice appear in all copies and that both that copyright notice and14* this permission notice appear in supporting documentation, and that15* the name of M.I.T. not be used in advertising or publicity pertaining16* to distribution of the software without specific, written prior17* permission. Furthermore if you modify this software you must label18* your software as modified software and not distribute it in such a19* fashion that it might be confused with the original M.I.T. software.20* M.I.T. makes no representations about the suitability of21* this software for any purpose. It is provided "as is" without express22* or implied warranty.23*/2425#include "string.h"26#include <stdlib.h>27#include <malloc.h>2829#include "tls.h"3031void tspdata_setUUID(struct tspdata* p, unsigned char __RPC_FAR* uuidString) {32strncpy(p->_uuid, uuidString, UUID_SIZE-1);33};3435void tspdata_setListening (struct tspdata* p, BOOL b) {p->_listening = b;}3637void tspdata_setConnected (struct tspdata* p, BOOL b) {p->_CCAPI_Connected = b;}3839void tspdata_setReplyEvent(struct tspdata* p, HANDLE h) {p->_replyEvent = h;}4041void tspdata_setRpcAState (struct tspdata* p, RPC_ASYNC_STATE* rpcState) {42p->_rpcState = rpcState;}4344void tspdata_setSST (struct tspdata* p, time_t t) {p->_sst = t;}4546void tspdata_setStream (struct tspdata* p, k5_ipc_stream s) {p->_stream = s;}4748BOOL tspdata_getListening (const struct tspdata* p) {return p->_listening;}4950BOOL tspdata_getConnected (const struct tspdata* p) {return p->_CCAPI_Connected;}5152HANDLE tspdata_getReplyEvent(const struct tspdata* p) {return p->_replyEvent;}5354time_t tspdata_getSST (const struct tspdata* p) {return p->_sst;}5556k5_ipc_stream tspdata_getStream (const struct tspdata* p) {return p->_stream;}5758char* tspdata_getUUID (const struct tspdata* p) {return p->_uuid;}5960RPC_ASYNC_STATE* tspdata_getRpcAState (const struct tspdata* p) {return p->_rpcState;}616263BOOL WINAPI GetTspData(DWORD dwTlsIndex, struct tspdata** pdw) {64struct tspdata* pData; // The stored memory pointer6566pData = (struct tspdata*)TlsGetValue(dwTlsIndex);67if (pData == NULL) {68pData = malloc(sizeof(*pData));69if (pData == NULL)70return FALSE;71memset(pData, 0, sizeof(*pData));72TlsSetValue(dwTlsIndex, pData);73}74(*pdw) = pData;75return TRUE;76}777879