6ba14b9c6b0c6b67c6b011e10340c9a4baf47e45
[framework/uifw/eet.git] / src / lib / Eet_private.h
1 /*
2  * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
3  */
4
5 #ifndef _EET_PRIVATE_H
6 #define _EET_PRIVATE_H
7
8 #ifdef __GNUC__
9 # if __GNUC__ >= 4
10 // BROKEN in gcc 4 on amd64
11 //#  pragma GCC visibility push(hidden)
12 # endif
13 #endif
14
15 #include "config.h"
16
17 #ifdef HAVE_OPENSSL
18 #include <openssl/evp.h>
19 #include <openssl/x509.h>
20 #include <openssl/pem.h>
21 #endif
22
23 typedef struct _Eet_String              Eet_String;
24
25 struct _Eet_String
26 {
27   const char            *mmap;
28   char                  *str;
29
30   int                    hash;
31   int                    len;
32
33   int                    next;
34   int                    prev;
35
36   union
37   {
38     float                f;
39     double               d;
40   } convert;
41
42   struct
43   {
44     unsigned int         converted : 1;
45     unsigned int         is_float : 1;
46   } flags;
47 };
48 struct _Eet_Dictionary
49 {
50   Eet_String   *all;
51
52   int           size;
53   int           offset;
54
55   int           hash[256];
56
57   int           count;
58   int           total;
59
60   const char   *start;
61   const char   *end;
62 };
63
64 struct _Eet_Key
65 {
66    int          references;
67 #ifdef HAVE_SIGNATURE
68    X509        *certificate;
69    EVP_PKEY    *private_key;
70 #endif
71 };
72
73 Eet_Dictionary  *eet_dictionary_add(void);
74 void             eet_dictionary_free(Eet_Dictionary *ed);
75 int              eet_dictionary_string_add(Eet_Dictionary *ed, const char *string);
76 int              eet_dictionary_string_get_size(const Eet_Dictionary *ed, int index);
77 const char      *eet_dictionary_string_get_char(const Eet_Dictionary *ed, int index);
78 int              eet_dictionary_string_get_float(const Eet_Dictionary *ed, int index, float *result);
79 int              eet_dictionary_string_get_double(const Eet_Dictionary *ed, int index, double *result);
80 int              eet_dictionary_string_get_hash(const Eet_Dictionary *ed, int index);
81
82 int   _eet_hash_gen(const char *key, int hash_size);
83
84 const void* eet_identity_check(const void *data_base, unsigned int data_length,
85                                const void *signature_base, unsigned int signature_length,
86                                int *x509_length);
87 Eet_Error eet_cypher(void *data, unsigned int size, const char *key, unsigned int length);
88 Eet_Error eet_decypher(void *data, unsigned int size, const char *key, unsigned int length);
89 Eet_Error eet_identity_sign(FILE *fp, Eet_Key *key);
90 void eet_identity_unref(Eet_Key *key);
91 void eet_identity_ref(Eet_Key *key);
92
93 #ifndef PATH_MAX
94 #define PATH_MAX 4096
95 #endif
96
97 #ifdef DNDEBUG
98 #define EET_ASSERT(Test, Do) if (Test == 0) Do;
99 #else
100 #define EET_ASSERT(Test, Do) if (Test == 0) abort();
101 #endif
102
103 #endif