--- lbbs/src/article_post.c 2025/11/10 14:22:18 1.42 +++ lbbs/src/article_post.c 2025/12/19 06:16:26 1.44 @@ -6,6 +6,10 @@ * Copyright (C) 2004-2025 Leaflet */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include "article_cache.h" #include "article_post.h" #include "bbs.h" @@ -53,7 +57,7 @@ int article_post(const SECTION_LIST *p_s if (p_section == NULL || p_article_new == NULL) { - log_error("NULL pointer error\n"); + log_error("NULL pointer error"); } if (!checkpriv(&BBS_priv, p_section->sid, S_POST)) @@ -73,7 +77,7 @@ int article_post(const SECTION_LIST *p_s p_editor_data = editor_data_load(""); if (p_editor_data == NULL) { - log_error("editor_data_load() error\n"); + log_error("editor_data_load() error"); ret = -1; goto cleanup; } @@ -125,7 +129,7 @@ int article_post(const SECTION_LIST *p_s { if ((ret = check_badwords(p, '*')) < 0) { - log_error("check_badwords(title) error\n"); + log_error("check_badwords(title) error"); } else if (ret > 0) { @@ -219,7 +223,7 @@ int article_post(const SECTION_LIST *p_s content = malloc(ARTICLE_CONTENT_MAX_LEN); if (content == NULL) { - log_error("malloc(content) error: OOM\n"); + log_error("malloc(content) error: OOM"); ret = -1; goto cleanup; } @@ -227,14 +231,14 @@ int article_post(const SECTION_LIST *p_s len_content = editor_data_save(p_editor_data, content, ARTICLE_CONTENT_MAX_LEN); if (len_content < 0) { - log_error("editor_data_save() error\n"); + log_error("editor_data_save() error"); ret = -1; goto cleanup; } if (check_badwords(content, '*') < 0) { - log_error("check_badwords(content) error\n"); + log_error("check_badwords(content) error"); ret = -1; goto cleanup; } @@ -242,7 +246,7 @@ int article_post(const SECTION_LIST *p_s db = db_open(); if (db == NULL) { - log_error("db_open() error: %s\n", mysql_error(db)); + log_error("db_open() error: %s", mysql_error(db)); ret = -1; goto cleanup; } @@ -255,13 +259,13 @@ int article_post(const SECTION_LIST *p_s if (mysql_query(db, sql) != 0) { - log_error("Query sign error: %s\n", mysql_error(db)); + log_error("Query sign error: %s", mysql_error(db)); ret = -1; goto cleanup; } if ((rs = mysql_use_result(db)) == NULL) { - log_error("Get sign data failed\n"); + log_error("Get sign data failed"); ret = -1; goto cleanup; } @@ -282,14 +286,14 @@ int article_post(const SECTION_LIST *p_s // Begin transaction if (mysql_query(db, "SET autocommit=0") != 0) { - log_error("SET autocommit=0 error: %s\n", mysql_error(db)); + log_error("SET autocommit=0 error: %s", mysql_error(db)); ret = -1; goto cleanup; } if (mysql_query(db, "BEGIN") != 0) { - log_error("Begin transaction error: %s\n", mysql_error(db)); + log_error("Begin transaction error: %s", mysql_error(db)); ret = -1; goto cleanup; } @@ -298,7 +302,7 @@ int article_post(const SECTION_LIST *p_s content_f = malloc((size_t)len_content * 2 + 1); if (content_f == NULL) { - log_error("malloc(content_f) error: OOM\n"); + log_error("malloc(content_f) error: OOM"); ret = -1; goto cleanup; } @@ -314,7 +318,7 @@ int article_post(const SECTION_LIST *p_s sql_content = malloc(SQL_BUFFER_LEN + (size_t)len_content * 2 + 1); if (sql_content == NULL) { - log_error("malloc(sql_content) error: OOM\n"); + log_error("malloc(sql_content) error: OOM"); ret = -1; goto cleanup; } @@ -328,7 +332,7 @@ int article_post(const SECTION_LIST *p_s if (mysql_query(db, sql_content) != 0) { - log_error("Add article content error: %s\n", mysql_error(db)); + log_error("Add article content error: %s", mysql_error(db)); ret = -1; goto cleanup; } @@ -349,7 +353,7 @@ int article_post(const SECTION_LIST *p_s if (mysql_query(db, sql) != 0) { - log_error("Add article error: %s\n", mysql_error(db)); + log_error("Add article error: %s", mysql_error(db)); ret = -1; goto cleanup; } @@ -363,7 +367,7 @@ int article_post(const SECTION_LIST *p_s if (mysql_query(db, sql) != 0) { - log_error("Update content error: %s\n", mysql_error(db)); + log_error("Update content error: %s", mysql_error(db)); ret = -1; goto cleanup; } @@ -377,7 +381,7 @@ int article_post(const SECTION_LIST *p_s if (mysql_query(db, sql) != 0) { - log_error("Update exp error: %s\n", mysql_error(db)); + log_error("Update exp error: %s", mysql_error(db)); ret = -1; goto cleanup; } @@ -391,7 +395,7 @@ int article_post(const SECTION_LIST *p_s if (mysql_query(db, sql) != 0) { - log_error("Add log error: %s\n", mysql_error(db)); + log_error("Add log error: %s", mysql_error(db)); ret = -1; goto cleanup; } @@ -399,7 +403,7 @@ int article_post(const SECTION_LIST *p_s // Commit transaction if (mysql_query(db, "COMMIT") != 0) { - log_error("Commit transaction error: %s\n", mysql_error(db)); + log_error("Commit transaction error: %s", mysql_error(db)); ret = -1; goto cleanup; } @@ -448,7 +452,7 @@ int article_modify(const SECTION_LIST *p if (p_section == NULL || p_article == NULL) { - log_error("NULL pointer error\n"); + log_error("NULL pointer error"); } if (p_article->excerption) // Modify is not allowed @@ -464,7 +468,7 @@ int article_modify(const SECTION_LIST *p db = db_open(); if (db == NULL) { - log_error("db_open() error: %s\n", mysql_error(db)); + log_error("db_open() error: %s", mysql_error(db)); ret = -1; goto cleanup; } @@ -477,13 +481,13 @@ int article_modify(const SECTION_LIST *p if (mysql_query(db, sql) != 0) { - log_error("Query article content error: %s\n", mysql_error(db)); + log_error("Query article content error: %s", mysql_error(db)); ret = -1; goto cleanup; } if ((rs = mysql_use_result(db)) == NULL) { - log_error("Get article content data failed\n"); + log_error("Get article content data failed"); ret = -1; goto cleanup; } @@ -493,7 +497,7 @@ int article_modify(const SECTION_LIST *p content = malloc(ARTICLE_CONTENT_MAX_LEN); if (content == NULL) { - log_error("malloc(content) error: OOM\n"); + log_error("malloc(content) error: OOM"); ret = -1; goto cleanup; } @@ -507,7 +511,7 @@ int article_modify(const SECTION_LIST *p p_editor_data = editor_data_load(content); if (p_editor_data == NULL) { - log_error("editor_data_load(aid=%d, cid=%d) error\n", p_article->aid, atoi(row[0])); + log_error("editor_data_load(aid=%d, cid=%d) error", p_article->aid, atoi(row[0])); ret = -1; goto cleanup; } @@ -572,7 +576,7 @@ int article_modify(const SECTION_LIST *p content = malloc(ARTICLE_CONTENT_MAX_LEN); if (content == NULL) { - log_error("malloc(content) error: OOM\n"); + log_error("malloc(content) error: OOM"); ret = -1; goto cleanup; } @@ -580,14 +584,14 @@ int article_modify(const SECTION_LIST *p len_content = editor_data_save(p_editor_data, content, ARTICLE_CONTENT_MAX_LEN - LINE_BUFFER_LEN); if (len_content < 0) { - log_error("editor_data_save() error\n"); + log_error("editor_data_save() error"); ret = -1; goto cleanup; } if (check_badwords(content, '*') < 0) { - log_error("check_badwords(content) error\n"); + log_error("check_badwords(content) error"); ret = -1; goto cleanup; } @@ -606,7 +610,7 @@ int article_modify(const SECTION_LIST *p db = db_open(); if (db == NULL) { - log_error("db_open() error: %s\n", mysql_error(db)); + log_error("db_open() error: %s", mysql_error(db)); ret = -1; goto cleanup; } @@ -614,14 +618,14 @@ int article_modify(const SECTION_LIST *p // Begin transaction if (mysql_query(db, "SET autocommit=0") != 0) { - log_error("SET autocommit=0 error: %s\n", mysql_error(db)); + log_error("SET autocommit=0 error: %s", mysql_error(db)); ret = -1; goto cleanup; } if (mysql_query(db, "BEGIN") != 0) { - log_error("Begin transaction error: %s\n", mysql_error(db)); + log_error("Begin transaction error: %s", mysql_error(db)); ret = -1; goto cleanup; } @@ -630,7 +634,7 @@ int article_modify(const SECTION_LIST *p content_f = malloc((size_t)len_content * 2 + 1); if (content_f == NULL) { - log_error("malloc(content_f) error: OOM\n"); + log_error("malloc(content_f) error: OOM"); ret = -1; goto cleanup; } @@ -644,7 +648,7 @@ int article_modify(const SECTION_LIST *p sql_content = malloc(SQL_BUFFER_LEN + (size_t)len_content * 2 + 1); if (sql_content == NULL) { - log_error("malloc(sql_content) error: OOM\n"); + log_error("malloc(sql_content) error: OOM"); ret = -1; goto cleanup; } @@ -658,7 +662,7 @@ int article_modify(const SECTION_LIST *p if (mysql_query(db, sql_content) != 0) { - log_error("Add article content error: %s\n", mysql_error(db)); + log_error("Add article content error: %s", mysql_error(db)); ret = -1; goto cleanup; } @@ -675,14 +679,14 @@ int article_modify(const SECTION_LIST *p if (mysql_query(db, sql) != 0) { - log_error("Add article error: %s\n", mysql_error(db)); + log_error("Add article error: %s", mysql_error(db)); ret = -1; goto cleanup; } if (mysql_query(db, sql) != 0) { - log_error("Update content error: %s\n", mysql_error(db)); + log_error("Update content error: %s", mysql_error(db)); ret = -1; goto cleanup; } @@ -695,7 +699,7 @@ int article_modify(const SECTION_LIST *p if (mysql_query(db, sql) != 0) { - log_error("Add log error: %s\n", mysql_error(db)); + log_error("Add log error: %s", mysql_error(db)); ret = -1; goto cleanup; } @@ -703,7 +707,7 @@ int article_modify(const SECTION_LIST *p // Commit transaction if (mysql_query(db, "COMMIT") != 0) { - log_error("Commit transaction error: %s\n", mysql_error(db)); + log_error("Commit transaction error: %s", mysql_error(db)); ret = -1; goto cleanup; } @@ -765,7 +769,7 @@ int article_reply(const SECTION_LIST *p_ if (p_section == NULL || p_article == NULL) { - log_error("NULL pointer error\n"); + log_error("NULL pointer error"); } if (!checkpriv(&BBS_priv, p_section->sid, S_POST)) @@ -786,7 +790,7 @@ int article_reply(const SECTION_LIST *p_ db = db_open(); if (db == NULL) { - log_error("db_open() error: %s\n", mysql_error(db)); + log_error("db_open() error: %s", mysql_error(db)); ret = -1; goto cleanup; } @@ -797,13 +801,13 @@ int article_reply(const SECTION_LIST *p_ if (mysql_query(db, sql) != 0) { - log_error("Query article status error: %s\n", mysql_error(db)); + log_error("Query article status error: %s", mysql_error(db)); ret = -1; goto cleanup; } if ((rs = mysql_store_result(db)) == NULL) { - log_error("Get article status data failed\n"); + log_error("Get article status data failed"); ret = -1; goto cleanup; } @@ -839,13 +843,13 @@ int article_reply(const SECTION_LIST *p_ if (mysql_query(db, sql) != 0) { - log_error("Query article content error: %s\n", mysql_error(db)); + log_error("Query article content error: %s", mysql_error(db)); ret = -1; goto cleanup; } if ((rs = mysql_use_result(db)) == NULL) { - log_error("Get article content data failed\n"); + log_error("Get article content data failed"); ret = -1; goto cleanup; } @@ -855,7 +859,7 @@ int article_reply(const SECTION_LIST *p_ content = malloc(ARTICLE_CONTENT_MAX_LEN); if (content == NULL) { - log_error("malloc(content) error: OOM\n"); + log_error("malloc(content) error: OOM"); ret = -1; goto cleanup; } @@ -863,7 +867,7 @@ int article_reply(const SECTION_LIST *p_ content_f = malloc(ARTICLE_CONTENT_MAX_LEN); if (content_f == NULL) { - log_error("malloc(content_f) error: OOM\n"); + log_error("malloc(content_f) error: OOM"); ret = -1; goto cleanup; } @@ -927,7 +931,7 @@ int article_reply(const SECTION_LIST *p_ { if ((ret = check_badwords(p, '*')) < 0) { - log_error("check_badwords(title) error\n"); + log_error("check_badwords(title) error"); } else if (ret > 0) { @@ -1003,7 +1007,7 @@ int article_reply(const SECTION_LIST *p_ p_editor_data = editor_data_load(content); if (p_editor_data == NULL) { - log_error("editor_data_load(aid=%d, cid=%d) error\n", p_article->aid, atoi(row[0])); + log_error("editor_data_load(aid=%d, cid=%d) error", p_article->aid, atoi(row[0])); ret = -1; goto cleanup; } @@ -1062,7 +1066,7 @@ int article_reply(const SECTION_LIST *p_ content = malloc(ARTICLE_CONTENT_MAX_LEN); if (content == NULL) { - log_error("malloc(content) error: OOM\n"); + log_error("malloc(content) error: OOM"); ret = -1; goto cleanup; } @@ -1070,14 +1074,14 @@ int article_reply(const SECTION_LIST *p_ len_content = editor_data_save(p_editor_data, content, ARTICLE_CONTENT_MAX_LEN); if (len_content < 0) { - log_error("editor_data_save() error\n"); + log_error("editor_data_save() error"); ret = -1; goto cleanup; } if (check_badwords(content, '*') < 0) { - log_error("check_badwords(content) error\n"); + log_error("check_badwords(content) error"); ret = -1; goto cleanup; } @@ -1085,7 +1089,7 @@ int article_reply(const SECTION_LIST *p_ db = db_open(); if (db == NULL) { - log_error("db_open() error: %s\n", mysql_error(db)); + log_error("db_open() error: %s", mysql_error(db)); ret = -1; goto cleanup; } @@ -1098,13 +1102,13 @@ int article_reply(const SECTION_LIST *p_ if (mysql_query(db, sql) != 0) { - log_error("Query sign error: %s\n", mysql_error(db)); + log_error("Query sign error: %s", mysql_error(db)); ret = -1; goto cleanup; } if ((rs = mysql_use_result(db)) == NULL) { - log_error("Get sign data failed\n"); + log_error("Get sign data failed"); ret = -1; goto cleanup; } @@ -1125,14 +1129,14 @@ int article_reply(const SECTION_LIST *p_ // Begin transaction if (mysql_query(db, "SET autocommit=0") != 0) { - log_error("SET autocommit=0 error: %s\n", mysql_error(db)); + log_error("SET autocommit=0 error: %s", mysql_error(db)); ret = -1; goto cleanup; } if (mysql_query(db, "BEGIN") != 0) { - log_error("Begin transaction error: %s\n", mysql_error(db)); + log_error("Begin transaction error: %s", mysql_error(db)); ret = -1; goto cleanup; } @@ -1141,7 +1145,7 @@ int article_reply(const SECTION_LIST *p_ content_f = malloc((size_t)len_content * 2 + 1); if (content_f == NULL) { - log_error("malloc(content_f) error: OOM\n"); + log_error("malloc(content_f) error: OOM"); ret = -1; goto cleanup; } @@ -1157,7 +1161,7 @@ int article_reply(const SECTION_LIST *p_ sql_content = malloc(SQL_BUFFER_LEN + (size_t)len_content * 2 + 1); if (sql_content == NULL) { - log_error("malloc(sql_content) error: OOM\n"); + log_error("malloc(sql_content) error: OOM"); ret = -1; goto cleanup; } @@ -1171,7 +1175,7 @@ int article_reply(const SECTION_LIST *p_ if (mysql_query(db, sql_content) != 0) { - log_error("Add article content error: %s\n", mysql_error(db)); + log_error("Add article content error: %s", mysql_error(db)); ret = -1; goto cleanup; } @@ -1193,7 +1197,7 @@ int article_reply(const SECTION_LIST *p_ if (mysql_query(db, sql) != 0) { - log_error("Add article error: %s\n", mysql_error(db)); + log_error("Add article error: %s", mysql_error(db)); ret = -1; goto cleanup; } @@ -1210,7 +1214,7 @@ int article_reply(const SECTION_LIST *p_ if (mysql_query(db, sql) != 0) { - log_error("Update topic article error: %s\n", mysql_error(db)); + log_error("Update topic article error: %s", mysql_error(db)); ret = -1; goto cleanup; } @@ -1222,7 +1226,7 @@ int article_reply(const SECTION_LIST *p_ if (mysql_query(db, sql) != 0) { - log_error("Update content error: %s\n", mysql_error(db)); + log_error("Update content error: %s", mysql_error(db)); ret = -1; goto cleanup; } @@ -1235,13 +1239,13 @@ int article_reply(const SECTION_LIST *p_ if (mysql_query(db, sql) != 0) { - log_error("Read reply info error: %s\n", mysql_error(db)); + log_error("Read reply info error: %s", mysql_error(db)); ret = -1; goto cleanup; } if ((rs = mysql_store_result(db)) == NULL) { - log_error("Get reply info failed\n"); + log_error("Get reply info failed"); ret = -1; goto cleanup; } @@ -1263,7 +1267,7 @@ int article_reply(const SECTION_LIST *p_ if (mysql_query(db, sql) != 0) { - log_error("Insert msg error: %s\n", mysql_error(db)); + log_error("Insert msg error: %s", mysql_error(db)); ret = -1; goto cleanup; } @@ -1280,7 +1284,7 @@ int article_reply(const SECTION_LIST *p_ if (mysql_query(db, sql) != 0) { - log_error("Update exp error: %s\n", mysql_error(db)); + log_error("Update exp error: %s", mysql_error(db)); ret = -1; goto cleanup; } @@ -1294,7 +1298,7 @@ int article_reply(const SECTION_LIST *p_ if (mysql_query(db, sql) != 0) { - log_error("Add log error: %s\n", mysql_error(db)); + log_error("Add log error: %s", mysql_error(db)); ret = -1; goto cleanup; } @@ -1302,7 +1306,7 @@ int article_reply(const SECTION_LIST *p_ // Commit transaction if (mysql_query(db, "COMMIT") != 0) { - log_error("Commit transaction error: %s\n", mysql_error(db)); + log_error("Commit transaction error: %s", mysql_error(db)); ret = -1; goto cleanup; }