COPASI API  4.16.103
Macros | Functions | Variables
stdsoap2.cpp File Reference
#include "stdsoap2.h"
Include dependency graph for stdsoap2.cpp:

Go to the source code of this file.

Macros

#define SOAP_AP   (soap_wchar)(-6) /* XML character ''' */
 
#define soap_blank(c)   ((c) >= 0 && (c) <= 32)
 
#define SOAP_CANARY   (0xC0DE)
 
#define SOAP_GT   (soap_wchar)(-4) /* XML character '>' */
 
#define soap_hash_ptr(p)   ((size_t)(((unsigned long)(p) >> 3) & (SOAP_PTRHASH-1)))
 
#define SOAP_LT   (soap_wchar)(-2) /* XML character '<' */
 
#define SOAP_NON_NULL   (soap_padding)
 
#define soap_notblank(c)   ((c) > 32)
 
#define SOAP_QT   (soap_wchar)(-5) /* XML character '"' */
 
#define SOAP_SOCKBLOCK(fd)   fcntl(fd, F_SETFL, fcntl(fd, F_GETFL)&~O_NONBLOCK);
 
#define SOAP_SOCKNONBLOCK(fd)   fcntl(fd, F_SETFL, fcntl(fd, F_GETFL)|O_NONBLOCK);
 
#define SOAP_STR_EOS   (soap_padding)
 
#define SOAP_STR_PADDING   (soap_padding)
 
#define SOAP_TT   (soap_wchar)(-3) /* XML character '</' */
 
#define SOAP_UNKNOWN_CHAR   (127)
 

Functions

static voidfplugin (struct soap *, const char *)
 
static size_t frecv (struct soap *, char *, size_t)
 
static int fsend (struct soap *, const char *, size_t)
 
static int http_del (struct soap *)
 
static const char * http_error (struct soap *, int)
 
static int http_get (struct soap *)
 
static int http_head (struct soap *)
 
static int http_parse (struct soap *)
 
static int http_parse_header (struct soap *, const char *, const char *)
 
static int http_post (struct soap *, const char *, const char *, int, const char *, const char *, size_t)
 
static int http_post_header (struct soap *, const char *, const char *)
 
static int http_put (struct soap *)
 
static int http_response (struct soap *, int, size_t)
 
static int http_send_header (struct soap *, const char *)
 
int soap_accept (struct soap *soap)
 
int soap_append_lab (struct soap *soap, const char *s, size_t n)
 
int soap_array_begin_out (struct soap *soap, const char *tag, int id, const char *type, const char *offset)
 
int soap_array_pointer_lookup (struct soap *soap, const void *p, const struct soap_array *a, int n, int type, struct soap_plist **ppp)
 
int soap_array_reference (struct soap *soap, const void *p, const struct soap_array *a, int n, int t)
 
int soap_attachment (struct soap *soap, const char *tag, int id, const void *p, const struct soap_array *a, const char *aid, const char *atype, const char *aoptions, int n, const char *type, int t)
 
const char * soap_attr_value (struct soap *soap, const char *name, int flag)
 
int soap_attribute (struct soap *soap, const char *name, const char *value)
 
const char * soap_base642s (struct soap *soap, const char *s, char *t, size_t l, int *n)
 
void soap_begin (struct soap *soap)
 
int soap_begin_count (struct soap *soap)
 
int soap_begin_recv (struct soap *soap)
 
int soap_begin_send (struct soap *soap)
 
int soap_bind (struct soap *soap, const char *host, int port, int backlog)
 
size_t soap_block_size (struct soap *soap, struct soap_blist *b)
 
int soap_body_begin_in (struct soap *soap)
 
int soap_body_begin_out (struct soap *soap)
 
int soap_body_end_in (struct soap *soap)
 
int soap_body_end_out (struct soap *soap)
 
const char * soap_byte2s (struct soap *soap, char n)
 
static soap_wchar soap_char (struct soap *)
 
int soap_check_mime_attachments (struct soap *soap)
 
void soap_check_result (struct soap *soap, const char *tag)
 
void soap_cleanup (struct soap *soap)
 
int soap_closesock (struct soap *soap)
 
void soap_clr_attr (struct soap *soap)
 
void soap_clr_dime (struct soap *soap)
 
void soap_clr_mime (struct soap *soap)
 
const struct soap_code_mapsoap_code (const struct soap_code_map *code_map, const char *str)
 
long soap_code_bits (const struct soap_code_map *code_map, const char *str)
 
long soap_code_int (const struct soap_code_map *code_map, const char *str, long other)
 
const char * soap_code_list (struct soap *soap, const struct soap_code_map *code_map, long code)
 
const char * soap_code_str (const struct soap_code_map *code_map, long code)
 
int soap_connect (struct soap *soap, const char *endpoint, const char *action)
 
int soap_connect_command (struct soap *soap, int http_command, const char *endpoints, const char *action)
 
struct soapsoap_copy (const struct soap *soap)
 
struct soapsoap_copy_context (struct soap *copy, const struct soap *soap)
 
static int soap_copy_fault (struct soap *, const char *, const char *, const char *, const char *)
 
void soap_copy_stream (struct soap *copy, struct soap *soap)
 
static size_t soap_count_attachments (struct soap *soap)
 
const char * soap_current_namespace (struct soap *soap, const char *tag)
 
const char * soap_dateTime2s (struct soap *soap, time_t n)
 
void soap_dealloc (struct soap *soap, void *p)
 
static const char * soap_decode (char *, size_t, const char *, const char *)
 
const char * soap_decode_key (char *buf, size_t len, const char *val)
 
const char * soap_decode_val (char *buf, size_t len, const char *val)
 
void soap_del (struct soap *soap)
 
void soap_delete (struct soap *soap, void *p)
 
int soap_dime_forward (struct soap *soap, unsigned char **ptr, int *size, char **id, char **type, char **options)
 
char * soap_dime_option (struct soap *soap, unsigned short optype, const char *option)
 
void soap_done (struct soap *soap)
 
const char * soap_double2s (struct soap *soap, double n)
 
int soap_element (struct soap *soap, const char *tag, int id, const char *type)
 
int soap_element_begin_in (struct soap *soap, const char *tag, int nillable, const char *type)
 
int soap_element_begin_out (struct soap *soap, const char *tag, int id, const char *type)
 
int soap_element_end_in (struct soap *soap, const char *tag)
 
int soap_element_end_out (struct soap *soap, const char *tag)
 
int soap_element_href (struct soap *soap, const char *tag, int id, const char *ref, const char *val)
 
int soap_element_id (struct soap *soap, const char *tag, int id, const void *p, const struct soap_array *a, int n, const char *type, int t)
 
int soap_element_null (struct soap *soap, const char *tag, int id, const char *type)
 
int soap_element_ref (struct soap *soap, const char *tag, int id, int href)
 
int soap_element_result (struct soap *soap, const char *tag)
 
int soap_element_start_end_out (struct soap *soap, const char *tag)
 
int soap_embed (struct soap *soap, const void *p, const struct soap_array *a, int n, const char *tag, int type)
 
void soap_embedded (struct soap *soap, const void *p, int t)
 
int soap_embedded_id (struct soap *soap, int id, const void *p, int t)
 
void soap_end (struct soap *soap)
 
void soap_end_block (struct soap *soap, struct soap_blist *b)
 
int soap_end_count (struct soap *soap)
 
int soap_end_recv (struct soap *soap)
 
int soap_end_send (struct soap *soap)
 
struct soap_ilistsoap_enter (struct soap *soap, const char *id)
 
int soap_envelope_begin_in (struct soap *soap)
 
int soap_envelope_begin_out (struct soap *soap)
 
int soap_envelope_end_in (struct soap *soap)
 
int soap_envelope_end_out (struct soap *soap)
 
void soap_fcopy (struct soap *soap, int st, int tt, void *p, size_t len, const void *q, size_t n)
 
char * soap_first_block (struct soap *soap, struct soap_blist *b)
 
const char * soap_float2s (struct soap *soap, float n)
 
int soap_flush (struct soap *soap)
 
int soap_flush_raw (struct soap *soap, const char *s, size_t n)
 
void soap_free (struct soap *soap)
 
static void soap_free_iht (struct soap *)
 
static void soap_free_ns (struct soap *soap)
 
static void soap_free_pht (struct soap *)
 
void soap_free_temp (struct soap *soap)
 
soap_wchar soap_get (struct soap *soap)
 
const char * soap_get_header_attribute (struct soap *soap, const char *line, const char *key)
 
static char * soap_get_http_body (struct soap *)
 
struct soap_multipartsoap_get_mime_attachment (struct soap *soap, void *handle)
 
static soap_wchar soap_get_pi (struct soap *)
 
static int soap_getattrval (struct soap *, char *, size_t, soap_wchar)
 
unsigned char * soap_getbase64 (struct soap *soap, int *n, int malloc_flag)
 
soap_wchar soap_getchar (struct soap *soap)
 
static soap_wchar soap_getchunkchar (struct soap *)
 
int soap_getdime (struct soap *soap)
 
static char * soap_getdimefield (struct soap *, size_t)
 
int soap_getdimehdr (struct soap *soap)
 
unsigned char * soap_gethex (struct soap *soap, int *n)
 
int soap_getline (struct soap *soap, char *s, int len)
 
int soap_getmime (struct soap *soap)
 
int soap_getmimehdr (struct soap *soap)
 
int soap_getoffsets (const char *attr, const int *size, int *offset, int dim)
 
int soap_getposition (const char *attr, int *pos)
 
int soap_getsize (const char *attr1, const char *attr2, int *j)
 
int soap_getsizes (const char *attr, int *size, int dim)
 
soap_wchar soap_getutf8 (struct soap *soap)
 
static int soap_has_copies (struct soap *, const char *, const char *)
 
static int soap_has_copies (struct soap *soap, register const char *start, register const char *end)
 
size_t soap_hash (register const char *s)
 
const char * soap_hex2s (struct soap *soap, const char *s, char *t, size_t l, int *n)
 
voidsoap_id_enter (struct soap *soap, const char *id, void *p, int t, size_t n, unsigned int k, const char *type, const char *arrayType, void *(*finstantiate)(struct soap *, int, const char *, const char *, size_t *))
 
voidsoap_id_forward (struct soap *soap, const char *href, void *p, size_t len, int st, int tt, size_t n, unsigned int k, void(*fcopy)(struct soap *, int, int, void *, size_t, const void *, size_t))
 
voidsoap_id_lookup (struct soap *soap, const char *id, void **p, int t, size_t n, unsigned int k)
 
char * soap_inbyte (struct soap *soap, const char *tag, char *p, const char *type, int t)
 
time_t * soap_indateTime (struct soap *soap, const char *tag, time_t *p, const char *type, int t)
 
double * soap_indouble (struct soap *soap, const char *tag, double *p, const char *type, int t)
 
float * soap_infloat (struct soap *soap, const char *tag, float *p, const char *type, int t)
 
int * soap_inint (struct soap *soap, const char *tag, int *p, const char *type, int t)
 
void soap_init (struct soap *soap)
 
void soap_init1 (struct soap *soap, soap_mode mode)
 
void soap_init2 (struct soap *soap, soap_mode imode, soap_mode omode)
 
static void soap_init_iht (struct soap *)
 
static void soap_init_logs (struct soap *)
 
static void soap_init_pht (struct soap *)
 
char ** soap_inliteral (struct soap *soap, const char *tag, char **p)
 
long * soap_inlong (struct soap *soap, const char *tag, long *p, const char *type, int t)
 
long long * soap_inLONG64 (struct soap *soap, const char *tag, long long *p, const char *type, int t)
 
short * soap_inshort (struct soap *soap, const char *tag, short *p, const char *type, int t)
 
char ** soap_instring (struct soap *soap, const char *tag, char **p, const char *type, int t, int flag, long minlen, long maxlen)
 
const char * soap_int2s (struct soap *soap, int n)
 
unsigned long long * soap_inULONG64 (struct soap *soap, const char *tag, unsigned long long *p, const char *type, int t)
 
unsigned char * soap_inunsignedByte (struct soap *soap, const char *tag, unsigned char *p, const char *type, int t)
 
unsigned int * soap_inunsignedInt (struct soap *soap, const char *tag, unsigned int *p, const char *type, int t)
 
unsigned long * soap_inunsignedLong (struct soap *soap, const char *tag, unsigned long *p, const char *type, int t)
 
unsigned short * soap_inunsignedShort (struct soap *soap, const char *tag, unsigned short *p, const char *type, int t)
 
wchar_t ** soap_inwliteral (struct soap *soap, const char *tag, wchar_t **p)
 
wchar_t ** soap_inwstring (struct soap *soap, const char *tag, wchar_t **p, const char *type, int t, long minlen, long maxlen)
 
int soap_is_embedded (struct soap *soap, struct soap_plist *pp)
 
int soap_is_single (struct soap *soap, struct soap_plist *pp)
 
static int soap_isnumeric (struct soap *, const char *)
 
static int soap_isxdigit (int)
 
struct soap_clistsoap_link (struct soap *soap, void *p, int t, int n, int(*fdelete)(struct soap_clist *))
 
const char * soap_long2s (struct soap *soap, long n)
 
const char * soap_LONG642s (struct soap *soap, long long n)
 
struct soap_ilistsoap_lookup (struct soap *soap, const char *id)
 
struct soap_nlistsoap_lookup_ns (struct soap *soap, const char *tag, size_t n)
 
voidsoap_lookup_plugin (struct soap *soap, const char *id)
 
int soap_lookup_type (struct soap *soap, const char *id)
 
voidsoap_malloc (struct soap *soap, size_t n)
 
int soap_match_array (struct soap *soap, const char *type)
 
int soap_match_cid (struct soap *soap, const char *s, const char *t)
 
int soap_match_namespace (struct soap *soap, const char *id1, const char *id2, size_t n1, size_t n2)
 
int soap_match_tag (struct soap *soap, const char *tag1, const char *tag2)
 
int soap_move (struct soap *soap, long n)
 
struct soapsoap_new ()
 
struct soapsoap_new1 (soap_mode mode)
 
struct soapsoap_new2 (soap_mode imode, soap_mode omode)
 
struct soap_blistsoap_new_block (struct soap *soap)
 
static struct soap_multipartsoap_new_multipart (struct soap *, struct soap_multipart **, struct soap_multipart **, char *, size_t)
 
char * soap_next_block (struct soap *soap, struct soap_blist *b)
 
struct soap_multipartsoap_next_multipart (struct soap_multipart *content)
 
void soap_open_logfile (struct soap *soap, int i)
 
int soap_outbyte (struct soap *soap, const char *tag, int id, const char *p, const char *type, int n)
 
int soap_outdateTime (struct soap *soap, const char *tag, int id, const time_t *p, const char *type, int n)
 
int soap_outdouble (struct soap *soap, const char *tag, int id, const double *p, const char *type, int n)
 
int soap_outfloat (struct soap *soap, const char *tag, int id, const float *p, const char *type, int n)
 
int soap_outint (struct soap *soap, const char *tag, int id, const int *p, const char *type, int n)
 
int soap_outliteral (struct soap *soap, const char *tag, char *const *p, const char *type)
 
int soap_outlong (struct soap *soap, const char *tag, int id, const long *p, const char *type, int n)
 
int soap_outLONG64 (struct soap *soap, const char *tag, int id, const long long *p, const char *type, int n)
 
int soap_outshort (struct soap *soap, const char *tag, int id, const short *p, const char *type, int n)
 
int soap_outstring (struct soap *soap, const char *tag, int id, char *const *p, const char *type, int n)
 
int soap_outULONG64 (struct soap *soap, const char *tag, int id, const unsigned long long *p, const char *type, int n)
 
int soap_outunsignedByte (struct soap *soap, const char *tag, int id, const unsigned char *p, const char *type, int n)
 
int soap_outunsignedInt (struct soap *soap, const char *tag, int id, const unsigned int *p, const char *type, int n)
 
int soap_outunsignedLong (struct soap *soap, const char *tag, int id, const unsigned long *p, const char *type, int n)
 
int soap_outunsignedShort (struct soap *soap, const char *tag, int id, const unsigned short *p, const char *type, int n)
 
int soap_outwliteral (struct soap *soap, const char *tag, wchar_t *const *p, const char *type)
 
int soap_outwstring (struct soap *soap, const char *tag, int id, wchar_t *const *p, const char *type, int n)
 
int soap_peek_element (struct soap *soap)
 
int soap_pointer_enter (struct soap *soap, const void *p, const struct soap_array *a, int n, int type, struct soap_plist **ppp)
 
int soap_pointer_lookup (struct soap *soap, const void *p, int type, struct soap_plist **ppp)
 
int soap_poll (struct soap *soap)
 
void soap_pop_block (struct soap *soap, struct soap_blist *b)
 
void soap_pop_namespace (struct soap *soap)
 
static void soap_pop_ns (struct soap *soap)
 
void soap_post_check_mime_attachments (struct soap *soap)
 
void soap_print_fault (struct soap *soap, FILE *fd)
 
void soap_print_fault_location (struct soap *soap, FILE *fd)
 
voidsoap_push_block (struct soap *soap, struct soap_blist *b, size_t n)
 
int soap_push_namespace (struct soap *soap, const char *id, const char *ns)
 
static struct soap_nlistsoap_push_ns (struct soap *soap, const char *id, const char *ns, short utilized)
 
int soap_putbase64 (struct soap *soap, const unsigned char *s, int n)
 
int soap_putdime (struct soap *soap)
 
static int soap_putdimefield (struct soap *, const char *, size_t)
 
int soap_putdimehdr (struct soap *soap)
 
int soap_puthex (struct soap *soap, const unsigned char *s, int n)
 
int soap_puthttphdr (struct soap *soap, int status, size_t count)
 
int soap_putmime (struct soap *soap)
 
int soap_putmimehdr (struct soap *soap, struct soap_multipart *content)
 
char * soap_putoffset (struct soap *soap, int offset)
 
char * soap_putoffsets (struct soap *soap, const int *offset, int dim)
 
char * soap_putsize (struct soap *soap, const char *type, int size)
 
char * soap_putsizes (struct soap *soap, const char *type, const int *size, int dim)
 
char * soap_putsizesoffsets (struct soap *soap, const char *type, const int *size, const int *offset, int dim)
 
int soap_pututf8 (struct soap *soap, register unsigned long c)
 
const char * soap_QName2s (struct soap *soap, const char *s)
 
int soap_receiver_fault (struct soap *soap, const char *faultstring, const char *faultdetailXML)
 
int soap_receiver_fault_subcode (struct soap *soap, const char *faultsubcodeQName, const char *faultstring, const char *faultdetailXML)
 
int soap_recv (struct soap *soap)
 
int soap_recv_empty_response (struct soap *soap)
 
int soap_recv_fault (struct soap *soap)
 
int soap_recv_header (struct soap *soap)
 
int soap_recv_raw (struct soap *soap)
 
int soap_reference (struct soap *soap, const void *p, int t)
 
int soap_register_plugin_arg (struct soap *soap, int(*fcreate)(struct soap *, struct soap_plugin *, void *), void *arg)
 
int soap_resolve (struct soap *soap)
 
static void soap_resolve_attachment (struct soap *, struct soap_multipart *)
 
int soap_response (struct soap *soap, int status)
 
void soap_retry (struct soap *soap)
 
void soap_revert (struct soap *soap)
 
char * soap_s2base64 (struct soap *soap, const unsigned char *s, char *t, int n)
 
int soap_s2byte (struct soap *soap, const char *s, char *p)
 
int soap_s2dateTime (struct soap *soap, const char *s, time_t *p)
 
int soap_s2double (struct soap *soap, const char *s, double *p)
 
int soap_s2float (struct soap *soap, const char *s, float *p)
 
char * soap_s2hex (struct soap *soap, const unsigned char *s, char *t, int n)
 
int soap_s2int (struct soap *soap, const char *s, int *p)
 
int soap_s2long (struct soap *soap, const char *s, long *p)
 
int soap_s2LONG64 (struct soap *soap, const char *s, long long *p)
 
int soap_s2QName (struct soap *soap, const char *s, char **t)
 
int soap_s2short (struct soap *soap, const char *s, short *p)
 
int soap_s2string (struct soap *soap, const char *s, char **t)
 
int soap_s2ULONG64 (struct soap *soap, const char *s, unsigned long long *p)
 
int soap_s2unsignedByte (struct soap *soap, const char *s, unsigned char *p)
 
int soap_s2unsignedInt (struct soap *soap, const char *s, unsigned int *p)
 
int soap_s2unsignedLong (struct soap *soap, const char *s, unsigned long *p)
 
int soap_s2unsignedShort (struct soap *soap, const char *s, unsigned short *p)
 
int soap_s2wchar (struct soap *soap, const char *s, wchar_t **t)
 
char * soap_save_block (struct soap *soap, struct soap_blist *b, char *p, int flag)
 
static void soap_select_mime_boundary (struct soap *)
 
int soap_send (struct soap *soap, const char *s)
 
int soap_send2 (struct soap *soap, const char *s1, const char *s2)
 
int soap_send3 (struct soap *soap, const char *s1, const char *s2, const char *s3)
 
int soap_send_empty_response (struct soap *soap, int httpstatuscode)
 
int soap_send_fault (struct soap *soap)
 
int soap_send_raw (struct soap *soap, const char *s, size_t n)
 
int soap_sender_fault (struct soap *soap, const char *faultstring, const char *faultdetailXML)
 
int soap_sender_fault_subcode (struct soap *soap, const char *faultsubcodeQName, const char *faultstring, const char *faultdetailXML)
 
int soap_set_attr (struct soap *soap, const char *name, const char *value)
 
void soap_set_dime (struct soap *soap)
 
int soap_set_dime_attachment (struct soap *soap, char *ptr, size_t size, const char *type, const char *id, unsigned short optype, const char *option)
 
void soap_set_embedded (struct soap *soap, struct soap_plist *pp)
 
void soap_set_endpoint (struct soap *soap, const char *endpoint)
 
static int soap_set_error (struct soap *, const char *, const char *, const char *, const char *, int)
 
void soap_set_fault (struct soap *soap)
 
void soap_set_local_namespaces (struct soap *soap)
 
void soap_set_mime (struct soap *soap, const char *boundary, const char *start)
 
int soap_set_mime_attachment (struct soap *soap, char *ptr, size_t size, enum soap_mime_encoding encoding, const char *type, const char *id, const char *location, const char *description)
 
int soap_set_namespaces (struct soap *soap, const struct Namespace *p)
 
int soap_set_receiver_error (struct soap *soap, const char *faultstring, const char *faultdetailXML, int soaperror)
 
int soap_set_sender_error (struct soap *soap, const char *faultstring, const char *faultdetailXML, int soaperror)
 
static const char * soap_set_validation_fault (struct soap *, const char *, const char *)
 
const char * soap_short2s (struct soap *soap, short n)
 
int soap_size (const int *size, int dim)
 
size_t soap_size_block (struct soap *soap, struct soap_blist *b, size_t n)
 
char * soap_sprint_fault (struct soap *soap, char *buf, size_t len)
 
int soap_store_lab (struct soap *soap, const char *s, size_t n)
 
