summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pttbbs/common/bbs/fhdr_stamp.c14
-rw-r--r--pttbbs/include/cmbbs.h1
-rw-r--r--pttbbs/mbbsd/record.c59
3 files changed, 19 insertions, 55 deletions
diff --git a/pttbbs/common/bbs/fhdr_stamp.c b/pttbbs/common/bbs/fhdr_stamp.c
index ac9acb6a..5a4af1db 100644
--- a/pttbbs/common/bbs/fhdr_stamp.c
+++ b/pttbbs/common/bbs/fhdr_stamp.c
@@ -20,6 +20,7 @@
static inline int fhdr_stamp(char *fpath, fileheader_t *fh, int type) GCC_INLINE;
int stampfile(char *fpath, fileheader_t *fh) GCC_WEAK;
+int stampfile_u(char *fpath, fileheader_t *fh) GCC_WEAK;
int stampdir(char *fpath, fileheader_t *fh) GCC_WEAK;
int stamplink(char *fpath, fileheader_t * fh) GCC_WEAK;
@@ -27,6 +28,8 @@ int stamplink(char *fpath, fileheader_t * fh) GCC_WEAK;
#define STAMP_DIR 1
#define STAMP_LINK 2
+/* mail / post 時,依據時間建立檔案或目錄,加上郵戳 */
+/* @param[in,out] fpath input as dirname, output as filename */
static inline int
fhdr_stamp(char *fpath, fileheader_t *fh, int type)
{
@@ -69,7 +72,6 @@ fhdr_stamp(char *fpath, fileheader_t *fh, int type)
if (type == STAMP_FILE)
close(res);
- memset(fh, 0, sizeof(fileheader_t));
strlcpy(fh->filename, ip, sizeof(fh->filename));
localtime4_r(&dtime, &ptime);
snprintf(fh->date, sizeof(fh->date), "%2d/%02d", ptime.tm_mon + 1, ptime.tm_mday);
@@ -80,18 +82,28 @@ fhdr_stamp(char *fpath, fileheader_t *fh, int type)
int
stampfile(char *fpath, fileheader_t *fh)
{
+ memset(fh, 0, sizeof(fileheader_t));
+ return fhdr_stamp(fpath, fh, STAMP_FILE);
+}
+
+int
+stampfile_u(char *fpath, fileheader_t *fh)
+{
+ // XXX do not reset fileheader (untouched)
return fhdr_stamp(fpath, fh, STAMP_FILE);
}
int
stampdir(char *fpath, fileheader_t *fh)
{
+ memset(fh, 0, sizeof(fileheader_t));
return fhdr_stamp(fpath, fh, STAMP_DIR);
}
int
stamplink(char *fpath, fileheader_t * fh)
{
+ memset(fh, 0, sizeof(fileheader_t));
return fhdr_stamp(fpath, fh, STAMP_LINK);
}
diff --git a/pttbbs/include/cmbbs.h b/pttbbs/include/cmbbs.h
index 26f695fe..3171f1c7 100644
--- a/pttbbs/include/cmbbs.h
+++ b/pttbbs/include/cmbbs.h
@@ -36,6 +36,7 @@ extern const char *Now(); // m3 flavor time string
extern int stampfile(char *fpath, fileheader_t * fh);
extern int stampdir(char *fpath, fileheader_t * fh);
extern int stamplink(char *fpath, fileheader_t * fh);
+extern int stampfile_u(char *fpath, fileheader_t *fh); // does not zero existing data in fh
/* cache.c */
#define search_ulist(uid) search_ulistn(uid, 1)
diff --git a/pttbbs/mbbsd/record.c b/pttbbs/mbbsd/record.c
index 8e311bb4..e4564f34 100644
--- a/pttbbs/mbbsd/record.c
+++ b/pttbbs/mbbsd/record.c
@@ -2,6 +2,10 @@
#include "bbs.h"
+#ifdef _BBS_UTIL_C_
+#error sorry, mbbsd/record.c does not support utility mode anymore. please use libcmbbs or libcmsys instead.
+#endif
+
#define BUFSIZE 512
#define safewrite write
@@ -113,7 +117,6 @@ substitute_ref_record(const char *direct, fileheader_t * fhdr, int ent)
/* rocker.011022: קKlockɶ}Үɤ`_u,yä[lock */
-#ifndef _BBS_UTIL_C_
int
force_open(const char *fname)
{
@@ -242,7 +245,6 @@ delete_range(const char *fpath, int id1, int id2)
close(fd);
return dcount;
}
-#endif // _BBS_UTIL_C_
void
set_safedel_fhdr(fileheader_t *fhdr, const char *newtitle)
@@ -324,57 +326,10 @@ safe_article_delete_range(const char *direct, int from, int to)
}
return -1;
}
-
-
#endif
-/* mail / post ɡA̾ڮɶإɮסA[WlW */
-/* @param[in,out] fpath input as dirname, output as filename */
-int
-stampfile_u(char *fpath, fileheader_t * fh)
- // Ptt: stampfile_u: won't clear fileheader
- // stampfile: will clear fileheader
-{
- register char *ip = fpath;
- time4_t dtime = COMMON_TIME;
- struct tm ptime;
-#ifdef _BBS_UTIL_C_
- int fp = 0; //Ptt: don't need to check
- // for utils, the time may be the same between several runs, by scw
-#endif
-
- if (access(fpath, X_OK | R_OK | W_OK))
- mkdir(fpath, 0755);
-
- while (*(++ip));
- *ip++ = '/';
-#ifdef _BBS_UTIL_C_
- do {
-#endif
- sprintf(ip, "M.%d.A.%3.3X", (int)(++dtime), (unsigned int)(random() & 0xFFF));
-#ifdef _BBS_UTIL_C_
- if (fp == -1 && errno != EEXIST)
- return -1;
- } while ((fp = open(fpath, O_CREAT | O_EXCL | O_WRONLY, 0644)) == -1);
- close(fp);
-#endif
- strlcpy(fh->filename, ip, sizeof(fh->filename));
- localtime4_r(&dtime, &ptime);
- snprintf(fh->date, sizeof(fh->date),
- "%2d/%02d", ptime.tm_mon + 1, ptime.tm_mday);
- return 0;
-}
-
-// XXX p... ثeڪ stampfile GO common/bbs/fhdr_stamp.c [A
-// ]NO|h _u.
-inline int
-stampfile(char *fpath, fileheader_t * fh)
-{
- memset(fh, 0, sizeof(fileheader_t));
- return stampfile_u(fpath, fh);
-}
-
// XXX announce(man) directory uses a smaller range of file names.
+// TODO merge with common/bbs/fhdr_stamp.c
int
stampadir(char *fpath, fileheader_t * fh, int large_set)
{
@@ -423,7 +378,6 @@ int
append_record_forward(char *fpath, fileheader_t * record, int size, const char *origid)
{
// #ifdef USE_MAIL_AUTO_FORWARD
-#if !defined(_BBS_UTIL_C_)
if (get_num_records(fpath, sizeof(fileheader_t)) <= MAX_KEEPMAIL * 2) {
FILE *fp;
char buf[512];
@@ -477,7 +431,6 @@ append_record_forward(char *fpath, fileheader_t * record, int size, const char *
}
}
}
-#endif
// #endif // USE_MAIL_AUTO_FORWARD
append_record(fpath, record, size);
@@ -485,7 +438,6 @@ append_record_forward(char *fpath, fileheader_t * record, int size, const char *
return 0;
}
-#ifndef _BBS_UTIL_C_
void
setaidfile(char *buf, const char *bn, aidu_t aidu)
{
@@ -521,4 +473,3 @@ setaidfile(char *buf, const char *bn, aidu_t aidu)
}
close(fd);
}
-#endif