示例#1
0
/**
 * Go over the headers of the part and update
 * the fields in "pp" according to what we find.
 * If we are at the end of the headers (as indicated
 * by an empty line), transition into next_state.
 *
 * @param pp post processor context
 * @param ioffptr set to how many bytes have been
 *                processed
 * @return MHD_YES if we can continue processing,
 *         MHD_NO on error or if we do not have
 *                enough data yet
 */
static int
process_multipart_headers (struct MHD_PostProcessor *pp,
                           size_t *ioffptr, enum PP_State next_state)
{
  char *buf = (char *) &pp[1];
  size_t newline;

  newline = 0;
  while ((newline < pp->buffer_pos) &&
         (buf[newline] != '\r') && (buf[newline] != '\n'))
    newline++;
  if (newline == pp->buffer_size)
    {
      pp->state = PP_Error;
      return MHD_NO;            /* out of memory */
    }
  if (newline == pp->buffer_pos)
    return MHD_NO;              /* will need more data */
  if (newline == 0)
    {
      /* empty line - end of headers */
      pp->skip_rn = RN_Full;
      pp->state = next_state;
      return MHD_YES;
    }
  /* got an actual header */
  if (buf[newline] == '\r')
    pp->skip_rn = RN_OptN;
  buf[newline] = '\0';
  if (0 == strncasecmp ("Content-disposition: ",
                        buf, strlen ("Content-disposition: ")))
    {
      try_get_value (&buf[strlen ("Content-disposition: ")],
                     "name", &pp->content_name);
      try_get_value (&buf[strlen ("Content-disposition: ")],
                     "filename", &pp->content_filename);
    }
  else
    {
      try_match_header ("Content-type: ", buf, &pp->content_type);
      try_match_header ("Content-Transfer-Encoding: ",
                        buf, &pp->content_transfer_encoding);
    }
  (*ioffptr) += newline + 1;
  return MHD_YES;
}
示例#2
0
static int get_operations_test()
{
   VCOS_EVENT_FLAGS_T event;
   int passed = 1;

   if(vcos_event_flags_create(&event,"test") != VCOS_SUCCESS)
      passed = 0;
   else
   {
      int testnum = 0;
      try_get_value(&testnum, &event, 0, 0, VCOS_OR,          VCOS_EAGAIN, 0, &passed);
      try_get_value(&testnum, &event, 0, 0, VCOS_AND,         VCOS_SUCCESS, 0, &passed);
      try_get_value(&testnum, &event, 0, 0, VCOS_OR_CONSUME,  VCOS_EAGAIN, 0, &passed);
      try_get_value(&testnum, &event, 0, 0, VCOS_AND_CONSUME, VCOS_SUCCESS, 0, &passed);

      try_get_value(&testnum, &event, 1, 0, VCOS_OR,          VCOS_EAGAIN, 1, &passed);
      try_get_value(&testnum, &event, 1, 0, VCOS_AND,         VCOS_SUCCESS, 1, &passed);
      try_get_value(&testnum, &event, 1, 0, VCOS_OR_CONSUME,  VCOS_EAGAIN, 1, &passed);
      try_get_value(&testnum, &event, 1, 0, VCOS_AND_CONSUME, VCOS_SUCCESS, 1, &passed);

      try_get_value(&testnum, &event, 7, 7, VCOS_OR,          VCOS_SUCCESS, 7, &passed);
      try_get_value(&testnum, &event, 7, 7, VCOS_OR_CONSUME,  VCOS_SUCCESS, 0, &passed);
      try_get_value(&testnum, &event, 7, 3, VCOS_OR,          VCOS_SUCCESS, 7, &passed);
      try_get_value(&testnum, &event, 7, 3, VCOS_OR_CONSUME,  VCOS_SUCCESS, 4, &passed);
      try_get_value(&testnum, &event, 7, 15, VCOS_OR,         VCOS_SUCCESS, 7, &passed);
      try_get_value(&testnum, &event, 7, 15, VCOS_OR_CONSUME, VCOS_SUCCESS, 0, &passed);
      try_get_value(&testnum, &event, 7, 8, VCOS_OR,          VCOS_EAGAIN, 7, &passed);
      try_get_value(&testnum, &event, 7, 8, VCOS_OR_CONSUME,  VCOS_EAGAIN, 7, &passed);

      try_get_value(&testnum, &event, 7, 7, VCOS_AND,         VCOS_SUCCESS, 7, &passed);
      try_get_value(&testnum, &event, 7, 7, VCOS_AND_CONSUME, VCOS_SUCCESS, 0, &passed);
      try_get_value(&testnum, &event, 7, 3, VCOS_AND,         VCOS_SUCCESS, 7, &passed);
      try_get_value(&testnum, &event, 7, 3, VCOS_AND_CONSUME, VCOS_SUCCESS, 4, &passed);
      try_get_value(&testnum, &event, 7, 15, VCOS_AND,        VCOS_EAGAIN, 7, &passed);
      try_get_value(&testnum, &event, 7, 15, VCOS_AND_CONSUME, VCOS_EAGAIN, 7, &passed);
      try_get_value(&testnum, &event, 7, 8, VCOS_AND,         VCOS_EAGAIN, 7, &passed);
      try_get_value(&testnum, &event, 7, 8, VCOS_AND_CONSUME, VCOS_EAGAIN, 7, &passed);

      vcos_event_flags_delete(&event);
   }

   return passed;
}