Fix includes

This commit is contained in:
2021-01-17 17:56:16 +01:00
parent 77b80ca67b
commit 4b3c067a75
13 changed files with 66 additions and 24 deletions

View File

@ -5,9 +5,8 @@
* Lorenz Stechauner, 2020-12-19
*/
#include <zlib.h>
#include "cache.h"
#include "uri.h"
int magic_init() {
magic = magic_open(MAGIC_MIME);

View File

@ -8,10 +8,14 @@
#ifndef NECRONDA_SERVER_CACHE_H
#define NECRONDA_SERVER_CACHE_H
#include "uri.h"
#include <stdio.h>
#include <zlib.h>
#include <magic.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include "uri.h"
magic_t magic;

View File

@ -5,18 +5,9 @@
* Lorenz Stechauner, 2020-12-03
*/
#include "necronda-server.h"
#include "utils.h"
#include "uri.h"
#include "http.h"
#include "fastcgi.h"
#include "client.h"
int server_keep_alive = 1;
char *log_client_prefix, *log_conn_prefix, *log_req_prefix, *client_geoip;
struct timeval client_timeout = {.tv_sec = CLIENT_TIMEOUT, .tv_usec = 0};
host_config *get_host_config(const char *host) {
for (int i = 0; i < MAX_HOST_CONFIG; i++) {
host_config *hc = &config[i];

23
src/client.h Normal file
View File

@ -0,0 +1,23 @@
/**
* Necronda Web Server
* Client connection and request handlers (header file)
* src/client.h
* Lorenz Stechauner, 2021-01-17
*/
#ifndef NECRONDA_SERVER_CLIENT_H
#define NECRONDA_SERVER_CLIENT_H
#include "necronda-server.h"
#include "utils.h"
#include "uri.h"
#include "http.h"
#include "fastcgi.h"
int server_keep_alive = 1;
char *log_client_prefix, *log_conn_prefix, *log_req_prefix, *client_geoip;
struct timeval client_timeout = {.tv_sec = CLIENT_TIMEOUT, .tv_usec = 0};
#endif //NECRONDA_SERVER_CLIENT_H

View File

@ -6,9 +6,7 @@
*/
#include "config.h"
#include "uri.h"
#include <sys/ipc.h>
#include <sys/shm.h>
int config_init() {
int shm_id = shmget(SHM_KEY_CONFIG, MAX_HOST_CONFIG * sizeof(host_config), IPC_CREAT | IPC_EXCL | 0640);

View File

@ -13,6 +13,12 @@
#define CONFIG_TYPE_LOCAL 1
#define CONFIG_TYPE_REVERSE_PROXY 2
#include "uri.h"
#include <stdio.h>
#include <sys/ipc.h>
#include <sys/shm.h>
typedef struct {
int type;

View File

@ -6,9 +6,6 @@
*/
#include "fastcgi.h"
#include "necronda-server.h"
#include <sys/un.h>
char *fastcgi_add_param(char *buf, const char *key, const char *value) {
@ -205,7 +202,7 @@ int fastcgi_close_stdin(fastcgi_conn *conn) {
return 0;
}
int fastcgi_php_error(char *msg, int msg_len, char *err_msg) {
int fastcgi_php_error(const char *msg, int msg_len, char *err_msg) {
char *msg_str = malloc(msg_len + 1);
char *ptr0 = msg_str;
strncpy(msg_str, msg, msg_len);
@ -265,6 +262,7 @@ int fastcgi_php_error(char *msg, int msg_len, char *err_msg) {
}
ptr0 = ptr1 + 13;
}
free(msg_str);
return err;
}

View File

@ -11,6 +11,15 @@
#define FASTCGI_CHUNKED 1
#define FASTCGI_COMPRESS 2
#include "necronda-server.h"
#include "http.h"
#include "uri.h"
#include "client.h"
#include <sys/un.h>
#include <zlib.h>
typedef struct {
int socket;
unsigned short req_id;
@ -26,6 +35,8 @@ int fastcgi_init(fastcgi_conn *conn, unsigned int client_num, unsigned int req_n
int fastcgi_close_stdin(fastcgi_conn *conn);
int fastcgi_php_error(const char *msg, int msg_len, char *err_msg);
int fastcgi_header(fastcgi_conn *conn, http_res *res, char *err_msg);
int fastcgi_send(fastcgi_conn *conn, sock *client, int flags);

View File

@ -6,7 +6,6 @@
*/
#include "http.h"
#include "utils.h"
void http_to_camel_case(char *str, int mode) {

View File

@ -16,6 +16,10 @@
#define HTTP_REMOVE_ALL 1
#define HTTP_REMOVE_LAST 2
#include "sock.h"
#include "utils.h"
typedef struct {
unsigned short code;
char type[16];

View File

@ -8,6 +8,13 @@
#ifndef NECRONDA_SERVER_SOCK_H
#define NECRONDA_SERVER_SOCK_H
#include <openssl/err.h>
#include <openssl/pem.h>
#include <openssl/ssl.h>
#include <openssl/conf.h>
#include <openssl/engine.h>
#include <openssl/dh.h>
typedef struct {
unsigned int enc:1;
int socket;

View File

@ -8,13 +8,14 @@
#ifndef NECRONDA_SERVER_URI_H
#define NECRONDA_SERVER_URI_H
#include <sys/stat.h>
#define URI_DIR_MODE_NO_VALIDATION 0
#define URI_DIR_MODE_FORBIDDEN 1
#define URI_DIR_MODE_LIST 2
#define URI_DIR_MODE_INFO 3
#include <sys/stat.h>
typedef struct {
char etag[64];
char type[24];

View File

@ -7,6 +7,7 @@
#include "utils.h"
char *format_duration(unsigned long micros, char *buf) {
if (micros < 10000) {
sprintf(buf, "%.1f ms", (double) micros / 1000);