1 /*
2  * Copyright (c) 2002-2011 by XMLVM.org
3  *
4  * Project Info:  http://www.xmlvm.org
5  *
6  * This program is free software; you can redistribute it and/or modify it
7  * under the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation; either version 2.1 of the License, or
9  * (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14  * License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
19  * USA.
20  */
21 
22 #ifndef __XMLVM_HY_H__
23 
24 #define __XMLVM_HY_H__
25 
26 #ifdef __APPLE__
27 #define MACOSX
28 #endif
29 
30 #include "xmlvm.h"
31 #include "hycomp.h"
32 #include "hysock.h"
33 #include "hysocket.h"
34 
35 
36 #define HYERROR_DEFAULT_BUFFER_SIZE 256 /**< default customized error message size if we need to create one */
37 
38 #if defined(__linux__)
39 #define DIR_SEPARATOR '/'
40 #endif
41 
42 
43 typedef struct PortlibPTBuffers_struct
44 {
45     I_32 platformErrorCode;         /**< error code as reported by the OS */
46     I_32 portableErrorCode;         /**< error code translated to portable format by application */
47     char *errorMessageBuffer;       /**< last saved error message, either customized or from OS */
48     U_32 errorMessageBufferSize;    /**< error message buffer size */
49     I_32 reportedErrorCode;         /**< last reported error code */
50     char *reportedMessageBuffer;    /**< last reported error message, either customized or from OS */
51     U_32 reportedMessageBufferSize; /**< reported message buffer size */
52     hyfdset_t fdset;
53 
54 #if HOSTENT_DATA_R||GLIBC_R||OTHER_R||NO_R
55     OSHOSTENT hostent;
56 #endif
57 
58 #if HOSTENT_DATA_R
59     OSHOSTENT_DATA *hostent_data;
60 #elif GLIBC_R || OTHER_R || NO_R
61     int gethostBufferSize;
62     char *gethostBuffer;
63 #endif                          /* HOSTENT_DATA_R */
64 
65 } PortlibPTBuffers_struct;
66 
67 typedef struct PortlibPTBuffers_struct *PortlibPTBuffers_t;
68 
69 
70 typedef pthread_mutex_t MUTEX;
71 
72 /* MUTEX_INIT */
73 #define MUTEX_INIT(mutex) (pthread_mutex_init(&(mutex), NULL) == 0)
74 
75 /* MUTEX_DESTROY */
76 #define MUTEX_DESTROY(mutex) pthread_mutex_destroy(&(mutex))
77 
78 /* MUTEX_ENTER */
79 #define MUTEX_ENTER(mutex) pthread_mutex_lock(&(mutex))
80 
81 /*
82  *  MUTEX_TRY_ENTER
83  *  returns 0 on success
84  */
85 #define MUTEX_TRY_ENTER(mutex) pthread_mutex_trylock(&(mutex))
86 
87 /* MUTEX_EXIT */
88 #define MUTEX_EXIT(mutex) pthread_mutex_unlock(&(mutex))
89 
90 
91 #if defined(SEEK_SET)
92 #define HySeekSet SEEK_SET        /* Values for HyFileSeek */
93 #else
94 #define HySeekSet 0
95 #endif
96 
97 #if defined(SEEK_CUR)
98 #define HySeekCur SEEK_CUR
99 #else
100 #define HySeekCur 1
101 #endif
102 
103 #if defined(SEEK_END)
104 #define HySeekEnd SEEK_END
105 #else
106 #define HySeekEnd 2
107 #endif
108 
109 
110 typedef JAVA_INT jsize;
111 
112 
113 void* hyport_tls_get ();
114 void* hyport_tls_peek ();
115 const char* hyerror_last_error_message ();
116 I_32 hyerror_last_error_number ();
117 I_32 hyerror_set_last_error (I_32 platformCode, I_32 portableCode);
118 I_32 hyerror_set_last_error_with_message (I_32 portableCode, const char *errorMessage);
119 
120 
121 #endif
122