📄 stdsoap2.c
字号:
for (i = 0; i < SOAP_IDHASH; i++) for (ip = soap->iht[i]; ip; ip = ip->next) for (p = (char*)ip->copy; p; p = *(char**)p) if (p >= start && p < end) return SOAP_ERR; return SOAP_OK;}#endif/******************************************************************************/#ifndef PALM_1SOAP_FMAC1intSOAP_FMAC2soap_resolve(struct soap *soap){ int i, flag1 = 0, flag2; register struct soap_ilist *ip; for (i = 0; i < SOAP_IDHASH; i++) for (ip = soap->iht[i]; ip; ip = ip->next) { if (ip->ptr) soap_resolve_ptr(ip); else if (*ip->id == '#') flag1 = 1; } do { flag2 = 0; DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Resolving forwarded data\n")); for (i = 0; i < SOAP_IDHASH; i++) for (ip = soap->iht[i]; ip; ip = ip->next) if (ip->copy && ip->ptr && ip->size) if (!soap_has_copies(soap, (char*)ip->ptr, (char*)ip->ptr + ip->size)) { register void *p, **q = (void**)ip->copy; DBGLOG(TEST, if (q) SOAP_MESSAGE(fdebug, "Traversing copy chain to resolve id='%s'\n", ip->id)); ip->copy = NULL; do { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "... copy %p -> %p (%u bytes)\n", ip->ptr, q, (unsigned int)ip->size)); p = *q; memcpy(q, ip->ptr, ip->size); q = (void**)p; } while (q); flag2 = 1; } } while (flag2); if (flag1) return soap->error = SOAP_MISSING_ID; return SOAP_OK;}#endif/******************************************************************************/#ifndef PALM_1SOAP_FMAC1voidSOAP_FMAC2soap_resolve_ptr(struct soap_ilist *ip){ register void *p, **q, *r; q = (void**)ip->link; ip->link = NULL; r = ip->ptr; while (q) { p = *q; *q = r; q = (void**)p; }}#endif/******************************************************************************/#ifndef PALM_1SOAP_FMAC1size_tSOAP_FMAC2soap_size_block(struct soap *soap, size_t n){ if (soap->blist->ptr) { soap->blist->size -= *(size_t*)(soap->blist->ptr + sizeof(char*)) - n; *(size_t*)(soap->blist->ptr + sizeof(char*)) = n; } return soap->blist->size;}#endif/******************************************************************************/#ifndef PALM_1SOAP_FMAC1char*SOAP_FMAC2soap_first_block(struct soap *soap){ char *p, *q, *r; if (!(p = soap->blist->ptr)) return NULL; DBGLOG(TEST, SOAP_MESSAGE(fdebug, "First block\n")); r = NULL; do { q = *(char**)p; *(char**)p = r; r = p; p = q; } while (p); soap->blist->ptr = r; return r + sizeof(char*) + sizeof(size_t);}#endif/******************************************************************************/#ifndef PALM_1SOAP_FMAC1char*SOAP_FMAC2soap_next_block(struct soap *soap){ char *p; if ((p = soap->blist->ptr)) { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Next block\n")); soap->blist->ptr = *(char**)p; SOAP_FREE(p); if (soap->blist->ptr) return soap->blist->ptr + sizeof(char*) + sizeof(size_t); } return NULL;}#endif/******************************************************************************/#ifndef PALM_1SOAP_FMAC1size_tSOAP_FMAC2soap_block_size(struct soap *soap){ return *(size_t*)(soap->blist->ptr + sizeof(char*));}#endif/******************************************************************************/#ifndef PALM_1SOAP_FMAC1voidSOAP_FMAC2soap_end_block(struct soap *soap){ struct soap_blist *bp; char *p, *q; if ((bp = soap->blist)) { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "End of block sequence, free all remaining blocks\n")); for (p = bp->ptr; p; p = q) { q = *(char**)p; SOAP_FREE(p); } soap->blist = bp->next; SOAP_FREE(bp); } DBGLOG(TEST, if (soap->blist) SOAP_MESSAGE(fdebug, "Restore previous block sequence\n"));}#endif/******************************************************************************/#ifndef PALM_1SOAP_FMAC1char*SOAP_FMAC2soap_save_block(struct soap *soap, char *p){ size_t n; char *q, *s; DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Save all blocks in contiguous memory space of %u bytes (%p->%p)\n", (unsigned int)soap->blist->size, soap->blist->ptr, p)); if (soap->blist->size) { if (!p) p = (char*)soap_malloc(soap, soap->blist->size); if (p) for (s = p, q = soap_first_block(soap); q; q = soap_next_block(soap)) { n = soap_block_size(soap); soap_update_ptrs(soap, q, q + n, (long)(s - q)); /* s and q may or may not be related */ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copy %u bytes from %p to %p\n", (unsigned int)n, q, s)); memcpy(s, q, n); s += n; } else soap->error = SOAP_EOM; } soap_end_block(soap); return p;}#endif/******************************************************************************/#ifndef PALM_1SOAP_FMAC1char*SOAP_FMAC2soap_store_block(struct soap *soap, char *p){ p = soap_save_block(soap, p); if (!soap->blist) { struct soap_ilist *ip; int i; for (i = 0; i < SOAP_IDHASH; i++) for (ip = soap->iht[i]; ip; ip = ip->next) if (ip->ptr) { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Resolve link chain to point to %p\n", ip->ptr)); soap_resolve_ptr(ip); } } return p;}#endif/******************************************************************************/#ifndef PALM_2SOAP_FMAC1char *SOAP_FMAC2soap_putsize(struct soap *soap, const char *type, int size){ return soap_putsizes(soap, type, &size, 1);}#endif/******************************************************************************/#ifndef PALM_2SOAP_FMAC1char *SOAP_FMAC2soap_putsizes(struct soap *soap, const char *type, const int *size, int dim){ return soap_putsizesoffsets(soap, type, size, NULL, dim);}#endif/******************************************************************************/#ifndef PALM_2SOAP_FMAC1char *SOAP_FMAC2soap_putsizesoffsets(struct soap *soap, const char *type, const int *size, const int *offset, int dim){ int i; if (!type) return NULL; if (soap->version == 2) { sprintf(soap->type, "%s[%d", type, size[0]); for (i = 1; i < dim; i++) sprintf(soap->type + strlen(soap->type), " %d", size[i]); } else { if (offset) { sprintf(soap->type, "%s[%d", type, size[0] + offset[0]); for (i = 1; i < dim; i++) sprintf(soap->type + strlen(soap->type), ",%d", size[i] + offset[i]); } else { sprintf(soap->type, "%s[%d", type, size[0]); for (i = 1; i < dim; i++) sprintf(soap->type + strlen(soap->type), ",%d", size[i]); } strcat(soap->type, "]"); } return soap->type;}#endif/******************************************************************************/#ifndef PALM_2SOAP_FMAC1char *SOAP_FMAC2soap_putoffset(struct soap *soap, int offset){ return soap_putoffsets(soap, &offset, 1);}#endif/******************************************************************************/#ifndef PALM_2SOAP_FMAC1char *SOAP_FMAC2soap_putoffsets(struct soap *soap, const int *offset, int dim){ register int i; sprintf(soap->arrayOffset, "[%d", offset[0]); for (i = 1; i < dim; i++) sprintf(soap->arrayOffset + strlen(soap->arrayOffset), ",%d", offset[i]); strcat(soap->arrayOffset, "]"); return soap->arrayOffset;}#endif/******************************************************************************/#ifndef PALM_2SOAP_FMAC1intSOAP_FMAC2soap_size(const int *size, int dim){ register int i, n = size[0]; for (i = 1; i < dim; i++) n *= size[i]; return n;}#endif/******************************************************************************/#ifndef PALM_2SOAP_FMAC1intSOAP_FMAC2soap_getoffsets(const char *attr, const int *size, int *offset, int dim){ register int i, j = 0; if (offset) for (i = 0; i < dim && attr && *attr; i++) { attr++; j *= size[i]; j += offset[i] = (int)atol(attr); attr = strchr(attr, ','); } else for (i = 0; i < dim && attr && *attr; i++) { attr++; j *= size[i]; j += (int)atol(attr); attr = strchr(attr, ','); } return j;}#endif/******************************************************************************/#ifndef PALM_2SOAP_FMAC1intSOAP_FMAC2soap_getsize(const char *attr1, const char *attr2, int *j){ register int n, k; char *s; *j = 0; if (!*attr1) return -1; n = 1; do { attr1++; k = (int)strtol(attr1, &s, 10); if (s == attr1) return -1; n *= k; attr1 = strchr(s, ','); if (!attr1) attr1 = strchr(s, ' '); if (attr2 && *attr2) { attr2++; *j *= k; *j += (int)strtol(attr2, &s, 10); attr2 = s; } } while (attr1 && *attr1 != ']'); return n - *j;}#endif/******************************************************************************/#ifndef PALM_2SOAP_FMAC1intSOAP_FMAC2soap_getsizes(const char *attr, int *size, int dim){ register int i, n; if (!*attr) return -1; i = strlen(attr); n = 1; do { for (i = i-1; i >= 0; i--) if (attr[i] == '[' || attr[i] == ',' || attr[i] == ' ') break; n *= size[--dim] = (int)atol(attr + i + 1); } while (i >= 0 && attr[i] != '['); return n;}#endif/******************************************************************************/#ifndef PALM_2SOAP_FMAC1intSOAP_FMAC2soap_getposition(const char *attr, int *pos){ register int i, n; if (!*attr) return -1; n = 0; i = 1; do { pos[n++] = (int)atol(attr + i); while (attr[i] && attr[i] != ',' && attr[i] != ']') i++; if (attr[i] == ',') i++; } while (n < SOAP_MAXDIMS && attr[i] && attr[i] != ']'); return n;}#endif/******************************************************************************/#ifndef PALM_2SOAP_FMAC1intSOAP_FMAC2soap_push_namespace(struct soap *soap, const char *id, const char *ns){ register int i; register struct soap_nlist *np; register struct Namespace *p; np = (struct soap_nlist*)SOAP_MALLOC(sizeof(struct soap_nlist) + strlen(id)); if (!np) return soap->error = SOAP_EOM; np->next = soap->nlist; soap->nlist = np; strcpy(np->id, id); np->level = soap->level; np->index = -1; np->ns = NULL; DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Push namespace binding (level=%u) '%s' '%s'\n", soap->level, id, ns)); if ((p = soap->local_namespaces)) { for (i = 0; p->id; p++, i++) { if (p->ns) if (!soap_tag_cmp(ns, p->ns)) break; if (p->in) if (!soap_tag_cmp(ns, p->in)) { if (p->out) SOAP_FREE(p->out); if ((p->out = (char*)SOAP_MALLOC(strlen(ns) + 1))) strcpy(p->out, ns); if (i == 0) { if (!strcmp(ns, soap_env1)) { soap->version = 1; /* and make sure we use SOAP 1.1 encoding */ if (p->out) SOAP_FREE(p[1].out); if ((p[1].out = (char*)SOAP_MALLOC(sizeof(soap_enc1)))) strcpy(p[1].out, soap_enc1); } else if (!strcmp(ns, soap_env2)) { soap->version = 2; /* and make sure we use the SOAP 1.2 encoding */ if (p[1].out) SOAP_FREE(p[1].out); if ((p[1].out = (char*)SOAP_MALLOC(sizeof(soap_enc2)))) strcpy(p[1].out, soap_enc2); } } break; } } if (p && p->id) { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Push OK ('%s' matches '%s' in namespace table)\n", id, p->id)); np->index = i; } } if (!p || !p->id) { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Push NOT OK: no match found for '%s' in namespace mapping table (added to stack anyway)\n", ns)); np->ns = (char*)SOAP_MALLOC(strlen(ns) + 1); if (!np->ns) return soap->error = SOAP_EOM; strcpy(np->ns, ns); } return SOAP_OK;}#endif/******************************************************************************/#ifndef PALM_2SOAP_FMAC1voidSOAP_FMAC2soap_pop_namespace(struct soap *soap){ register struct soap_nlist *np; while (soap->nlist && soap->nlist->level >= soap->level) { np = soap->nlist->next; DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Popped namespace binding (level=%u) '%s'\n", soap->level, soap->nlist->id)); if (soap->nlist->ns) SOAP_FREE(soap->nlist->ns); SOAP_FREE(soap->nlist); soap->nlist = np; }}#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -