4556240 [rkeene@sledge /home/rkeene/devel/dact-0.8.37]$ cat -n dendian.h
 1 /*
 2  * Copyright (C) 2001, 2002, and 2003  Roy Keene
 3  *
 4  * This program is free software; you can redistribute it and/or
 5  * modify it under the terms of the GNU General Public License
 6  * as published by the Free Software Foundation; either version 2
 7  * of the License, or (at your option) any later version.
 8  *
 9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
17  *
18  *      email: dact@rkeene.org
19  */
20 
21 #ifndef __ENDIAN_LOCAL_H
22 #define __ENDIAN_LOCAL_H
23 
24 int write_de(const int dst, const uint32_t num, const int sze);
25 int read_de(const int src, void *dest, const int sze, const int out_sze);
26 
27 /*
28 #ifdef __DACT_C
29 unsigned char ENDIAN_LOCAL_BUF[4]={0, 0, 0, 0};
30 #endif
31 
32 #define WRITE_2BYTE_DE(x,y) 2; \
33             ENDIAN_LOCAL_BUF[0]=((y&0xff00) >> 8); \
34             ENDIAN_LOCAL_BUF[1]=((y&0x00ff)); \
35             write(x,&ENDIAN_LOCAL_BUF[0],1); \
36             write(x,&ENDIAN_LOCAL_BUF[1],1)
37 
38 #define WRITE_4BYTE_DE(x,y) 4; \
39             ENDIAN_LOCAL_BUF[0]=((y&0xff000000) >> 24); \
40             ENDIAN_LOCAL_BUF[1]=((y&0x00ff0000) >> 16); \
41             ENDIAN_LOCAL_BUF[2]=((y&0x0000ff00) >> 8); \
42             ENDIAN_LOCAL_BUF[3]=((y&0x000000ff)); \
43             write(x,&ENDIAN_LOCAL_BUF[0],1); \
44             write(x,&ENDIAN_LOCAL_BUF[1],1); \
45             write(x,&ENDIAN_LOCAL_BUF[2],1); \
46             write(x,&ENDIAN_LOCAL_BUF[3],1)
47 
48 #define READ_2BYTE_DE(x,y) (read(x,&ENDIAN_LOCAL_BUF[0],1)+ \
49                 read(x,&ENDIAN_LOCAL_BUF[1],1)); \
50             y=((ENDIAN_LOCAL_BUF[0]<<8)|ENDIAN_LOCAL_BUF[1])
51 
52 #define READ_4BYTE_DE(x,y) (read(x,&ENDIAN_LOCAL_BUF[0],1)+\
53                 read(x,&ENDIAN_LOCAL_BUF[1],1)+\
54                 read(x,&ENDIAN_LOCAL_BUF[2],1)+\
55                 read(x,&ENDIAN_LOCAL_BUF[3],1)); \
56             y=((ENDIAN_LOCAL_BUF[0]<<24)|(ENDIAN_LOCAL_BUF[1]<<16)|(ENDIAN_LOCAL_BUF[2]<<8)|ENDIAN_LOCAL_BUF[3])
57 
58 #define WRITE_NBYTE_DE(x,y,n) (((int) (n/2))*2); if (n<=2) { WRITE_2BYTE_DE(x,y); } else { WRITE_4BYTE_DE(x,y); }
59 
60 #define READ_NBYTE_DE(x,y,n) (((int) (n/2))*2); if (n<=2) { READ_2BYTE_DE(x,y); } else { READ_4BYTE_DE(x,y); }
61 
62 */
63 
64 #endif
4556241 [rkeene@sledge /home/rkeene/devel/dact-0.8.37]$

Click here to go back to the directory listing.
Click here to download this file.
last modified: 2004-04-04 07:01:51