char * soap_strdup (struct soap *soap, const char *s)
 
static const char * soap_strerror (struct soap *)
 
char * soap_string_in (struct soap *soap, int flag, long minlen, long maxlen)
 
int soap_string_out (struct soap *soap, const char *s, int flag)
 
const char * soap_strsearch (const char *big, const char *little)
 
int soap_tag_cmp (const char *s, const char *t)
 
size_t soap_tell (struct soap *soap)
 
time_t soap_timegm (struct tm *T)
 
static int soap_try_connect_command (struct soap *, int http_command, const char *endpoint, const char *action)
 
const char * soap_ULONG642s (struct soap *soap, unsigned long long n)
 
void soap_unlink (struct soap *soap, const void *p)
 
const char * soap_unsignedByte2s (struct soap *soap, unsigned char n)
 
const char * soap_unsignedInt2s (struct soap *soap, unsigned int n)
 
const char * soap_unsignedLong2s (struct soap *soap, unsigned long n)
 
const char * soap_unsignedShort2s (struct soap *soap, unsigned short n)
 
static void soap_update_ptrs (struct soap *, char *, char *, char *, char *)
 
static void soap_utilize_ns (struct soap *soap, const char *tag, size_t n)
 
static int soap_valid_mime_boundary (struct soap *)
 
const char * soap_value (struct soap *soap)
 
const char * soap_wchar2s (struct soap *soap, const wchar_t *s)
 
wchar_t * soap_wstrdup (struct soap *soap, const wchar_t *s)
 
wchar_t * soap_wstring_in (struct soap *soap, int flag, long minlen, long maxlen)
 
int soap_wstring_out (struct soap *soap, const wchar_t *s, int flag)
 
int soap_xop_forward (struct soap *soap, unsigned char **ptr, int *size, char **id, char **type, char **options)
 
static int tcp_accept (struct soap *, int, struct sockaddr *, int *)
 
static int tcp_closesocket (struct soap *, int)
 
static int tcp_connect (struct soap *, const char *endpoint, const char *host, int port)
 
static int tcp_disconnect (struct soap *)
 
static const char * tcp_error (struct soap *)
 
static int tcp_gethost (struct soap *, const char *addr, struct in_addr *inaddr)
 
static int tcp_init (struct soap *)
 
static int tcp_shutdownsocket (struct soap *, int, int)
 

Variables

static const struct soap_code_map h_error_codes []
 
static const struct soap_code_map h_http_error_codes []
 
static const struct soap_code_map html_entity_codes []
 
static const struct soap_code_map mime_codes []
 
static const char soap_base64i [81] = "\76XXX\77\64\65\66\67\70\71\72\73\74\75XXXXXXX\00\01\02\03\04\05\06\07\10\11\12\13\14\15\16\17\20\21\22\23\24\25\26\27\30\31XXXXXX\32\33\34\35\36\37\40\41\42\43\44\45\46\47\50\51\52\53\54\55\56\57\60\61\62\63"
 
static const char soap_base64o [65] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
 
const struct soap_double_nan soap_double_nan = {0xFFFFFFFF, 0xFFFFFFFF}
 
static const char soap_enc1 [42] = "http://schemas.xmlsoap.org/soap/encoding/"
 
static const char soap_enc2 [40] = "http://www.w3.org/2003/05/soap-encoding"
 
static const char soap_env1 [42] = "http://schemas.xmlsoap.org/soap/envelope/"
 
static const char soap_env2 [40] = "http://www.w3.org/2003/05/soap-envelope"
 
static const char soap_indent [11] = "\n\t\t\t\t\t\t\t\t\t"
 
static const char soap_padding [4] = "\0\0\0"
 
static const char soap_rpc [35] = "http://www.w3.org/2003/05/soap-rpc"
 

Macro Definition Documentation

#define SOAP_AP   (soap_wchar)(-6) /* XML character ''' */
#define soap_blank (   c)    ((c) >= 0 && (c) <= 32)
#define SOAP_CANARY   (0xC0DE)

Definition at line 305 of file stdsoap2.cpp.

Referenced by soap_dealloc(), and soap_malloc().

#define SOAP_GT   (soap_wchar)(-4) /* XML character '>' */
#define soap_hash_ptr (   p)    ((size_t)(((unsigned long)(p) >> 3) & (SOAP_PTRHASH-1)))
#define SOAP_LT   (soap_wchar)(-2) /* XML character '<' */
#define SOAP_NON_NULL   (soap_padding)

Definition at line 311 of file stdsoap2.cpp.

Referenced by soap_base642s(), soap_hex2s(), and soap_malloc().

#define soap_notblank (   c)    ((c) > 32)

Definition at line 119 of file stdsoap2.cpp.

Referenced by soap_element_end_in(), and soap_peek_element().

#define SOAP_QT   (soap_wchar)(-5) /* XML character '"' */
#define SOAP_SOCKBLOCK (   fd)    fcntl(fd, F_SETFL, fcntl(fd, F_GETFL)&~O_NONBLOCK);

Definition at line 273 of file stdsoap2.cpp.

Referenced by soap_accept(), and tcp_connect().

#define SOAP_SOCKNONBLOCK (   fd)    fcntl(fd, F_SETFL, fcntl(fd, F_GETFL)|O_NONBLOCK);

Definition at line 274 of file stdsoap2.cpp.

Referenced by soap_accept(), and tcp_connect().

#define SOAP_STR_EOS   (soap_padding)
#define SOAP_STR_PADDING   (soap_padding)

Definition at line 309 of file stdsoap2.cpp.

Referenced by soap_envelope_end_out(), soap_putdime(), and soap_putdimefield().

#define SOAP_TT   (soap_wchar)(-3) /* XML character '</' */
#define SOAP_UNKNOWN_CHAR   (127)

Definition at line 108 of file stdsoap2.cpp.

Referenced by soap_char(), and soap_string_in().

Function Documentation

static void * fplugin ( struct soap soap,
const char *  id 
)
static

Definition at line 19476 of file stdsoap2.cpp.

References soap_plugin::data, soap_plugin::id, soap_plugin::next, and soap::plugins.

Referenced by soap_done(), and soap_init().

19477  {
19478  register struct soap_plugin *p;
19479 
19480  for (p = soap->plugins; p; p = p->next)
19481  if (p->id == id || !strcmp(p->id, id))
19482  return p->data;
19483 
19484  return NULL;
19485  }
struct soap_plugin * plugins
Definition: stdsoap2.h:1635
struct soap_plugin * next
Definition: stdsoap2.h:1880
const char * id
Definition: stdsoap2.h:1881
void * data
Definition: stdsoap2.h:1882
static size_t frecv ( struct soap soap,
char *  s,
size_t  n 
)
static

Definition at line 1005 of file stdsoap2.cpp.

References soap::bio, soap::errnum, soap::error, FD_SETSIZE, soap::ip, soap::is, soap::omode, soap::peer, soap::peerlen, soap::recv_timeout, soap::recvfd, SOAP_EAGAIN, SOAP_EINTR, soap_errno, SOAP_EWOULDBLOCK, SOAP_FD_EXCEEDED, SOAP_IO_UDP, soap_socket_errno, SOAP_SOCKLEN_T, soap_valid_socket, SOAP_WINSOCKINT, soap::socket, soap::socket_flags, and soap::ssl.

Referenced by soap_done(), and soap_init().

1006  {
1007  register int r;
1008 #ifndef WITH_LEAN
1009  register int retries = 100; /* max 100 retries with non-blocking sockets */
1010 #endif
1011  soap->errnum = 0;
1012 #if defined(__cplusplus) && !defined(WITH_LEAN) && !defined(WITH_COMPAT)
1013 
1014  if (soap->is)
1015  {
1016  if (soap->is->good())
1017  return soap->is->read(s, (std::streamsize)n).gcount();
1018 
1019  return 0;
1020  }
1021 
1022 #endif
1023 
1024  if (soap_valid_socket(soap->socket))
1025  {
1026  for (;;)
1027  {
1028 #ifdef WITH_OPENSSL
1029  register int err = 0;
1030 #endif
1031 #ifndef WITH_LEAN
1032 #ifdef WITH_OPENSSL
1033 
1034  if (soap->recv_timeout && !soap->ssl) /* SSL: sockets are nonblocking */
1035 #else
1036  if (soap->recv_timeout)
1037 #endif
1038  {
1039 #ifndef WIN32
1040 
1041  if ((int)soap->socket >= (int)FD_SETSIZE)
1042  {
1043  soap->error = SOAP_FD_EXCEEDED;
1044  return 0; /* Hint: MUST increase FD_SETSIZE */
1045  }
1046 
1047 #endif
1048 
1049  for (;;)
1050  {
1051  struct timeval timeout;
1052  fd_set fd;
1053 
1054  if (soap->recv_timeout > 0)
1055  {
1056  timeout.tv_sec = soap->recv_timeout;
1057  timeout.tv_usec = 0;
1058  }
1059  else
1060  {
1061  timeout.tv_sec = -soap->recv_timeout / 1000000;
1062  timeout.tv_usec = -soap->recv_timeout % 1000000;
1063  }
1064 
1065  FD_ZERO(&fd);
1066  FD_SET(soap->socket, &fd);
1067  r = select((int)soap->socket + 1, &fd, NULL, &fd, &timeout);
1068 
1069  if (r > 0)
1070  break;
1071 
1072  if (!r)
1073  {
1074  soap->errnum = 0;
1075  return 0;
1076  }
1077 
1078  r = soap_socket_errno(soap->socket);
1079 
1080  if (r != SOAP_EINTR && r != SOAP_EAGAIN && r != SOAP_EWOULDBLOCK)
1081  {
1082  soap->errnum = r;
1083  return 0;
1084  }
1085  }
1086  }
1087 #endif
1088 #ifdef WITH_OPENSSL
1089 
1090  if (soap->ssl)
1091  {
1092  r = SSL_read(soap->ssl, s, (int)n);
1093 
1094  if (r > 0)
1095  return (size_t)r;
1096 
1097  err = SSL_get_error(soap->ssl, r);
1098 
1099  if (err != SSL_ERROR_NONE && err != SSL_ERROR_WANT_READ && err != SSL_ERROR_WANT_WRITE)
1100  return 0;
1101  }
1102  else if (soap->bio)
1103  {
1104  r = BIO_read(soap->bio, s, (int)n);
1105 
1106  if (r > 0)
1107  return (size_t)r;
1108 
1109  return 0;
1110  }
1111  else
1112 #endif
1113 
1114  {
1115 #ifndef WITH_LEAN
1116 
1117  if ((soap->omode & SOAP_IO_UDP))
1118  {
1119  SOAP_SOCKLEN_T k = (SOAP_SOCKLEN_T)sizeof(soap->peer);
1120  memset((void*)&soap->peer, 0, sizeof(soap->peer));
1121  r = recvfrom(soap->socket, s, (SOAP_WINSOCKINT)n, soap->socket_flags, (struct sockaddr*) & soap->peer, &k); /* portability note: see SOAP_SOCKLEN_T definition in stdsoap2.h */
1122  soap->peerlen = (size_t)k;
1123 #ifndef WITH_IPV6
1124  soap->ip = ntohl(soap->peer.sin_addr.s_addr);
1125 #endif
1126  }
1127  else
1128 #endif
1129  r = recv(soap->socket, s, (int)n, soap->socket_flags);
1130 
1131 #ifdef PALM
1132  /* CycleSyncDisplay(curStatusMsg); */
1133 #endif
1134 
1135  if (r >= 0)
1136  return (size_t)r;
1137 
1138  r = soap_socket_errno(soap->socket);
1139 
1140  if (r != SOAP_EINTR && r != SOAP_EAGAIN && r != SOAP_EWOULDBLOCK)
1141  {
1142  soap->errnum = r;
1143  return 0;
1144  }
1145  }
1146 
1147 #ifndef WITH_LEAN
1148  {struct timeval timeout;
1149  fd_set fd;
1150 
1151  if (soap->recv_timeout > 0)
1152  {
1153  timeout.tv_sec = soap->recv_timeout;
1154  timeout.tv_usec = 0;
1155  }
1156  else if (soap->recv_timeout < 0)
1157  {
1158  timeout.tv_sec = -soap->recv_timeout / 1000000;
1159  timeout.tv_usec = -soap->recv_timeout % 1000000;
1160  }
1161  else
1162  {
1163  timeout.tv_sec = 5;
1164  timeout.tv_usec = 0;
1165  }
1166 
1167 #ifndef WIN32
1168 
1169  if ((int)soap->socket >= (int)FD_SETSIZE)
1170  {
1171  soap->error = SOAP_FD_EXCEEDED;
1172  return 0; /* Hint: MUST increase FD_SETSIZE */
1173  }
1174 
1175 #endif
1176  FD_ZERO(&fd);
1177  FD_SET(soap->socket, &fd);
1178 #ifdef WITH_OPENSSL
1179 
1180  if (soap->ssl && err == SSL_ERROR_WANT_WRITE)
1181  r = select((int)soap->socket + 1, NULL, &fd, &fd, &timeout);
1182  else
1183  r = select((int)soap->socket + 1, &fd, NULL, &fd, &timeout);
1184 
1185 #else
1186  r = select((int)soap->socket + 1, &fd, NULL, &fd, &timeout);
1187 #endif
1188 
1189  if (!r && soap->recv_timeout)
1190  {
1191  soap->errnum = 0;
1192  return 0;
1193  }
1194 
1195  if (r < 0)
1196  {
1197  r = soap_socket_errno(soap->socket);
1198 
1199  if (r != SOAP_EINTR && r != SOAP_EAGAIN && r != SOAP_EWOULDBLOCK)
1200  {
1201  soap->errnum = r;
1202  return 0;
1203  }
1204  }
1205 
1206  if (retries-- <= 0)
1207  {
1208  soap->errnum = soap_socket_errno(soap->socket);
1209  return 0;
1210  }
1211  }
1212 #endif
1213 #ifdef PALM
1214  r = soap_socket_errno(soap->socket);
1215 
1216  if (r != SOAP_EINTR && retries-- <= 0)
1217  {
1218  soap->errnum = r;
1219  return 0;
1220  }
1221 
1222 #endif
1223  }
1224  }
1225 
1226 #ifdef WITH_FASTCGI
1227  return fread(s, 1, n, stdin);
1228 #else
1229 #ifdef UNDER_CE
1230  return fread(s, 1, n, soap->recvfd);
1231 #else
1232 #ifdef WMW_RPM_IO
1233 
1234  if (soap->rpmreqid)
1235  r = httpBlockRead(soap->rpmreqid, s, n);
1236  else
1237 #endif
1238 #ifdef WIN32
1239  r = _read(soap->recvfd, s, (unsigned int)n);
1240 
1241 #else
1242  r = read(soap->recvfd, s, (unsigned int)n);
1243 #endif
1244 
1245  if (r >= 0)
1246  return (size_t)r;
1247 
1248  soap->errnum = soap_errno;
1249  return 0;
1250 #endif
1251 #endif
1252  }
#define soap_socket_errno(s)
Definition: stdsoap2.h:803
#define soap_errno
Definition: stdsoap2.h:802
void * is
Definition: stdsoap2.h:1690
int socket_flags
Definition: stdsoap2.h:1616
int recvfd
Definition: stdsoap2.h:1694
int error
Definition: stdsoap2.h:1755
unsigned long ip
Definition: stdsoap2.h:1740
#define soap_valid_socket(n)
Definition: stdsoap2.h:698
#define SOAP_EWOULDBLOCK
Definition: stdsoap2.h:785
#define FD_SETSIZE
Definition: stdsoap2.h:705
#define SOAP_IO_UDP
Definition: stdsoap2.h:1092
#define SOAP_EAGAIN
Definition: stdsoap2.h:779
void * bio
Definition: stdsoap2.h:1798
soap_mode omode
Definition: stdsoap2.h:1603
void * ssl
Definition: stdsoap2.h:1799
size_t peerlen
Definition: stdsoap2.h:1787
#define SOAP_WINSOCKINT
Definition: stdsoap2.h:587
struct sockaddr_in peer
Definition: stdsoap2.h:1784
int errnum
Definition: stdsoap2.h:1757
int recv_timeout
Definition: stdsoap2.h:1612
#define SOAP_SOCKLEN_T
Definition: stdsoap2.h:684
int socket
Definition: stdsoap2.h:1684
#define SOAP_FD_EXCEEDED
Definition: stdsoap2.h:1041
#define SOAP_EINTR
Definition: stdsoap2.h:778
static int fsend ( struct soap soap,
const char *  s,
size_t  n 
)
static

Definition at line 526 of file stdsoap2.cpp.

References soap::bio, soap::connect_flags, soap::errnum, FD_SETSIZE, soap::omode, soap::os, soap::peer, soap::peerlen, soap::send_timeout, soap::sendfd, SOAP_EAGAIN, SOAP_EINTR, SOAP_EOF, soap_errno, SOAP_EWOULDBLOCK, SOAP_FD_EXCEEDED, SOAP_IO_UDP, SOAP_OK, soap_random, soap_socket_errno, soap_valid_socket, SOAP_WINSOCKINT, soap::socket, soap::socket_flags, and soap::ssl.

Referenced by soap_done(), and soap_init().

527  {
528  register int nwritten, err;
529 #if defined(__cplusplus) && !defined(WITH_LEAN) && !defined(WITH_COMPAT)
530 
531  if (soap->os)
532  {
533  soap->os->write(s, (std::streamsize)n);
534 
535  if (soap->os->good())
536  return SOAP_OK;
537 
538  soap->errnum = 0;
539  return SOAP_EOF;
540  }
541 
542 #endif
543 
544  while (n)
545  {
546  if (soap_valid_socket(soap->socket))
547  {
548 #ifndef WITH_LEAN
549 
550  if (soap->send_timeout)
551  {
552 #ifndef WIN32
553 
554  if ((int)soap->socket >= (int)FD_SETSIZE)
555  return SOAP_FD_EXCEEDED; /* Hint: MUST increase FD_SETSIZE */
556 
557 #endif
558 
559  for (;;)
560  {
561  struct timeval timeout;
562  fd_set fd;
563  register int r;
564 
565  if (soap->send_timeout > 0)
566  {
567  timeout.tv_sec = soap->send_timeout;
568  timeout.tv_usec = 0;
569  }
570  else
571  {
572  timeout.tv_sec = -soap->send_timeout / 1000000;
573  timeout.tv_usec = -soap->send_timeout % 1000000;
574  }
575 
576  FD_ZERO(&fd);
577  FD_SET(soap->socket, &fd);
578 #ifdef WITH_OPENSSL
579 
580  if (soap->ssl)
581  r = select((int)soap->socket + 1, &fd, &fd, &fd, &timeout);
582  else
583 #endif
584  r = select((int)soap->socket + 1, NULL, &fd, &fd, &timeout);
585 
586  if (r > 0)
587  break;
588 
589  if (!r)
590  {
591  soap->errnum = 0;
592  return SOAP_EOF;
593  }
594 
595  err = soap_socket_errno(soap->socket);
596 
597  if (err != SOAP_EINTR && err != SOAP_EAGAIN && err != SOAP_EWOULDBLOCK)
598  {
599  soap->errnum = err;
600  return SOAP_EOF;
601  }
602  }
603  }
604 
605 #endif
606 #ifdef WITH_OPENSSL
607 
608  if (soap->ssl)
609  nwritten = SSL_write(soap->ssl, s, (int)n);
610  else if (soap->bio)
611  nwritten = BIO_write(soap->bio, s, (int)n);
612  else
613 #endif
614 #ifndef WITH_LEAN
615  if ((soap->omode & SOAP_IO_UDP))
616  {
617  if (soap->peerlen)
618  nwritten = sendto(soap->socket, s, (SOAP_WINSOCKINT)n, soap->socket_flags, (struct sockaddr*) & soap->peer, (SOAP_WINSOCKINT)soap->peerlen);
619  else
620  nwritten = send(soap->socket, s, (SOAP_WINSOCKINT)n, soap->socket_flags);
621 
622  /* retry and back-off algorithm */
623 
624  /* TODO: this is not very clear from specs so verify and limit conditions under which we should loop (e.g. ENOBUFS) */
625  if (nwritten < 0)
626  {
627  struct timeval timeout;
628  fd_set fd;
629  int udp_repeat;
630  int udp_delay;
631 #ifndef WIN32
632 
633  if ((int)soap->socket >= (int)FD_SETSIZE)
634  return SOAP_FD_EXCEEDED; /* Hint: MUST increase FD_SETSIZE */
635 
636 #endif
637 
638  if ((soap->connect_flags & SO_BROADCAST))
639  udp_repeat = 3; /* SOAP-over-UDP MULTICAST_UDP_REPEAT - 1 */
640  else
641  udp_repeat = 1; /* SOAP-over-UDP UNICAST_UDP_REPEAT - 1 */
642 
643  udp_delay = (soap_random % 201) + 50; /* UDP_MIN_DELAY .. UDP_MAX_DELAY */
644 
645  do
646  {
647  timeout.tv_sec = 0;
648  timeout.tv_usec = 1000 * udp_delay; /* ms */
649  FD_ZERO(&fd);
650  FD_SET(soap->socket, &fd);
651  select((int)soap->socket + 1, NULL, NULL, &fd, &timeout);
652 
653  if (soap->peerlen)
654  nwritten = sendto(soap->socket, s, (SOAP_WINSOCKINT)n, soap->socket_flags, (struct sockaddr*) & soap->peer, (SOAP_WINSOCKINT)soap->peerlen);
655  else
656  nwritten = send(soap->socket, s, (SOAP_WINSOCKINT)n, soap->socket_flags);
657 
658  udp_delay <<= 1;
659 
660  if (udp_delay > 500) /* UDP_UPPER_DELAY */
661  udp_delay = 500;
662  }
663  while (nwritten < 0 && --udp_repeat > 0);
664  }
665  }
666  else
667 #endif
668 #if !defined(PALM) && !defined(AS400)
669  nwritten = send(soap->socket, s, (int)n, soap->socket_flags);
670 
671 #else
672  nwritten = send(soap->socket, (void*)s, n, soap->socket_flags);
673 #endif
674 
675  if (nwritten <= 0)
676  {
677 #if defined(WITH_OPENSSL) || !defined(WITH_LEAN)
678  register int r = 0;
679 #endif
680  err = soap_socket_errno(soap->socket);
681 #ifdef WITH_OPENSSL
682 
683  if (soap->ssl && (r = SSL_get_error(soap->ssl, nwritten)) != SSL_ERROR_NONE && r != SSL_ERROR_WANT_READ && r != SSL_ERROR_WANT_WRITE)
684  {
685  soap->errnum = err;
686  return SOAP_EOF;
687  }
688 
689 #endif
690 
691  if (err == SOAP_EWOULDBLOCK || err == SOAP_EAGAIN)
692  {
693 #ifndef WITH_LEAN
694  struct timeval timeout;
695  fd_set fd;
696 #ifndef WIN32
697 
698  if ((int)soap->socket >= (int)FD_SETSIZE)
699  return SOAP_FD_EXCEEDED; /* Hint: MUST increase FD_SETSIZE */
700 
701 #endif
702 
703  if (soap->send_timeout > 0)
704  {
705  timeout.tv_sec = soap->send_timeout;
706  timeout.tv_usec = 0;
707  }
708  else if (soap->send_timeout < 0)
709  {
710  timeout.tv_sec = -soap->send_timeout / 1000000;
711  timeout.tv_usec = -soap->send_timeout % 1000000;
712  }
713  else
714  {
715  timeout.tv_sec = 0;
716  timeout.tv_usec = 10000;
717  }
718 
719  FD_ZERO(&fd);
720  FD_SET(soap->socket, &fd);
721 #ifdef WITH_OPENSSL
722 
723  if (soap->ssl && r == SSL_ERROR_WANT_READ)
724  r = select((int)soap->socket + 1, &fd, NULL, &fd, &timeout);
725  else
726  r = select((int)soap->socket + 1, NULL, &fd, &fd, &timeout);
727 
728 #else
729  r = select((int)soap->socket + 1, NULL, &fd, &fd, &timeout);
730 #endif
731 
732  if (!r && soap->send_timeout)
733  {
734  soap->errnum = 0;
735  return SOAP_EOF;
736  }
737 
738  if (r < 0 && (r = soap_socket_errno(soap->socket)) != SOAP_EINTR)
739  {
740  soap->errnum = r;
741  return SOAP_EOF;
742  }
743 
744 #endif
745  }
746  else if (err && err != SOAP_EINTR)
747  {
748  soap->errnum = err;
749  return SOAP_EOF;
750  }
751 
752  nwritten = 0; /* and call write() again */
753  }
754  }
755  else
756  {
757 #ifdef WITH_FASTCGI
758  nwritten = fwrite((void*)s, 1, n, stdout);
759  fflush(stdout);
760 #else
761 #ifdef UNDER_CE
762  nwritten = fwrite(s, 1, n, soap->sendfd);
763 #else
764 #ifdef VXWORKS
765 #ifdef WMW_RPM_IO
766 
767  if (soap->rpmreqid)
768  nwritten = (httpBlockPut(soap->rpmreqid, s, n) == 0) ? n : -1;
769  else
770 #endif
771  nwritten = fwrite(s, sizeof(char), n, fdopen(soap->sendfd, "w"));
772 
773 #else
774 #ifdef WIN32
775  nwritten = _write(soap->sendfd, s, (unsigned int)n);
776 #else
777  nwritten = write(soap->sendfd, s, (unsigned int)n);
778 #endif
779 #endif
780 #endif
781 #endif
782 
783  if (nwritten <= 0)
784  {
785 #ifndef WITH_FASTCGI
786  err = soap_errno;
787 #else
788  err = EOF;
789 #endif
790 
791  if (err && err != SOAP_EINTR && err != SOAP_EWOULDBLOCK && err != SOAP_EAGAIN)
792  {
793  soap->errnum = err;
794  return SOAP_EOF;
795  }
796 
797  nwritten = 0; /* and call write() again */
798  }
799  }
800 
801  n -= nwritten;
802  s += nwritten;
803  }
804 
805  return SOAP_OK;
806  }
#define soap_socket_errno(s)
Definition: stdsoap2.h:803
#define soap_errno
Definition: stdsoap2.h:802
int socket_flags
Definition: stdsoap2.h:1616
#define soap_valid_socket(n)
Definition: stdsoap2.h:698
int sendfd
Definition: stdsoap2.h:1693
#define SOAP_EWOULDBLOCK
Definition: stdsoap2.h:785
#define FD_SETSIZE
Definition: stdsoap2.h:705
#define SOAP_IO_UDP
Definition: stdsoap2.h:1092
#define SOAP_EAGAIN
Definition: stdsoap2.h:779
void * bio
Definition: stdsoap2.h:1798
soap_mode omode
Definition: stdsoap2.h:1603
void * ssl
Definition: stdsoap2.h:1799
int send_timeout
Definition: stdsoap2.h:1613
size_t peerlen
Definition: stdsoap2.h:1787
#define SOAP_WINSOCKINT
Definition: stdsoap2.h:587
struct sockaddr_in peer
Definition: stdsoap2.h:1784
int errnum
Definition: stdsoap2.h:1757
int connect_flags
Definition: stdsoap2.h:1617
#define soap_random
Definition: stdsoap2.h:1936
#define SOAP_OK
Definition: stdsoap2.h:995
void * os
Definition: stdsoap2.h:1689
#define SOAP_EOF
Definition: stdsoap2.h:993
int socket
Definition: stdsoap2.h:1684
#define SOAP_FD_EXCEEDED
Definition: stdsoap2.h:1041
#define SOAP_EINTR
Definition: stdsoap2.h:778
static int http_del ( struct soap soap)
static

