summaryrefslogtreecommitdiffstats
path: root/mbbsd/edit.c
diff options
context:
space:
mode:
authorin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2002-08-25 15:13:53 +0800
committerin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2002-08-25 15:13:53 +0800
commit093e88b99f01594ca10618c6bfa03acddf6dcfa4 (patch)
tree42aa670fdf9815df433155db4842b572957b521e /mbbsd/edit.c
parent66ef2c085317e18a704cfbe7e98f2b448ca58e16 (diff)
downloadpttbbs-093e88b99f01594ca10618c6bfa03acddf6dcfa4.tar
pttbbs-093e88b99f01594ca10618c6bfa03acddf6dcfa4.tar.gz
pttbbs-093e88b99f01594ca10618c6bfa03acddf6dcfa4.tar.bz2
pttbbs-093e88b99f01594ca10618c6bfa03acddf6dcfa4.tar.lz
pttbbs-093e88b99f01594ca10618c6bfa03acddf6dcfa4.tar.xz
pttbbs-093e88b99f01594ca10618c6bfa03acddf6dcfa4.tar.zst
pttbbs-093e88b99f01594ca10618c6bfa03acddf6dcfa4.zip
edit lock
git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk/pttbbs@493 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd/edit.c')
-rw-r--r--mbbsd/edit.c39
1 files changed, 38 insertions, 1 deletions
diff --git a/mbbsd/edit.c b/mbbsd/edit.c
index 589be70d..db335241 100644
--- a/mbbsd/edit.c
+++ b/mbbsd/edit.c
@@ -1,4 +1,4 @@
-/* $Id: edit.c,v 1.16 2002/08/20 02:42:36 in2 Exp $ */
+/* $Id: edit.c,v 1.17 2002/08/25 07:13:53 in2 Exp $ */
#include "bbs.h"
typedef struct textline_t {
struct textline_t *prev;
@@ -2280,3 +2280,40 @@ vedit(char *fpath, int saveheader, int *islocal)
}
}
}
+
+void editlock(char *fpath)
+{
+ char fn[256];
+ FILE *fp;
+ snprintf(fn, sizeof(fn), "%s.lock", fpath);
+ if( (fp = fopen(fn, "w")) != NULL ){
+ fprintf(fp, "%d\n", currpid);
+ fclose(fp);
+ }
+}
+
+void editunlock(char *fpath)
+{
+ char fn[256];
+ snprintf(fn, sizeof(fn), "%s.lock", fpath);
+ unlink(fn);
+}
+
+int iseditlocking(char *fpath, char *action)
+{
+ char fn[256];
+ FILE *fp;
+ snprintf(fn, sizeof(fn), "%s.lock", fpath);
+ if( (fp = fopen(fn, "r")) != NULL ){
+ int pid;
+ fscanf(fp, "%d", &pid);
+ fclose(fp);
+ if( kill(pid, 0) >= 0 ){
+ vmsg("文章編修中, 暫時無法%s", action);
+ return 1;
+ }
+ else
+ unlink(fn);
+ }
+ return 0;
+}