git-svn: trunk@2977
Tomasz Kojm authored on 2007/03/27 17:57:37... | ... |
@@ -1,3 +1,9 @@ |
1 |
+Tue Mar 27 09:03:42 CEST 2007 (tk) |
|
2 |
+---------------------------------- |
|
3 |
+ * libclamav/others.[ch]: on little endian use macro versions of |
|
4 |
+ cli_(read|write)int32 (bb#427), thanks to Andrey J. |
|
5 |
+ Melnikoff and Stephen Gran |
|
6 |
+ |
|
1 | 7 |
Tue Mar 27 03:49:13 CEST 2007 (acab) |
2 | 8 |
------------------------------------ |
3 | 9 |
* libclamav/pe.c: typo |
... | ... |
@@ -773,30 +773,6 @@ int cli_writen(int fd, const void *buff, unsigned int count) |
773 | 773 |
return count; |
774 | 774 |
} |
775 | 775 |
|
776 |
-int32_t cli_readint32(const char *buff) |
|
777 |
-{ |
|
778 |
- int32_t ret; |
|
779 |
- |
|
780 |
-#if WORDS_BIGENDIAN == 0 |
|
781 |
- ret = *(const int32_t *) buff; |
|
782 |
-#else |
|
783 |
- ret = buff[0] & 0xff; |
|
784 |
- ret |= (buff[1] & 0xff) << 8; |
|
785 |
- ret |= (buff[2] & 0xff) << 16; |
|
786 |
- ret |= (buff[3] & 0xff) << 24; |
|
787 |
-#endif |
|
788 |
- |
|
789 |
- return ret; |
|
790 |
-} |
|
791 |
- |
|
792 |
-void cli_writeint32(char *offset, uint32_t value) |
|
793 |
-{ |
|
794 |
- offset[0] = value & 0xff; |
|
795 |
- offset[1] = (value & 0xff00) >> 8; |
|
796 |
- offset[2] = (value & 0xff0000) >> 16; |
|
797 |
- offset[3] = (value & 0xff000000) >> 24; |
|
798 |
-} |
|
799 |
- |
|
800 | 776 |
int cli_filecopy(const char *src, const char *dest) |
801 | 777 |
{ |
802 | 778 |
char *buffer; |
... | ... |
@@ -181,8 +181,6 @@ char *cli_md5stream(FILE *fs, unsigned char *digcpy); |
181 | 181 |
char *cli_md5file(const char *filename); |
182 | 182 |
int cli_readn(int fd, void *buff, unsigned int count); |
183 | 183 |
int cli_writen(int fd, const void *buff, unsigned int count); |
184 |
-int32_t cli_readint32(const char *buff); |
|
185 |
-void cli_writeint32(char *offset, uint32_t value); |
|
186 | 184 |
char *cli_gentemp(const char *dir); |
187 | 185 |
char *cli_gentempdir(const char *dir); |
188 | 186 |
char *cli_gentempdesc(const char *dir, int *fd); |
... | ... |
@@ -194,4 +192,28 @@ void cli_bitset_free(bitset_t *bs); |
194 | 194 |
int cli_bitset_set(bitset_t *bs, unsigned long bit_offset); |
195 | 195 |
int cli_bitset_test(bitset_t *bs, unsigned long bit_offset); |
196 | 196 |
void cli_sanitise_filename(char *name); |
197 |
+ |
|
198 |
+#if WORDS_BIGENDIAN == 0 |
|
199 |
+#define cli_readint32(buff) (*(const int32_t *)(buff)) |
|
200 |
+#define cli_writeint32(offset, value) (*(uint32_t *)(offset)=(uint32_t)(value)) |
|
201 |
+#else |
|
202 |
+static inline int32_t cli_readint32(const char *buff) |
|
203 |
+{ |
|
204 |
+ int32_t ret; |
|
205 |
+ ret = buff[0] & 0xff; |
|
206 |
+ ret |= (buff[1] & 0xff) << 8; |
|
207 |
+ ret |= (buff[2] & 0xff) << 16; |
|
208 |
+ ret |= (buff[3] & 0xff) << 24; |
|
209 |
+ return ret; |
|
210 |
+} |
|
211 |
+ |
|
212 |
+static inline void cli_writeint32(char *offset, uint32_t value) |
|
213 |
+{ |
|
214 |
+ offset[0] = value & 0xff; |
|
215 |
+ offset[1] = (value & 0xff00) >> 8; |
|
216 |
+ offset[2] = (value & 0xff0000) >> 16; |
|
217 |
+ offset[3] = (value & 0xff000000) >> 24; |
|
218 |
+} |
|
219 |
+#endif /* WORDS_BIGENDIAN == 0 */ |
|
220 |
+ |
|
197 | 221 |
#endif |