Definition at line 18372 of file stdsoap2.cpp.

References SOAP_DEL_METHOD.

Referenced by soap_done(), and soap_init().

18373  {
18374  return SOAP_DEL_METHOD;
18375  }
#define SOAP_DEL_METHOD
Definition: stdsoap2.h:1012
static const char * http_error ( struct soap soap,
int  status 
)
static

Definition at line 4540 of file stdsoap2.cpp.

References soap_code_str(), and SOAP_STR_EOS.

Referenced by http_response(), and soap_set_fault().

4541  {
4542  register const char *msg = SOAP_STR_EOS;
4543 #ifndef WITH_LEAN
4544  msg = soap_code_str(h_http_error_codes, status);
4545 
4546  if (!msg)
4547  msg = SOAP_STR_EOS;
4548 
4549 #endif
4550  return msg;
4551  }
static const struct soap_code_map h_http_error_codes[]
Definition: stdsoap2.cpp:441
#define SOAP_STR_EOS
Definition: stdsoap2.cpp:310
const char * soap_code_str(const struct soap_code_map *code_map, long code)
Definition: stdsoap2.cpp:1682
static int http_get ( struct soap soap)
static

Definition at line 18350 of file stdsoap2.cpp.

References SOAP_GET_METHOD.

Referenced by soap_done(), and soap_init().

18351  {
18352  return SOAP_GET_METHOD;
18353  }
#define SOAP_GET_METHOD
Definition: stdsoap2.h:1010
static int http_head ( struct soap soap)
static

Definition at line 18383 of file stdsoap2.cpp.

References SOAP_HEAD_METHOD.

Referenced by soap_done(), and soap_init().

18384  {
18385  return SOAP_HEAD_METHOD;
18386  }
#define SOAP_HEAD_METHOD
Definition: stdsoap2.h:1013
static int http_parse ( struct soap soap)
static

Definition at line 16921 of file stdsoap2.cpp.

References soap::action, soap::authrealm, DBGLOG, soap::endpoint, soap::error, soap::fdel, soap::fget, soap::fhead, soap::fparsehdr, soap::fput, soap::http_content, soap::imode, soap::keep_alive, soap::length, soap::msgbuf, soap::omode, soap::passwd, soap::path, soap::proxy_from, soap_blank, SOAP_EOF, soap_get_http_body(), soap_getline(), SOAP_HDRLEN, SOAP_HTTP_METHOD, SOAP_IO, SOAP_IO_CHUNK, SOAP_IO_STORE, SOAP_OK, soap_set_receiver_error(), SOAP_STOP, soap_strtoul, soap::status, and soap::userid.

Referenced by soap_done(), and soap_init().

16922  {
16923  char header[SOAP_HDRLEN], *s;
16924  unsigned short httpcmd = 0, status = 0, k = 0;
16925  DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Waiting for HTTP request/response...\n"));
16926  *soap->endpoint = '\0';
16927  soap->length = 0;
16928  soap->userid = NULL;
16929  soap->passwd = NULL;
16930  soap->action = NULL;
16931  soap->authrealm = NULL;
16932  soap->proxy_from = NULL;
16933  soap->http_content = NULL;
16934  soap->status = 0;
16935 
16936  do
16937  {
16938  if (soap_getline(soap, soap->msgbuf, sizeof(soap->msgbuf)))
16939  {
16940  if (soap->error == SOAP_EOF)
16941  return SOAP_EOF;
16942 
16943  return soap->error = 414;
16944  }
16945 
16946  DBGLOG(TEST, SOAP_MESSAGE(fdebug, "HTTP status: %s\n", soap->msgbuf));
16947 
16948  for (;;)
16949  {
16950  if (soap_getline(soap, header, SOAP_HDRLEN))
16951  {
16952  if (soap->error == SOAP_EOF)
16953  {
16954  soap->error = SOAP_OK;
16955  DBGLOG(TEST, SOAP_MESSAGE(fdebug, "EOF in HTTP header, continue anyway\n"));
16956  break;
16957  }
16958 
16959  return soap->error;
16960  }
16961 
16962  if (!*header)
16963  break;
16964 
16965  DBGLOG(TEST, SOAP_MESSAGE(fdebug, "HTTP header: %s\n", header));
16966  s = strchr(header, ':');
16967 
16968  if (s)
16969  {
16970  char *t;
16971  *s = '\0';
16972 
16973  do s++;
16974 
16975  while (*s && *s <= 32);
16976 
16977  if (*s == '"')
16978  s++;
16979 
16980  t = s + strlen(s) - 1;
16981 
16982  while (t > s && *t <= 32)
16983  t--;
16984 
16985  if (t >= s && *t == '"')
16986  t--;
16987 
16988  t[1] = '\0';
16989 
16990  if ((soap->error = soap->fparsehdr(soap, header, s)))
16991  {
16992  if (soap->error < SOAP_STOP)
16993  return soap->error;
16994 
16995  status = soap->error;
16996  soap->error = SOAP_OK;
16997  }
16998  }
16999  }
17000 
17001  if ((s = strchr(soap->msgbuf, ' ')))
17002  {
17003  k = (unsigned short)soap_strtoul(s, &s, 10);
17004 
17005  if (!soap_blank(*s))
17006  k = 0;
17007  }
17008  else
17009  k = 0;
17010  }
17011  while (k == 100);
17012 
17013  DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Finished HTTP header parsing, status = %d\n", k));
17014  s = strstr(soap->msgbuf, "HTTP/");
17015 
17016  if (s && s[7] != '1')
17017  {
17018  if (soap->keep_alive == 1)
17019  soap->keep_alive = 0;
17020 
17021  if (k == 0 && (soap->omode & SOAP_IO) == SOAP_IO_CHUNK) /* k == 0 for HTTP request */
17022  {
17023  soap->imode |= SOAP_IO_CHUNK;
17024  soap->omode = (soap->omode & ~SOAP_IO) | SOAP_IO_STORE;
17025  }
17026  }
17027 
17028  if (soap->keep_alive < 0)
17029  soap->keep_alive = 1;
17030 
17031  DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Keep alive connection = %d\n", soap->keep_alive));
17032 
17033  if (k == 0)
17034  {
17035  size_t l = 0;
17036 
17037  if (s)
17038  {
17039  if (!strncmp(soap->msgbuf, "POST ", l = 5))
17040  httpcmd = 1;
17041  else if (!strncmp(soap->msgbuf, "GET ", l = 4))
17042  httpcmd = 2;
17043  else if (!strncmp(soap->msgbuf, "PUT ", l = 4))
17044  httpcmd = 3;
17045  else if (!strncmp(soap->msgbuf, "DELETE ", l = 7))
17046  httpcmd = 4;
17047  else if (!strncmp(soap->msgbuf, "HEAD ", l = 5))
17048  httpcmd = 5;
17049  }
17050 
17051  if (s && httpcmd)
17052  {
17053  size_t m = strlen(soap->endpoint);
17054  size_t n = m + (s - soap->msgbuf) - l - 1;
17055 
17056  if (m > n)
17057  m = n;
17058 
17059  if (n >= sizeof(soap->endpoint))
17060  n = sizeof(soap->endpoint) - 1;
17061 
17062  strncpy(soap->path, soap->msgbuf + l, n - m);
17063  soap->path[n - m] = '\0';
17064  strcat(soap->endpoint, soap->path);
17065  DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Target endpoint='%s'\n", soap->endpoint));
17066 
17067  if (httpcmd > 1)
17068  {
17069  switch (httpcmd)
17070  {
17071  case 2: soap->error = soap->fget(soap); break;
17072  case 3: soap->error = soap->fput(soap); break;
17073  case 4: soap->error = soap->fdel(soap); break;
17074  case 5: soap->error = soap->fhead(soap); break;
17075  default: soap->error = SOAP_HTTP_METHOD; break;
17076  }
17077 
17078  if (soap->error == SOAP_OK)
17079  soap->error = SOAP_STOP; /* prevents further processing */
17080 
17081  return soap->error;
17082  }
17083 
17084  if (status)
17085  return soap->error = status;
17086  }
17087  else if (status)
17088  return soap->error = status;
17089  else if (s)
17090  return soap->error = 405;
17091  }
17092 
17093  soap->status = k;
17094 
17095  /* Status OK (HTTP 200) */
17096  if (k == 0 || k == 200)
17097  return SOAP_OK;
17098 
17099  /* Status 201 (Created), 202 (Accepted), ... and HTTP 400 and 500 errors
17100  require normal return to try parsing SOAP/XML body.
17101  Otherwise, try to parse HTTP body.
17102  */
17103  if (soap->length > 0 || (soap->imode & SOAP_IO) == SOAP_IO_CHUNK)
17104  {
17105  if (((k > 200 && k <= 299) || k == 400 || k == 500))
17106  return SOAP_OK;
17107 
17108  /* force close afterwards in soap_closesock() */
17109  soap->keep_alive = 0;
17110  /* read HTTP body for error details */
17111  s = soap_get_http_body(soap);
17112 
17113  if (s)
17114  return soap_set_receiver_error(soap, soap->msgbuf, s, k);
17115  }
17116 
17117  DBGLOG(TEST, SOAP_MESSAGE(fdebug, "HTTP error %d\n", k));
17118  return soap_set_receiver_error(soap, "HTTP Error", soap->msgbuf, k);
17119  }
char msgbuf[1024]
Definition: stdsoap2.h:1711
char path[(1024)]
Definition: stdsoap2.h:1735
short keep_alive
Definition: stdsoap2.h:1742
int error
Definition: stdsoap2.h:1755
char * action
Definition: stdsoap2.h:1737
soap_mode imode
Definition: stdsoap2.h:1602
int(* fhead)(struct soap *)
Definition: stdsoap2.h:1642
#define SOAP_IO
Definition: stdsoap2.h:1086
#define DBGLOG(DBGFILE, CMD)
Definition: stdsoap2.h:1247
static char * soap_get_http_body(struct soap *)
Definition: stdsoap2.cpp:17498
char * authrealm
Definition: stdsoap2.h:1738
#define SOAP_IO_CHUNK
Definition: stdsoap2.h:1090
#define soap_strtoul(s, t, b)
Definition: stdsoap2.h:1925
int soap_set_receiver_error(struct soap *soap, const char *faultstring, const char *faultdetailXML, int soaperror)
Definition: stdsoap2.cpp:19218
#define soap_blank(c)
Definition: stdsoap2.cpp:118
int(* fdel)(struct soap *)
Definition: stdsoap2.h:1641
const char * http_content
Definition: stdsoap2.h:1608
#define SOAP_HDRLEN
Definition: stdsoap2.h:855
#define SOAP_STOP
Definition: stdsoap2.h:1056
soap_mode omode
Definition: stdsoap2.h:1603
int soap_getline(struct soap *soap, char *s, int len)
Definition: stdsoap2.cpp:14288
int(* fput)(struct soap *)
Definition: stdsoap2.h:1640
const char * proxy_from
Definition: stdsoap2.h:1753
int(* fparsehdr)(struct soap *, const char *, const char *)
Definition: stdsoap2.h:1647
#define SOAP_OK
Definition: stdsoap2.h:995
#define SOAP_HTTP_METHOD
Definition: stdsoap2.h:1014
int status
Definition: stdsoap2.h:1754
char * userid
Definition: stdsoap2.h:1636
size_t length
Definition: stdsoap2.h:1706
#define SOAP_IO_STORE
Definition: stdsoap2.h:1089
#define SOAP_EOF
Definition: stdsoap2.h:993
char endpoint[(1024)]
Definition: stdsoap2.h:1734
int(* fget)(struct soap *)
Definition: stdsoap2.h:1639
char * passwd
Definition: stdsoap2.h:1637
static int http_parse_header ( struct soap soap,
const char *  key,
const char *  val 
)
static

Definition at line 17127 of file stdsoap2.cpp.

References soap::action, soap::authrealm, soap_mime::boundary, soap::endpoint, soap::error, soap::fposthdr, soap::http_content, soap::imode, soap::keep_alive, soap::length, soap::mime, soap::passwd, soap::proxy_from, soap_base642s(), SOAP_ENC_DIME, SOAP_ENC_MIME, SOAP_ENC_SSL, soap_get_header_attribute(), SOAP_IO, SOAP_IO_CHUNK, SOAP_OK, soap_strdup(), soap_strtoul, soap_tag_cmp(), SOAP_ZLIB_DEFLATE, SOAP_ZLIB_ERROR, SOAP_ZLIB_GZIP, SOAP_ZLIB_NONE, soap_mime::start, soap::tmpbuf, soap::userid, soap::zlib_in, and soap::zlib_out.

Referenced by soap_done(), and soap_init().

17128  {
17129  if (!soap_tag_cmp(key, "Host"))
17130  {
17131 #ifdef WITH_OPENSSL
17132 
17133  if (soap->imode & SOAP_ENC_SSL)
17134  strcpy(soap->endpoint, "https://");
17135  else
17136 #endif
17137  strcpy(soap->endpoint, "http://");
17138 
17139  strncat(soap->endpoint, val, sizeof(soap->endpoint) - 8);
17140  soap->endpoint[sizeof(soap->endpoint) - 1] = '\0';
17141  }
17142 
17143 #ifndef WITH_LEANER
17144  else if (!soap_tag_cmp(key, "Content-Type"))
17145  {
17146  const char *action;
17147  soap->http_content = soap_strdup(soap, val);
17148 
17149  if (soap_get_header_attribute(soap, val, "application/dime"))
17150  soap->imode |= SOAP_ENC_DIME;
17151  else if (soap_get_header_attribute(soap, val, "multipart/related")
17152  || soap_get_header_attribute(soap, val, "multipart/form-data"))
17153  {
17154  soap->mime.boundary = soap_strdup(soap, soap_get_header_attribute(soap, val, "boundary"));
17155  soap->mime.start = soap_strdup(soap, soap_get_header_attribute(soap, val, "start"));
17156  soap->imode |= SOAP_ENC_MIME;
17157  }
17158 
17159  action = soap_get_header_attribute(soap, val, "action");
17160 
17161  if (action)
17162  {
17163  if (*action == '"')
17164  {
17165  soap->action = soap_strdup(soap, action + 1);
17166  soap->action[strlen(soap->action) - 1] = '\0';
17167  }
17168  else
17169  soap->action = soap_strdup(soap, action);
17170  }
17171  }
17172 
17173 #endif
17174  else if (!soap_tag_cmp(key, "Content-Length"))
17175  {
17176  soap->length = soap_strtoul(val, NULL, 10);
17177  }
17178  else if (!soap_tag_cmp(key, "Content-Encoding"))
17179  {
17180  if (!soap_tag_cmp(val, "deflate"))
17181 #ifdef WITH_ZLIB
17182  soap->zlib_in = SOAP_ZLIB_DEFLATE;
17183 
17184 #else
17185  return SOAP_ZLIB_ERROR;
17186 #endif
17187  else if (!soap_tag_cmp(val, "gzip"))
17188 #ifdef WITH_GZIP
17189  soap->zlib_in = SOAP_ZLIB_GZIP;
17190 
17191 #else
17192  return SOAP_ZLIB_ERROR;
17193 #endif
17194  }
17195 
17196 #ifdef WITH_ZLIB
17197  else if (!soap_tag_cmp(key, "Accept-Encoding"))
17198  {
17199 #ifdef WITH_GZIP
17200 
17201  if (strchr(val, '*') || soap_get_header_attribute(soap, val, "gzip"))
17202  soap->zlib_out = SOAP_ZLIB_GZIP;
17203  else
17204 #endif
17205  if (strchr(val, '*') || soap_get_header_attribute(soap, val, "deflate"))
17206  soap->zlib_out = SOAP_ZLIB_DEFLATE;
17207  else
17208  soap->zlib_out = SOAP_ZLIB_NONE;
17209  }
17210 
17211 #endif
17212  else if (!soap_tag_cmp(key, "Transfer-Encoding"))
17213  {
17214  soap->imode &= ~SOAP_IO;
17215 
17216  if (!soap_tag_cmp(val, "chunked"))
17217  soap->imode |= SOAP_IO_CHUNK;
17218  }
17219  else if (!soap_tag_cmp(key, "Connection"))
17220  {
17221  if (!soap_tag_cmp(val, "keep-alive"))
17222  soap->keep_alive = -soap->keep_alive;
17223  else if (!soap_tag_cmp(val, "close"))
17224  soap->keep_alive = 0;
17225  }
17226 
17227 #ifndef WITH_LEAN
17228  else if (!soap_tag_cmp(key, "Authorization"))
17229  {
17230  if (!soap_tag_cmp(val, "Basic *"))
17231  {
17232  int n;
17233  char *s;
17234  soap_base642s(soap, val + 6, soap->tmpbuf, sizeof(soap->tmpbuf) - 1, &n);
17235  soap->tmpbuf[n] = '\0';
17236 
17237  if ((s = strchr(soap->tmpbuf, ':')))
17238  {
17239  *s = '\0';
17240  soap->userid = soap_strdup(soap, soap->tmpbuf);
17241  soap->passwd = soap_strdup(soap, s + 1);
17242  }
17243  }
17244  }
17245  else if (!soap_tag_cmp(key, "WWW-Authenticate"))
17246  {
17247  soap->authrealm = soap_strdup(soap, soap_get_header_attribute(soap, val + 6, "realm"));
17248  }
17249  else if (!soap_tag_cmp(key, "Expect"))
17250  {
17251  if (!soap_tag_cmp(val, "100-continue"))
17252  {
17253  if ((soap->error = soap->fposthdr(soap, "HTTP/1.1 100 Continue", NULL))
17254  || (soap->error = soap->fposthdr(soap, NULL, NULL)))
17255  return soap->error;
17256  }
17257  }
17258 
17259 #endif
17260  else if (!soap_tag_cmp(key, "SOAPAction"))
17261  {
17262  if (*val == '"')
17263  {
17264  soap->action = soap_strdup(soap, val + 1);
17265  soap->action[strlen(soap->action) - 1] = '\0';
17266  }
17267  else
17268  soap->action = soap_strdup(soap, val);
17269  }
17270  else if (!soap_tag_cmp(key, "Location"))
17271  {
17272  strncpy(soap->endpoint, val, sizeof(soap->endpoint));
17273  soap->endpoint[sizeof(soap->endpoint) - 1] = '\0';
17274  }
17275  else if (!soap_tag_cmp(key, "X-Forwarded-For"))
17276  {
17277  soap->proxy_from = soap_strdup(soap, val);
17278  }
17279 
17280 #ifdef WITH_COOKIES
17281  else if (!soap_tag_cmp(key, "Cookie")
17282  || !soap_tag_cmp(key, "Cookie2")
17283  || !soap_tag_cmp(key, "Set-Cookie")
17284  || !soap_tag_cmp(key, "Set-Cookie2"))
17285  {
17286  soap_getcookies(soap, val);
17287  }
17288 
17289 #endif
17290  return SOAP_OK;
17291  }
char tmpbuf[1024]
Definition: stdsoap2.h:1712
short keep_alive
Definition: stdsoap2.h:1742
int error
Definition: stdsoap2.h:1755
char * action
Definition: stdsoap2.h:1737
soap_mode imode
Definition: stdsoap2.h:1602
int soap_tag_cmp(const char *s, const char *t)
Definition: stdsoap2.cpp:3657
#define SOAP_IO
Definition: stdsoap2.h:1086
#define SOAP_ZLIB_NONE
Definition: stdsoap2.h:1077
#define SOAP_ZLIB_DEFLATE
Definition: stdsoap2.h:1078
#define SOAP_ZLIB_GZIP
Definition: stdsoap2.h:1080
char * authrealm
Definition: stdsoap2.h:1738
#define SOAP_IO_CHUNK
Definition: stdsoap2.h:1090
#define soap_strtoul(s, t, b)
Definition: stdsoap2.h:1925
const char * soap_base642s(struct soap *soap, const char *s, char *t, size_t l, int *n)
Definition: stdsoap2.cpp:18039
const char * http_content
Definition: stdsoap2.h:1608
int(* fposthdr)(struct soap *, const char *, const char *)
Definition: stdsoap2.h:1644
const char * start
Definition: stdsoap2.h:1411
const char * proxy_from
Definition: stdsoap2.h:1753
char * boundary
Definition: stdsoap2.h:1410
#define SOAP_OK
Definition: stdsoap2.h:995
short zlib_in
Definition: stdsoap2.h:1826
const char * soap_get_header_attribute(struct soap *soap, const char *line, const char *key)
Definition: stdsoap2.cpp:17301
char * userid
Definition: stdsoap2.h:1636
size_t length
Definition: stdsoap2.h:1706
#define SOAP_ZLIB_ERROR
Definition: stdsoap2.h:1026
struct soap_mime mime
Definition: stdsoap2.h:1761
char * soap_strdup(struct soap *soap, const char *s)
Definition: stdsoap2.cpp:2688
#define SOAP_ENC_DIME
Definition: stdsoap2.h:1099
char endpoint[(1024)]
Definition: stdsoap2.h:1734
#define SOAP_ENC_MIME
Definition: stdsoap2.h:1100
char * passwd
Definition: stdsoap2.h:1637
short zlib_out
Definition: stdsoap2.h:1827
#define SOAP_ENC_SSL
Definition: stdsoap2.h:1103
static int http_post ( struct soap soap,
const char *  endpoint,
const char *  host,
int  port,
const char *  path,
const char *  action,
size_t  count 
)
static

Definition at line 18394 of file stdsoap2.cpp.

References soap::error, soap::fposthdr, soap::http_version, if(), soap::passwd, soap::port, soap::proxy_host, soap::proxy_passwd, soap::proxy_userid, SOAP_EOM, SOAP_GET, SOAP_OK, soap_puthttphdr(), soap_s2base64(), SOAP_STR_EOS, soap_tag_cmp(), soap::ssl, soap::status, soap::tmpbuf, soap::userid, and soap::version.

Referenced by soap_done(), and soap_init().

18395  {
18396  register const char *s;
18397  register int err;
18398 
18399  if (soap->status == SOAP_GET)
18400  s = "GET";
18401  else
18402  s = "POST";
18403 
18404 #ifdef PALM
18405 
18406  if (!endpoint || (soap_tag_cmp(endpoint, "http:*") && soap_tag_cmp(endpoint, "https:*") && strncmp(endpoint, "httpg:", 6)) && strncmp(endpoint, "_beam:", 6) && strncmp(endpoint, "_local:", 7) && strncmp(endpoint, "_btobex:", 8))
18407 #else
18408  if (!endpoint || (soap_tag_cmp(endpoint, "http:*") && soap_tag_cmp(endpoint, "https:*") && strncmp(endpoint, "httpg:", 6)))
18409 #endif
18410  return SOAP_OK;
18411 
18412  if (strlen(endpoint) + strlen(soap->http_version) > sizeof(soap->tmpbuf) - 80)
18413  return soap->error = SOAP_EOM;
18414 
18415  if (soap->proxy_host && soap_tag_cmp(endpoint, "https:*"))
18416  sprintf(soap->tmpbuf, "%s %s HTTP/%s", s, endpoint, soap->http_version);
18417  else
18418  sprintf(soap->tmpbuf, "%s /%s HTTP/%s", s, (*path == '/' ? path + 1 : path), soap->http_version);
18419 
18420  if ((err = soap->fposthdr(soap, soap->tmpbuf, NULL)))
18421  return err;
18422 
18423 #ifdef WITH_OPENSSL
18424 
18425  if ((soap->ssl && soap->port != 443) || (!soap->ssl && soap->port != 80))
18426  sprintf(soap->tmpbuf, "%s:%d", host, port);
18427  else
18428  strcpy(soap->tmpbuf, host);
18429 
18430 #else
18431 
18432  if (port != 80)
18433  sprintf(soap->tmpbuf, "%s:%d", host, port);
18434  else
18435  strcpy(soap->tmpbuf, host);
18436 
18437 #endif
18438 
18439  if ((err = soap->fposthdr(soap, "Host", soap->tmpbuf))
18440  || (err = soap->fposthdr(soap, "User-Agent", "gSOAP/2.7"))
18441  || (err = soap_puthttphdr(soap, SOAP_OK, count)))
18442  return err;
18443 
18444 #ifdef WITH_ZLIB
18445 #ifdef WITH_GZIP
18446 
18447  if ((err = soap->fposthdr(soap, "Accept-Encoding", "gzip, deflate")))
18448 #else
18449  if ((err = soap->fposthdr(soap, "Accept-Encoding", "deflate")))
18450 #endif
18451  return err;
18452 
18453 #endif
18454 #ifndef WITH_LEAN
18455 
18456  if (soap->userid && soap->passwd && strlen(soap->userid) + strlen(soap->passwd) < 761)
18457  {
18458  sprintf(soap->tmpbuf + 262, "%s:%s", soap->userid, soap->passwd);
18459  strcpy(soap->tmpbuf, "Basic ");
18460  soap_s2base64(soap, (const unsigned char*)(soap->tmpbuf + 262), soap->tmpbuf + 6, (int)strlen(soap->tmpbuf + 262));
18461 
18462  if ((err = soap->fposthdr(soap, "Authorization", soap->tmpbuf)))
18463  return err;
18464  }
18465 
18466  if (soap->proxy_userid && soap->proxy_passwd && strlen(soap->proxy_userid) + strlen(soap->proxy_passwd) < 761)
18467  {
18468  sprintf(soap->tmpbuf + 262, "%s:%s", soap->proxy_userid, soap->proxy_passwd);
18469  strcpy(soap->tmpbuf, "Basic ");
18470  soap_s2base64(soap, (const unsigned char*)(soap->tmpbuf + 262), soap->tmpbuf + 6, (int)strlen(soap->tmpbuf + 262));
18471 
18472  if ((err = soap->fposthdr(soap, "Proxy-Authorization", soap->tmpbuf)))
18473  return err;
18474  }
18475 
18476 #endif
18477 #ifdef WITH_COOKIES
18478 #ifdef WITH_OPENSSL
18479 
18480  if (soap_putcookies(soap, host, path, soap->ssl != NULL))
18481  return soap->error;
18482 
18483 #else
18484 
18485  if (soap_putcookies(soap, host, path, 0))
18486  return soap->error;
18487 
18488 #endif
18489 #endif
18490 
18491  if (soap->status != SOAP_GET && (soap->version == 1 || (action && *action)))
18492  {
18493  sprintf(soap->tmpbuf, "\"%s\"", action && strlen(action) < sizeof(soap->tmpbuf) - 3 ? action : SOAP_STR_EOS);
18494 
18495  if ((err = soap->fposthdr(soap, "SOAPAction", soap->tmpbuf)))
18496  return err;
18497  }
18498 
18499  return soap->fposthdr(soap, NULL, NULL);
18500  }
char tmpbuf[1024]
Definition: stdsoap2.h:1712
int error
Definition: stdsoap2.h:1755
const char * http_version
Definition: stdsoap2.h:1607
short version
Definition: stdsoap2.h:1600
int soap_tag_cmp(const char *s, const char *t)
Definition: stdsoap2.cpp:3657
const char * proxy_host
Definition: stdsoap2.h:1749
#define SOAP_GET
Definition: stdsoap2.h:1064
int(* fposthdr)(struct soap *, const char *, const char *)
Definition: stdsoap2.h:1644
int soap_puthttphdr(struct soap *soap, int status, size_t count)
Definition: stdsoap2.cpp:18241
void * ssl
Definition: stdsoap2.h:1799
const char * proxy_userid
Definition: stdsoap2.h:1751
const char * proxy_passwd
Definition: stdsoap2.h:1752
int port
Definition: stdsoap2.h:1741
#define SOAP_OK
Definition: stdsoap2.h:995
#define SOAP_STR_EOS
Definition: stdsoap2.cpp:310
int status
Definition: stdsoap2.h:1754
char * userid
Definition: stdsoap2.h:1636
#define SOAP_EOM
Definition: stdsoap2.h:1015
if(!yymsg) yymsg
char * soap_s2base64(struct soap *soap, const unsigned char *s, char *t, int n)
Definition: stdsoap2.cpp:17979
char * passwd
Definition: stdsoap2.h:1637
static int http_post_header ( struct soap soap,
const char *  key,
const char *  val 
)
static

Definition at line 18535 of file stdsoap2.cpp.

References soap::error, http_send_header(), and soap_send_raw().

Referenced by soap_done(), and soap_init().

18536  {
18537  if (key)
18538  {
18539  if (http_send_header(soap, key))
18540  return soap->error;
18541 
18542  if (val && (soap_send_raw(soap, ": ", 2) || http_send_header(soap, val)))
18543  return soap->error;
18544  }
18545 
18546  return soap_send_raw(soap, "\r\n", 2);
18547  }
static int http_send_header(struct soap *, const char *)
Definition: stdsoap2.cpp:18508
int error
Definition: stdsoap2.h:1755
int soap_send_raw(struct soap *soap, const char *s, size_t n)
Definition: stdsoap2.cpp:815
static int http_put ( struct soap soap)
static

Definition at line 18361 of file stdsoap2.cpp.

References SOAP_PUT_METHOD.

Referenced by soap_done(), and soap_init().

18362  {
18363  return SOAP_PUT_METHOD;
18364  }
#define SOAP_PUT_METHOD
Definition: stdsoap2.h:1011
static int http_response ( struct soap soap,
int  status,
size_t  count 
)
static

Definition at line 18555 of file stdsoap2.cpp.

References soap::authrealm, DBGLOG, soap::endpoint, soap::error, soap::fposthdr, http_error(), soap::http_version, soap::master, soap::omode, SOAP_EOM, soap_faultcode(), SOAP_FILE, SOAP_HTML, SOAP_IO, SOAP_IO_CHUNK, soap_puthttphdr(), soap_valid_socket, soap::socket, soap::tmpbuf, and soap::version.

Referenced by soap_done(), and soap_init().

18556  {
18557  register int err;
18558 #ifdef WMW_RPM_IO
18559 
18560  if (soap->rpmreqid)
18561  httpOutputEnable(soap->rpmreqid);
18562 
18563 #endif
18564 
18565  if (strlen(soap->http_version) > 4)
18566  return soap->error = SOAP_EOM;
18567 
18568  if (!status || status == SOAP_HTML || status == SOAP_FILE)
18569  {
18570  const char *s;
18571 
18572  if (count || ((soap->omode & SOAP_IO) == SOAP_IO_CHUNK))
18573  s = "200 OK";
18574  else
18575  s = "202 ACCEPTED";
18576 
18577  DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Status = %s\n", s));
18578 #ifdef WMW_RPM_IO
18579 
18580  if (soap->rpmreqid || soap_valid_socket(soap->master) || soap_valid_socket(soap->socket)) /* RPM behaves as if standalone */
18581 #else
18582  if (soap_valid_socket(soap->master) || soap_valid_socket(soap->socket)) /* standalone application */
18583 #endif
18584  {sprintf(soap->tmpbuf, "HTTP/%s %s", soap->http_version, s);
18585 
18586  if ((err = soap->fposthdr(soap, soap->tmpbuf, NULL)))
18587  return err;
18588  }
18589  else if ((err = soap->fposthdr(soap, "Status", s)))
18590  return err;
18591  }
18592  else if (status >= 200 && status < 600)
18593  {
18594  sprintf(soap->tmpbuf, "HTTP/%s %d %s", soap->http_version, status, http_error(soap, status));
18595 
18596  if ((err = soap->fposthdr(soap, soap->tmpbuf, NULL)))
18597  return err;
18598 
18599 #ifndef WITH_LEAN
18600 
18601  if (status == 401)
18602  {
18603  sprintf(soap->tmpbuf, "Basic realm=\"%s\"", (soap->authrealm && strlen(soap->authrealm) < sizeof(soap->tmpbuf) - 14) ? soap->authrealm : "gSOAP Web Service");
18604 
18605  if ((err = soap->fposthdr(soap, "WWW-Authenticate", soap->tmpbuf)))
18606  return err;
18607  }
18608  else if ((status >= 301 && status <= 303) || status == 307)
18609  {
18610  if ((err = soap->fposthdr(soap, "Location", soap->endpoint)))
18611  return err;
18612  }
18613 
18614 #endif
18615  }
18616  else
18617  {
18618  const char *s = *soap_faultcode(soap);
18619 
18620  if (soap->version == 2 && (!s || !strcmp(s, "SOAP-ENV:Sender")))
18621  s = "400 Bad Request";
18622  else
18623  s = "500 Internal Server Error";
18624 
18625  DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Error %s (status=%d)\n", s, status));
18626 #ifdef WMW_RPM_IO
18627 
18628  if (soap->rpmreqid || soap_valid_socket(soap->master) || soap_valid_socket(soap->socket)) /* RPM behaves as if standalone */
18629 #else
18630  if (soap_valid_socket(soap->master) || soap_valid_socket(soap->socket)) /* standalone application */
18631 #endif
18632  {sprintf(soap->tmpbuf, "HTTP/%s %s", soap->http_version, s);
18633 
18634  if ((err = soap->fposthdr(soap, soap->tmpbuf, NULL)))
18635  return err;
18636  }
18637  else if ((err = soap->fposthdr(soap, "Status", s))) /* CGI */
18638  return err;
18639  }
18640 
18641  if ((err = soap->fposthdr(soap, "Server", "gSOAP/2.7"))
18642  || (err = soap_puthttphdr(soap, status, count)))
18643  return err;
18644 
18645 #ifdef WITH_COOKIES
18646 
18647  if (soap_putsetcookies(soap))
18648  return soap->error;
18649 
18650 #endif
18651  return soap->fposthdr(soap, NULL, NULL);
18652  }
char tmpbuf[1024]
Definition: stdsoap2.h:1712
#define SOAP_FILE
Definition: stdsoap2.h:1059
int error
Definition: stdsoap2.h:1755
#define soap_valid_socket(n)
Definition: stdsoap2.h:698
const char * http_version
Definition: stdsoap2.h:1607
short version
Definition: stdsoap2.h:1600
#define SOAP_IO
Definition: stdsoap2.h:1086
#define DBGLOG(DBGFILE, CMD)
Definition: stdsoap2.h:1247
static const char * http_error(struct soap *, int)
Definition: stdsoap2.cpp:4540
char * authrealm
Definition: stdsoap2.h:1738
#define SOAP_IO_CHUNK
Definition: stdsoap2.h:1090
int master
Definition: stdsoap2.h:1683
soap_mode omode
Definition: stdsoap2.h:1603
int(* fposthdr)(struct soap *, const char *, const char *)
Definition: stdsoap2.h:1644
int soap_puthttphdr(struct soap *soap, int status, size_t count)
Definition: stdsoap2.cpp:18241
const char ** soap_faultcode(struct soap *soap)
Definition: soapC.cpp:111
#define SOAP_HTML
Definition: stdsoap2.h:1058
#define SOAP_EOM
Definition: stdsoap2.h:1015
int socket
Definition: stdsoap2.h:1684
char endpoint[(1024)]
Definition: stdsoap2.h:1734
static int http_send_header ( struct soap soap,
const char *  s 
)
static

Definition at line 18508 of file stdsoap2.cpp.

References soap::error, SOAP_OK, and soap_send_raw().

Referenced by http_post_header().

18509  {
18510  register const char *t;
18511 
18512  do
18513  {
18514  t = strchr(s, '\n'); /* disallow \n in HTTP headers */
18515 
18516  if (!t)
18517  t = s + strlen(s);
18518 
18519  if (soap_send_raw(soap, s, t - s))
18520  return soap->error;
18521 
18522  s = t + 1;
18523  }
18524  while (*t);
18525 
18526  return SOAP_OK;
18527  }
int error
Definition: stdsoap2.h:1755
int soap_send_raw(struct soap *soap, const char *s, size_t n)
Definition: stdsoap2.cpp:815
#define SOAP_OK
Definition: stdsoap2.h:995
int soap_accept ( struct soap soap)

Definition at line 5779 of file stdsoap2.cpp.

References soap::accept_flags, soap::accept_timeout, DBGLOG, soap::errmode, soap::errnum, soap::error, soap::faccept, soap::host, soap::imode, soap::ip, soap::keep_alive, soap::linger_time, soap::master, soap::omode, soap::peer, soap::peerlen, soap::port, soap::recv_timeout, soap::send_timeout, SOAP_BUFLEN, soap_closesock(), SOAP_EAGAIN, SOAP_EINTR, SOAP_EWOULDBLOCK, SOAP_FD_EXCEEDED, SOAP_INVALID_SOCKET, SOAP_IO_KEEPALIVE, SOAP_IO_UDP, SOAP_OK, soap_set_receiver_error(), soap_set_sender_error(), SOAP_SOCKBLOCK, soap_socket_errno, SOAP_SOCKNONBLOCK, SOAP_TCP_ERROR, soap_valid_socket, soap::socket, and tcp_error().

