Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
cta
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
dCache
cta
Commits
401aaf14
Commit
401aaf14
authored
8 years ago
by
Steven Murray
Browse files
Options
Downloads
Patches
Plain Diff
Removed marshall.h
parent
fc67b195
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
mediachanger/IoTest.cpp
+0
-114
0 additions, 114 deletions
mediachanger/IoTest.cpp
mediachanger/marshall.h
+0
-206
0 additions, 206 deletions
mediachanger/marshall.h
with
0 additions
and
320 deletions
mediachanger/IoTest.cpp
+
0
−
114
View file @
401aaf14
...
...
@@ -24,7 +24,6 @@
#include
"common/exception/Errnum.hpp"
#include
"common/SmartFd.hpp"
#include
"mediachanger/io.hpp"
#include
"mediachanger/marshall.h"
#include
<fcntl.h>
#include
<gtest/gtest.h>
...
...
@@ -197,18 +196,6 @@ TEST_F(cta_mediachanger_IoTest, marshalUint8) {
ASSERT_EQ
(
0x87
&
0xFF
,
buf
[
0
]
&
0xFF
);
}
TEST_F
(
cta_mediachanger_IoTest
,
marshall_BYTE
)
{
const
uint8_t
v
=
0x87
;
char
buf
[
1
];
char
*
ptr
=
buf
;
memset
(
buf
,
'\0'
,
sizeof
(
buf
));
marshall_BYTE
(
ptr
,
v
);
ASSERT_EQ
(
buf
+
1
,
ptr
);
ASSERT_EQ
(
0x87
&
0xFF
,
buf
[
0
]
&
0xFF
);
}
static
void
check16BitsWereMarshalledBigEndian
(
const
char
*
const
buf
)
{
ASSERT_EQ
(
0x87
&
0xFF
,
buf
[
0
]
&
0xFF
);
ASSERT_EQ
(
0x65
&
0xFF
,
buf
[
1
]
&
0xFF
);
...
...
@@ -238,18 +225,6 @@ TEST_F(cta_mediachanger_IoTest, marshalUint16) {
check16BitsWereMarshalledBigEndian
(
buf
);
}
TEST_F
(
cta_mediachanger_IoTest
,
marshall_SHORT
)
{
const
uint16_t
v
=
0x8765
;
char
buf
[
2
];
char
*
ptr
=
buf
;
memset
(
buf
,
'\0'
,
sizeof
(
buf
));
marshall_SHORT
(
ptr
,
v
);
ASSERT_EQ
(
buf
+
2
,
ptr
);
check16BitsWereMarshalledBigEndian
(
buf
);
}
static
void
check32BitsWereMarshalledBigEndian
(
const
char
*
const
buf
)
{
ASSERT_EQ
(
0x87
&
0xFF
,
buf
[
0
]
&
0xFF
);
ASSERT_EQ
(
0x65
&
0xFF
,
buf
[
1
]
&
0xFF
);
...
...
@@ -281,18 +256,6 @@ TEST_F(cta_mediachanger_IoTest, marshalUint32) {
check32BitsWereMarshalledBigEndian
(
buf
);
}
TEST_F
(
cta_mediachanger_IoTest
,
marshall_LONG
)
{
const
uint32_t
v
=
0x87654321
;
char
buf
[
4
];
char
*
ptr
=
buf
;
memset
(
buf
,
'\0'
,
sizeof
(
buf
));
marshall_LONG
(
ptr
,
v
);
ASSERT_EQ
(
buf
+
4
,
ptr
);
check32BitsWereMarshalledBigEndian
(
buf
);
}
static
void
check64BitsWereMarshalledBigEndian
(
const
char
*
const
buf
)
{
ASSERT_EQ
(
0x88
&
0xFF
,
buf
[
0
]
&
0xFF
);
ASSERT_EQ
(
0x77
&
0xFF
,
buf
[
1
]
&
0xFF
);
...
...
@@ -316,22 +279,6 @@ TEST_F(cta_mediachanger_IoTest, marshalUint64) {
check64BitsWereMarshalledBigEndian
(
buf
);
}
// The following test MUST call check64BitsWereMarshalledBigEndian() like
// the marshalUint64 test above in order to prove that the new C++
// marshalling code of castor::io is compatible with that of the legacy
// code found in h/mashall.h
TEST_F
(
cta_mediachanger_IoTest
,
marshall_HYPER
)
{
const
uint64_t
v
=
0x8877665544332211LL
;
char
buf
[
8
];
char
*
ptr
=
buf
;
memset
(
buf
,
'\0'
,
sizeof
(
buf
));
marshall_HYPER
(
ptr
,
v
);
ASSERT_EQ
(
buf
+
8
,
ptr
);
check64BitsWereMarshalledBigEndian
(
buf
);
}
static
void
checkStringWasMarshalled
(
const
char
*
const
buf
)
{
ASSERT_EQ
(
'V'
,
buf
[
0
]);
ASSERT_EQ
(
'a'
,
buf
[
1
]);
...
...
@@ -355,18 +302,6 @@ TEST_F(cta_mediachanger_IoTest, marshalString) {
checkStringWasMarshalled
(
buf
);
}
TEST_F
(
cta_mediachanger_IoTest
,
marshall_STRING
)
{
const
char
*
const
v
=
"Value"
;
char
buf
[
8
];
char
*
ptr
=
buf
;
memset
(
buf
,
'E'
,
sizeof
(
buf
));
marshall_STRING
(
ptr
,
v
);
ASSERT_EQ
(
buf
+
6
,
ptr
);
checkStringWasMarshalled
(
buf
);
}
TEST_F
(
cta_mediachanger_IoTest
,
unmarshalUint8
)
{
char
buf
[]
=
{
'\x87'
};
size_t
bufLen
=
sizeof
(
buf
);
...
...
@@ -378,15 +313,6 @@ TEST_F(cta_mediachanger_IoTest, unmarshalUint8) {
ASSERT_EQ
(
0x87
,
v
);
}
TEST_F
(
cta_mediachanger_IoTest
,
unmarshall_BYTE
)
{
char
buf
[]
=
{
'\x87'
};
const
char
*
ptr
=
buf
;
uint8_t
v
=
0
;
unmarshall_BYTE
(
ptr
,
v
);
ASSERT_EQ
(
buf
+
1
,
ptr
);
ASSERT_EQ
(
0x87
,
v
);
}
TEST_F
(
cta_mediachanger_IoTest
,
unmarshalInt16
)
{
char
buf
[]
=
{
'\x87'
,
'\x65'
};
size_t
bufLen
=
sizeof
(
buf
);
...
...
@@ -409,15 +335,6 @@ TEST_F(cta_mediachanger_IoTest, unmarshalUint16) {
ASSERT_EQ
((
uint16_t
)
0x8765
,
v
);
}
TEST_F
(
cta_mediachanger_IoTest
,
unmarshall_SHORT
)
{
char
buf
[]
=
{
'\x87'
,
'\x65'
};
const
char
*
ptr
=
buf
;
uint16_t
v
=
0
;
unmarshall_SHORT
(
ptr
,
v
);
ASSERT_EQ
(
buf
+
2
,
ptr
);
ASSERT_EQ
((
uint16_t
)
0x8765
,
v
);
}
TEST_F
(
cta_mediachanger_IoTest
,
unmarshalUint32
)
{
char
buf
[]
=
{
'\x87'
,
'\x65'
,
'\x43'
,
'\x21'
};
size_t
bufLen
=
sizeof
(
buf
);
...
...
@@ -429,15 +346,6 @@ TEST_F(cta_mediachanger_IoTest, unmarshalUint32) {
ASSERT_EQ
((
uint32_t
)
0x87654321
,
v
);
}
TEST_F
(
cta_mediachanger_IoTest
,
unmarshall_LONG
)
{
char
buf
[]
=
{
'\x87'
,
'\x65'
,
'\x43'
,
'\x21'
};
const
char
*
ptr
=
buf
;
uint32_t
v
=
0
;
unmarshall_LONG
(
ptr
,
v
);
ASSERT_EQ
(
buf
+
4
,
ptr
);
ASSERT_EQ
((
uint32_t
)
0x87654321
,
v
);
}
TEST_F
(
cta_mediachanger_IoTest
,
unmarshalInt32
)
{
char
buf
[]
=
{
'\x87'
,
'\x65'
,
'\x43'
,
'\x21'
};
size_t
bufLen
=
sizeof
(
buf
);
...
...
@@ -460,18 +368,6 @@ TEST_F(cta_mediachanger_IoTest, unmarshalUint64) {
ASSERT_EQ
((
uint64_t
)
0x8877665544332211LL
,
v
);
}
// The following test MUST be the same as the unmarshalUint64 test above in
// order to prove that the new C++ un-marshalling code of castor::io is
// compatible with that of the legacy code found in h/mashall.h
TEST_F
(
cta_mediachanger_IoTest
,
unmarshall_HYPER
)
{
char
buf
[]
=
{
'\x88'
,
'\x77'
,
'\x66'
,
'\x55'
,
'\x44'
,
'\x33'
,
'\x22'
,
'\x11'
};
const
char
*
ptr
=
buf
;
uint64_t
v
=
0
;
unmarshall_HYPER
(
ptr
,
v
);
ASSERT_EQ
(
buf
+
8
,
ptr
);
ASSERT_EQ
((
uint64_t
)
0x8877665544332211LL
,
v
);
}
TEST_F
(
cta_mediachanger_IoTest
,
unmarshalString
)
{
char
src
[]
=
{
'V'
,
'a'
,
'l'
,
'u'
,
'e'
,
'\0'
,
'E'
,
'E'
};
size_t
srcLen
=
sizeof
(
src
);
...
...
@@ -485,14 +381,4 @@ TEST_F(cta_mediachanger_IoTest, unmarshalString) {
ASSERT_EQ
(
std
::
string
(
"Value"
),
std
::
string
(
dst
));
}
TEST_F
(
cta_mediachanger_IoTest
,
unmarshall_STRING
)
{
char
src
[]
=
{
'V'
,
'a'
,
'l'
,
'u'
,
'e'
,
'\0'
,
'E'
,
'E'
};
const
char
*
srcPtr
=
src
;
char
dst
[
6
];
unmarshall_STRING
(
srcPtr
,
dst
);
ASSERT_EQ
(
src
+
6
,
srcPtr
);
ASSERT_EQ
(
std
::
string
(
"Value"
),
std
::
string
(
dst
));
}
}
// namespace unitTests
This diff is collapsed.
Click to expand it.
mediachanger/marshall.h
deleted
100644 → 0
+
0
−
206
View file @
fc67b195
/*
* $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
<memory.h>
/* memory operations definition */
#include
<arpa/inet.h>
// Imported old stuff needed by marshal_XXX macros
typedef
unsigned
char
U_BYTE
;
typedef
unsigned
short
U_SHORT
;
typedef
unsigned
int
U_LONG
;
typedef
char
BYTE
;
typedef
short
WORD
;
typedef
int
LONG
;
typedef
uint64_t
U_HYPER
;
#define BYTEADDR(x) (((char *)&(x))+sizeof(BYTE)-BYTESIZE)
#define BYTESIZE 1
#define SHORT WORD
/* #define U_SHORT U_WORD */
#define WORDSIZE 2
#define WORDADDR(x) (((char *)&(x))+sizeof(WORD)-WORDSIZE)
#define SHORTSIZE WORDSIZE
#define SHORTADDR WORDADDR
#define LONGSIZE 4
#define LONGADDR(x) (((char *)&(x))+sizeof(LONG)-LONGSIZE)
#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*/
/*
* 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; \
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment