The non-java project is being replaced by a client and a server project
in order to allow for the client component to be consumed by distributions targeting the desktop. This check-in is for the server project.
This commit is contained in:
152
CASA-auth-token/server/utilities/IpcLibs/linux/common/ipcint.h
Normal file
152
CASA-auth-token/server/utilities/IpcLibs/linux/common/ipcint.h
Normal file
@@ -0,0 +1,152 @@
|
||||
/**********************\*************************************************
|
||||
*
|
||||
* Copyright (C) 2006 Novell, Inc. All Rights Reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, Novell, Inc.
|
||||
*
|
||||
* To contact Novell about this file by physical or electronic mail,
|
||||
* you may find current contact information at www.novell.com.
|
||||
*
|
||||
* Author: Juan Carlos Luciani <jluciani@novell.com>
|
||||
*
|
||||
***********************************************************************/
|
||||
|
||||
#ifndef _IPCINT_
|
||||
#define _IPCINT_
|
||||
|
||||
//===[ Include files ]=====================================================
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
using namespace std;
|
||||
|
||||
extern "C" {
|
||||
#include <stdint.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
#include <netinet/in.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <pthread.h>
|
||||
#include <syslog.h>
|
||||
#include <signal.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/file.h>
|
||||
#include <assert.h> // Ensure that NDEBUG is defined for release builds!
|
||||
#include <sys/ipc.h>
|
||||
}
|
||||
|
||||
//===[ External data ]=====================================================
|
||||
|
||||
extern int DebugLevel;
|
||||
extern bool UseSyslog;
|
||||
extern char *pAppName;
|
||||
extern pthread_mutex_t interlockedMutex;
|
||||
|
||||
//===[ Macro definitions ]=================================================
|
||||
|
||||
//
|
||||
// DbgTrace macro define
|
||||
//
|
||||
#define MAX_FORMAT_STRING_LEN 1024
|
||||
#define DbgTrace(LEVEL, X, Y) { \
|
||||
if (LEVEL == 0 || DebugLevel >= LEVEL) { \
|
||||
if (UseSyslog) \
|
||||
syslog(LOG_USER | LOG_INFO, X, Y); \
|
||||
else { \
|
||||
char *pFormatString = new char[MAX_FORMAT_STRING_LEN]; \
|
||||
if (pFormatString) { \
|
||||
snprintf(pFormatString, MAX_FORMAT_STRING_LEN, X, Y); \
|
||||
fprintf(stderr, "%s -%s", pAppName, pFormatString); \
|
||||
delete[] pFormatString; \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
//
|
||||
// Interlocked Increment and Decrement macros
|
||||
//
|
||||
// Well, kind of interlocked :-).
|
||||
//
|
||||
__inline static unsigned long
|
||||
InterlockedIncrement(unsigned long *pValue)
|
||||
{
|
||||
unsigned long retVal;
|
||||
pthread_mutex_lock(&interlockedMutex);
|
||||
(*pValue) ++;
|
||||
retVal = *pValue;
|
||||
pthread_mutex_unlock(&interlockedMutex);
|
||||
return retVal;
|
||||
}
|
||||
|
||||
__inline static unsigned long
|
||||
InterlockedDecrement(unsigned long *pValue)
|
||||
{
|
||||
unsigned long retVal;
|
||||
pthread_mutex_lock(&interlockedMutex);
|
||||
(*pValue) --;
|
||||
retVal = *pValue;
|
||||
pthread_mutex_unlock(&interlockedMutex);
|
||||
return retVal;
|
||||
}
|
||||
|
||||
__inline static uint32_t
|
||||
InterlockedIncrement(uint32_t *pValue)
|
||||
{
|
||||
uint32_t retVal;
|
||||
pthread_mutex_lock(&interlockedMutex);
|
||||
(*pValue) ++;
|
||||
retVal = *pValue;
|
||||
pthread_mutex_unlock(&interlockedMutex);
|
||||
return retVal;
|
||||
}
|
||||
|
||||
__inline static uint32_t
|
||||
InterlockedDecrement(uint32_t *pValue)
|
||||
{
|
||||
uint32_t retVal;
|
||||
pthread_mutex_lock(&interlockedMutex);
|
||||
(*pValue) --;
|
||||
retVal = *pValue;
|
||||
pthread_mutex_unlock(&interlockedMutex);
|
||||
return retVal;
|
||||
}
|
||||
|
||||
//===[ Include files ]=====================================================
|
||||
|
||||
#include "smartptr.h"
|
||||
#include "channelproto.h"
|
||||
|
||||
//===[ External prototypes ]===============================================
|
||||
|
||||
//===[ Manifest constants ]================================================
|
||||
|
||||
//===[ Type definitions ]==================================================
|
||||
|
||||
//===[ Function prototypes ]===============================================
|
||||
|
||||
|
||||
#endif // _IPCINT_
|
||||
|
||||
//=========================================================================
|
||||
//=========================================================================
|
||||
Reference in New Issue
Block a user