summaryrefslogtreecommitdiff
path: root/src/lib/eet
diff options
context:
space:
mode:
authorVincent Torri <vincent.torri@gmail.com>2019-02-01 11:04:17 +0000
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2019-02-01 14:25:35 +0000
commitf7c560c311d0ba0da94346e17c8b20f40a0ed152 (patch)
treeaf5f63aceb78ff1b153f3727f8adab6ee4e1d653 /src/lib/eet
parent36286a23fe97e3667c1106116d1edbc301c7a9ba (diff)
replace hton and ntoh family functions with ones defined in eina
Summary: This fixes especially the execution of edje_cc on Windows Test Plan: execution of edje_cc Reviewers: cedric, raster Subscribers: #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D7834
Diffstat (limited to 'src/lib/eet')
-rw-r--r--src/lib/eet/eet_cipher.c16
-rw-r--r--src/lib/eet/eet_connection.c16
-rw-r--r--src/lib/eet/eet_data.c14
-rw-r--r--src/lib/eet/eet_image.c20
-rw-r--r--src/lib/eet/eet_lib.c56
5 files changed, 40 insertions, 82 deletions
diff --git a/src/lib/eet/eet_cipher.c b/src/lib/eet/eet_cipher.c
index ea4880edcb..3bdab4c2f1 100644
--- a/src/lib/eet/eet_cipher.c
+++ b/src/lib/eet/eet_cipher.c
@@ -8,10 +8,6 @@
8#include <sys/stat.h> 8#include <sys/stat.h>
9#include <unistd.h> 9#include <unistd.h>
10 10
11#ifdef HAVE_NETINET_IN_H
12# include <netinet/in.h>
13#endif
14
15#ifdef HAVE_SIGNATURE 11#ifdef HAVE_SIGNATURE
16# include <sys/mman.h> 12# include <sys/mman.h>
17# ifdef HAVE_GNUTLS 13# ifdef HAVE_GNUTLS
@@ -601,9 +597,9 @@ eet_identity_sign(FILE *fp,
601 597
602# endif /* ifdef HAVE_GNUTLS */ 598# endif /* ifdef HAVE_GNUTLS */
603 /* Append the signature at the end of the file. */ 599 /* Append the signature at the end of the file. */
604 head[0] = (int)htonl ((unsigned int)EET_MAGIC_SIGN); 600 head[0] = (int)eina_htonl ((unsigned int)EET_MAGIC_SIGN);
605 head[1] = (int)htonl ((unsigned int)sign_len); 601 head[1] = (int)eina_htonl ((unsigned int)sign_len);
606 head[2] = (int)htonl ((unsigned int)cert_len); 602 head[2] = (int)eina_htonl ((unsigned int)cert_len);
607 603
608 if (fwrite(head, sizeof(head), 1, fp) != 1) 604 if (fwrite(head, sizeof(head), 1, fp) != 1)
609 { 605 {
@@ -675,9 +671,9 @@ eet_identity_check(const void *data_base,
675 memcpy(&sign_len, header+1, sizeof(int)); 671 memcpy(&sign_len, header+1, sizeof(int));
676 memcpy(&cert_len, header+2, sizeof(int)); 672 memcpy(&cert_len, header+2, sizeof(int));
677 673
678 magic = ntohl(magic); 674 magic = eina_ntohl(magic);
679 sign_len = ntohl(sign_len); 675 sign_len = eina_ntohl(sign_len);
680 cert_len = ntohl(cert_len); 676 cert_len = eina_ntohl(cert_len);
681 677
682 /* Verify the header */ 678 /* Verify the header */
683 if (magic != EET_MAGIC_SIGN) 679 if (magic != EET_MAGIC_SIGN)
diff --git a/src/lib/eet/eet_connection.c b/src/lib/eet/eet_connection.c
index 735e112271..c46f614960 100644
--- a/src/lib/eet/eet_connection.c
+++ b/src/lib/eet/eet_connection.c
@@ -5,14 +5,6 @@
5#include <string.h> 5#include <string.h>
6#include <stdlib.h> 6#include <stdlib.h>
7 7
8#ifdef HAVE_NETINET_IN_H
9# include <netinet/in.h>
10#endif
11
12#ifdef _WIN32
13# include <winsock2.h>
14#endif /* ifdef _WIN32 */
15
16#include <Eina.h> 8#include <Eina.h>
17 9
18#include "Eet.h" 10#include "Eet.h"
@@ -71,9 +63,9 @@ eet_connection_received(Eet_Connection *conn,
71 63
72 msg = data; 64 msg = data;
73 /* Check the magic */ 65 /* Check the magic */
74 if (ntohl(msg[0]) != MAGIC_EET_DATA_PACKET) break; 66 if (eina_ntohl(msg[0]) != MAGIC_EET_DATA_PACKET) break;
75 67
76 packet_size = ntohl(msg[1]); 68 packet_size = eina_ntohl(msg[1]);
77 /* Message should always be under MAX_MSG_SIZE */ 69 /* Message should always be under MAX_MSG_SIZE */
78 if (packet_size > MAX_MSG_SIZE) break; 70 if (packet_size > MAX_MSG_SIZE) break;
79 71
@@ -143,8 +135,8 @@ _eet_connection_raw_send(Eet_Connection *conn,
143 /* Message should always be under MAX_MSG_SIZE */ 135 /* Message should always be under MAX_MSG_SIZE */
144 if (data_size > MAX_MSG_SIZE) return EINA_FALSE; 136 if (data_size > MAX_MSG_SIZE) return EINA_FALSE;
145 message = malloc(data_size + (sizeof(int) * 2)); 137 message = malloc(data_size + (sizeof(int) * 2));
146 message[0] = htonl(MAGIC_EET_DATA_PACKET); 138 message[0] = eina_htonl(MAGIC_EET_DATA_PACKET);
147 message[1] = htonl(data_size); 139 message[1] = eina_htonl(data_size);
148 memcpy(message + 2, data, data_size); 140 memcpy(message + 2, data, data_size);
149 conn->eet_write_cb(message, 141 conn->eet_write_cb(message,
150 data_size + (sizeof(int) * 2), 142 data_size + (sizeof(int) * 2),
diff --git a/src/lib/eet/eet_data.c b/src/lib/eet/eet_data.c
index e00b8ac241..2cda26def6 100644
--- a/src/lib/eet/eet_data.c
+++ b/src/lib/eet/eet_data.c
@@ -8,14 +8,6 @@
8#include <ctype.h> 8#include <ctype.h>
9#include <limits.h> 9#include <limits.h>
10 10
11#ifdef HAVE_NETINET_IN_H
12# include <netinet/in.h>
13#endif
14
15#ifdef _WIN32
16# include <winsock2.h>
17#endif /* ifdef _WIN32 */
18
19#include <Eina.h> 11#include <Eina.h>
20 12
21#include "Eet.h" 13#include "Eet.h"
@@ -2877,7 +2869,7 @@ _eet_data_dump_encode(int parent_type,
2877 { 2869 {
2878 unsigned long int v; 2870 unsigned long int v;
2879 2871
2880 v = htonl(0x12345678); 2872 v = eina_htonl(0x12345678);
2881 if (v == 0x12345678) 2873 if (v == 0x12345678)
2882 _eet_data_words_bigendian = 1; 2874 _eet_data_words_bigendian = 1;
2883 else 2875 else
@@ -3483,7 +3475,7 @@ _eet_data_descriptor_decode(Eet_Free_Context *context,
3483 { 3475 {
3484 unsigned long int v; 3476 unsigned long int v;
3485 3477
3486 v = htonl(0x12345678); 3478 v = eina_htonl(0x12345678);
3487 if (v == 0x12345678) 3479 if (v == 0x12345678)
3488 _eet_data_words_bigendian = 1; 3480 _eet_data_words_bigendian = 1;
3489 else 3481 else
@@ -5088,7 +5080,7 @@ _eet_data_descriptor_encode(Eet_Dictionary *ed,
5088 { 5080 {
5089 unsigned long int v; 5081 unsigned long int v;
5090 5082
5091 v = htonl(0x12345678); 5083 v = eina_htonl(0x12345678);
5092 if (v == 0x12345678) 5084 if (v == 0x12345678)
5093 _eet_data_words_bigendian = 1; 5085 _eet_data_words_bigendian = 1;
5094 else 5086 else
diff --git a/src/lib/eet/eet_image.c b/src/lib/eet/eet_image.c
index 33dbcf7af9..3cfb5fca19 100644
--- a/src/lib/eet/eet_image.c
+++ b/src/lib/eet/eet_image.c
@@ -6,16 +6,6 @@
6# include <sys/types.h> 6# include <sys/types.h>
7#endif /* ifdef __OpenBSD__ */ 7#endif /* ifdef __OpenBSD__ */
8 8
9#ifdef HAVE_NETINET_IN_H
10# include <netinet/in.h>
11#endif
12
13#ifdef _WIN32
14# include <winsock2.h>
15# define HAVE_BOOLEAN
16# define XMD_H /* This prevents libjpeg to redefine INT32 */
17#endif /* ifdef _WIN32 */
18
19#include <stdio.h> 9#include <stdio.h>
20#include <string.h> 10#include <string.h>
21#include <setjmp.h> 11#include <setjmp.h>
@@ -254,7 +244,7 @@ _eet_image_endian_check(void)
254 { 244 {
255 unsigned long int v; 245 unsigned long int v;
256 246
257 v = htonl(0x12345678); 247 v = eina_htonl(0x12345678);
258 if (v == 0x12345678) 248 if (v == 0x12345678)
259 _eet_image_words_bigendian = 1; 249 _eet_image_words_bigendian = 1;
260 else 250 else
@@ -811,8 +801,8 @@ eet_data_image_etc1_compressed_convert(int *size,
811 801
812 image_stride = w; 802 image_stride = w;
813 image_height = h; 803 image_height = h;
814 nl_width = htonl(image_stride); 804 nl_width = eina_htonl(image_stride);
815 nl_height = htonl(image_height); 805 nl_height = eina_htonl(image_height);
816 compress = !!compress; 806 compress = !!compress;
817 807
818 // Disable dithering, as it will deteriorate the quality of flat surfaces 808 // Disable dithering, as it will deteriorate the quality of flat surfaces
@@ -1792,8 +1782,8 @@ eet_data_image_header_advance_decode_cipher(const void *data,
1792 const char *m = data; 1782 const char *m = data;
1793 1783
1794 // We only use Emile for decoding the actual data, seems simpler this way. 1784 // We only use Emile for decoding the actual data, seems simpler this way.
1795 if (w) *w = ntohl(*((unsigned int*) &(m[OFFSET_WIDTH]))); 1785 if (w) *w = eina_ntohl(*((unsigned int*) &(m[OFFSET_WIDTH])));
1796 if (h) *h = ntohl(*((unsigned int*) &(m[OFFSET_HEIGHT]))); 1786 if (h) *h = eina_ntohl(*((unsigned int*) &(m[OFFSET_HEIGHT])));
1797 if (comp) *comp = m[OFFSET_OPTIONS] & 0x1; 1787 if (comp) *comp = m[OFFSET_OPTIONS] & 0x1;
1798 switch (m[OFFSET_ALGORITHM] & 0xFF) 1788 switch (m[OFFSET_ALGORITHM] & 0xFF)
1799 { 1789 {
diff --git a/src/lib/eet/eet_lib.c b/src/lib/eet/eet_lib.c
index e53d1ed89a..0e05b2acaf 100644
--- a/src/lib/eet/eet_lib.c
+++ b/src/lib/eet/eet_lib.c
@@ -2,10 +2,6 @@
2# include <config.h> 2# include <config.h>
3#endif /* ifdef HAVE_CONFIG_H */ 3#endif /* ifdef HAVE_CONFIG_H */
4 4
5#ifdef _WIN32
6# include <winsock2.h>
7#endif /* ifdef _WIN32 */
8
9#include <stdio.h> 5#include <stdio.h>
10#include <errno.h> 6#include <errno.h>
11#include <sys/types.h> 7#include <sys/types.h>
@@ -16,14 +12,6 @@
16#include <fnmatch.h> 12#include <fnmatch.h>
17#include <fcntl.h> 13#include <fcntl.h>
18 14
19#ifdef HAVE_NETINET_IN_H
20# include <netinet/in.h>
21#endif
22
23#ifdef _WIN32
24# include <Evil.h>
25#endif /* ifdef _WIN32 */
26
27#include <Eina.h> 15#include <Eina.h>
28#include <Emile.h> 16#include <Emile.h>
29 17
@@ -384,9 +372,9 @@ eet_flush2(Eet_File *ef)
384 num_dictionary_entries; 372 num_dictionary_entries;
385 373
386 /* go thru and write the header */ 374 /* go thru and write the header */
387 head[0] = (int)htonl((unsigned int)EET_MAGIC_FILE2); 375 head[0] = (int)eina_htonl((unsigned int)EET_MAGIC_FILE2);
388 head[1] = (int)htonl((unsigned int)num_directory_entries); 376 head[1] = (int)eina_htonl((unsigned int)num_directory_entries);
389 head[2] = (int)htonl((unsigned int)num_dictionary_entries); 377 head[2] = (int)eina_htonl((unsigned int)num_dictionary_entries);
390 378
391 fseek(fp, 0, SEEK_SET); 379 fseek(fp, 0, SEEK_SET);
392 if (fwrite(head, sizeof (head), 1, fp) != 1) 380 if (fwrite(head, sizeof (head), 1, fp) != 1)
@@ -414,12 +402,12 @@ eet_flush2(Eet_File *ef)
414 402
415 efn->offset = data_offset; 403 efn->offset = data_offset;
416 404
417 ibuf[0] = (int)htonl((unsigned int)data_offset); 405 ibuf[0] = (int)eina_htonl((unsigned int)data_offset);
418 ibuf[1] = (int)htonl((unsigned int)efn->size); 406 ibuf[1] = (int)eina_htonl((unsigned int)efn->size);
419 ibuf[2] = (int)htonl((unsigned int)efn->data_size); 407 ibuf[2] = (int)eina_htonl((unsigned int)efn->data_size);
420 ibuf[3] = (int)htonl((unsigned int)strings_offset); 408 ibuf[3] = (int)eina_htonl((unsigned int)strings_offset);
421 ibuf[4] = (int)htonl((unsigned int)efn->name_size); 409 ibuf[4] = (int)eina_htonl((unsigned int)efn->name_size);
422 ibuf[5] = (int)htonl((unsigned int)flag); 410 ibuf[5] = (int)eina_htonl((unsigned int)flag);
423 411
424 strings_offset += efn->name_size; 412 strings_offset += efn->name_size;
425 data_offset += efn->size; 413 data_offset += efn->size;
@@ -449,11 +437,11 @@ eet_flush2(Eet_File *ef)
449 if (ef->ed->hash[ef->ed->all_hash[j]] == j) 437 if (ef->ed->hash[ef->ed->all_hash[j]] == j)
450 prev = -1; 438 prev = -1;
451 439
452 sbuf[0] = (int)htonl((unsigned int)ef->ed->all_hash[j]); 440 sbuf[0] = (int)eina_htonl((unsigned int)ef->ed->all_hash[j]);
453 sbuf[1] = (int)htonl((unsigned int)offset); 441 sbuf[1] = (int)eina_htonl((unsigned int)offset);
454 sbuf[2] = (int)htonl((unsigned int)ef->ed->all[j].len); 442 sbuf[2] = (int)eina_htonl((unsigned int)ef->ed->all[j].len);
455 sbuf[3] = (int)htonl((unsigned int)prev); 443 sbuf[3] = (int)eina_htonl((unsigned int)prev);
456 sbuf[4] = (int)htonl((unsigned int)ef->ed->all[j].next); 444 sbuf[4] = (int)eina_htonl((unsigned int)ef->ed->all[j].next);
457 445
458 offset += ef->ed->all[j].len; 446 offset += ef->ed->all[j].len;
459 447
@@ -755,14 +743,14 @@ eet_internal_read2(Eet_File *ef)
755 unsigned int i; 743 unsigned int i;
756 744
757 idx += sizeof(int); 745 idx += sizeof(int);
758 if (eet_test_close((int)ntohl(*data) != EET_MAGIC_FILE2, ef)) 746 if (eet_test_close((int)eina_ntohl(*data) != EET_MAGIC_FILE2, ef))
759 return NULL; 747 return NULL;
760 748
761 data++; 749 data++;
762 750
763#define GET_INT(Value, Pointer, Index) \ 751#define GET_INT(Value, Pointer, Index) \
764 { \ 752 { \
765 Value = ntohl(*Pointer); \ 753 Value = eina_ntohl(*Pointer); \
766 Pointer++; \ 754 Pointer++; \
767 Index += sizeof(int); \ 755 Index += sizeof(int); \
768 } 756 }
@@ -1003,9 +991,9 @@ eet_internal_read2(Eet_File *ef)
1003 /* check the signature has the magic number and sig + cert len 991 /* check the signature has the magic number and sig + cert len
1004 * + magic is sane */ 992 * + magic is sane */
1005 memcpy(head, buffer, 3 * sizeof(int)); 993 memcpy(head, buffer, 3 * sizeof(int));
1006 head[0] = ntohl(head[0]); 994 head[0] = eina_ntohl(head[0]);
1007 head[1] = ntohl(head[1]); 995 head[1] = eina_ntohl(head[1]);
1008 head[2] = ntohl(head[2]); 996 head[2] = eina_ntohl(head[2]);
1009 if ((head[0] == EET_MAGIC_SIGN) && (head[1] > 0) && (head[2] > 0)) 997 if ((head[0] == EET_MAGIC_SIGN) && (head[1] > 0) && (head[2] > 0))
1010 { 998 {
1011 /* there appears to be an actual valid identity at the end 999 /* there appears to be an actual valid identity at the end
@@ -1061,14 +1049,14 @@ eet_internal_read1(Eet_File *ef)
1061 /* build header table if read mode */ 1049 /* build header table if read mode */
1062 /* geat header */ 1050 /* geat header */
1063 idx += sizeof(int); 1051 idx += sizeof(int);
1064 if (eet_test_close((int)ntohl(*((int *)ef->data)) != EET_MAGIC_FILE, ef)) 1052 if (eet_test_close((int)eina_ntohl(*((int *)ef->data)) != EET_MAGIC_FILE, ef))
1065 return NULL; 1053 return NULL;
1066 1054
1067#define EXTRACT_INT(Value, Pointer, Index) \ 1055#define EXTRACT_INT(Value, Pointer, Index) \
1068 { \ 1056 { \
1069 int tmp; \ 1057 int tmp; \
1070 memcpy(&tmp, Pointer + Index, sizeof(int)); \ 1058 memcpy(&tmp, Pointer + Index, sizeof(int)); \
1071 Value = ntohl(tmp); \ 1059 Value = eina_ntohl(tmp); \
1072 Index += sizeof(int); \ 1060 Index += sizeof(int); \
1073 } 1061 }
1074 1062
@@ -1248,7 +1236,7 @@ eet_internal_read(Eet_File *ef)
1248 if (eet_test_close(ef->data_size < (int)sizeof(int) * 3, ef)) 1236 if (eet_test_close(ef->data_size < (int)sizeof(int) * 3, ef))
1249 return NULL; 1237 return NULL;
1250 1238
1251 switch (ntohl(*data)) 1239 switch (eina_ntohl(*data))
1252 { 1240 {
1253#if EET_OLD_EET_FILE_FORMAT 1241#if EET_OLD_EET_FILE_FORMAT
1254 case EET_MAGIC_FILE: 1242 case EET_MAGIC_FILE: