Be flexible on setting camera params
This commit is contained in:
34
http/http.c
34
http/http.c
@ -52,6 +52,40 @@ error:
|
||||
return -1;
|
||||
}
|
||||
|
||||
void *http_enum_params(http_worker_t *worker, FILE *stream, http_param_fn fn, void *opaque)
|
||||
{
|
||||
const char *params = strstr(worker->client_method, "?");
|
||||
if (!params) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void *ret = NULL;
|
||||
char *start = strdup(params + 1);
|
||||
char *string = start;
|
||||
char *option;
|
||||
|
||||
// Drop after ` `
|
||||
if ((option = strstr(start, " ")) != NULL) {
|
||||
*option = 0;
|
||||
}
|
||||
|
||||
while ((option = strsep(&string, "&")) != NULL) {
|
||||
char *value = option;
|
||||
char *key = strsep(&value, "=");
|
||||
|
||||
ret = fn(worker, stream, key, value, opaque);
|
||||
if (ret) {
|
||||
break;
|
||||
}
|
||||
|
||||
// consume all separators
|
||||
while (strsep(&value, "="));
|
||||
}
|
||||
|
||||
free(start);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void http_process(http_worker_t *worker, FILE *stream)
|
||||
{
|
||||
// Read headers
|
||||
|
@ -11,6 +11,7 @@ typedef struct buffer_s buffer_t;
|
||||
typedef struct http_worker_s http_worker_t;
|
||||
|
||||
typedef void (*http_method_fn)(struct http_worker_s *worker, FILE *stream);
|
||||
typedef void *(*http_param_fn)(struct http_worker_s *worker, FILE *stream, const char *key, const char *value, void *opaque);
|
||||
|
||||
#define BUFSIZE 256
|
||||
|
||||
@ -48,6 +49,7 @@ void http_content(http_worker_t *worker, FILE *stream);
|
||||
void http_200(FILE *stream, const char *data);
|
||||
void http_404(FILE *stream, const char *data);
|
||||
void http_500(FILE *stream, const char *data);
|
||||
void *http_enum_params(http_worker_t *worker, FILE *stream, http_param_fn fn, void *opaque);
|
||||
|
||||
// M-JPEG
|
||||
void http_snapshot(http_worker_t *worker, FILE *stream);
|
||||
|
Reference in New Issue
Block a user