refactoring

This commit is contained in:
Devaev Maxim
2019-03-21 01:28:02 +03:00
parent 17099e86de
commit c50388ab9f
13 changed files with 116 additions and 88 deletions

View File

@@ -24,7 +24,7 @@
#include <string.h>
#include <assert.h>
#include "tools.h"
#include "../tools.h"
#include "base64.h"

View File

@@ -20,6 +20,8 @@
*****************************************************************************/
#pragma once
#include <stdlib.h>

View File

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

View File

@@ -20,6 +20,9 @@
*****************************************************************************/
#pragma once
const unsigned BLANK_JPEG_WIDTH = 640;
const unsigned BLANK_JPEG_HEIGHT = 480;

View File

@@ -22,7 +22,7 @@
#pragma once
#include "../config.h"
#include "../../config.h"
const char HTML_INDEX_PAGE[] = " \

View File

@@ -46,12 +46,13 @@
# error Required libevent-pthreads support
#endif
#include "tools.h"
#include "logging.h"
#include "encoder.h"
#include "stream.h"
#include "../tools.h"
#include "../logging.h"
#include "../encoder.h"
#include "../stream.h"
#include "base64.h"
#include "http.h"
#include "server.h"
#include "data/index_html.h"
#include "data/blank_jpeg.h"
@@ -92,6 +93,7 @@ struct http_server_t *http_server_init(struct stream_t *stream) {
A_CALLOC(server, 1);
server->host = "127.0.0.1";
server->port = 8080;
server->unix_path = "";
server->user = "";
server->passwd = "";
server->static_path = "";
@@ -188,7 +190,7 @@ int http_server_listen(struct http_server_t *server) {
LOG_INFO("Using HTTP basic auth");
}
if (server->unix_path) {
if (server->unix_path[0] != '\0') {
struct sockaddr_un unix_addr;
int unix_fd_flags;
@@ -255,7 +257,12 @@ static bool _http_get_param_true(struct evkeyvalq *params, const char *key) {
const char *value_str;
if ((value_str = evhttp_find_header(params, key)) != NULL) {
if (!strcasecmp(value_str, "true") || !strcasecmp(value_str, "yes") || value_str[0] == '1') {
if (
value_str[0] == '1'
|| value_str[0] == 'y'
|| !evutil_ascii_strcasecmp(value_str, "true")
|| !evutil_ascii_strcasecmp(value_str, "yes")
) {
return true;
}
}

View File

@@ -20,6 +20,8 @@
*****************************************************************************/
#pragma once
#include <stdbool.h>
#include <sys/stat.h>
@@ -28,8 +30,8 @@
#include <event2/http.h>
#include <event2/util.h>
#include "tools.h"
#include "stream.h"
#include "../tools.h"
#include "../stream.h"
struct stream_client_t {

View File

@@ -38,7 +38,7 @@
#include "device.h"
#include "encoder.h"
#include "stream.h"
#include "http.h"
#include "http/server.h"
static const char _SHORT_OPTS[] = "d:i:x:y:m:a:f:z:ntb:w:q:c:s:p:u:ro:e:lhv";