Optimize code

Signed-off-by: Jianhui Zhao <jianhuizhao329@gmail.com>
This commit is contained in:
Jianhui Zhao committed 2018-01-17 12:50:25 +08:00
1 parent 60f339003e
commit 573969eadd
15 files changed
+52 -56

No files matched your search

-2
View File
@@ -34,9 +34,7 @@ install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/config.h
${CMAKE_CURRENT_SOURCE_DIR}/uhttpd.h
${CMAKE_CURRENT_SOURCE_DIR}/log.h
${CMAKE_CURRENT_SOURCE_DIR}/client.h
${CMAKE_CURRENT_SOURCE_DIR}/common.h
${CMAKE_CURRENT_SOURCE_DIR}/action.h
DESTINATION
include/uhttpd
+3
View File
@@ -19,8 +19,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdlib.h>
#include "action.h"
#include "uhttpd.h"
#include "log.h"
#define UH_ACTION_DATA_BUF_SIZE 1024
#define UH_ACTION_MAX_POST_SIZE 4096
+7
View File
@@ -15,11 +15,18 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <ctype.h>
#include <assert.h>
#include <arpa/inet.h>
#include <linux/limits.h>
#include <libubox/blobmsg.h>
#include "uhttpd.h"
#include "client.h"
#include "file.h"
#include "utils.h"
#include "uh_ssl.h"
#include "log.h"
const char *const http_versions[] = {
[UH_HTTP_VER_0_9] = "HTTP/0.9",
+5 -1
View File
@@ -18,7 +18,11 @@
#ifndef _CLIENT_H_
#define _CLIENT_H_
#include "common.h"
#include <netinet/in.h>
#include <libubox/kvlist.h>
#include <libubox/ustream.h>
#include "config.h"
#if (UHTTPD_SSL_SUPPORT)
#include <libubox/ustream-ssl.h>
-47
View File
@@ -1,47 +0,0 @@
/*
* Copyright (C) 2017 Jianhui Zhao <jianhuizhao329@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _COMMON_H
#define _COMMON_H
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <fcntl.h>
#include <errno.h>
#include <ctype.h>
#include <assert.h>
#include <stdbool.h>
#include <unistd.h>
#include <inttypes.h>
#include <sys/stat.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <linux/limits.h>
#include <libubox/uloop.h>
#include <libubox/utils.h>
#include <libubox/blobmsg.h>
#include <libubox/kvlist.h>
#include <libubox/avl-cmp.h>
#include <libubox/ustream.h>
#include "config.h"
#include "log.h"
#endif
+6
View File
@@ -15,11 +15,17 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <fcntl.h>
#include <dirent.h>
#include <errno.h>
#include <unistd.h>
#include <time.h>
#include "file.h"
#include "utils.h"
#include "uhttpd.h"
#include "log.h"
static const struct mimetype uh_mime_types[] = {
{ "txt", "text/plain" },
+2
View File
@@ -18,6 +18,8 @@
#ifndef _FILE_H
#define _FILE_H
#include <sys/stat.h>
#include "client.h"
struct path_info {
+6 -1
View File
@@ -14,7 +14,12 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <stdarg.h>
#include "log.h"
void __uh_log(const char *filename, int line, int priority, const char *fmt, ...)
+1 -2
View File
@@ -18,8 +18,7 @@
#ifndef _LOG_H
#define _LOG_H
#include "common.h"
#include <string.h>
#include <libubox/ulog.h>
#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
+3
View File
@@ -17,8 +17,11 @@
*/
#include <dlfcn.h>
#include <errno.h>
#include "uhttpd.h"
#include "uh_ssl.h"
#include "log.h"
static bool _init = false;
static struct ustream_ssl_ops *ops;
+2
View File
@@ -19,6 +19,8 @@
#ifndef __UHTTPD_SSL_H
#define __UHTTPD_SSL_H
#include "config.h"
#if (UHTTPD_SSL_SUPPORT)
int uh_ssl_init(struct uh_server *srv, const char *key, const char *crt);
+5
View File
@@ -15,9 +15,14 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdlib.h>
#include <unistd.h>
#include <libubox/usock.h>
#include <libubox/avl-cmp.h>
#include "uhttpd.h"
#include "uh_ssl.h"
#include "log.h"
static void uh_set_docroot(struct uh_server *srv, const char *docroot)
{
+1
View File
@@ -18,6 +18,7 @@
#ifndef _UHTTPD_H
#define _UHTTPD_H
#include "config.h"
#include "client.h"
#include "action.h"
+4
View File
@@ -15,6 +15,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include "utils.h"
void uh_printf(struct uh_client *cl, const char *format, ...)