refactor: move struct laye and struct tunnel to packet.h

This commit is contained in:
luwenpeng
2024-08-22 14:31:46 +08:00
parent 41969adee2
commit 3014e0feef
22 changed files with 159 additions and 216 deletions

View File

@@ -1,11 +1,9 @@
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>
#include <unistd.h>
#include <stdarg.h>
#include <time.h>
#include <stdlib.h>
#include <limits.h>
#include <pthread.h>
#include "log.h"
@@ -22,8 +20,7 @@ struct log_config
{
enum log_output output;
enum log_level level;
char work_dir[1024];
char log_file[1024];
char log_file[PATH_MAX];
};
struct log_context
@@ -198,11 +195,9 @@ static int log_reopen()
int new_fd;
int old_fd;
struct tm local;
char buff[4096] = {0};
char buff[PATH_MAX * 2] = {0};
local_time(&local);
snprintf(buff, sizeof(buff), "%s/%s.%d-%02d-%02d",
g_log_ctx->config.work_dir, g_log_ctx->config.log_file,
local.tm_year + 1900, local.tm_mon + 1, local.tm_mday);
snprintf(buff, sizeof(buff), "%s.%d-%02d-%02d", g_log_ctx->config.log_file, local.tm_year + 1900, local.tm_mon + 1, local.tm_mday);
new_fd = open(buff, O_WRONLY | O_APPEND | O_CREAT, 0644);
if (new_fd == -1)
@@ -233,12 +228,6 @@ int log_init(const char *config_file)
{
memset(g_log_ctx, 0, sizeof(struct log_context));
if (getcwd(g_log_ctx->config.work_dir, sizeof(g_log_ctx->config.work_dir)) == NULL)
{
fprintf(stderr, "getcwd() failed, %s\n", strerror(errno));
return -1;
}
if (parse_config(&g_log_ctx->config, config_file) != 0)
{
return -1;