faubackup2/src/common common.cpp,1.1.1.1,1.2
Erik Merkel <[email protected]> Tue, 07 Jun 2005 10:33:37 +0000
| Newsgroups | gmane.comp.sysutils.backup.faubackup.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/faubackup/faubackup2/src/common
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8950/src/common
Modified Files:
common.cpp
Log Message:
removing dead endian code
Index: common.cpp
===================================================================
RCS file: /cvsroot/faubackup/faubackup2/src/common/common.cpp,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** common.cpp 2 Jun 2005 09:31:13 -0000 1.1.1.1
--- common.cpp 7 Jun 2005 10:33:34 -0000 1.2
***************
*** 9,19 ****
$Log$
Revision 1.1.1.1 2005/06/02 09:31:13 tali
import
!
Revision 1.28 2005/05/17 22:30:20 siermerk
Netzerkinterface komplett neu geschrieben;
Prozessstruktur arbeitet nun mit pthreads
!
Revision 1.27 2005/03/28 22:19:33 siermerk
neue Tests hinzugefuegt; Kommentare und Namen weiter bereinigt; C++ Initialisierungslisten eingebaut fuer
--- 9,22 ----
$Log$
+ Revision 1.2 2005/06/07 10:33:34 siermerk
+ removing dead endian code
+
Revision 1.1.1.1 2005/06/02 09:31:13 tali
import
!
Revision 1.28 2005/05/17 22:30:20 siermerk
Netzerkinterface komplett neu geschrieben;
Prozessstruktur arbeitet nun mit pthreads
!
Revision 1.27 2005/03/28 22:19:33 siermerk
neue Tests hinzugefuegt; Kommentare und Namen weiter bereinigt; C++ Initialisierungslisten eingebaut fuer
***************
*** 34,113 ****
{
- char *hostToNetByte(void *source, int length)
- {
- char *value = new char[length];
- #ifdef WORDS_BIGENDIAN
- /* just copy the bytes into the new array */
- char *temp = reinterpret_cast<char *> (source);
- for(int i = 0; i < length - 1; i++) {
- value[i] = *(temp++);
- }
- #else
- unsigned int *temp = reinterpret_cast<unsigned int *>
- (source);
-
- if (length == 8) { //64 bit value
- /* Split the 8 bytes into two 4 byte integers.
- Convert these 2 Ints into network byte order.
- Swap high and low Int for correct 64bit
- network order */
-
- //these are the first 4 bytes from left
- unsigned int low = htonl(*temp);
-
- //second 4 bytes
- unsigned int high = htonl(*(++temp));
-
- //assign to new array
- *(int *)value = high;
- *((int *)value + 1) = low;
-
- }
- if (length == 4) {
- //just make the old system call and copy
- *(int *)value = htonl(*(int *)source);
- }
-
- #endif
- return value;
- }
-
- char *netToHostByte(void *source, int length)
- {
- char *value = new char[length];
- #ifdef WORDS_BIGENDIAN
- /* just copy the bytes into the new array */
- char *temp = reinterpret_cast<char *> (source);
- for(int i = 0; i < length - 1; i++) {
- value[i] = *(temp++);
- }
- #else
- uint32_t *temp = reinterpret_cast<uint32_t *>
- (source);
- if (length == 8) { //64 bit value
- /* Split the 8 bytes into two 4 byte integers.
- Convert these 2 Ints into network byte order.
- Swap high and low Int for correct 64bit
- network order */
-
- //these are the first 4 bytes from left
- uint32_t low = ntohl(*temp);
-
- //second 4 bytes
- uint32_t high = ntohl(*(++temp));
-
- //assign to new array
- *(uint32_t *)value = high;
- *((uint32_t *)value + 1) = low;
-
- }
- if (length == 4) {
- //just make the old system call and copy
- *(uint32_t *)value = ntohl(*(uint32_t *)source);
- }
- #endif
- return value;
- }
-
uint64_t hostToNetByte(uint64_t value, int length)
{
--- 37,40 ----
-------------------------------------------------------
This SF.Net email is sponsored by: NEC IT Guy Games. How far can you shotput
a projector? How fast can you ride your desk chair down the office luge track?
If you want to score the big prize, get to know the little guy.
Play to win an NEC 61" plasma display: http://www.necitguy.com/?r=20