5780  {
5781  int n = (int)sizeof(soap->peer);
5782 #ifndef WITH_LEAN
5783  int len = SOAP_BUFLEN;
5784  int set = 1;
5785 #endif
5786  soap->error = SOAP_OK;
5787 #ifndef WITH_LEAN
5788 
5789  if ((soap->omode & SOAP_IO_UDP))
5790  return soap->socket = soap->master;
5791 
5792 #endif
5793  memset((void*)&soap->peer, 0, sizeof(soap->peer));
5794  soap->socket = SOAP_INVALID_SOCKET;
5795  soap->errmode = 0;
5796  soap->keep_alive = 0;
5797 
5798  if (soap_valid_socket(soap->master))
5799  {
5800  register int err;
5801 
5802  for (;;)
5803  {
5804 #ifndef WITH_LEAN
5805 
5806  if (soap->accept_timeout || soap->send_timeout || soap->recv_timeout)
5807  {
5808 #ifndef WIN32
5809 
5810  if ((int)soap->socket >= (int)FD_SETSIZE)
5811  {
5812  soap->error = SOAP_FD_EXCEEDED;
5813  return SOAP_INVALID_SOCKET; /* Hint: MUST increase FD_SETSIZE */
5814  }
5815 
5816 #endif
5817 
5818  for (;;)
5819  {
5820  struct timeval timeout;
5821  fd_set fd;
5822  register int r;
5823 
5824  if (soap->accept_timeout > 0)
5825  {
5826  timeout.tv_sec = soap->accept_timeout;
5827  timeout.tv_usec = 0;
5828  }
5829  else if (soap->accept_timeout < 0)
5830  {
5831  timeout.tv_sec = -soap->accept_timeout / 1000000;
5832  timeout.tv_usec = -soap->accept_timeout % 1000000;
5833  }
5834  else
5835  {
5836  timeout.tv_sec = 60;
5837  timeout.tv_usec = 0;
5838  }
5839 
5840  FD_ZERO(&fd);
5841  FD_SET(soap->master, &fd);
5842  r = select((int)soap->master + 1, &fd, &fd, &fd, &timeout);
5843 
5844  if (r > 0)
5845  break;
5846 
5847  if (!r && soap->accept_timeout)
5848  {
5849  soap->errnum = 0;
5850  soap_set_receiver_error(soap, "Timeout", "accept failed in soap_accept()", SOAP_TCP_ERROR);
5851  return SOAP_INVALID_SOCKET;
5852  }
5853 
5854  if (r < 0)
5855  {
5856  r = soap_socket_errno(soap->master);
5857 
5858  if (r != SOAP_EINTR)
5859  {
5860  soap->errnum = r;
5861  soap_closesock(soap);
5862  soap_set_sender_error(soap, tcp_error(soap), "accept failed in soap_accept()", SOAP_TCP_ERROR);
5863  return SOAP_INVALID_SOCKET;
5864  }
5865  }
5866  }
5867  }
5868 
5869  if (soap->accept_timeout || soap->send_timeout || soap->recv_timeout)
5870  SOAP_SOCKNONBLOCK(soap->master)
5871  else
5872  SOAP_SOCKBLOCK(soap->master)
5873 #endif
5874  soap->socket = soap->faccept(soap, soap->master, (struct sockaddr*) & soap->peer, &n);
5875 
5876  soap->peerlen = (size_t)n;
5877 
5878  if (soap_valid_socket(soap->socket))
5879  {
5880 #ifdef WITH_IPV6
5881  /* Use soap->host to store the numeric form of the remote host */
5882  getnameinfo((struct sockaddr*)&soap->peer, n, soap->host, sizeof(soap->host), NULL, 0, NI_NUMERICHOST | NI_NUMERICSERV);
5883  DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Accept socket %d from %s\n", soap->socket, soap->host));
5884  soap->ip = 0; /* info stored in soap->peer and soap->host */
5885  soap->port = 0; /* info stored in soap->peer and soap->host */
5886 #else
5887  soap->ip = ntohl(soap->peer.sin_addr.s_addr);
5888  soap->port = (int)ntohs(soap->peer.sin_port); /* does not return port number on some systems */
5889  DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Accept socket %d at port %d from IP %d.%d.%d.%d\n", soap->socket, soap->port, (int)(soap->ip >> 24)&0xFF, (int)(soap->ip >> 16)&0xFF, (int)(soap->ip >> 8)&0xFF, (int)soap->ip&0xFF));
5890 #endif
5891 #ifndef WITH_LEAN
5892 
5893  if (soap->accept_flags == SO_LINGER)
5894  {
5895  struct linger linger;
5896  memset((void*)&linger, 0, sizeof(linger));
5897  linger.l_onoff = 1;
5898  linger.l_linger = soap->linger_time;
5899 
5900  if (setsockopt(soap->socket, SOL_SOCKET, SO_LINGER, (char*)&linger, sizeof(struct linger)))
5901  {
5902  soap->errnum = soap_socket_errno(soap->socket);
5903  soap_set_receiver_error(soap, tcp_error(soap), "setsockopt SO_LINGER failed in soap_accept()", SOAP_TCP_ERROR);
5904  soap_closesock(soap);
5905  return SOAP_INVALID_SOCKET;
5906  }
5907  }
5908  else if (soap->accept_flags && setsockopt(soap->socket, SOL_SOCKET, soap->accept_flags, (char*)&set, sizeof(int)))
5909  {
5910  soap->errnum = soap_socket_errno(soap->socket);
5911  soap_set_receiver_error(soap, tcp_error(soap), "setsockopt failed in soap_accept()", SOAP_TCP_ERROR);
5912  soap_closesock(soap);
5913  return SOAP_INVALID_SOCKET;
5914  }
5915 
5916  if (((soap->imode | soap->omode) & SOAP_IO_KEEPALIVE) && setsockopt(soap->socket, SOL_SOCKET, SO_KEEPALIVE, (char*)&set, sizeof(int)))
5917  {
5918  soap->errnum = soap_socket_errno(soap->socket);
5919  soap_set_receiver_error(soap, tcp_error(soap), "setsockopt SO_KEEPALIVE failed in soap_accept()", SOAP_TCP_ERROR);
5920  soap_closesock(soap);
5921  return SOAP_INVALID_SOCKET;
5922  }
5923 
5924  if (setsockopt(soap->socket, SOL_SOCKET, SO_SNDBUF, (char*)&len, sizeof(int)))
5925  {
5926  soap->errnum = soap_socket_errno(soap->socket);
5927  soap_set_receiver_error(soap, tcp_error(soap), "setsockopt SO_SNDBUF failed in soap_accept()", SOAP_TCP_ERROR);
5928  soap_closesock(soap);
5929  return SOAP_INVALID_SOCKET;
5930  }
5931 
5932  if (setsockopt(soap->socket, SOL_SOCKET, SO_RCVBUF, (char*)&len, sizeof(int)))
5933  {
5934  soap->errnum = soap_socket_errno(soap->socket);
5935  soap_set_receiver_error(soap, tcp_error(soap), "setsockopt SO_RCVBUF failed in soap_accept()", SOAP_TCP_ERROR);
5936  soap_closesock(soap);
5937  return SOAP_INVALID_SOCKET;
5938  }
5939 
5940 #ifdef TCP_NODELAY
5941 
5942  if (!(soap->omode & SOAP_IO_UDP) && setsockopt(soap->socket, IPPROTO_TCP, TCP_NODELAY, (char*)&set, sizeof(int)))
5943  {
5944  soap->errnum = soap_socket_errno(soap->socket);
5945  soap_set_receiver_error(soap, tcp_error(soap), "setsockopt TCP_NODELAY failed in soap_accept()", SOAP_TCP_ERROR);
5946  soap_closesock(soap);
5947  return SOAP_INVALID_SOCKET;
5948  }
5949 
5950 #endif
5951 #endif
5952  soap->keep_alive = (((soap->imode | soap->omode) & SOAP_IO_KEEPALIVE) != 0);
5953  return soap->socket;
5954  }
5955 
5956  err = soap_socket_errno(soap->socket);
5957 
5958  if (err != 0 && err != SOAP_EINTR && err != SOAP_EAGAIN && err != SOAP_EWOULDBLOCK)
5959  {
5960  DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Accept failed from %s\n", soap->host));
5961  soap->errnum = err;
5962  soap_set_receiver_error(soap, tcp_error(soap), "accept failed in soap_accept()", SOAP_TCP_ERROR);
5963  soap_closesock(soap);
5964  return SOAP_INVALID_SOCKET;
5965  }
5966  }
5967  }
5968  else
5969  {
5970  soap->errnum = 0;
5971  soap_set_receiver_error(soap, tcp_error(soap), "no master socket in soap_accept()", SOAP_TCP_ERROR);
5972  return SOAP_INVALID_SOCKET;
5973  }
5974  }
#define soap_socket_errno(s)
Definition: stdsoap2.h:803
short keep_alive
Definition: stdsoap2.h:1742
int error
Definition: stdsoap2.h:1755
#define SOAP_SOCKNONBLOCK(fd)
Definition: stdsoap2.cpp:274
unsigned long ip
Definition: stdsoap2.h:1740
#define soap_valid_socket(n)
Definition: stdsoap2.h:698
int(* faccept)(struct soap *, int, struct sockaddr *, int *n)
Definition: stdsoap2.h:1655
soap_mode imode
Definition: stdsoap2.h:1602
#define SOAP_EWOULDBLOCK
Definition: stdsoap2.h:785
#define SOAP_BUFLEN
Definition: stdsoap2.h:814
#define FD_SETSIZE
Definition: stdsoap2.h:705
#define SOAP_IO_UDP
Definition: stdsoap2.h:1092
int accept_timeout
Definition: stdsoap2.h:1615
#define DBGLOG(DBGFILE, CMD)
Definition: stdsoap2.h:1247
#define SOAP_EAGAIN
Definition: stdsoap2.h:779
int errmode
Definition: stdsoap2.h:1756
int soap_set_receiver_error(struct soap *soap, const char *faultstring, const char *faultdetailXML, int soaperror)
Definition: stdsoap2.cpp:19218
int master
Definition: stdsoap2.h:1683
soap_mode omode
Definition: stdsoap2.h:1603
int send_timeout
Definition: stdsoap2.h:1613
size_t peerlen
Definition: stdsoap2.h:1787
int soap_set_sender_error(struct soap *soap, const char *faultstring, const char *faultdetailXML, int soaperror)
Definition: stdsoap2.cpp:19207
static const char * tcp_error(struct soap *)
Definition: stdsoap2.cpp:4506
#define SOAP_SOCKBLOCK(fd)
Definition: stdsoap2.cpp:273
struct sockaddr_in peer
Definition: stdsoap2.h:1784
int errnum
Definition: stdsoap2.h:1757
char host[(1024)]
Definition: stdsoap2.h:1736
int recv_timeout
Definition: stdsoap2.h:1612
int port
Definition: stdsoap2.h:1741
int soap_closesock(struct soap *soap)
Definition: stdsoap2.cpp:6121
#define SOAP_INVALID_SOCKET
Definition: stdsoap2.h:697
#define SOAP_OK
Definition: stdsoap2.h:995
#define SOAP_TCP_ERROR
Definition: stdsoap2.h:1023
unsigned short linger_time
Definition: stdsoap2.h:1620
int socket
Definition: stdsoap2.h:1684
#define SOAP_IO_KEEPALIVE
Definition: stdsoap2.h:1095
#define SOAP_FD_EXCEEDED
Definition: stdsoap2.h:1041
int accept_flags
Definition: stdsoap2.h:1619
#define SOAP_EINTR
Definition: stdsoap2.h:778
int soap_append_lab ( struct soap soap,
const char *  s,
size_t  n 
)

Definition at line 10289 of file stdsoap2.cpp.

References DBGLOG, soap::error, soap::labbuf, soap::labidx, soap::lablen, SOAP_EOM, SOAP_FREE, SOAP_LABLEN, SOAP_MALLOC, and SOAP_OK.

Referenced by soap_get_http_body(), soap_getbase64(), soap_gethex(), soap_peek_element(), soap_QName2s(), soap_s2QName(), soap_store_lab(), and soap_string_in().

10290  {
10291  if (soap->labidx + n >= soap->lablen)
10292  {
10293  register char *t = soap->labbuf;
10294  DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Enlarging look-aside buffer to append data, old size=%lu", (unsigned long)soap->lablen));
10295 
10296  if (soap->lablen == 0)
10297  soap->lablen = SOAP_LABLEN;
10298 
10299  while (soap->labidx + n >= soap->lablen)
10300  soap->lablen <<= 1;
10301 
10302  DBGLOG(TEST, SOAP_MESSAGE(fdebug, ", new size=%lu\n", (unsigned long)soap->lablen));
10303  soap->labbuf = (char*)SOAP_MALLOC(soap, soap->lablen);
10304 
10305  if (!soap->labbuf)
10306  {
10307  if (t)
10308  SOAP_FREE(soap, t);
10309 
10310  return soap->error = SOAP_EOM;
10311  }
10312 
10313  if (t)
10314  {
10315  memcpy(soap->labbuf, t, soap->labidx);
10316  SOAP_FREE(soap, t);
10317  }
10318  }
10319 
10320  if (s)
10321  {
10322  memcpy(soap->labbuf + soap->labidx, s, n);
10323  soap->labidx += n;
10324  }
10325 
10326  return SOAP_OK;
10327  }
size_t lablen
Definition: stdsoap2.h:1708
#define SOAP_LABLEN
Definition: stdsoap2.h:820
int error
Definition: stdsoap2.h:1755
#define DBGLOG(DBGFILE, CMD)
Definition: stdsoap2.h:1247
#define SOAP_MALLOC(soap, size)
Definition: stdsoap2.h:1190
size_t labidx
Definition: stdsoap2.h:1709
char * labbuf
Definition: stdsoap2.h:1707
#define SOAP_OK
Definition: stdsoap2.h:995
#define SOAP_EOM
Definition: stdsoap2.h:1015
#define SOAP_FREE(soap, ptr)
Definition: stdsoap2.h:1194
int soap_array_begin_out ( struct soap soap,
const char *  tag,
int  id,
const char *  type,
const char *  offset 
)

Definition at line 9404 of file stdsoap2.cpp.

References soap::error, soap::mode, soap_attribute(), soap_element(), soap_element_begin_out(), soap_element_start_end_out(), soap_strrchr, soap_utilize_ns(), SOAP_XML_CANONICAL, soap::tmpbuf, and soap::version.

Referenced by soap_out_ArrayOf_USCORExsd_USCOREstring().

9405  {
9406  if (!type || !*type)
9407  return soap_element_begin_out(soap, tag, id, NULL);
9408 
9409  if (soap_element(soap, tag, id, "SOAP-ENC:Array"))
9410  return soap->error;
9411 
9412  if (soap->version == 2)
9413  {
9414  const char *s;
9415  s = soap_strrchr(type, '[');
9416 
9417  if ((size_t)(s - type) < sizeof(soap->tmpbuf))
9418  {
9419  strncpy(soap->tmpbuf, type, s - type);
9420  soap->tmpbuf[s - type] = '\0';
9421 
9422  if (soap_attribute(soap, "SOAP-ENC:itemType", soap->tmpbuf))
9423  return soap->error;
9424 
9425  if (s && (soap_attribute(soap, "SOAP-ENC:arraySize", s + 1)))
9426  return soap->error;
9427  }
9428  }
9429  else
9430  {
9431  if (offset && soap_attribute(soap, "SOAP-ENC:offset", offset))
9432  return soap->error;
9433 
9434  if (soap_attribute(soap, "SOAP-ENC:arrayType", type))
9435  return soap->error;
9436  }
9437 
9438 #ifndef WITH_LEAN
9439 
9440  if ((soap->mode & SOAP_XML_CANONICAL))
9441  {
9442  const char *s = strchr(type, ':');
9443 
9444  if (s)
9445  soap_utilize_ns(soap, type, s - type);
9446  }
9447 
9448 #endif
9449  return soap_element_start_end_out(soap, NULL);
9450  }
char tmpbuf[1024]
Definition: stdsoap2.h:1712
int soap_element(struct soap *soap, const char *tag, int id, const char *type)
Definition: stdsoap2.cpp:9009
int error
Definition: stdsoap2.h:1755
soap_mode mode
Definition: stdsoap2.h:1601
short version
Definition: stdsoap2.h:1600
#define SOAP_XML_CANONICAL
Definition: stdsoap2.h:1109
int soap_element_start_end_out(struct soap *soap, const char *tag)
Definition: stdsoap2.cpp:9458
int soap_element_begin_out(struct soap *soap, const char *tag, int id, const char *type)
Definition: stdsoap2.cpp:9244
#define soap_strrchr(s, t)
Definition: stdsoap2.h:1913
static void soap_utilize_ns(struct soap *soap, const char *tag, size_t n)
Definition: stdsoap2.cpp:8976
int soap_attribute(struct soap *soap, const char *name, const char *value)
Definition: stdsoap2.cpp:9802
int soap_array_pointer_lookup ( struct soap soap,
const void p,
const struct soap_array a,
int  n,
int  type,
struct soap_plist **  ppp 
)

Definition at line 6383 of file stdsoap2.cpp.

References soap_array::__ptr, soap_array::__size, soap_plist::array, DBGLOG, soap_plist::id, soap_plist::next, soap::pht, soap_hash_ptr, and soap_plist::type.

Referenced by soap_array_reference(), soap_attachment(), soap_element_id(), and soap_embed().

6384  {
6385  register struct soap_plist *pp;
6386  *ppp = NULL;
6387 
6388  if (!p || !a->__ptr)
6389  return 0;
6390 
6391  for (pp = soap->pht[soap_hash_ptr(a->__ptr)]; pp; pp = pp->next)
6392  {
6393  if (pp->type == type && pp->array && pp->array->__ptr == a->__ptr)
6394  {
6395  register int i;
6396 
6397  for (i = 0; i < n; i++)
6398  if (((const int*)&pp->array->__size)[i] != ((const int*)&a->__size)[i])
6399  break;
6400 
6401  if (i == n)
6402  {
6403  *ppp = pp;
6404  DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Array lookup location=%p type=%d id=%d\n", a->__ptr, type, pp->id));
6405  return pp->id;
6406  }
6407  }
6408  }
6409 
6410  DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Array lookup location=%p type=%d: not found\n", a->__ptr, type));
6411  return 0;
6412  }
struct soap_plist * next
Definition: stdsoap2.h:1296
#define DBGLOG(DBGFILE, CMD)
Definition: stdsoap2.h:1247
const struct soap_array * array
Definition: stdsoap2.h:1298
int __size
Definition: stdsoap2.h:1290
struct soap_plist * pht[(1024)]
Definition: stdsoap2.h:1628
#define soap_hash_ptr(p)
Definition: stdsoap2.cpp:124
void * __ptr
Definition: stdsoap2.h:1289
int soap_array_reference ( struct soap soap,
const void p,
const struct soap_array a,
int  n,
int  t 
)

Definition at line 6723 of file stdsoap2.cpp.

References soap_array::__ptr, DBGLOG, soap_plist::mark1, soap_plist::mark2, soap_array_pointer_lookup(), and soap_pointer_enter().

Referenced by ArrayOf_USCORExsd_USCOREstring::soap_serialize().

6724  {
6725  register int i;
6726  struct soap_plist *pp;
6727 
6728  if (!p || !a->__ptr)
6729  return 1;
6730 
6731  i = soap_array_pointer_lookup(soap, p, a, n, t, &pp);
6732 
6733  if (i)
6734  {
6735  if (pp->mark1 == 0)
6736  {
6737  pp->mark1 = 2;
6738  pp->mark2 = 2;
6739  }
6740  }
6741  else if (!soap_pointer_enter(soap, p, a, n, t, &pp))
6742  return 1;
6743  else
6744  {
6745  pp->mark1 = 0;
6746  pp->mark2 = 0;
6747  }
6748 
6749  DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Array reference %p ptr=%p dim=%d type=%d (%d %d)\n", p, a->__ptr, n, t, (int)pp->mark1, (int)pp->mark2));
6750  return pp->mark1;
6751  }
#define DBGLOG(DBGFILE, CMD)
Definition: stdsoap2.h:1247
char mark1
Definition: stdsoap2.h:1301
int soap_pointer_enter(struct soap *soap, const void *p, const struct soap_array *a, int n, int type, struct soap_plist **ppp)
Definition: stdsoap2.cpp:6336
int soap_array_pointer_lookup(struct soap *soap, const void *p, const struct soap_array *a, int n, int type, struct soap_plist **ppp)
Definition: stdsoap2.cpp:6383
void * __ptr
Definition: stdsoap2.h:1289
char mark2
Definition: stdsoap2.h:1302
int soap_attachment ( struct soap soap,
const char *  tag,
int  id,
const void p,
const struct soap_array a,
const char *  aid,
const char *  atype,
const char *  aoptions,
int  n,
const char *  type,
int  t 
)

Definition at line 6888 of file stdsoap2.cpp.

References soap_array::__ptr, soap_array::__size, DBGLOG, soap::dime, soap::dime_id_format, soap_multipart::encoding, soap::error, soap_dime::first, soap_mime::first, soap_multipart::id, soap_dime::last, soap_mime::last, soap_plist::mark1, soap_plist::mark2, soap::mime, soap::mode, soap_multipart::options, soap_array_pointer_lookup(), soap_element_begin_out(), soap_element_end_out(), soap_element_href(), soap_element_id(), SOAP_ENC_MTOM, SOAP_EOM, SOAP_IO_LENGTH, soap_malloc(), SOAP_MIME_BINARY, soap_new_multipart(), soap_pointer_enter(), SOAP_STR_EOS, soap_strdup(), soap::tmpbuf, and soap_multipart::type.

6889  {
6890 #ifndef WITH_NOIDREF
6891  struct soap_plist *pp;
6892  int i;
6893 
6894  if (!p || !a->__ptr || (!aid && !atype))
6895  return soap_element_id(soap, tag, id, p, a, n, type, t);
6896 
6897  DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Attachment tag='%s' id='%s' (%d) type='%s'\n", tag, aid ? aid : SOAP_STR_EOS, id, atype ? atype : SOAP_STR_EOS));
6898  i = soap_array_pointer_lookup(soap, p, a, n, t, &pp);
6899 
6900  if (!i)
6901  {
6902  i = soap_pointer_enter(soap, p, a, n, t, &pp);
6903 
6904  if (!i)
6905  {
6906  soap->error = SOAP_EOM;
6907  return - 1;
6908  }
6909  }
6910 
6911  if (id <= 0)
6912  id = i;
6913 
6914  if (!aid)
6915  {
6916  sprintf(soap->tmpbuf, soap->dime_id_format, id);
6917  aid = soap_strdup(soap, soap->tmpbuf);
6918  }
6919 
6920  /* Add MTOM xop:Include element when necessary */
6921 
6922  /* TODO: this code to be obsoleted with new import/xop.h conventions */
6923  if ((soap->mode & SOAP_ENC_MTOM) && strcmp(tag, "xop:Include"))
6924  {
6925  if (soap_element_begin_out(soap, tag, 0, type)
6926  || soap_element_href(soap, "xop:Include", 0, "href", aid)
6927  || soap_element_end_out(soap, tag))
6928  return soap->error;
6929  }
6930  else if (soap_element_href(soap, tag, 0, "href", aid))
6931  return soap->error;
6932 
6933  if (soap->mode & SOAP_IO_LENGTH)
6934  {
6935  if (pp->mark1 != 3)
6936  {
6937  struct soap_multipart *content;
6938 
6939  if (soap->mode & SOAP_ENC_MTOM)
6940  content = soap_new_multipart(soap, &soap->mime.first, &soap->mime.last, (char*)a->__ptr, a->__size);
6941  else
6942  content = soap_new_multipart(soap, &soap->dime.first, &soap->dime.last, (char*)a->__ptr, a->__size);
6943 
6944  if (!content)
6945  {
6946  soap->error = SOAP_EOM;
6947  return - 1;
6948  }
6949 
6950  if (!strncmp(aid, "cid:", 4)) /* RFC 2111 */
6951  {
6952  if (soap->mode & SOAP_ENC_MTOM)
6953  {
6954  char *s = (char*)soap_malloc(soap, strlen(aid) - 1);
6955 
6956  if (s)
6957  {
6958  *s = '<';
6959  strcpy(s + 1, aid + 4);
6960  strcat(s, ">");
6961  content->id = s;
6962  }
6963  }
6964  else
6965  content->id = aid + 4;
6966  }
6967  else
6968  content->id = aid;
6969 
6970  content->type = atype;
6971  content->options = aoptions;
6972  content->encoding = SOAP_MIME_BINARY;
6973  pp->mark1 = 3;
6974  }
6975  }
6976  else
6977  pp->mark2 = 3;
6978 
6979 #endif
6980  return - 1;
6981  }
char tmpbuf[1024]
Definition: stdsoap2.h:1712
const char * id
Definition: stdsoap2.h:1444
const char * dime_id_format
Definition: stdsoap2.h:1606
int error
Definition: stdsoap2.h:1755
struct soap_multipart * first
Definition: stdsoap2.h:1413
int soap_element_end_out(struct soap *soap, const char *tag)
Definition: stdsoap2.cpp:9588
soap_mode mode
Definition: stdsoap2.h:1601
struct soap_multipart * first
Definition: stdsoap2.h:1397
#define SOAP_ENC_MTOM
Definition: stdsoap2.h:1101
static struct soap_multipart * soap_new_multipart(struct soap *, struct soap_multipart **, struct soap_multipart **, char *, size_t)
Definition: stdsoap2.cpp:15487
#define DBGLOG(DBGFILE, CMD)
Definition: stdsoap2.h:1247
char mark1
Definition: stdsoap2.h:1301
enum soap_mime_encoding encoding
Definition: stdsoap2.h:1447
struct soap_dime dime
Definition: stdsoap2.h:1760
int soap_element_id(struct soap *soap, const char *tag, int id, const void *p, const struct soap_array *a, int n, const char *type, int t)
Definition: stdsoap2.cpp:9717
#define SOAP_IO_LENGTH
Definition: stdsoap2.h:1094
int soap_element_begin_out(struct soap *soap, const char *tag, int id, const char *type)
Definition: stdsoap2.cpp:9244
struct soap_multipart * last
Definition: stdsoap2.h:1397
struct soap_multipart * last
Definition: stdsoap2.h:1413
int soap_element_href(struct soap *soap, const char *tag, int id, const char *ref, const char *val)
Definition: stdsoap2.cpp:9668
int soap_pointer_enter(struct soap *soap, const void *p, const struct soap_array *a, int n, int type, struct soap_plist **ppp)
Definition: stdsoap2.cpp:6336
int __size
Definition: stdsoap2.h:1290
int soap_array_pointer_lookup(struct soap *soap, const void *p, const struct soap_array *a, int n, int type, struct soap_plist **ppp)
Definition: stdsoap2.cpp:6383
#define SOAP_STR_EOS
Definition: stdsoap2.cpp:310
#define SOAP_EOM
Definition: stdsoap2.h:1015
const char * options
Definition: stdsoap2.h:1446
void * __ptr
Definition: stdsoap2.h:1289
struct soap_mime mime
Definition: stdsoap2.h:1761
char * soap_strdup(struct soap *soap, const char *s)
Definition: stdsoap2.cpp:2688
char mark2
Definition: stdsoap2.h:1302
const char * type
Definition: stdsoap2.h:1445
void * soap_malloc(struct soap *soap, size_t n)
Definition: stdsoap2.cpp:7080
const char* soap_attr_value ( struct soap soap,
const char *  name,
int  flag 
)

Definition at line 10003 of file stdsoap2.cpp.

References soap::attributes, soap::error, soap::mode, soap_attribute::name, soap_attribute::next, soap_match_tag(), SOAP_PROHIBITED, SOAP_REQUIRED, SOAP_STR_EOS, SOAP_XML_STRICT, soap_attribute::value, and soap_attribute::visible.

