⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stdsoap2.c

📁 apache模组的源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
  { c = soap_get1(soap);    if (c == ';' || c == EOF)      break;    *s++ = (char)c;  }  *s = '\0';  if (*tmp == '#')  { if (tmp[1] == 'x' || tmp[1] == 'X')      return strtol(tmp + 2, NULL, 16);    return atol(tmp + 1);  }  if (!strcmp(tmp, "lt"))    return '<';  if (!strcmp(tmp, "gt"))    return '>';  if (!strcmp(tmp, "amp"))    return '&';  if (!strcmp(tmp, "quot"))    return '"';  if (!strcmp(tmp, "apos"))    return '\'';#ifndef WITH_LEAN  for (map = html_entity_codes; map->code && map->string; map++)    if (!strcmp(tmp, map->string))      return map->code;#endif  return 127; /* use this to represent unknown code */}#endif/******************************************************************************/#ifndef PALM_1SOAP_FMAC1wcharSOAP_FMAC2soap_get(struct soap *soap){ 	register wchar c;  	if ((c = soap->ahead)) 		soap->ahead = 0;  	else    	c = soap_get1(soap);  	for (;;) {		if (soap->cdata){			if (c == ']')		    { c = soap_get1(soap);        if (c == ']')        { soap->cdata = 0;          soap_get1(soap); /* skip > */          c = soap_get1(soap);        }	else        { soap_revget1(soap);          return ']';        }      }      else        return c;    }    switch (c)    { case '<':        do c = soap_get1(soap);        while (blank(c));        if (c == '!' || c == '%')        { if (c == '!')          { c = soap_get1(soap);            if (c == '[')            { do c = soap_get1(soap);              while (c != EOF && c != '[');              if (c == EOF)                break;              soap->cdata = 1;              return soap_get1(soap);            }            if (c == '-' && (c = soap_get1(soap)) == '-')            { do              { c = soap_get1(soap);                if (c == '-' && (c = soap_get1(soap)) == '-')                  break;              } while (c != EOF);            }          }          while (c != EOF && c != '>')            c = soap_get1(soap);	  if (c == EOF)	    break;          c = soap_get1(soap);          continue;        }        if (c == '/')          return TT;        soap_revget1(soap);        return LT;      case '>':        return GT;      case '"':        return QT;      case '\'':        return AP;      case '&':        return soap_char(soap) | 0x80000000;    }    break;  }  return c;}#endif/******************************************************************************/#ifndef PALM_1SOAP_FMAC1wcharSOAP_FMAC2soap_advance(struct soap *soap){ 	register wchar c;  	while (((c = soap_get(soap)) != EOF) && c != LT && c != TT)		;  	return c;}#endif/******************************************************************************/#ifndef PALM_1SOAP_FMAC1wcharSOAP_FMAC2soap_skip(struct soap *soap){ register wchar c;  do c = soap_get(soap);  while (blank(c));  return c;}#endif/******************************************************************************/#ifndef WITH_LEANER#ifndef PALM_1SOAP_FMAC1intSOAP_FMAC2soap_move(struct soap *soap, int n){ DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Moving %d bytes forward\n", n));  for (; n > 0; n--)    if (soap_getchar(soap) == EOF)      return SOAP_EOF;  return SOAP_OK;}#endif#endif/******************************************************************************/#ifndef WITH_LEANER#ifndef PALM_1SOAP_FMAC1size_tSOAP_FMAC2soap_tell(struct soap *soap){ return soap->count - soap->buflen + soap->bufidx - (soap->ahead != 0);}#endif#endif/******************************************************************************/#ifndef PALM_1SOAP_FMAC1intSOAP_FMAC2soap_pututf8(struct soap *soap, register unsigned long c){ char tmp[16];  if (c > 0 && c < 0x80)  { *tmp = (char)c;    return soap_send_raw(soap, tmp, 1);  }#ifndef WITH_LEAN  if (soap->mode & SOAP_XML_CANONICAL)  { register char *t = tmp;    if (c < 0x0800)      *t++ = (char)(0xA0 | ((c >> 6) & 0x1F));    else    { if (c < 0x010000)        *t++ = (char)(0xE0 | ((c >> 12) & 0x0F));      else      { if (c < 0x200000)          *t++ = (char)(0xF0 | ((c >> 18) & 0x07));        else        { if (c < 0x04000000)            *t++ = (char)(0xF8 | ((c >> 24) & 0x03));          else          { *t++ = (char)(0xFA | ((c >> 30) & 0x01));            *t++ = (char)(0x80 | ((c >> 24) & 0x3F));          }          *t++ = (char)(0x80 | ((c >> 18) & 0x3F));        }             *t++ = (char)(0x80 | ((c >> 12) & 0x3F));      }      *t++ = (char)(0x80 | ((c >> 6) & 0x3F));    }    *t++ = (char)(0x80 | (c & 0x3F));    *t = '\0';  }  else#endif    sprintf(tmp, "&#%lu;", c);  return soap_send(soap, tmp);}#endif/******************************************************************************/#ifndef PALM_1SOAP_FMAC1wcharSOAP_FMAC2soap_getutf8(struct soap *soap){ register wchar c, c1, c2, c3, c4;  c = soap_get(soap);  if (c < 0x80)    return c;  c1 = soap_get(soap);  if (c1 < 0x80)  { soap_unget(soap, c1);    return c;  }  c1 &= 0x3F;  if (c < 0xE0)    return (wchar)(c & 0x1F) << 6 | c1;  c2 = (wchar)soap_get1(soap) & 0x3F;  if (c < 0xF0)    return (wchar)(c & 0x0F) << 12 | c1 << 6 | c2;  c3 = (wchar)soap_get1(soap) & 0x3F;  if (c < 0xF8)    return (wchar)(c & 0x07) << 18 | c1 << 12 | c2 << 6 | c3;  c4 = (wchar)soap_get1(soap) & 0x3F;  if (c < 0xFA)    return (wchar)(c & 0x07) << 24 | c1 << 18 | c2 << 12 | c3 << 6 | c4;  return (wchar)(c & 0x07) << 30 | c1 << 24 | c2 << 18 | c3 << 12 | c4 << 6 | (wchar)(soap_get1(soap) & 0x3F);}#endif/******************************************************************************/#ifndef PALM_1SOAP_FMAC1intSOAP_FMAC2soap_puthex(struct soap *soap, int n){ char tmp[2];  tmp[0] = (n >> 4) + (n > 159 ? '7' : '0');  n &= 0x0F;  tmp[1] = n + (n > 9 ? '7' : '0');  return soap_send_raw(soap, tmp, 2);}#endif/******************************************************************************/#ifndef PALM_1SOAP_FMAC1intSOAP_FMAC2soap_gethex(struct soap *soap){ register wchar c;  register char d1, d2;  if (!isxdigit((int)(c = soap_get(soap))))  { soap_unget(soap, c);    return EOF;  }  d1 = (char)c;  if (!isxdigit((int)(c = soap_get(soap))))  { soap_unget(soap, c);    return EOF;  }  d2 = (char)c;  return ((d1 >= 'A' ? (d1 & 0x7) + 9 : d1 - '0') << 4) + (d2 >= 'A' ? (d2 & 0x7) + 9 : d2 - '0');}#endif/******************************************************************************/#ifndef PALM_1SOAP_FMAC1intSOAP_FMAC2soap_putbase64(struct soap *soap, const unsigned char *s, size_t n){ register size_t i;  register unsigned long m;  char d[4];  if (!s)    return SOAP_OK;  for (; n > 2; n -= 3, s += 3)  { m = (unsigned long)s[0] << 16 | (unsigned long)s[1] << 8 | (unsigned long)s[2];    for (i = 4; i > 0; m >>= 6)      d[--i] = soap_base64o[m & 0x3F];    if (soap_send_raw(soap, d, 4))      return soap->error;  }  if (n)  { m = 0;    for (i = 0; i < n; i++)      m = m << 8 | *s++;    for (; i < 3; i++)      m <<= 8;    for (i++; i > 0; m >>= 6)      d[--i] = soap_base64o[m & 0x3F];    for (i = 3; i > n; i--)      d[i] = '=';    if (soap_send_raw(soap, d, 4))      return soap->error;  }  return SOAP_OK;}#endif/******************************************************************************/#ifndef PALM_1SOAP_FMAC1unsigned char*SOAP_FMAC2soap_getbase64(struct soap *soap, size_t *n, int malloc_flag){ register int i, j;  register wchar c;  register unsigned long m;  register char *s;  unsigned char *p;  if (soap_new_block(soap))    return NULL;  for (;;)  { s = (char*)soap_push_block(soap, 3*SOAP_BLKLEN); /* must be multiple of 3 */    if (!s)    { soap_end_block(soap);      *n = 0;      return NULL;    }    for (i = 0; i < SOAP_BLKLEN; i++)    { m = 0;      j = 0;      while (j < 4)      { c = soap_get(soap);        if (c == '=' || c < 0)        { i *= 3;          switch (j)          { case 2:              *s++ = (char)((m >> 4) & 0xFF);              i++;              break;            case 3:              *s++ = (char)((m >> 10) & 0xFF);              *s++ = (char)((m >> 2) & 0xFF);              i += 2;          }          if (n)	    *n = soap_size_block(soap, i);          p = (unsigned char*)soap_save_block(soap, NULL);          if (c >= 0)            c = soap_advance(soap);          soap_unget(soap, c);          return p;        }        c -= '+';        if (c >= 0 && c <= 79)        { m = (m << 6) + soap_base64i[c];          j++;        }      }      *s++ = (char)((m >> 16) & 0xFF);      *s++ = (char)((m >> 8) & 0xFF);      *s++ = (char)(m & 0xFF);    }  }}#endif/******************************************************************************/#ifndef PALM_1SOAP_FMAC1char *SOAP_FMAC2soap_strdup(struct soap *soap, const char *s){ char *t = NULL;  if (s && (t = (char*)soap_malloc(soap, strlen(s) + 1)))    strcpy(t, s);  return t;}#endif/******************************************************************************/#ifndef PALM_1SOAP_FMAC1intSOAP_FMAC2soap_new_block(struct soap *soap){ struct soap_blist *p;  DBGLOG(TEST, SOAP_MESSAGE(fdebug, "New block sequence (prev=%p)\n", soap->blist));  if (!(p = (struct soap_blist*)SOAP_MALLOC(sizeof(struct soap_blist))))    return SOAP_EOM;     p->next = soap->blist;   p->ptr = NULL;  p->size = 0;  soap->blist = p;  return SOAP_OK;}#endif/******************************************************************************/#ifndef PALM_1SOAP_FMAC1void*SOAP_FMAC2soap_push_block(struct soap *soap, size_t n){ char *p;  DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Push block of %u bytes (%u bytes total)\n", (unsigned int)n, (unsigned int)soap->blist->size));  if (!(p = (char*)SOAP_MALLOC(n + sizeof(char*) + sizeof(size_t))))  { soap->error = SOAP_EOM;    return NULL;  }  *(char**)p = soap->blist->ptr;  *(size_t*)(p + sizeof(char*)) = n;  soap->blist->ptr = p;  soap->blist->size += n;  return p + sizeof(char*) + sizeof(size_t);}#endif/******************************************************************************/#ifndef PALM_1SOAP_FMAC1voidSOAP_FMAC2soap_pop_block(struct soap *soap){ char *p;  if (!soap->blist->ptr)    return;  DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Pop block\n"));  p = soap->blist->ptr;  soap->blist->size -= *(size_t*)(p + sizeof(char*));  soap->blist->ptr = *(char**)p;  SOAP_FREE(p);}#endif/******************************************************************************/#ifndef PALM_1static voidsoap_update_ptrs(struct soap *soap, char *start, char *end, long offset){ int i;  register struct soap_ilist *ip;  register void *p, **q;  for (i = 0; i < SOAP_IDHASH; i++)    for (ip = soap->iht[i]; ip; ip = ip->next)    { if (ip->ptr && (char*)ip->ptr >= start && (char*)ip->ptr < end)        ip->ptr = (char*)ip->ptr + offset;      for (q = &ip->link; q; q = (void**)p)      { p = *q;        if (p && (char*)p >= start && (char*)p < end)        { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Link update id='%s' %p\n", ip->id, p));          *q = (char*)p + offset;        }      }      for (q = &ip->copy; q; q = (void**)p)      { p = *q;        if (p && (char*)p >= start && (char*)p < end)        { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Copy update id='%s' %p\n", ip->id, p));          *q = (char*)p + offset;        }      }    }}#endif/******************************************************************************/#ifndef PALM_1static intsoap_has_copies(struct soap *soap, register char *start, register char *end){ int i;  register struct soap_ilist *ip;  register char *p;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -