version 1.1, 2005/03/11 02:52:49
|
version 1.2, 2005/03/11 03:08:30
|
|
|
{ | { |
int opentype; | int opentype; |
struct WS_hostent *he_buffer; | struct WS_hostent *he_buffer; |
struct WS_servent *se_buffer; |
|
struct WS_protoent *pe_buffer; | struct WS_protoent *pe_buffer; |
|
|
|
char *se_buffer; |
|
struct WS_servent se; |
|
|
int he_len; | int he_len; |
int se_len; | int se_len; |
int pe_len; | int pe_len; |
|
|
{ | { |
ptb = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*ptb) ); | ptb = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*ptb) ); |
TlsSetValue( tls_index, ptb ); | TlsSetValue( tls_index, ptb ); |
|
|
|
ptb->se_len = 0; |
} | } |
return ptb; | return ptb; |
} | } |
|
|
return ptb->he_buffer; | return ptb->he_buffer; |
} | } |
| |
static struct WS_servent *check_buffer_se(int size) |
static char *check_buffer_se(int size) |
{ | { |
struct per_thread_data * ptb = get_per_thread_data(); | struct per_thread_data * ptb = get_per_thread_data(); |
if (ptb->se_buffer) |
if (ptb->se_len > 0) |
{ | { |
if (ptb->se_len >= size ) return ptb->se_buffer; | if (ptb->se_len >= size ) return ptb->se_buffer; |
HeapFree( GetProcessHeap(), 0, ptb->se_buffer ); | HeapFree( GetProcessHeap(), 0, ptb->se_buffer ); |
|
|
static struct WS_servent *WS_dup_se(const struct servent* p_se) | static struct WS_servent *WS_dup_se(const struct servent* p_se) |
{ | { |
char *p; | char *p; |
struct WS_servent *p_to; |
struct per_thread_data * ptb = get_per_thread_data(); |
| |
int size = (sizeof(*p_se) + |
int size = (strlen(p_se->s_proto) + 1 + |
strlen(p_se->s_proto) + 1 + |
|
strlen(p_se->s_name) + 1 + | strlen(p_se->s_name) + 1 + |
list_size(p_se->s_aliases, 0)); | list_size(p_se->s_aliases, 0)); |
| |
if (!(p_to = check_buffer_se(size))) return NULL; |
if (!(p = check_buffer_se(size))) return NULL; |
p_to->s_port = p_se->s_port; |
ptb->se.s_port = p_se->s_port; |
| |
p = (char *)(p_to + 1); |
ptb->se.s_name = p; |
p_to->s_name = p; |
|
strcpy(p, p_se->s_name); | strcpy(p, p_se->s_name); |
p += strlen(p) + 1; | p += strlen(p) + 1; |
| |
p_to->s_proto = p; |
ptb->se.s_proto = p; |
strcpy(p, p_se->s_proto); | strcpy(p, p_se->s_proto); |
p += strlen(p) + 1; | p += strlen(p) + 1; |
| |
p_to->s_aliases = (char **)p; |
ptb->se.s_aliases = (char **)p; |
list_dup(p_se->s_aliases, p_to->s_aliases, 0); |
list_dup(p_se->s_aliases, ptb->se.s_aliases, 0); |
return p_to; |
|
|
return &ptb->se; |
} | } |
| |
/* ----------------------------------- error handling */ | /* ----------------------------------- error handling */ |