summaryrefslogtreecommitdiffstats
path: root/innbbsd/dbztool.c
diff options
context:
space:
mode:
authorin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2002-03-07 23:13:44 +0800
committerin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2002-03-07 23:13:44 +0800
commitae31e19f92e717919ac8e3db9039eb38d2b89aae (patch)
treec70164d6a1852344f44b04a653ae2815043512af /innbbsd/dbztool.c
downloadpttbbs-ae31e19f92e717919ac8e3db9039eb38d2b89aae.tar
pttbbs-ae31e19f92e717919ac8e3db9039eb38d2b89aae.tar.gz
pttbbs-ae31e19f92e717919ac8e3db9039eb38d2b89aae.tar.bz2
pttbbs-ae31e19f92e717919ac8e3db9039eb38d2b89aae.tar.lz
pttbbs-ae31e19f92e717919ac8e3db9039eb38d2b89aae.tar.xz
pttbbs-ae31e19f92e717919ac8e3db9039eb38d2b89aae.tar.zst
pttbbs-ae31e19f92e717919ac8e3db9039eb38d2b89aae.zip
Initial revision
git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk/pttbbs@1 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'innbbsd/dbztool.c')
-rw-r--r--innbbsd/dbztool.c88
1 files changed, 88 insertions, 0 deletions
diff --git a/innbbsd/dbztool.c b/innbbsd/dbztool.c
new file mode 100644
index 00000000..5318721b
--- /dev/null
+++ b/innbbsd/dbztool.c
@@ -0,0 +1,88 @@
+#include <sys/file.h>
+#include "his.h"
+
+#define DEBUG 1
+#undef DEBUG
+
+static datum content, inputkey, inputvalue;
+static char dboutput[1025];
+static char dbinput[1025];
+static char valueinput[100];
+
+enum {SUBJECT, FROM, NAME};
+char *DBfetch(key)
+char *key;
+{
+ int i;
+ char *tail, *ptr;
+ if (key == NULL) return NULL;
+ sprintf(dbinput,"%.510s",key);
+ inputkey.dptr = dbinput;
+ inputkey.dsize = strlen(dbinput);
+ content.dptr = dboutput;
+ ptr = (char*)HISfilesfor(&inputkey,&content);
+ if (ptr == NULL) {
+ return NULL;
+ }
+ return ptr;
+}
+
+DBstore(key,paths)
+char *key;
+char *paths;
+{
+ int i;
+ char *tail;
+ time_t now;
+ time(&now);
+ if (key == NULL) return -1;
+ sprintf(dbinput,"%.510s",key);
+ inputkey.dptr = dbinput;
+ inputkey.dsize = strlen(dbinput);
+ if (HISwrite(&inputkey, now, paths ) == FALSE) {
+ return -1;
+ } else {
+ return 0;
+ }
+}
+
+int storeDB(mid,paths)
+char *mid;
+char *paths;
+{
+ char *key,*ptr;
+ int rel;
+ ptr = DBfetch(mid);
+ if (ptr != NULL) {
+ return 0;
+ } else {
+ return DBstore(mid , paths);
+ }
+}
+
+my_mkdir (idir,mode)
+char *idir;
+int mode;
+{
+ char buffer[LEN];
+ char *ptr, *dir = buffer;
+ struct stat st;
+ strncpy(dir, idir, LEN - 1);
+ for (;dir!=NULL && *dir;) {
+ ptr = (char*)strchr(dir,'/');
+ if (ptr != NULL) {
+ *ptr = '\0';
+ }
+ if (stat(dir,&st) != 0) {
+ if (mkdir(dir,mode) != 0 )
+ return -1;
+ }
+ chdir(dir);
+ if (ptr != NULL)
+ dir = ptr +1;
+ else
+ dir = ptr;
+ }
+ return 0;
+}
+