10004  {
10005  register struct soap_attribute *tp;
10006 
10007  if (*name == '-')
10008  return SOAP_STR_EOS;
10009 
10010  for (tp = soap->attributes; tp; tp = tp->next)
10011  {
10012  if (tp->visible && !soap_match_tag(soap, tp->name, name))
10013  break;
10014  }
10015 
10016  if (tp)
10017  {
10018  if (flag == 2 && (soap->mode & SOAP_XML_STRICT))
10019  soap->error = SOAP_PROHIBITED;
10020  else
10021  return tp->value;
10022  }
10023  else if (flag == 1 && (soap->mode & SOAP_XML_STRICT))
10024  soap->error = SOAP_REQUIRED;
10025 
10026  return NULL;
10027  }
int soap_match_tag(struct soap *soap, const char *tag1, const char *tag2)
Definition: stdsoap2.cpp:3727
int error
Definition: stdsoap2.h:1755
soap_mode mode
Definition: stdsoap2.h:1601
struct soap_attribute * next
Definition: stdsoap2.h:1337
#define SOAP_XML_STRICT
Definition: stdsoap2.h:1107
long int flag
Definition: f2c.h:52
struct soap_attribute * attributes
Definition: stdsoap2.h:1724
char name[1]
Definition: stdsoap2.h:1342
#define SOAP_PROHIBITED
Definition: stdsoap2.h:1038
#define SOAP_STR_EOS
Definition: stdsoap2.cpp:310
#define SOAP_REQUIRED
Definition: stdsoap2.h:1037
char * value
Definition: stdsoap2.h:1338
int soap_attribute ( struct soap soap,
const char *  name,
const char *  value 
)

Definition at line 9802 of file stdsoap2.cpp.

References soap_dom_element::atts, soap_dom_attribute::data, DBGLOG, soap::dom, soap::error, soap::mode, soap_dom_attribute::name, soap_dom_attribute::next, soap_dom_attribute::nstr, soap_dom_attribute::soap, soap_malloc(), SOAP_OK, soap_push_ns(), soap_send(), soap_send_raw(), soap_set_attr(), soap_strdup(), soap_string_out(), SOAP_XML_CANONICAL, SOAP_XML_DOM, and soap_dom_attribute::wide.

Referenced by soap_array_begin_out(), soap_element(), soap_element_href(), soap_element_null(), soap_element_result(), soap_outliteral(), and soap_outwliteral().

9803  {
9804  DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Attribute '%s'='%s'\n", name, value));
9805 #ifdef WITH_DOM
9806 
9807  if ((soap->mode & SOAP_XML_DOM) && !(soap->mode & SOAP_XML_CANONICAL) && soap->dom)
9808  {
9809  register struct soap_dom_attribute *a = (struct soap_dom_attribute*)soap_malloc(soap, sizeof(struct soap_dom_attribute));
9810 
9811  if (!a)
9812  return soap->error;
9813 
9814  a->next = soap->dom->atts;
9815  a->nstr = NULL;
9816  a->name = soap_strdup(soap, name);
9817  a->data = soap_strdup(soap, value);
9818  a->wide = NULL;
9819  a->soap = soap;
9820  soap->dom->atts = a;
9821  return SOAP_OK;
9822  }
9823 
9824 #endif
9825 #ifndef WITH_LEAN
9826 
9827  if (soap->mode & SOAP_XML_CANONICAL)
9828  {/* TODO: consider using this code to handle default namespace bindings
9829  if (!strncmp(name, "xmlns", 5) && (name[5] == ':' || name[5] == '\0'))
9830  {if (name[5] == ':')
9831  soap_push_ns(soap, name + 6, value, 0);
9832  else
9833  soap_push_ns(soap, "", value, 0);
9834  }
9835  */
9836  if (!strncmp(name, "xmlns:", 6))
9837  soap_push_ns(soap, name + 6, value, 0);
9838  else if (soap_set_attr(soap, name, value))
9839  return soap->error;
9840  }
9841  else
9842 #endif
9843 
9844  {
9845  if (soap_send(soap, " ") || soap_send(soap, name))
9846  return soap->error;
9847 
9848  if (value)
9849  if (soap_send_raw(soap, "=\"", 2)
9850  || soap_string_out(soap, value, 1)
9851  || soap_send_raw(soap, "\"", 1))
9852  return soap->error;
9853  }
9854 
9855  return SOAP_OK;
9856  }
struct soap_dom_element * dom
Definition: stdsoap2.h:1759
int error
Definition: stdsoap2.h:1755
const char * nstr
Definition: stdsoap2.h:1494
soap_mode mode
Definition: stdsoap2.h:1601
int soap_send_raw(struct soap *soap, const char *s, size_t n)
Definition: stdsoap2.cpp:815
#define SOAP_XML_DOM
Definition: stdsoap2.h:1113
int soap_string_out(struct soap *soap, const char *s, int flag)
Definition: stdsoap2.cpp:10882
#define DBGLOG(DBGFILE, CMD)
Definition: stdsoap2.h:1247
#define SOAP_XML_CANONICAL
Definition: stdsoap2.h:1109
int soap_send(struct soap *soap, const char *s)
Definition: stdsoap2.cpp:959
wchar_t * wide
Definition: stdsoap2.h:1497
static struct soap_nlist * soap_push_ns(struct soap *soap, const char *id, const char *ns, short utilized)
Definition: stdsoap2.cpp:8914
struct soap_dom_attribute * next
Definition: stdsoap2.h:1493
char name[1]
Definition: stdsoap2.h:1342
#define SOAP_OK
Definition: stdsoap2.h:995
int soap_set_attr(struct soap *soap, const char *name, const char *value)
Definition: stdsoap2.cpp:10035
struct soap_dom_attribute * atts
Definition: stdsoap2.h:1541
char * soap_strdup(struct soap *soap, const char *s)
Definition: stdsoap2.cpp:2688
void * soap_malloc(struct soap *soap, size_t n)
Definition: stdsoap2.cpp:7080
char * value
Definition: stdsoap2.h:1338
struct soap * soap
Definition: stdsoap2.h:1498
const char* soap_base642s ( struct soap soap,
const char *  s,
char *  t,
size_t  l,
int *  n 
)

Definition at line 18039 of file stdsoap2.cpp.

References soap::error, soap_blank, SOAP_BLKLEN, soap_malloc(), SOAP_NON_NULL, and SOAP_TYPE.

Referenced by http_parse_header(), and soap_getbase64().

18040  {
18041  register int i, j, c;
18042  register unsigned long m;
18043  register const char *p;
18044 
18045  if (!s || !*s)
18046  {
18047  if (n)
18048  *n = 0;
18049 
18050  if (soap->error)
18051  return NULL;
18052 
18053  return SOAP_NON_NULL;
18054  }
18055 
18056  if (!t)
18057  {
18058  l = (strlen(s) + 3) / 4 * 3;
18059  t = (char*)soap_malloc(soap, l);
18060  }
18061 
18062  if (!t)
18063  return NULL;
18064 
18065  p = t;
18066 
18067  if (n)
18068  *n = 0;
18069 
18070  for (;;)
18071  {
18072  for (i = 0; i < SOAP_BLKLEN; i++)
18073  {
18074  m = 0;
18075  j = 0;
18076 
18077  while (j < 4)
18078  {
18079  c = *s++;
18080 
18081  if (c == '=' || !c)
18082  {
18083  i *= 3;
18084 
18085  switch (j)
18086  {
18087  case 2:
18088  *t++ = (char)((m >> 4) & 0xFF);
18089  i++;
18090  break;
18091  case 3:
18092  *t++ = (char)((m >> 10) & 0xFF);
18093  *t++ = (char)((m >> 2) & 0xFF);
18094  i += 2;
18095  }
18096 
18097  if (n)
18098  *n += i;
18099 
18100  return p;
18101  }
18102 
18103  c -= '+';
18104 
18105  if (c >= 0 && c <= 79)
18106  {
18107  int b = soap_base64i[c];
18108 
18109  if (b >= 64)
18110  {
18111  soap->error = SOAP_TYPE;
18112  return NULL;
18113  }
18114 
18115  m = (m << 6) + b;
18116  j++;
18117  }
18118  else if (!soap_blank(c + '+'))
18119  {
18120  soap->error = SOAP_TYPE;
18121  return NULL;
18122  }
18123  }
18124 
18125  *t++ = (char)((m >> 16) & 0xFF);
18126  *t++ = (char)((m >> 8) & 0xFF);
18127  *t++ = (char)(m & 0xFF);
18128 
18129  if (l < 3)
18130  {
18131  if (n)
18132  *n += i;
18133 
18134  return p;
18135  }
18136 
18137  l -= 3;
18138  }
18139 
18140  if (n)
18141  *n += 3 * SOAP_BLKLEN;
18142  }
18143  }
int error
Definition: stdsoap2.h:1755
#define SOAP_NON_NULL
Definition: stdsoap2.cpp:311
#define SOAP_TYPE
Definition: stdsoap2.h:999
#define soap_blank(c)
Definition: stdsoap2.cpp:118
#define SOAP_BLKLEN
Definition: stdsoap2.h:841
void * soap_malloc(struct soap *soap, size_t n)
Definition: stdsoap2.cpp:7080
static const char soap_base64i[81]
Definition: stdsoap2.cpp:294
void soap_begin ( struct soap soap)

Definition at line 8685 of file stdsoap2.cpp.

References soap::ahead, soap::alloced, soap::bufidx, soap_dime::buflen, soap::buflen, soap::cdata, soap_dime::chunksize, soap::count, DBGLOG, soap::dime, soap::encoding, soap::endpoint, soap::error, soap::idnum, soap::imode, soap::keep_alive, soap::length, soap::level, soap::mode, soap::mustUnderstand, soap::ns, soap::null, soap::omode, soap::part, soap::peeked, soap::position, SOAP_END, soap_free_temp(), SOAP_IO_KEEPALIVE, and SOAP_OK.

Referenced by MiriamWebServicesSoapBindingProxy::checkRegExp(), MiriamWebServicesSoapBindingProxy::getDataResources(), MiriamWebServicesSoapBindingProxy::getDataTypeDef(), MiriamWebServicesSoapBindingProxy::getDataTypePattern(), MiriamWebServicesSoapBindingProxy::getDataTypesId(), MiriamWebServicesSoapBindingProxy::getDataTypesName(), MiriamWebServicesSoapBindingProxy::getDataTypeSynonyms(), MiriamWebServicesSoapBindingProxy::getDataTypeURI(), MiriamWebServicesSoapBindingProxy::getDataTypeURIs(), MiriamWebServicesSoapBindingProxy::getJavaLibraryVersion(), MiriamWebServicesSoapBindingProxy::getLocation(), MiriamWebServicesSoapBindingProxy::getLocations(), MiriamWebServicesSoapBindingProxy::getLocations_(), MiriamWebServicesSoapBindingProxy::getMiriamURI(), MiriamWebServicesSoapBindingProxy::getName(), MiriamWebServicesSoapBindingProxy::getNames(), MiriamWebServicesSoapBindingProxy::getOfficialDataTypeURI(), MiriamWebServicesSoapBindingProxy::getResourceInfo(), MiriamWebServicesSoapBindingProxy::getResourceInstitution(), MiriamWebServicesSoapBindingProxy::getResourceLocation(), MiriamWebServicesSoapBindingProxy::getServicesInfo(), MiriamWebServicesSoapBindingProxy::getServicesVersion(), MiriamWebServicesSoapBindingProxy::getURI(), MiriamWebServicesSoapBindingProxy::isDeprecated(), and soap_init().

8686  {
8687  DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Reinitializing context\n"));
8688 
8689  if (!soap->keep_alive)
8690  {
8691  soap->buflen = 0;
8692  soap->bufidx = 0;
8693  }
8694 
8695  soap->keep_alive = (((soap->imode | soap->omode) & SOAP_IO_KEEPALIVE) != 0);
8696  soap->null = 0;
8697  soap->position = 0;
8698  soap->encoding = 0;
8699  soap->mustUnderstand = 0;
8700  soap->mode = 0;
8701  soap->ns = 0;
8702  soap->part = SOAP_END;
8703  soap->alloced = 0;
8704  soap->count = 0;
8705  soap->length = 0;
8706  soap->cdata = 0;
8707  soap->error = SOAP_OK;
8708  soap->peeked = 0;
8709  soap->ahead = 0;
8710  soap->idnum = 0;
8711  soap->level = 0;
8712  soap->endpoint[0] = '\0';
8713 #ifndef WITH_LEANER
8714  soap->dime.chunksize = 0;
8715  soap->dime.buflen = 0;
8716 #endif
8717  soap_free_temp(soap);
8718  }
short alloced
Definition: stdsoap2.h:1730
short keep_alive
Definition: stdsoap2.h:1742
size_t chunksize
Definition: stdsoap2.h:1389
int error
Definition: stdsoap2.h:1755
void soap_free_temp(struct soap *soap)
Definition: stdsoap2.cpp:8060
short part
Definition: stdsoap2.h:1729
soap_mode imode
Definition: stdsoap2.h:1602
soap_mode mode
Definition: stdsoap2.h:1601
short ns
Definition: stdsoap2.h:1728
unsigned int level
Definition: stdsoap2.h:1704
#define DBGLOG(DBGFILE, CMD)
Definition: stdsoap2.h:1247
struct soap_dime dime
Definition: stdsoap2.h:1760
short peeked
Definition: stdsoap2.h:1731
soap_wchar ahead
Definition: stdsoap2.h:1701
soap_mode omode
Definition: stdsoap2.h:1603
short encoding
Definition: stdsoap2.h:1725
short cdata
Definition: stdsoap2.h:1702
size_t bufidx
Definition: stdsoap2.h:1699
#define SOAP_END
Definition: stdsoap2.h:1162
short mustUnderstand
Definition: stdsoap2.h:1726
#define SOAP_OK
Definition: stdsoap2.h:995
int idnum
Definition: stdsoap2.h:1633
size_t length
Definition: stdsoap2.h:1706
short position
Definition: stdsoap2.h:1721
size_t buflen
Definition: stdsoap2.h:1390
char endpoint[(1024)]
Definition: stdsoap2.h:1734
#define SOAP_IO_KEEPALIVE
Definition: stdsoap2.h:1095
short null
Definition: stdsoap2.h:1727
size_t buflen
Definition: stdsoap2.h:1700
size_t count
Definition: stdsoap2.h:1705
int soap_begin_count ( struct soap soap)

Definition at line 6421 of file stdsoap2.cpp.

References soap_dime::count, soap::count, DBGLOG, soap::dime, soap::encoding, soap::encodingStyle, soap::error, soap::fprepareinit, soap::fpreparesend, soap::idnum, soap_dime::last, soap_dime::list, soap::mode, soap::mustUnderstand, soap::ns, soap::null, soap::omode, soap::part, soap::position, soap_dime::size, SOAP_BEGIN, soap_clr_attr(), SOAP_ENC_DIME, SOAP_ENC_MIME, SOAP_ENC_MTOM, SOAP_ENC_XML, SOAP_ENC_ZLIB, soap_free_ns(), SOAP_IO, SOAP_IO_BUFFER, SOAP_IO_CHUNK, SOAP_IO_FLUSH, SOAP_IO_LENGTH, SOAP_IO_STORE, SOAP_OK, soap_select_mime_boundary(), soap_set_local_namespaces(), SOAP_XML_GRAPH, SOAP_XML_TREE, and soap::socket.

Referenced by MiriamWebServicesSoapBindingProxy::checkRegExp(), MiriamWebServicesSoapBindingProxy::getDataResources(), MiriamWebServicesSoapBindingProxy::getDataTypeDef(), MiriamWebServicesSoapBindingProxy::getDataTypePattern(), MiriamWebServicesSoapBindingProxy::getDataTypesId(), MiriamWebServicesSoapBindingProxy::getDataTypesName(), MiriamWebServicesSoapBindingProxy::getDataTypeSynonyms(), MiriamWebServicesSoapBindingProxy::getDataTypeURI(), MiriamWebServicesSoapBindingProxy::getDataTypeURIs(), MiriamWebServicesSoapBindingProxy::getJavaLibraryVersion(), MiriamWebServicesSoapBindingProxy::getLocation(), MiriamWebServicesSoapBindingProxy::getLocations(), MiriamWebServicesSoapBindingProxy::getLocations_(), MiriamWebServicesSoapBindingProxy::getMiriamURI(), MiriamWebServicesSoapBindingProxy::getName(), MiriamWebServicesSoapBindingProxy::getNames(), MiriamWebServicesSoapBindingProxy::getOfficialDataTypeURI(), MiriamWebServicesSoapBindingProxy::getResourceInfo(), MiriamWebServicesSoapBindingProxy::getResourceInstitution(), MiriamWebServicesSoapBindingProxy::getResourceLocation(), MiriamWebServicesSoapBindingProxy::getServicesInfo(), MiriamWebServicesSoapBindingProxy::getServicesVersion(), MiriamWebServicesSoapBindingProxy::getURI(), MiriamWebServicesSoapBindingProxy::isDeprecated(), and soap_send_fault().

6422  {
6423  soap_free_ns(soap);
6424 #ifndef WITH_LEANER
6425 
6426  if ((soap->mode & SOAP_ENC_DIME) || (soap->omode & SOAP_ENC_DIME))
6427  soap->mode = soap->omode | SOAP_IO_LENGTH | SOAP_ENC_DIME;
6428  else
6429 #endif
6430 
6431  {
6432  soap->mode = soap->omode;
6433 
6434  if ((soap->mode & SOAP_IO) == SOAP_IO_STORE
6435  || (((soap->mode & SOAP_IO) == SOAP_IO_CHUNK || (soap->mode & SOAP_ENC_XML))
6436 #ifndef WITH_LEANER
6437  && !soap->fpreparesend
6438 #endif
6439  ))
6440  soap->mode &= ~SOAP_IO_LENGTH;
6441  else
6442  soap->mode |= SOAP_IO_LENGTH;
6443  }
6444 
6445 #ifdef WITH_ZLIB
6446 
6447  if ((soap->mode & SOAP_ENC_ZLIB) && (soap->mode & SOAP_IO) == SOAP_IO_FLUSH)
6448  {
6449  if (!(soap->mode & SOAP_ENC_DIME))
6450  soap->mode &= ~SOAP_IO_LENGTH;
6451 
6452  if (soap->mode & SOAP_ENC_XML)
6453  soap->mode |= SOAP_IO_BUFFER;
6454  else
6455  soap->mode |= SOAP_IO_STORE;
6456  }
6457 
6458 #endif
6459 
6460  if (!soap->encodingStyle && !(soap->mode & SOAP_XML_GRAPH))
6461  soap->mode |= SOAP_XML_TREE;
6462 
6463 #ifndef WITH_LEANER
6464 
6465  if ((soap->mode & SOAP_ENC_MTOM) && (soap->mode & SOAP_ENC_DIME))
6466  soap->mode |= SOAP_ENC_MIME;
6467  else
6468  soap->mode &= ~SOAP_ENC_MTOM;
6469 
6470  if (soap->mode & SOAP_ENC_MIME)
6472 
6473  soap->dime.list = soap->dime.last; /* keep track of last DIME attachment */
6474 #endif
6475  soap->count = 0;
6476  soap->ns = 0;
6477  soap->null = 0;
6478  soap->position = 0;
6479  soap->mustUnderstand = 0;
6480  soap->encoding = 0;
6481  soap->part = SOAP_BEGIN;
6482  soap->idnum = 0;
6483  soap_clr_attr(soap);
6485  DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Begin count phase (socket=%d mode=0x%x count=%lu)\n", soap->socket, soap->mode, (unsigned long)soap->count));
6486 #ifndef WITH_LEANER
6487  soap->dime.count = 0; /* count # of attachments */
6488  soap->dime.size = 0; /* accumulate total size of attachments */
6489 
6490  if (soap->fprepareinit && (soap->mode & SOAP_IO) != SOAP_IO_STORE)
6491  return soap->error = soap->fprepareinit(soap);
6492 
6493 #endif
6494  return SOAP_OK;
6495  }
#define SOAP_XML_GRAPH
Definition: stdsoap2.h:1111
int error
Definition: stdsoap2.h:1755
short part
Definition: stdsoap2.h:1729
soap_mode mode
Definition: stdsoap2.h:1601
#define SOAP_ENC_MTOM
Definition: stdsoap2.h:1101
size_t size
Definition: stdsoap2.h:1388
#define SOAP_BEGIN
Definition: stdsoap2.h:1154
short ns
Definition: stdsoap2.h:1728
#define SOAP_IO_FLUSH
Definition: stdsoap2.h:1087
#define SOAP_IO
Definition: stdsoap2.h:1086
#define DBGLOG(DBGFILE, CMD)
Definition: stdsoap2.h:1247
struct soap_multipart * list
Definition: stdsoap2.h:1396
void soap_set_local_namespaces(struct soap *soap)
Definition: stdsoap2.cpp:8831
struct soap_dime dime
Definition: stdsoap2.h:1760
#define SOAP_IO_CHUNK
Definition: stdsoap2.h:1090
#define SOAP_XML_TREE
Definition: stdsoap2.h:1110
#define SOAP_IO_LENGTH
Definition: stdsoap2.h:1094
int(* fpreparesend)(struct soap *, const char *, size_t)
Definition: stdsoap2.h:1667
soap_mode omode
Definition: stdsoap2.h:1603
size_t count
Definition: stdsoap2.h:1387
short encoding
Definition: stdsoap2.h:1725
#define SOAP_IO_BUFFER
Definition: stdsoap2.h:1088
#define SOAP_ENC_ZLIB
Definition: stdsoap2.h:1102
struct soap_multipart * last
Definition: stdsoap2.h:1397
short mustUnderstand
Definition: stdsoap2.h:1726
int(* fprepareinit)(struct soap *)
Definition: stdsoap2.h:1666
#define SOAP_OK
Definition: stdsoap2.h:995
int idnum
Definition: stdsoap2.h:1633
#define SOAP_IO_STORE
Definition: stdsoap2.h:1089
short position
Definition: stdsoap2.h:1721
static void soap_select_mime_boundary(struct soap *)
Definition: stdsoap2.cpp:15582
#define SOAP_ENC_XML
Definition: stdsoap2.h:1098
#define SOAP_ENC_DIME
Definition: stdsoap2.h:1099
int socket
Definition: stdsoap2.h:1684
#define SOAP_ENC_MIME
Definition: stdsoap2.h:1100
short null
Definition: stdsoap2.h:1727
void soap_clr_attr(struct soap *soap)
Definition: stdsoap2.cpp:10164
static void soap_free_ns(struct soap *soap)
Definition: stdsoap2.cpp:8135
const char * encodingStyle
Definition: stdsoap2.h:1609
size_t count
Definition: stdsoap2.h:1705
int soap_begin_recv ( struct soap soap)

Definition at line 16617 of file stdsoap2.cpp.

