#include <locale.h>#include <errno.h>#include "gwlib.h"Include dependency graph for protected.c:

Go to the source code of this file.
Enumerations | |
| enum | { RAND, GETHOSTBYNAME, GWTIME, NUM_LOCKS } |
Functions | |
| void | lock (int which) |
| void | unlock (int which) |
| void | gwlib_protected_init (void) |
| void | gwlib_protected_shutdown (void) |
| tm | gw_localtime (time_t t) |
| tm | gw_gmtime (time_t t) |
| time_t | gw_mktime (struct tm *tm) |
| size_t | gw_strftime (char *s, size_t max, const char *format, const struct tm *tm) |
| int | gw_rand (void) |
| int | gw_gethostbyname (struct hostent *ent, const char *name, char **buff) |
Variables | |
| Mutex | locks [NUM_LOCKS] |
|
|
Definition at line 80 of file protected.c. 00080 {
00081 RAND,
00082 GETHOSTBYNAME,
00083 GWTIME,
00084 NUM_LOCKS
00085 };
|
|
||||||||||||||||
|
Definition at line 186 of file protected.c. References error(), name, and res. Referenced by make_server_socket(), setup_official_name(), tcpip_connect_nb_to_server_with_port(), tcpip_connect_to_server_with_port(), udp_bind(), and udp_create_address(). 00187 {
00188 struct hostent *tmphp, hp;
00189 int herr, res;
00190 size_t bufflen;
00191
00192 tmphp = NULL; /* for compiler please */
00193
00194 bufflen = 1024;
00195 *buff = (char*) gw_malloc(bufflen);
00196 while ((res=gethostbyname_r(name, &hp,*buff, bufflen, &tmphp, &herr)) == ERANGE) {
00197 /* enlarge the buffer */
00198 bufflen *= 2;
00199 *buff = (char*) gw_realloc(*buff, bufflen);
00200 }
00201
00202 if (res != 0 || tmphp == NULL) {
00203 error(herr, "Error while gw_gethostbyname occurs.");
00204 gw_free(*buff);
00205 *buff = NULL;
00206 res = -1;
00207 }
00208 else {
00209 *ent = hp;
00210 }
00211
00212 return res;
00213 }
|
Here is the call graph for this function:

|
|
Definition at line 137 of file protected.c. References gmtime, gw_gmtime(), GWTIME, lock, and unlock. Referenced by date_create_iso(), date_format_http(), delivery_time_constraints(), format(), get_pattern(), gw_gmtime(), make_timestamp(), msg_to_pdu(), obey_request(), set_time(), status_cb(), store_file_status(), and urltrans_fill_escape_codes(). 00138 {
00139 struct tm tm;
00140
00141 #ifndef HAVE_GMTIME_R
00142 lock(GWTIME);
00143 tm = *gmtime(&t);
00144 unlock(GWTIME);
00145 #else
00146 gmtime_r(&t, &tm);
00147 #endif
00148
00149 return tm;
00150 }
|
Here is the call graph for this function:

|
|
Definition at line 121 of file protected.c. References gw_localtime(), GWTIME, localtime, lock, and unlock. Referenced by format(), gw_localtime(), msg_to_emimsg(), status_cb(), and store_file_status(). 00122 {
00123 struct tm tm;
00124
00125 #ifndef HAVE_LOCALTIME_R
00126 lock(GWTIME);
00127 tm = *localtime(&t);
00128 unlock(GWTIME);
00129 #else
00130 localtime_r(&t, &tm);
00131 #endif
00132
00133 return tm;
00134 }
|
Here is the call graph for this function:

|
|
Definition at line 153 of file protected.c. References GWTIME, lock, mktime, and unlock. Referenced by clickatell_receive_sms(), and parse_http_date(). 00154 {
00155 time_t t;
00156 lock(GWTIME);
00157 t = mktime(tm);
00158 unlock(GWTIME);
00159
00160 return t;
00161 }
|
|
|
Definition at line 174 of file protected.c. References lock, RAND, rand, and unlock. Referenced by choose_message(), gw_generate_id(), main(), randomize(), route_incoming_to_boxc(), route_msg(), set_zero(), smsc2_rout(), and soap_rand_attribute(). 00175 {
00176 int ret;
00177
00178 lock(RAND);
00179 ret = rand();
00180 unlock(RAND);
00181 return ret;
00182 }
|
|
||||||||||||||||||||
|
Definition at line 164 of file protected.c. References GWTIME, lock, strftime, and unlock. 00165 {
00166 size_t ret;
00167 lock(GWTIME);
00168 ret = strftime(s, max, format, tm);
00169 unlock(GWTIME);
00170 return ret;
00171 }
|
|
|
Definition at line 103 of file protected.c. References locks, and mutex_init_static. Referenced by gwlib_init(). 00104 {
00105 int i;
00106
00107 for (i = 0; i < NUM_LOCKS; ++i)
00108 mutex_init_static(&locks[i]);
00109 }
|
|
|
Definition at line 112 of file protected.c. References locks, and mutex_destroy(). Referenced by gwlib_shutdown(). 00113 {
00114 int i;
00115
00116 for (i = 0; i < NUM_LOCKS; ++i)
00117 mutex_destroy(&locks[i]);
00118 }
|
Here is the call graph for this function:

|
|
Definition at line 91 of file protected.c. References locks, and mutex_lock. 00092 {
00093 mutex_lock(&locks[which]);
00094 }
|
|
|
Definition at line 97 of file protected.c. References locks, and mutex_unlock. 00098 {
00099 mutex_unlock(&locks[which]);
00100 }
|
|
|
Definition at line 88 of file protected.c. Referenced by gwlib_protected_init(), gwlib_protected_shutdown(), lock(), and unlock(). |