コード例 #1
0
void
CClientMimeHandler::body()
{
    theBody->type = TYPEOTHER;

    Iterator_t lChildIter;
    Item lChild;
    String lNodeName;

    lChildIter = theBodyItem.getChildren();
    lChildIter->open();
    while (lChildIter->next(lChild)) {
        if (lChild.getNodeKind() != store::StoreConsts::elementNode) {
            continue;
        }

        getNodeName(lChild, lNodeName);

        if (lNodeName == "content") {
            parse_content(theBody, lChild);
        }
        else if (lNodeName == "multipart") {
            parse_multipart(theBody, lChild);
        }
    }
    lChildIter->close();
}
コード例 #2
0
ファイル: cgi.c プロジェクト: NUOG/ejudge
/**
 * NAME:    cgi_read
 * PURPOSE: read all the given CGI parameters
 * ARGS:    charset - character set to report errors
 * RETURN:   0 - OK,
 *          -1 - error
 * NOTE:    parse routines write error messages directly to stderr
 */
int
cgi_read(char const *charset)
{
  char *ct = 0;
  query = getenv("QUERY_STRING");
  if (query) {
    source = 0;
    if (do_cgi_read() < 0) return -1;
  }
  ct = getenv("CONTENT_TYPE");
  if (ct && !strncmp(ct, multipart, sizeof(multipart) - 1)) {
    /* got a multipart/form-data */
    return parse_multipart(charset);
  }

  const unsigned char *cl = getenv("CONTENT_LENGTH");
  if (cl) {
    errno = 0;
    char *eptr = NULL;
    int val = strtol(cl, &eptr, 10);
    if (errno || *eptr || val < 0) {
      bad_request(charset);
      exit(0);
    }
    if (val > MAX_CONTENT_LENGTH) {
      request_too_large(charset);
      exit(0);
    }
    content_length = val;
  }

  source = 1;
  if (do_cgi_read() < 0) return -1;
  return 0;
}