References soap::action, soap::ahead, soap::alloced, soap_mime::boundary, soap::buf, soap::bufidx, soap_dime::buflen, soap::buflen, soap::cdata, soap::chunkbuflen, soap_dime::chunksize, soap::chunksize, soap::count, soap::d_stream, DBGLOG, soap::dime, soap::dom, soap::endpoint, soap::error, soap::fault, soap::fform, soap_dime::first, soap_mime::first, soap_dime::flags, soap::fparse, soap::fprepareinit, soap::fpreparerecv, soap::header, soap_multipart::id, if(), soap::imode, soap::keep_alive, soap_dime::last, soap_mime::last, soap::length, soap::level, soap_dime::list, soap_mime::list, soap::mime, soap::mode, soap::omode, soap::part, soap::peeked, soap::recvfd, soap_dime::size, SOAP_BEGIN, soap_blank, SOAP_BUFLEN, SOAP_DIME_CF, SOAP_DIME_MB, SOAP_DIME_VERSION, SOAP_ENC_DIME, SOAP_ENC_MIME, SOAP_ENC_ZLIB, SOAP_EOF, SOAP_FORM, soap_free_iht(), soap_free_temp(), soap_get0, soap_get1, soap_get_header_attribute(), soap_get_mime_attachment(), soap_getchar(), soap_getdimehdr(), soap_getmimehdr(), SOAP_IO, SOAP_IO_CHUNK, SOAP_IO_KEEPALIVE, SOAP_MALLOC, soap_match_cid(), SOAP_NO_DATA, SOAP_OK, soap_revget1, soap_set_local_namespaces(), SOAP_STOP, soap_unget, soap_valid_socket, SOAP_ZLIB_DEFLATE, SOAP_ZLIB_ERROR, SOAP_ZLIB_GZIP, SOAP_ZLIB_INFLATE, SOAP_ZLIB_NONE, soap::socket, soap::ssl, soap_mime::start, soap::status, soap_multipart::type, soap::version, soap::z_buf, soap::z_buflen, soap::z_crc, soap::z_ratio_in, soap::zlib_in, soap::zlib_out, and soap::zlib_state.

Referenced by MiriamWebServicesSoapBindingProxy::checkRegExp(), MiriamWebServicesSoapBindingProxy::getDataResources(), MiriamWebServicesSoapBindingProxy::getDataTypeDef(), MiriamWebServicesSoapBindingProxy::getDataTypePattern(), MiriamWebServicesSoapBindingProxy::getDataTypesId(), MiriamWebServicesSoapBindingProxy::getDataTypesName(), MiriamWebServicesSoapBindingProxy::getDataTypeSynonyms(), MiriamWebServicesSoapBindingProxy::getDataTypeURI(), MiriamWebServicesSoapBindingProxy::getDataTypeURIs(), MiriamWebServicesSoapBindingProxy::getJavaLibraryVersion(), MiriamWebServicesSoapBindingProxy::getLocation(), MiriamWebServicesSoapBindingProxy::getLocations(), MiriamWebServicesSoapBindingProxy::getLocations_(), MiriamWebServicesSoapBindingProxy::getMiriamURI(), MiriamWebServicesSoapBindingProxy::getName(), MiriamWebServicesSoapBindingProxy::getNames(), MiriamWebServicesSoapBindingProxy::getOfficialDataTypeURI(), MiriamWebServicesSoapBindingProxy::getResourceInfo(), MiriamWebServicesSoapBindingProxy::getResourceInstitution(), MiriamWebServicesSoapBindingProxy::getResourceLocation(), MiriamWebServicesSoapBindingProxy::getServicesInfo(), MiriamWebServicesSoapBindingProxy::getServicesVersion(), MiriamWebServicesSoapBindingProxy::getURI(), MiriamWebServicesSoapBindingProxy::isDeprecated(), and soap_recv_empty_response().

16618  {
16619  soap_wchar c;
16620  DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Initializing for input\n"));
16621  soap->error = SOAP_OK;
16622  soap_free_temp(soap);
16624  soap->version = 0; /* don't assume we're parsing SOAP content by default */
16625 #ifndef WITH_NOIDREF
16626  soap_free_iht(soap);
16627 #endif
16628 
16629  if ((soap->imode & SOAP_IO) == SOAP_IO_CHUNK)
16630  soap->omode |= SOAP_IO_CHUNK;
16631 
16632  soap->imode &= ~(SOAP_IO | SOAP_ENC_MIME);
16633  soap->mode = soap->imode;
16634 
16635  if (!soap->keep_alive)
16636  {
16637  soap->buflen = 0;
16638  soap->bufidx = 0;
16639  }
16640 
16641  if (!(soap->mode & SOAP_IO_KEEPALIVE))
16642  soap->keep_alive = 0;
16643 
16644  soap->ahead = 0;
16645  soap->peeked = 0;
16646  soap->level = 0;
16647  soap->part = SOAP_BEGIN;
16648  soap->alloced = 0;
16649  soap->count = 0;
16650  soap->length = 0;
16651  soap->cdata = 0;
16652  *soap->endpoint = '\0';
16653  soap->action = NULL;
16654  soap->header = NULL;
16655  soap->fault = NULL;
16656  soap->status = 0;
16657 #ifndef WITH_LEANER
16658  soap->dom = NULL;
16659  soap->dime.chunksize = 0;
16660  soap->dime.buflen = 0;
16661  soap->dime.list = NULL;
16662  soap->dime.first = NULL;
16663  soap->dime.last = NULL;
16664  soap->mime.list = NULL;
16665  soap->mime.first = NULL;
16666  soap->mime.last = NULL;
16667  soap->mime.boundary = NULL;
16668  soap->mime.start = NULL;
16669 #endif
16670 #ifdef WIN32
16671 #ifndef UNDER_CE
16672 #ifndef WITH_FASTCGI
16673 
16674  if (!soap_valid_socket(soap->socket))
16675  _setmode(soap->recvfd, _O_BINARY);
16676 
16677 #endif
16678 #endif
16679 #endif
16680 #ifdef WITH_ZLIB
16681  soap->mode &= ~SOAP_ENC_ZLIB;
16682  soap->zlib_in = SOAP_ZLIB_NONE;
16683  soap->zlib_out = SOAP_ZLIB_NONE;
16684  soap->d_stream->next_in = Z_NULL;
16685  soap->d_stream->avail_in = 0;
16686  soap->d_stream->next_out = (Byte*)soap->buf;
16687  soap->d_stream->avail_out = SOAP_BUFLEN;
16688  soap->z_ratio_in = 1.0;
16689 #endif
16690 #ifdef WITH_OPENSSL
16691 
16692  if (soap->ssl)
16693  ERR_clear_error();
16694 
16695 #endif
16696 #ifndef WITH_LEANER
16697 
16698  if (soap->fprepareinit)
16699  soap->fprepareinit(soap);
16700 
16701 #endif
16702  c = soap_getchar(soap);
16703 #ifdef WITH_GZIP
16704 
16705  if (c == 0x1F)
16706  {
16707  if (soap_getgziphdr(soap))
16708  return soap->error;
16709 
16710  if (inflateInit2(soap->d_stream, -MAX_WBITS) != Z_OK)
16711  return soap->error = SOAP_ZLIB_ERROR;
16712 
16713  soap->zlib_state = SOAP_ZLIB_INFLATE;
16714  soap->mode |= SOAP_ENC_ZLIB;
16715  soap->zlib_in = SOAP_ZLIB_GZIP;
16716  soap->z_crc = crc32(0L, NULL, 0);
16717  DBGLOG(TEST, SOAP_MESSAGE(fdebug, "gzip initialized\n"));
16718 
16719  if (!soap->z_buf)
16720  soap->z_buf = (char*)SOAP_MALLOC(soap, SOAP_BUFLEN);
16721 
16722  memcpy(soap->z_buf, soap->buf, SOAP_BUFLEN);
16723  /* should not chunk over plain transport, so why bother to check? */
16724  /* if ((soap->mode & SOAP_IO) == SOAP_IO_CHUNK) */
16725  /* soap->z_buflen = soap->bufidx; */
16726  /* else */
16727  soap->d_stream->next_in = (Byte*)(soap->z_buf + soap->bufidx);
16728  soap->d_stream->avail_in = soap->buflen - soap->bufidx;
16729  soap->z_buflen = soap->buflen;
16730  soap->buflen = soap->bufidx;
16731  c = soap_getchar(soap);
16732  }
16733 
16734 #endif
16735 #ifndef WITH_LEANER
16736 
16737  if (c == '-' && soap_get0(soap) == '-')
16738  soap->mode |= SOAP_ENC_MIME;
16739  else if ((c & 0xFFFC) == (SOAP_DIME_VERSION | SOAP_DIME_MB) && (soap_get0(soap) & 0xFFF0) == 0x20)
16740  soap->mode |= SOAP_ENC_DIME;
16741  else
16742 #endif
16743 
16744  {
16745  while (soap_blank(c))
16746  c = soap_getchar(soap);
16747  }
16748 
16749  if ((int)c == EOF)
16750  return soap->error = SOAP_EOF;
16751 
16752  soap_unget(soap, c);
16753 #ifndef WITH_NOHTTP
16754 
16755  /* if not XML or (start of)BOM or MIME/DIME/ZLIB, assume HTTP header */
16756  if (c != '<' && c != 0xEF && !(soap->mode & (SOAP_ENC_MIME | SOAP_ENC_DIME | SOAP_ENC_ZLIB)))
16757  {
16758  soap_mode m = soap->imode;
16759  soap->mode &= ~SOAP_IO;
16760  soap->error = soap->fparse(soap);
16761 
16762  if (soap->error && soap->error < SOAP_STOP)
16763  {
16764  soap->keep_alive = 0; /* force close later */
16765  return soap->error;
16766  }
16767 
16768  if (soap->error == SOAP_STOP)
16769  return soap->error;
16770 
16771  soap->mode = soap->imode; /* if imode is changed, effectuate */
16772  soap->imode = m; /* restore imode */
16773 #ifdef WITH_ZLIB
16774  soap->mode &= ~SOAP_ENC_ZLIB;
16775 #endif
16776 
16777  if ((soap->mode & SOAP_IO) == SOAP_IO_CHUNK)
16778  {
16779  soap->chunkbuflen = soap->buflen;
16780  soap->buflen = soap->bufidx;
16781  soap->chunksize = 0;
16782  }
16783 
16784 #ifndef WITH_LEANER
16785  else if (soap->fpreparerecv && soap->buflen != soap->bufidx)
16786  soap->fpreparerecv(soap, soap->buf + soap->bufidx, soap->buflen - soap->bufidx);
16787 
16788 #endif
16789 
16790  /* Note: fparse should not use soap_unget to push back last char */
16791  if (soap_get0(soap) == (int)EOF)
16792  {
16793  if (soap->status == 200)
16794  return soap->error = SOAP_NO_DATA; /* HTTP OK: always expect data */
16795 
16796  return soap->error = soap->status;
16797  }
16798 
16799 #ifdef WITH_ZLIB
16800 
16801  if (soap->zlib_in != SOAP_ZLIB_NONE)
16802  {
16803 #ifdef WITH_GZIP
16804 
16805  if (soap->zlib_in != SOAP_ZLIB_DEFLATE)
16806  {
16807  c = soap_get1(soap);
16808 
16809  if (c == 0x1F)
16810  {
16811  if (soap_getgziphdr(soap))
16812  return soap->error;
16813 
16814  if (inflateInit2(soap->d_stream, -MAX_WBITS) != Z_OK)
16815  return soap->error = SOAP_ZLIB_ERROR;
16816 
16817  soap->z_crc = crc32(0L, NULL, 0);
16818  DBGLOG(TEST, SOAP_MESSAGE(fdebug, "gzip initialized\n"));
16819  }
16820  else
16821  {
16822  soap_revget1(soap);
16823 
16824  if (inflateInit(soap->d_stream) != Z_OK)
16825  return soap->error = SOAP_ZLIB_ERROR;
16826 
16827  soap->zlib_in = SOAP_ZLIB_DEFLATE;
16828  }
16829  }
16830  else
16831 #endif
16832  if (inflateInit(soap->d_stream) != Z_OK)
16833  return soap->error = SOAP_ZLIB_ERROR;
16834 
16835  soap->zlib_state = SOAP_ZLIB_INFLATE;
16836  DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Inflate initialized\n"));
16837  soap->mode |= SOAP_ENC_ZLIB;
16838 
16839  if (!soap->z_buf)
16840  soap->z_buf = (char*)SOAP_MALLOC(soap, SOAP_BUFLEN);
16841 
16842  memcpy(soap->z_buf, soap->buf, SOAP_BUFLEN);
16843  soap->d_stream->next_in = (Byte*)(soap->z_buf + soap->bufidx);
16844  soap->d_stream->avail_in = soap->buflen - soap->bufidx;
16845  soap->z_buflen = soap->buflen;
16846  soap->buflen = soap->bufidx;
16847  }
16848 
16849 #endif
16850 
16851  if (soap->error)
16852  {
16853  if (soap->error == SOAP_FORM && soap->fform)
16854  {
16855  soap->error = soap->fform(soap);
16856 
16857  if (soap->error == SOAP_OK)
16858  soap->error = SOAP_STOP; /* prevents further processing */
16859  }
16860 
16861  return soap->error;
16862  }
16863  }
16864 
16865 #endif
16866 #ifndef WITH_LEANER
16867 
16868  if (soap->mode & SOAP_ENC_MIME)
16869  {
16870  if (soap_getmimehdr(soap))
16871  return soap->error;
16872 
16873  if (soap->mime.start)
16874  {
16875  do
16876  {
16877  if (!soap->mime.last->id)
16878  break;
16879 
16880  if (!soap_match_cid(soap, soap->mime.start, soap->mime.last->id))
16881  break;
16882  }
16883  while (soap_get_mime_attachment(soap, NULL));
16884  }
16885 
16886  if (soap_get_header_attribute(soap, soap->mime.first->type, "application/dime"))
16887  soap->mode |= SOAP_ENC_DIME;
16888  }
16889 
16890  if (soap->mode & SOAP_ENC_DIME)
16891  {
16892  if (soap_getdimehdr(soap))
16893  return soap->error;
16894 
16895  if (soap->dime.flags & SOAP_DIME_CF)
16896  {
16897  DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Chunked DIME SOAP message\n"));
16898  soap->dime.chunksize = soap->dime.size;
16899 
16900  if (soap->buflen - soap->bufidx >= soap->dime.chunksize)
16901  {
16902  soap->dime.buflen = soap->buflen;
16903  soap->buflen = soap->bufidx + soap->dime.chunksize;
16904  }
16905  else
16906  soap->dime.chunksize -= soap->buflen - soap->bufidx;
16907  }
16908 
16909  soap->count = soap->buflen - soap->bufidx;
16910  }
16911 
16912 #endif
16913  return SOAP_OK;
16914  }
const char * id
Definition: stdsoap2.h:1444
short alloced
Definition: stdsoap2.h:1730
short keep_alive
Definition: stdsoap2.h:1742
int recvfd
Definition: stdsoap2.h:1694
struct soap_dom_element * dom
Definition: stdsoap2.h:1759
size_t chunksize
Definition: stdsoap2.h:1389
int error
Definition: stdsoap2.h:1755
struct soap_multipart * first
Definition: stdsoap2.h:1413
struct soap_multipart * list
Definition: stdsoap2.h:1412
#define soap_valid_socket(n)
Definition: stdsoap2.h:698
void soap_free_temp(struct soap *soap)
Definition: stdsoap2.cpp:8060
short part
Definition: stdsoap2.h:1729
char * action
Definition: stdsoap2.h:1737
soap_mode imode
Definition: stdsoap2.h:1602
soap_mode mode
Definition: stdsoap2.h:1601
struct soap_multipart * first
Definition: stdsoap2.h:1397
struct SOAP_ENV__Fault * fault
Definition: stdsoap2.h:1632
#define SOAP_BUFLEN
Definition: stdsoap2.h:814
size_t size
Definition: stdsoap2.h:1388
#define SOAP_BEGIN
Definition: stdsoap2.h:1154
size_t chunksize
Definition: stdsoap2.h:1732
short version
Definition: stdsoap2.h:1600
#define SOAP_IO
Definition: stdsoap2.h:1086
unsigned int level
Definition: stdsoap2.h:1704
#define DBGLOG(DBGFILE, CMD)
Definition: stdsoap2.h:1247
#define SOAP_ZLIB_NONE
Definition: stdsoap2.h:1077
struct soap_multipart * list
Definition: stdsoap2.h:1396
struct soap_multipart * soap_get_mime_attachment(struct soap *soap, void *handle)
Definition: stdsoap2.cpp:15054
#define SOAP_ZLIB_INFLATE
Definition: stdsoap2.h:1079
int32_t z_crc
Definition: stdsoap2.h:1823
void soap_set_local_namespaces(struct soap *soap)
Definition: stdsoap2.cpp:8831
struct soap_dime dime
Definition: stdsoap2.h:1760
size_t z_buflen
Definition: stdsoap2.h:1829
short zlib_state
Definition: stdsoap2.h:1825
int(* fform)(struct soap *)
Definition: stdsoap2.h:1643
#define SOAP_ZLIB_DEFLATE
Definition: stdsoap2.h:1078
int soap_getmimehdr(struct soap *soap)
Definition: stdsoap2.cpp:14923
short peeked
Definition: stdsoap2.h:1731
#define SOAP_ZLIB_GZIP
Definition: stdsoap2.h:1080
#define SOAP_IO_CHUNK
Definition: stdsoap2.h:1090
#define soap_unget(soap, c)
Definition: stdsoap2.h:1900
soap_wchar ahead
Definition: stdsoap2.h:1701
int32_t soap_mode
Definition: stdsoap2.h:1084
#define soap_blank(c)
Definition: stdsoap2.cpp:118
void * d_stream
Definition: stdsoap2.h:1822
char buf[(65536)]
Definition: stdsoap2.h:1710
#define soap_revget1(soap)
Definition: stdsoap2.h:1899
#define SOAP_STOP
Definition: stdsoap2.h:1056
#define SOAP_DIME_VERSION
Definition: stdsoap2.h:1071
soap_mode omode
Definition: stdsoap2.h:1603
#define SOAP_MALLOC(soap, size)
Definition: stdsoap2.h:1190
void * ssl
Definition: stdsoap2.h:1799
soap_wchar soap_getchar(struct soap *soap)
Definition: stdsoap2.cpp:1616
const char * start
Definition: stdsoap2.h:1411
static void soap_free_iht(struct soap *)
Definition: stdsoap2.cpp:7004
short cdata
Definition: stdsoap2.h:1702
#define SOAP_ENC_ZLIB
Definition: stdsoap2.h:1102
struct SOAP_ENV__Header * header
Definition: stdsoap2.h:1631
float z_ratio_in
Definition: stdsoap2.h:1831
struct soap_multipart * last
Definition: stdsoap2.h:1397
#define SOAP_FORM
Definition: stdsoap2.h:1057
struct soap_multipart * last
Definition: stdsoap2.h:1413
size_t bufidx
Definition: stdsoap2.h:1699
#define SOAP_DIME_CF
Definition: stdsoap2.h:1068
int soap_getdimehdr(struct soap *soap)
Definition: stdsoap2.cpp:14690
char * boundary
Definition: stdsoap2.h:1410
int(* fprepareinit)(struct soap *)
Definition: stdsoap2.h:1666
#define SOAP_OK
Definition: stdsoap2.h:995
short zlib_in
Definition: stdsoap2.h:1826
char * z_buf
Definition: stdsoap2.h:1828
int status
Definition: stdsoap2.h:1754
const char * soap_get_header_attribute(struct soap *soap, const char *line, const char *key)
Definition: stdsoap2.cpp:17301
int soap_match_cid(struct soap *soap, const char *s, const char *t)
Definition: stdsoap2.cpp:15216
#define soap_get1(soap)
Definition: stdsoap2.h:1893
#define soap_get0(soap)
Definition: stdsoap2.h:1892
size_t length
Definition: stdsoap2.h:1706
char flags
Definition: stdsoap2.h:1391
#define SOAP_NO_DATA
Definition: stdsoap2.h:1009
int(* fpreparerecv)(struct soap *, const char *, size_t)
Definition: stdsoap2.h:1668
size_t chunkbuflen
Definition: stdsoap2.h:1733
#define SOAP_ZLIB_ERROR
Definition: stdsoap2.h:1026
struct soap_mime mime
Definition: stdsoap2.h:1761
#define SOAP_EOF
Definition: stdsoap2.h:993
if(!yymsg) yymsg
#define SOAP_ENC_DIME
Definition: stdsoap2.h:1099
size_t buflen
Definition: stdsoap2.h:1390
int socket
Definition: stdsoap2.h:1684
const char * type
Definition: stdsoap2.h:1445
char endpoint[(1024)]
Definition: stdsoap2.h:1734
#define SOAP_IO_KEEPALIVE
Definition: stdsoap2.h:1095
#define SOAP_ENC_MIME
Definition: stdsoap2.h:1100
int32_t soap_wchar
Definition: stdsoap2.h:1257
size_t buflen
Definition: stdsoap2.h:1700
int(* fparse)(struct soap *)
Definition: stdsoap2.h:1646
short zlib_out
Definition: stdsoap2.h:1827
#define SOAP_DIME_MB
Definition: stdsoap2.h:1070
size_t count
Definition: stdsoap2.h:1705
int soap_begin_send ( struct soap soap)

Definition at line 6521 of file stdsoap2.cpp.

References soap::bufidx, soap::buflen, soap::chunksize, soap::count, soap::d_stream, DBGLOG, soap::encoding, soap::encodingStyle, soap::error, soap::fprepareinit, soap::idnum, if(), soap::keep_alive, soap::level, soap::mode, soap::mustUnderstand, soap::ns, soap::null, soap::omode, soap::part, soap::position, soap::sendfd, SOAP_BEGIN, SOAP_BUFLEN, soap_clr_attr(), SOAP_ENC_DIME, SOAP_ENC_MIME, SOAP_ENC_MTOM, SOAP_ENC_XML, SOAP_ENC_ZLIB, soap_free_ns(), SOAP_IO, SOAP_IO_BUFFER, SOAP_IO_FLUSH, SOAP_IO_KEEPALIVE, SOAP_IO_LENGTH, SOAP_IO_STORE, SOAP_IO_UDP, SOAP_MALLOC, soap_new_block(), SOAP_OK, soap_select_mime_boundary(), soap_set_local_namespaces(), SOAP_UDP_ERROR, soap_valid_socket, SOAP_XML_GRAPH, SOAP_XML_TREE, SOAP_ZLIB_DEFLATE, SOAP_ZLIB_ERROR, SOAP_ZLIB_GZIP, soap::socket, soap::ssl, soap::z_buf, soap::z_crc, soap::z_level, soap::z_ratio_out, soap::zlib_out, and soap::zlib_state.

Referenced by soap_response(), soap_try_connect_command(), and tcp_connect().

6522  {
6523  DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Initializing for output\n"));
6524  soap_free_ns(soap);
6525  soap->error = SOAP_OK;
6526  soap->mode = soap->omode | (soap->mode & (SOAP_IO_LENGTH | SOAP_ENC_DIME));
6527 #ifdef WITH_ZLIB
6528 
6529  if ((soap->mode & SOAP_ENC_ZLIB) && (soap->mode & SOAP_IO) == SOAP_IO_FLUSH)
6530  {
6531  if (soap->mode & SOAP_ENC_XML)
6532  soap->mode |= SOAP_IO_BUFFER;
6533  else
6534  soap->mode |= SOAP_IO_STORE;
6535  }
6536 
6537 #endif
6538 #ifndef WITH_LEAN
6539 
6540  if ((soap->mode & SOAP_IO_UDP))
6541  {
6542  soap->mode |= SOAP_ENC_XML;
6543 
6544  if (soap->count > SOAP_BUFLEN)
6545  return soap->error = SOAP_UDP_ERROR;
6546  }
6547 
6548 #endif
6549 
6550  if ((soap->mode & SOAP_IO) == SOAP_IO_FLUSH && soap_valid_socket(soap->socket))
6551  {
6552  if (soap->count || (soap->mode & SOAP_IO_LENGTH) || (soap->mode & SOAP_ENC_XML))
6553  soap->mode |= SOAP_IO_BUFFER;
6554  else
6555  soap->mode |= SOAP_IO_STORE;
6556  }
6557 
6558  soap->mode &= ~SOAP_IO_LENGTH;
6559 
6560  if ((soap->mode & SOAP_IO) == SOAP_IO_STORE)
6561  if (soap_new_block(soap) == NULL)
6562  return soap->error;
6563 
6564  if (!(soap->mode & SOAP_IO_KEEPALIVE))
6565  soap->keep_alive = 0;
6566 
6567  if (!soap->encodingStyle && !(soap->mode & SOAP_XML_GRAPH))
6568  soap->mode |= SOAP_XML_TREE;
6569 
6570 #ifndef WITH_LEANER
6571 
6572  if ((soap->mode & SOAP_ENC_MTOM) && (soap->mode & SOAP_ENC_DIME))
6573  {
6574  soap->mode |= SOAP_ENC_MIME;
6575  soap->mode &= ~SOAP_ENC_DIME;
6576  }
6577  else
6578  soap->mode &= ~SOAP_ENC_MTOM;
6579 
6580  if (soap->mode & SOAP_ENC_MIME)
6582 
6583 #ifdef WIN32
6584 #ifndef UNDER_CE
6585 #ifndef WITH_FASTCGI
6586 
6587  if (!soap_valid_socket(soap->socket)) /* Set win32 stdout or soap->sendfd to BINARY, e.g. to support DIME */
6588  _setmode(soap->sendfd, _O_BINARY);
6589 
6590 #endif
6591 #endif
6592 #endif
6593 #endif
6594 
6595  if (soap->mode & SOAP_IO)
6596  {
6597  soap->bufidx = 0;
6598  soap->buflen = 0;
6599  }
6600 
6601  soap->chunksize = 0;
6602  soap->ns = 0;
6603  soap->null = 0;
6604  soap->position = 0;
6605  soap->mustUnderstand = 0;
6606  soap->encoding = 0;
6607  soap->idnum = 0;
6608  soap->level = 0;
6609  soap_clr_attr(soap);
6611 #ifdef WITH_ZLIB
6612  soap->z_ratio_out = 1.0;
6613 
6614  if ((soap->mode & SOAP_ENC_ZLIB) && soap->zlib_state != SOAP_ZLIB_DEFLATE)
6615  {
6616  if (!soap->z_buf)
6617  soap->z_buf = (char*)SOAP_MALLOC(soap, SOAP_BUFLEN);
6618 
6619  soap->d_stream->next_out = (Byte*)soap->z_buf;
6620  soap->d_stream->avail_out = SOAP_BUFLEN;
6621 #ifdef WITH_GZIP
6622 
6623  if (soap->zlib_out != SOAP_ZLIB_DEFLATE)
6624  {
6625  memcpy(soap->z_buf, "\37\213\10\0\0\0\0\0\0\377", 10);
6626  soap->d_stream->next_out = (Byte*)soap->z_buf + 10;
6627  soap->d_stream->avail_out = SOAP_BUFLEN - 10;
6628  soap->z_crc = crc32(0L, NULL, 0);
6629  soap->zlib_out = SOAP_ZLIB_GZIP;
6630 
6631  if (deflateInit2(soap->d_stream, soap->z_level, Z_DEFLATED, -MAX_WBITS, 8, Z_DEFAULT_STRATEGY) != Z_OK)
6632  return soap->error = SOAP_ZLIB_ERROR;
6633  }
6634  else
6635 #endif
6636  if (deflateInit(soap->d_stream, soap->z_level) != Z_OK)
6637  return soap->error = SOAP_ZLIB_ERROR;
6638 
6639  DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Deflate initialized\n"));
6640  soap->zlib_state = SOAP_ZLIB_DEFLATE;
6641  }
6642 
6643 #endif
6644 #ifdef WITH_OPENSSL
6645 
6646  if (soap->ssl)
6647  ERR_clear_error();
6648 
6649 #endif
6650  DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Begin send phase (socket=%d mode=0x%x count=%lu)\n", soap->socket, soap->mode, (unsigned long)soap->count));
6651  soap->part = SOAP_BEGIN;
6652 #ifndef WITH_LEANER
6653 
6654  if (soap->fprepareinit && (soap->mode & SOAP_IO) == SOAP_IO_STORE)
6655  soap->fprepareinit(soap);
6656 
6657 #endif
6658  return SOAP_OK;
6659  }
short keep_alive
Definition: stdsoap2.h:1742
#define SOAP_XML_GRAPH
Definition: stdsoap2.h:1111
unsigned short z_level
Definition: stdsoap2.h:1830
int error
Definition: stdsoap2.h:1755
#define soap_valid_socket(n)
Definition: stdsoap2.h:698
int sendfd
Definition: stdsoap2.h:1693
short part
Definition: stdsoap2.h:1729
#define SOAP_UDP_ERROR
Definition: stdsoap2.h:1022
soap_mode mode
Definition: stdsoap2.h:1601
#define SOAP_ENC_MTOM
Definition: stdsoap2.h:1101
#define SOAP_BUFLEN
Definition: stdsoap2.h:814
#define SOAP_BEGIN
Definition: stdsoap2.h:1154
short ns
Definition: stdsoap2.h:1728
#define SOAP_IO_UDP
Definition: stdsoap2.h:1092
size_t chunksize
Definition: stdsoap2.h:1732
#define SOAP_IO_FLUSH
Definition: stdsoap2.h:1087
#define SOAP_IO
Definition: stdsoap2.h:1086
unsigned int level
Definition: stdsoap2.h:1704
#define DBGLOG(DBGFILE, CMD)
Definition: stdsoap2.h:1247
int32_t z_crc
Definition: stdsoap2.h:1823
void soap_set_local_namespaces(struct soap *soap)
Definition: stdsoap2.cpp:8831
short zlib_state
Definition: stdsoap2.h:1825
#define SOAP_ZLIB_DEFLATE
Definition: stdsoap2.h:1078
#define SOAP_ZLIB_GZIP
Definition: stdsoap2.h:1080
struct soap_blist * soap_new_block(struct soap *soap)
Definition: stdsoap2.cpp:2728
#define SOAP_XML_TREE
Definition: stdsoap2.h:1110
void * d_stream
Definition: stdsoap2.h:1822
#define SOAP_IO_LENGTH
Definition: stdsoap2.h:1094
float z_ratio_out
Definition: stdsoap2.h:1832
soap_mode omode
Definition: stdsoap2.h:1603
#define SOAP_MALLOC(soap, size)
Definition: stdsoap2.h:1190
short encoding
Definition: stdsoap2.h:1725
void * ssl
Definition: stdsoap2.h:1799
#define SOAP_IO_BUFFER
Definition: stdsoap2.h:1088
#define SOAP_ENC_ZLIB
Definition: stdsoap2.h:1102
size_t bufidx
Definition: stdsoap2.h:1699
short mustUnderstand
Definition: stdsoap2.h:1726
int(* fprepareinit)(struct soap *)
Definition: stdsoap2.h:1666
#define SOAP_OK
Definition: stdsoap2.h:995
char * z_buf
Definition: stdsoap2.h:1828
int idnum
Definition: stdsoap2.h:1633
#define SOAP_IO_STORE
Definition: stdsoap2.h:1089
short position
Definition: stdsoap2.h:1721
static void soap_select_mime_boundary(struct soap *)
Definition: stdsoap2.cpp:15582
#define SOAP_ZLIB_ERROR
Definition: stdsoap2.h:1026
#define SOAP_ENC_XML
Definition: stdsoap2.h:1098
if(!yymsg) yymsg
#define SOAP_ENC_DIME
Definition: stdsoap2.h:1099
int socket
Definition: stdsoap2.h:1684
#define SOAP_IO_KEEPALIVE
Definition: stdsoap2.h:1095
#define SOAP_ENC_MIME
Definition: stdsoap2.h:1100
short null
Definition: stdsoap2.h:1727
void soap_clr_attr(struct soap *soap)
Definition: stdsoap2.cpp:10164
size_t buflen
Definition: stdsoap2.h:1700
static void soap_free_ns(struct soap *soap)
Definition: stdsoap2.cpp:8135
const char * encodingStyle
Definition: stdsoap2.h:1609
short zlib_out
Definition: stdsoap2.h:1827
size_t count
Definition: stdsoap2.h:1705
int soap_bind ( struct soap soap,
const char *  host,
int  port,
int  backlog 
)

Definition at line 5457 of file stdsoap2.cpp.

References soap::bind_flags, DBGLOG, soap::errmode, soap::errnum, soap::fclosesocket, soap::fresolve, soap::imode, soap::master, soap::omode, soap::peer, soap::peerlen, SOAP_BUFLEN, soap_closesock(), SOAP_GAI_STRERROR, soap_int2s(), SOAP_INVALID_SOCKET, SOAP_IO_KEEPALIVE, SOAP_IO_UDP, soap_set_receiver_error(), soap_socket_errno, SOAP_TCP_ERROR, soap_valid_socket, soap::socket, tcp_error(), and tcp_init().

5458  {
5459 #ifdef WITH_IPV6
5460  struct addrinfo *addrinfo = NULL;
5461  struct addrinfo hints;
5462  struct addrinfo res;
5463  int err;
5464 #ifdef IPV6_V6ONLY
5465  int unset = 0;
5466 #ifdef SOL_IP
5467  int level = SOL_IP;
5468 #else
5469  int level = IPPROTO_IPV6;
5470 #endif
5471 #endif
5472 #endif
5473 #ifndef WITH_LEAN
5474  int len = SOAP_BUFLEN;
5475  int set = 1;
5476 #endif
5477 
5478  if (soap_valid_socket(soap->master))
5479  {
5480  soap->fclosesocket(soap, soap->master);
5481  soap->master = SOAP_INVALID_SOCKET;
5482  }
5483 
5484  soap->socket = SOAP_INVALID_SOCKET;
5485  soap->errmode = 1;
5486 
5487  if (tcp_init(soap))
5488  {
5489  soap_set_receiver_error(soap, tcp_error(soap), "TCP init failed in soap_bind()", SOAP_TCP_ERROR);
5490  return SOAP_INVALID_SOCKET;
5491  }
5492 
5493 #ifdef WITH_IPV6
5494  memset((void*)&hints, 0, sizeof(hints));
5495  hints.ai_family = PF_UNSPEC;
5496 #ifndef WITH_LEAN
5497 
5498  if ((soap->omode & SOAP_IO_UDP))
5499  hints.ai_socktype = SOCK_DGRAM;
5500  else
5501 #endif
5502  hints.ai_socktype = SOCK_STREAM;
5503 
5504  hints.ai_flags = AI_PASSIVE;
5505  soap->errmode = 2;
5506  err = getaddrinfo(host, soap_int2s(soap, port), &hints, &addrinfo);
5507 
5508  if (addrinfo)
5509  {
5510  res = *addrinfo;
5511  memcpy(&soap->peer, addrinfo->ai_addr, addrinfo->ai_addrlen);
5512  soap->peerlen = addrinfo->ai_addrlen;
5513  res.ai_addr = (struct sockaddr*) & soap->peer;
5514  res.ai_addrlen = soap->peerlen;
5515  freeaddrinfo(addrinfo);
5516  }
5517 
5518  if (err || !addrinfo)
5519  {
5520  soap_set_receiver_error(soap, SOAP_GAI_STRERROR(err), "getaddrinfo failed in soap_bind()", SOAP_TCP_ERROR);
5521  return SOAP_INVALID_SOCKET;
5522  }
5523 
5524  soap->master = (int)socket(res.ai_family, res.ai_socktype, res.ai_protocol);
5525 #else
5526 #ifndef WITH_LEAN
5527 
5528  if ((soap->omode & SOAP_IO_UDP))
5529  soap->master = (int)socket(AF_INET, SOCK_DGRAM, 0);
5530  else
5531 #endif
5532  soap->master = (int)socket(AF_INET, SOCK_STREAM, 0);
5533 
5534 #endif
5535  soap->errmode = 0;
5536 
5537  if (!soap_valid_socket(soap->master))
5538  {
5539  soap->errnum = soap_socket_errno(soap->master);
5540  soap_set_receiver_error(soap, tcp_error(soap), "socket failed in soap_bind()", SOAP_TCP_ERROR);
5541  return SOAP_INVALID_SOCKET;
5542  }
5543 
5544 #ifndef WITH_LEAN
5545 
5546  if ((soap->omode & SOAP_IO_UDP))
5547  soap->socket = soap->master;
5548 
5549 #endif
5550 #ifdef SOCKET_CLOSE_ON_EXEC
5551 #ifdef WIN32
5552 #ifndef UNDER_CE
5553  SetHandleInformation((HANDLE)soap->master, HANDLE_FLAG_INHERIT, 0);
5554 #endif
5555 #else
5556  fcntl(soap->master, F_SETFD, 1);
5557 #endif
5558 #endif
5559 #ifndef WITH_LEAN
5560 
5561  if (soap->bind_flags && setsockopt(soap->master, SOL_SOCKET, soap->bind_flags, (char*)&set, sizeof(int)))
5562  {
5563  soap->errnum = soap_socket_errno(soap->master);
5564  soap_set_receiver_error(soap, tcp_error(soap), "setsockopt failed in soap_bind()", SOAP_TCP_ERROR);
5565  return SOAP_INVALID_SOCKET;
5566  }
5567 
5568  if (((soap->imode | soap->omode) & SOAP_IO_KEEPALIVE) && setsockopt(soap->master, SOL_SOCKET, SO_KEEPALIVE, (char*)&set, sizeof(int)))
5569  {
5570  soap->errnum = soap_socket_errno(soap->master);
5571  soap_set_receiver_error(soap, tcp_error(soap), "setsockopt SO_KEEPALIVE failed in soap_bind()", SOAP_TCP_ERROR);
5572  return SOAP_INVALID_SOCKET;
5573  }
5574 
5575  if (setsockopt(soap->master, SOL_SOCKET, SO_SNDBUF, (char*)&len, sizeof(int)))
5576  {
5577  soap->errnum = soap_socket_errno(soap->master);
5578  soap_set_receiver_error(soap, tcp_error(soap), "setsockopt SO_SNDBUF failed in soap_bind()", SOAP_TCP_ERROR);
5579  return SOAP_INVALID_SOCKET;
5580  }
5581 
5582  if (setsockopt(soap->master, SOL_SOCKET, SO_RCVBUF, (char*)&len, sizeof(int)))
5583  {
5584  soap->errnum = soap_socket_errno(soap->master);
5585  soap_set_receiver_error(soap, tcp_error(soap), "setsockopt SO_RCVBUF failed in soap_bind()", SOAP_TCP_ERROR);
5586  return SOAP_INVALID_SOCKET;
5587  }
5588 
5589 #ifdef TCP_NODELAY
5590 
5591  if (!(soap->omode & SOAP_IO_UDP) && setsockopt(soap->master, IPPROTO_TCP, TCP_NODELAY, (char*)&set, sizeof(int)))
5592  {
5593  soap->errnum = soap_socket_errno(soap->master);
5594  soap_set_receiver_error(soap, tcp_error(soap), "setsockopt TCP_NODELAY failed in soap_bind()", SOAP_TCP_ERROR);
5595  return SOAP_INVALID_SOCKET;
5596  }
5597 
5598 #endif
5599 #endif
5600 #ifdef WITH_IPV6
5601 #ifdef IPV6_V6ONLY
5602 
5603  if (setsockopt(soap->master, level, IPV6_V6ONLY, (char*)&unset, sizeof(int)))
5604  {
5605  soap->errnum = soap_socket_errno(soap->master);
5606  soap_set_receiver_error(soap, tcp_error(soap), "setsockopt IPV6_V6ONLY failed in soap_bind()", SOAP_TCP_ERROR);
5607  return SOAP_INVALID_SOCKET;
5608  }
5609 
5610 #endif
5611  soap->errmode = 0;
5612 
5613  if (bind(soap->master, res.ai_addr, (int)res.ai_addrlen))
5614  {
5615  soap->errnum = soap_socket_errno(soap->master);
5616  DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Could not bind to host\n"));
5617  soap_closesock(soap);
5618  soap_set_receiver_error(soap, tcp_error(soap), "bind failed in soap_bind()", SOAP_TCP_ERROR);
5619  return SOAP_INVALID_SOCKET;
5620  }
5621 
5622 #else
5623  soap->peerlen = sizeof(soap->peer);
5624  memset((void*)&soap->peer, 0, sizeof(soap->peer));
5625  soap->peer.sin_family = AF_INET;
5626  soap->errmode = 2;
5627 
5628  if (host)
5629  {
5630  if (soap->fresolve(soap, host, &soap->peer.sin_addr))
5631  {
5632  soap_set_receiver_error(soap, tcp_error(soap), "get host by name failed in soap_bind()", SOAP_TCP_ERROR);
5633  return SOAP_INVALID_SOCKET;
5634  }
5635  }
5636  else
5637  soap->peer.sin_addr.s_addr = htonl(INADDR_ANY);
5638 
5639  soap->peer.sin_port = htons((short)port);
5640  soap->errmode = 0;
5641 
5642  if (bind(soap->master, (struct sockaddr*)&soap->peer, (int)soap->peerlen))
5643  {
5644  soap->errnum = soap_socket_errno(soap->master);
5645  DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Could not bind to host\n"));
5646  soap_closesock(soap);
5647  soap_set_receiver_error(soap, tcp_error(soap), "bind failed in soap_bind()", SOAP_TCP_ERROR);
5648  return SOAP_INVALID_SOCKET;
5649  }
5650 
5651 #endif
5652 
5653  if (!(soap->omode & SOAP_IO_UDP) && listen(soap->master, backlog))
5654  {
5655  soap->errnum = soap_socket_errno(soap->master);
5656  DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Could not bind to host\n"));
5657  soap_closesock(soap);
5658  soap_set_receiver_error(soap, tcp_error(soap), "listen failed in soap_bind()", SOAP_TCP_ERROR);
5659  return SOAP_INVALID_SOCKET;
5660  }
5661 
5662  return soap->master;
5663  }
#define soap_socket_errno(s)
Definition: stdsoap2.h:803
#define soap_valid_socket(n)
Definition: stdsoap2.h:698
static int tcp_init(struct soap *)
Definition: stdsoap2.cpp:4292
soap_mode imode
Definition: stdsoap2.h:1602
#define SOAP_BUFLEN
Definition: stdsoap2.h:814
#define SOAP_IO_UDP
Definition: stdsoap2.h:1092
#define DBGLOG(DBGFILE, CMD)
Definition: stdsoap2.h:1247
int errmode
Definition: stdsoap2.h:1756
int(* fresolve)(struct soap *, const char *, struct in_addr *inaddr)
Definition: stdsoap2.h:1649
int soap_set_receiver_error(struct soap *soap, const char *faultstring, const char *faultdetailXML, int soaperror)
Definition: stdsoap2.cpp:19218
#define SOAP_GAI_STRERROR
Definition: stdsoap2.h:701
int master
Definition: stdsoap2.h:1683
soap_mode omode
Definition: stdsoap2.h:1603
size_t peerlen
Definition: stdsoap2.h:1787
int bind_flags
Definition: stdsoap2.h:1618
int(* fclosesocket)(struct soap *, int)
Definition: stdsoap2.h:1652
const char * soap_int2s(struct soap *soap, int n)
Definition: stdsoap2.cpp:11949
static const char * tcp_error(struct soap *)
Definition: stdsoap2.cpp:4506
struct sockaddr_in peer
Definition: stdsoap2.h:1784
int errnum
Definition: stdsoap2.h:1757
int soap_closesock(struct soap *soap)
Definition: stdsoap2.cpp:6121
#define SOAP_INVALID_SOCKET
Definition: stdsoap2.h:697
#define SOAP_TCP_ERROR
Definition: stdsoap2.h:1023
int socket
Definition: stdsoap2.h:1684
#define SOAP_IO_KEEPALIVE
Definition: stdsoap2.h:1095
size_t soap_block_size ( struct soap soap,
struct soap_blist b 
)

Definition at line 3120 of file stdsoap2.cpp.

References soap::blist, and soap_blist::ptr.

Referenced by soap_end_send(), and soap_save_block().

3121  {
3122  if (!b)
3123  b = soap->blist;
3124 
3125  return *(size_t*)(b->ptr + sizeof(char*));
3126  }
struct soap_blist * blist
Definition: stdsoap2.h:1624
char * ptr
Definition: stdsoap2.h:1282
int soap_body_begin_in ( struct soap soap)

Definition at line 17685 of file stdsoap2.cpp.

References soap::body, soap::error, soap::part, soap_element_begin_in(), SOAP_IN_BODY, SOAP_NO_BODY, and SOAP_OK.

Referenced by MiriamWebServicesSoapBindingProxy::checkRegExp(), MiriamWebServicesSoapBindingProxy::getDataResources(), MiriamWebServicesSoapBindingProxy::getDataTypeDef(), MiriamWebServicesSoapBindingProxy::getDataTypePattern(), MiriamWebServicesSoapBindingProxy::getDataTypesId(), MiriamWebServicesSoapBindingProxy::getDataTypesName(), MiriamWebServicesSoapBindingProxy::getDataTypeSynonyms(), MiriamWebServicesSoapBindingProxy::getDataTypeURI(), MiriamWebServicesSoapBindingProxy::getDataTypeURIs(), MiriamWebServicesSoapBindingProxy::getJavaLibraryVersion(), MiriamWebServicesSoapBindingProxy::getLocation(), MiriamWebServicesSoapBindingProxy::getLocations(), MiriamWebServicesSoapBindingProxy::getLocations_(), MiriamWebServicesSoapBindingProxy::getMiriamURI(), MiriamWebServicesSoapBindingProxy::getName(), MiriamWebServicesSoapBindingProxy::getNames(), MiriamWebServicesSoapBindingProxy::getOfficialDataTypeURI(), MiriamWebServicesSoapBindingProxy::getResourceInfo(), MiriamWebServicesSoapBindingProxy::getResourceInstitution(), MiriamWebServicesSoapBindingProxy::getResourceLocation(), MiriamWebServicesSoapBindingProxy::getServicesInfo(), MiriamWebServicesSoapBindingProxy::getServicesVersion(), MiriamWebServicesSoapBindingProxy::getURI(), and MiriamWebServicesSoapBindingProxy::isDeprecated().

17686  {
17687  soap->part = SOAP_IN_BODY;