From d909b0b3b5cdb36032bcac395021d577d44a4d3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Wed, 23 Nov 2022 15:22:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81=E7=BB=93?= =?UTF-8?q?=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmoe.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/cmoe.c b/cmoe.c index 155b176..46d2eec 100644 --- a/cmoe.c +++ b/cmoe.c @@ -10,8 +10,8 @@ static uint32_t* items_len; static counter_t counter; -static char* DATFILE = "dat.sp"; -static char* TOKEN = "fumiama"; +static char* datfile = "dat.sp"; +static char* token = "fumiama"; #define ADD_HEADER_PARAM(buf, offset, h, p) sprintf(buf + offset, (h), (p)) #define HEADER(content_type) HTTP200 SERVER_STRING CACHE_CTRL CONTENT_TYPE(content_type) @@ -97,8 +97,8 @@ static uint32_t get_content_len(int isbig, uint16_t* len_type, char* cntstr) { len_type = l;\ } static void return_count(char* name, char* theme) { - FILE* fp = fopen(DATFILE, "rb+"); - if(!fp) fp = fopen(DATFILE, "wb+"); + FILE* fp = fopen(datfile, "rb+"); + if(!fp) fp = fopen(datfile, "wb+"); if(!fp) { http_error(HTTP500, "Open File Error."); return; @@ -164,8 +164,8 @@ static void return_count(char* name, char* theme) { } static int name_exist(char* name) { - FILE* fp = fopen(DATFILE, "rb+"); - if(!fp) fp = fopen(DATFILE, "wb+"); + FILE* fp = fopen(datfile, "rb+"); + if(!fp) fp = fopen(datfile, "wb+"); if(fp) { http_error(HTTP500, "Open File Error."); exit(EXIT_FAILURE); @@ -193,9 +193,9 @@ int main(int argc, char **argv) { return 1; } char* str = getenv("DATFILE"); - if(str != NULL) DATFILE = str; + if(str != NULL) datfile = str; str = getenv("TOKEN"); - if(str != NULL) TOKEN = str; + if(str != NULL) token = str; char* name = strstr(QS, "name="); items_len = align_struct(sizeof(counter_t), 2, &counter.name, &counter.count); if(!items_len) { @@ -225,7 +225,7 @@ int main(int argc, char **argv) { http_error(HTTP400, "Null Register Token."); return 5; } - if(strcmp(reg, TOKEN)) { + if(strcmp(reg, token)) { http_error(HTTP400, "Token Error."); return 6; } @@ -233,7 +233,7 @@ int main(int argc, char **argv) { http_error(HTTP400, "Name Exist."); return 7; } - FILE* fp = fopen(DATFILE, "ab+"); + FILE* fp = fopen(datfile, "ab+"); if (!fp) { http_error(HTTP500, "Open File Error."); return 8;