diff options
-rw-r--r-- | src/common/Makefile.in | 13 | ||||
-rw-r--r-- | src/common/lock.c | 59 | ||||
-rw-r--r-- | src/common/lock.h | 12 |
3 files changed, 4 insertions, 80 deletions
diff --git a/src/common/Makefile.in b/src/common/Makefile.in index 379f80231..c24499c02 100644 --- a/src/common/Makefile.in +++ b/src/common/Makefile.in @@ -1,5 +1,5 @@ -COMMON_OBJ = obj_all/core.o obj_all/socket.o obj_all/timer.o obj_all/db.o obj_all/lock.o \ +COMMON_OBJ = obj_all/core.o obj_all/socket.o obj_all/timer.o obj_all/db.o \ obj_all/nullpo.o obj_all/malloc.o obj_all/showmsg.o obj_all/strlib.o obj_all/utils.o \ obj_all/grfio.o obj_all/mapindex.o obj_all/ers.o obj_all/md5calc.o \ obj_all/minicore.o obj_all/minisocket.o obj_all/minimalloc.o obj_all/random.o obj_all/des.o \ @@ -23,23 +23,19 @@ LIBCONFIG_INCLUDE = -I../../3rdparty/libconfig HAVE_MYSQL=@HAVE_MYSQL@ ifeq ($(HAVE_MYSQL),yes) - ALL_DEPENDS=txt sql + ALL_DEPENDS=sql SQL_DEPENDS=common common_sql else - ALL_TARGET=txt SQL_DEPENDS=needs_mysql endif -TXT_DEPENDS=common @SET_MAKE@ ##################################################################### -.PHONY : all txt sql clean help +.PHONY : all sql clean help all: $(ALL_DEPENDS) -txt: $(TXT_DEPENDS) - sql: $(SQL_DEPENDS) clean: @@ -47,8 +43,7 @@ clean: @rm -rf *.o obj_all obj_sql help: - @echo "possible targets are 'txt' 'sql' 'all' 'clean' 'help'" - @echo "'txt' - builds object files used in txt servers" + @echo "possible targets are 'sql' 'all' 'clean' 'help'" @echo "'sql' - builds object files used in sql servers" @echo "'all' - builds all above targets" @echo "'clean' - cleans builds and objects" diff --git a/src/common/lock.c b/src/common/lock.c deleted file mode 100644 index d01a54ca4..000000000 --- a/src/common/lock.c +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (c) Athena Dev Teams - Licensed under GNU GPL -// For more information, see LICENCE in the main folder - -#include "cbasetypes.h" -#include "showmsg.h" -#include "utils.h" -#include "lock.h" - -#include <stdio.h> -#include <errno.h> -#include <string.h> -#ifndef WIN32 -#include <unistd.h> -#else -#include "../common/winapi.h" -#endif - -// 書き込みファイルの保護処理 -// (書き込みが終わるまで、旧ファイルを保管しておく) - -// 新しいファイルの書き込み開始 -FILE* lock_fopen (const char* filename, int *info) { - char newfile[512]; - int no = 0; - - // 安全なファイル名を得る(手抜き) - do { - sprintf(newfile, "%s_%04d.tmp", filename, ++no); - } while(exists(newfile) && no < 9999); - *info = no; - return fopen(newfile,"w"); -} - -// 旧ファイルを削除&新ファイルをリネーム -int lock_fclose (FILE *fp, const char* filename, int *info) { - int ret = 1; - char newfile[512]; - char oldfile[512]; - if (fp != NULL) { - ret = fclose(fp); - sprintf(newfile, "%s_%04d.tmp", filename, *info); - sprintf(oldfile, "%s.bak", filename); // old backup file - - if (exists(oldfile)) remove(oldfile); // remove backup file if it already exists - rename (filename, oldfile); // backup our older data instead of deleting it - - // このタイミングで落ちると最悪。 - if ((ret = rename(newfile,filename)) != 0) { // rename our temporary file to its correct name -#if defined(__NETBSD__) || defined(_WIN32) || defined(sun) || defined (_sun) || defined (__sun__) - ShowError("%s - '"CL_WHITE"%s"CL_RESET"'\n", strerror(errno), newfile); -#else - char ebuf[255]; - ShowError("%s - '"CL_WHITE"%s"CL_RESET"'\n", strerror_r(errno, ebuf, sizeof(ebuf)), newfile); -#endif - } - } - - return ret; -} diff --git a/src/common/lock.h b/src/common/lock.h deleted file mode 100644 index 537305ccf..000000000 --- a/src/common/lock.h +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (c) Athena Dev Teams - Licensed under GNU GPL -// For more information, see LICENCE in the main folder - -#ifndef _LOCK_H_ -#define _LOCK_H_ - -#include <stdio.h> - -FILE* lock_fopen(const char* filename,int *info); -int lock_fclose(FILE *fp,const char* filename,int *info); - -#endif /* _LOCK_H_ */ |