Пример #1
0
int WebRead(UpnpWebFileHandle FileHandle, char *buf, size_t buflen)
{
	int read;

	if (!FileHandle) return 0;

	read = sq_read(FileHandle, buf, buflen);

	LOG_DEBUG("read %d on %d", read, buflen);
	return read;
}
Пример #2
0
static void test_get_var(struct sq_connection *conn,
                         const struct sq_request_info *ri) {
  char *var, *buf;
  size_t buf_len;
  const char *cl;
  int var_len;

  sq_printf(conn, "%s", standard_reply);

  buf_len = 0;
  var = buf = NULL;
  cl = sq_get_header(conn, "Content-Length");
  sq_printf(conn, "cl: %p\n", cl);
  if ((!strcmp(ri->request_method, "POST") ||
       !strcmp(ri->request_method, "PUT"))
      && cl != NULL) {
    buf_len = atoi(cl);
    buf = malloc(buf_len);
    /* Read in two pieces, to test continuation */
    if (buf_len > 2) {
      sq_read(conn, buf, 2);
      sq_read(conn, buf + 2, buf_len - 2);
    } else {
      sq_read(conn, buf, buf_len);
    }
  } else if (ri->query_string != NULL) {
    buf_len = strlen(ri->query_string);
    buf = malloc(buf_len + 1);
    strcpy(buf, ri->query_string);
  }
  var = malloc(buf_len + 1);
  var_len = sq_get_var(buf, buf_len, "my_var", var, buf_len + 1);
  sq_printf(conn, "Value: [%s]\n", var);
  sq_printf(conn, "Value size: [%d]\n", var_len);
  free(buf);
  free(var);
}