Main Page | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

protected.h File Reference

#include <netdb.h>
#include <time.h>

Include dependency graph for protected.h:

Include dependency graph

This graph shows which files directly or indirectly include this file:

Included by dependency graph

Go to the source code of this file.

Defines

#define localtime(t)   do_not_use_localtime_directly
#define gmtime(t)   do_not_use_gmtime_directly
#define mktime(t)   do_not_use_mktime_directly
#define strftime(a, b, c, d)   do_not_use_strftime_directly
#define rand()   do_not_use_rand_directly
#define gethostbyname(a, b, c)   do_not_use_gethostbyname_directly
#define inet_ntoa(in)   use_gw_netaddr_to_octstr_instead_of_inet_ntoa

Functions

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)
int gw_rand (void)
int gw_gethostbyname (struct hostent *ret, const char *name, char **buff)
size_t gw_strftime (char *s, size_t max, const char *format, const struct tm *tm)


Define Documentation

#define gethostbyname a,
b,
 )     do_not_use_gethostbyname_directly
 

Definition at line 103 of file protected.h.

#define gmtime  )     do_not_use_gmtime_directly
 

Definition at line 91 of file protected.h.

Referenced by gw_gmtime().

#define inet_ntoa in   )     use_gw_netaddr_to_octstr_instead_of_inet_ntoa
 

Definition at line 106 of file protected.h.

#define localtime  )     do_not_use_localtime_directly
 

Definition at line 88 of file protected.h.

Referenced by gw_localtime().

#define mktime  )     do_not_use_mktime_directly
 

Definition at line 94 of file protected.h.

Referenced by gw_mktime().

 
#define rand  )     do_not_use_rand_directly
 

Definition at line 100 of file protected.h.

#define strftime a,
b,
c,
 )     do_not_use_strftime_directly
 

Definition at line 97 of file protected.h.

Referenced by gw_strftime().


Function Documentation

int gw_gethostbyname struct hostent *  ret,
const char *  name,
char **  buff
 

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:

struct tm gw_gmtime time_t  t  ) 
 

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:

struct tm gw_localtime time_t  t  ) 
 

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:

time_t gw_mktime struct tm *  tm  ) 
 

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 }

int gw_rand void   ) 
 

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 }

size_t gw_strftime char *  s,
size_t  max,
const char *  format,
const struct tm *  tm
 

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 }

void gwlib_protected_init void   ) 
 

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 }

void gwlib_protected_shutdown void   ) 
 

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:

See file LICENSE for details about the license agreement for using, modifying, copying or deriving work from this software.