Skip to content
Snippets Groups Projects
Commit 0a795f85 authored by Steven Murray's avatar Steven Murray
Browse files

WIP

parent 884d1175
No related branches found
No related tags found
No related merge requests found
......@@ -19,8 +19,9 @@
cmake_minimum_required (VERSION 2.6)
add_subdirectory (exception)
add_subdirectory (utils)
add_subdirectory (io)
add_subdirectory (log)
add_subdirectory (mediachanger)
add_subdirectory (messages)
add_subdirectory (log)
add_subdirectory (tape)
add_subdirectory (utils)
cmake_minimum_required (VERSION 2.6)
include_directories(${PROJECT_SOURCE_DIR}/tapeserver)
include_directories(${PROJECT_SOURCE_DIR}/tapeserver/h)
add_library (castoriounittests SHARED
IoTest.cpp)
/*
* $Id: marshall.h,v 1.15 2005/02/22 13:28:13 jdurand Exp $
*/
/*
*/
/*
* Copyright (C) 1990-2002 by CERN/IT/PDP/DM
* All rights reserved
*/
/* marshall.h - marshalling/unmarshalling definitions */
#pragma once
#include <osdep.h> /* Operating system dependencies */
#include <memory.h> /* memory operations definition */
#include <arpa/inet.h>
#define SHORT WORD
/* #define U_SHORT U_WORD */
#define SHORTSIZE WORDSIZE
#define SHORTADDR WORDADDR
#define marshall_WORD marshall_SHORT
#define unmarshall_WORD unmarshall_SHORT
#define INC_PTR(ptr,n) (ptr) = (char*)(ptr) + (n)
#define DIFF_PTR(ptr,base) (char*)(ptr) - (char*)(base)
/*
* BIT manipulation
*/
#define BITSOFBYTE 8 /* number of bits in a byte */
#define bitsof(t) sizeof(t)*BITSOFBYTE /* number of bits in a type*/
typedef char* bitvct; /* bit vector type definition */
/*
* Allocate enough memory for a 'bitvct' type variable containing
* 'size' bits
*/
#define bitalloc(size) (bitvct)malloc(size/BITSOFBYTE + \
((size%BITSOFBYTE) ? 1 : 0))
/*
* Set the bit 'bit-th' starting from the byte pointed to by 'ptr'
*/
#define BIT_SET(ptr,bit) { char *p = (char*)(ptr) + (bit)/8; \
*p = *p | (1 << (7-(bit)%8)) ; \
}
/*
* Clear the bit 'bit-th' starting from the byte pointed to by 'ptr'
*/
#define BIT_CLR(ptr,bit) { char *p = (char*)(ptr) + (bit)/8; \
*p = *p & ~(1 << (7-(bit)%8)); \
}
/*
* Test the bit 'bit-th' starting from the byte pointed to by 'ptr'
*/
#define BIT_ISSET(ptr,bit) (*(char*)((char*)(ptr)+(bit)/8) & (1 << (7-(bit)%8)))
/*
* B Y T E
*/
#define marshall_BYTE(ptr,n) { BYTE n_ = n; \
(void) memcpy((ptr),BYTEADDR(n_),BYTESIZE); \
INC_PTR(ptr,BYTESIZE); \
}
#define unmarshall_BYTE(ptr,n) { BYTE n_ = 0; \
(void) memcpy(BYTEADDR(n_),(ptr),BYTESIZE); \
n = n_; \
INC_PTR(ptr,BYTESIZE); \
}
/*
* S H O R T
*/
#define marshall_SHORT(ptr,n) { SHORT n_ = htons((unsigned short)(n)); \
(void) memcpy((ptr),SHORTADDR(n_),SHORTSIZE); \
INC_PTR(ptr,SHORTSIZE); \
}
#define unmarshall_SHORT(ptr,n) { SHORT n_ = 0; \
(void) memcpy(SHORTADDR(n_),(ptr),SHORTSIZE); \
n = ntohs((unsigned short)(n_)); \
if ( BIT_ISSET(ptr,0) && sizeof(SHORT)-SHORTSIZE > 0 ) \
(void) memset((char *)&n,255,sizeof(SHORT)-SHORTSIZE); \
INC_PTR(ptr,SHORTSIZE); \
}
/*
* L O N G
*/
#define marshall_LONG(ptr,n) { LONG n_ = htonl((unsigned long)(n)); \
(void) memcpy((ptr),LONGADDR(n_),LONGSIZE); \
INC_PTR(ptr,LONGSIZE); \
}
#define unmarshall_LONG(ptr,n) { LONG n_ = 0; \
(void) memcpy(LONGADDR(n_),(ptr),LONGSIZE); \
n = ntohl((unsigned long)(n_)); \
if ( BIT_ISSET(ptr,0) && sizeof(LONG)-LONGSIZE > 0 ) \
(void) memset((char *)&n,255,sizeof(LONG)-LONGSIZE); \
INC_PTR(ptr,LONGSIZE); \
}
/*
* S T R I N G
*/
#define marshall_STRING(ptr,str) { (void) strcpy((char*)(ptr),(char*)(str)); \
INC_PTR(ptr,strlen(str)+1); \
}
#define marshall_STRINGN(ptr,str,n) { (void) strncpy((char*)(ptr),(char*)(str),n); \
((char*)(ptr))[n-1] = 0; \
if (strlen(str)+1 > n) \
INC_PTR(ptr,n); \
else \
INC_PTR(ptr,strlen(str)+1); \
}
#define unmarshall_STRING(ptr,str) { (void) strcpy((char*)(str),(char*)(ptr)); \
INC_PTR(ptr,strlen(str)+1); \
}
EXTERN_C int _unmarshall_STRINGN (char **, char*, int);
#define unmarshall_STRINGN(ptr,str,n) _unmarshall_STRINGN(&ptr, str, n)
/*
* H Y P E R ( 6 4 B I T S )
*/
#define marshall_HYPER(ptr,n) { U_HYPER u_ = n; \
LONG n_ = htonl(*((U_LONG *)((char *)&(u_)+LONGSIZE))); \
(void) memcpy((ptr),LONGADDR(n_),LONGSIZE); \
INC_PTR(ptr,LONGSIZE); \
n_ = htonl(*((U_LONG *)&(u_))); \
(void) memcpy((ptr),LONGADDR(n_),LONGSIZE); \
INC_PTR(ptr,LONGSIZE); \
}
#define unmarshall_HYPER(ptr,n) { U_HYPER u_ = 0; \
LONG n_ = 0; \
(void) memcpy(LONGADDR(n_),(ptr),LONGSIZE); \
*((LONG *)((char *)&(u_)+LONGSIZE)) = \
ntohl((U_LONG)(n_)); \
INC_PTR(ptr,LONGSIZE); \
n_ = 0; \
(void) memcpy(LONGADDR(n_),(ptr),LONGSIZE); \
*((LONG *)&(u_)) = ntohl((U_LONG)(n_)); \
INC_PTR(ptr,LONGSIZE); \
n = u_; \
}
/*
* O P A Q U E
*/
#define marshall_OPAQUE(ptr,raw,n) { (void) memcpy((ptr),(raw),(n)); \
INC_PTR(ptr,(n)); \
}
#define unmarshall_OPAQUE(ptr,raw,n) { (void) memcpy((raw),(ptr),(n)); \
INC_PTR(ptr,(n)); \
}
/*
* T I M E
*/
#define marshall_TIME_T(ptr,n) { \
TIME_T _marshall_time_dummy = (TIME_T) n; \
marshall_HYPER(ptr,_marshall_time_dummy); \
}
#define unmarshall_TIME_T(ptr,n) { \
TIME_T _unmarshall_time_dummy; \
unmarshall_HYPER(ptr,_unmarshall_time_dummy); \
n = (time_t) _unmarshall_time_dummy; \
}
/*
* $Id: osdep.h,v 1.22 2009/05/13 10:06:27 sponcec3 Exp $
*/
/*
* Copyright (C) 1990-2002 by CERN/IT/PDP/IP
* All rights reserved
*/
/*
*/
/* osdep.h Operating system dependencies */
#pragma once
/*
* Data representation
*/
#define BYTESIZE 1
#define WORDSIZE 2
#define LONGSIZE 4
#define QUADSIZE 8
#define HYPERSIZE 8
#define TIME_TSIZE HYPERSIZE
typedef unsigned char U_BYTE;
typedef unsigned short U_SHORT;
typedef unsigned int U_LONG;
typedef char BYTE;
typedef short WORD;
typedef int LONG;
#define BYTEADDR(x) (((char *)&(x))+sizeof(BYTE)-BYTESIZE)
#define WORDADDR(x) (((char *)&(x))+sizeof(WORD)-WORDSIZE)
#define LONGADDR(x) (((char *)&(x))+sizeof(LONG)-LONGSIZE)
typedef long long signed64;
typedef unsigned long long u_signed64;
typedef signed64 HYPER;
typedef u_signed64 U_HYPER;
typedef U_HYPER TIME_T;
#define ONE_KIB 0x400
#define ONE_MIB 0x100000
#define ONE_GIB 0x40000000
#define ONE_TIB 0x10000000000LL
#define ONE_PIB 0x4000000000000LL
#define ONE_HIB 0x1000000000000000LL
#define ONE_KB 1000
#define ONE_MB 1000000
#define ONE_GB 1000000000
#define ONE_TB 1000000000000LL
#define ONE_PB 1000000000000000LL
#define ONE_HB 1000000000000000000LL
/*
* Error reporting
*/
#define NETERROR perror
#define OSERROR perror
/* Macros for externalization (UNIX) (J.-D.Durand) */
#ifdef EXTERN_C
#undef EXTERN_C
#endif
#if defined(__cplusplus)
#define EXTERN_C extern "C"
#else
#define EXTERN_C extern
#endif
#if defined(__APPLE__)
#define off64_t off_t
#endif
......@@ -48,8 +48,6 @@ set_property(SOURCE
APPEND PROPERTY COMPILE_FLAGS -fno-strict-aliasing)
#add_executable(castorUnitTests
# castorUnitTests.cpp
# ../castor/exception/ExceptionTest.cpp
# ../castor/io/IoTest.cpp
# ../castor/messages/TapeserverProxy.cpp
# ../castor/messages/TapeserverProxyZmq.cpp
# ../castor/legacymsg/CommonMarshalTest.cpp
......
......@@ -5,6 +5,7 @@ add_executable(unittests
target_link_libraries(unittests
castorexceptionunittests
castoriounittests
ctacommon
ctacommonunittests
CTAObjectStore
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment