[mw-devel] MW3 r1028 - in trunk: . src

welshbyte at sucs.org welshbyte at sucs.org
Wed Apr 2 13:08:47 BST 2008


Author: welshbyte
Date: 2008-04-02 13:08:46 +0100 (Wed, 02 Apr 2008)
New Revision: 1028

Modified:
   trunk/mw.spec
   trunk/src/Makefile
   trunk/src/bb.h
   trunk/src/del_user.c
   trunk/src/files.c
   trunk/src/files.h
   trunk/src/mod.c
Log:
Make the path to the .bb files configurable, default /var/lib/mw


Modified: trunk/mw.spec
===================================================================
--- trunk/mw.spec	2008-04-02 08:13:54 UTC (rev 1027)
+++ trunk/mw.spec	2008-04-02 12:08:46 UTC (rev 1028)
@@ -42,6 +42,7 @@
 %attr(771,mw,mw) %{_libdir}/mw/mesgs
 %attr(751,mw,mw) %{_libdir}/mw/rooms
 %attr(755,mw,mw) %dir /var/log/mw
+%attr(700,mw,mw) %dir /var/lib/mw
 %config %attr(640,mw,mw) %{_libdir}/mw/login.banner
 %{_libdir}/mw/help
 %{_libdir}/mw/mudhelp

Modified: trunk/src/Makefile
===================================================================
--- trunk/src/Makefile	2008-04-02 08:13:54 UTC (rev 1027)
+++ trunk/src/Makefile	2008-04-02 12:08:46 UTC (rev 1028)
@@ -3,6 +3,7 @@
 bindir ?= /usr/local/bin
 localstatedir ?= /var
 LOGDIR := $(localstatedir)/log/mw
+STATEDIR := $(localstatedir)/lib/mw
 HOMEPATH := $(libdir)/mw
 TMPDIR = /tmp
 
@@ -32,6 +33,7 @@
 DEFS+= -DVER_TWK=\"$(VERSION_TWEAK)\"
 DEFS+= -DHOMEPATH=\"$(HOMEPATH)\"
 DEFS+= -DLOGDIR=\"$(LOGDIR)\"
+DEFS+= -DSTATEDIR=\"$(STATEDIR)\"
 
 ### uncomment for add Electric fence
 #LDFLAGS+= -L. -lefence
@@ -103,6 +105,7 @@
 install: mw
 	install -Ds mw $(bindir)/mw
 	install -d $(LOGDIR)
+	install -d $(STATEDIR)
 
 clean:
 	-rm -f *.o *.d red mw del_user

Modified: trunk/src/bb.h
===================================================================
--- trunk/src/bb.h	2008-04-02 08:13:54 UTC (rev 1027)
+++ trunk/src/bb.h	2008-04-02 12:08:46 UTC (rev 1028)
@@ -16,6 +16,10 @@
 #define LOGDIR		"/var/log/mw"
 #endif
 
+#ifndef STATEDIR
+#define STATEDIR	"/var/lib/mw"
+#endif
+
 #define LOGFILE		LOGDIR"/log.bb"
 #define LOGIN_BANNER	"login.banner"
 #define DEVEL_BANNER	"login.banner.devel"

Modified: trunk/src/del_user.c
===================================================================
--- trunk/src/del_user.c	2008-04-02 08:13:54 UTC (rev 1027)
+++ trunk/src/del_user.c	2008-04-02 12:08:46 UTC (rev 1028)
@@ -6,18 +6,16 @@
 
 main()
 {
-	char oldpath[1024];
 	char newpath[1024];
 	int newfile,oldfile;
 	char buff[20];
 	long tt=0l;
 	
-	sprintf(oldpath,"%s/%s",HOMEPATH,USERFILE);
-	sprintf(newpath,"%s.new",oldpath);
+	sprintf(newpath,"%s.new",USERFILE);
 
-	if ((oldfile=open(oldpath,O_RDONLY))<0)
+	if ((oldfile=open(USERFILE,O_RDONLY))<0)
 	{
-		perror(oldpath);
+		perror(USERFILE);
 		exit(0);
 	}
 	if ((newfile=open(newpath,O_WRONLY|O_CREAT,0600))<0)

Modified: trunk/src/files.c
===================================================================
--- trunk/src/files.c	2008-04-02 08:13:54 UTC (rev 1027)
+++ trunk/src/files.c	2008-04-02 12:08:46 UTC (rev 1028)
@@ -16,7 +16,7 @@
 int createuserfile()
 {
 	int fd;
-	fd = creat(makepath(USERFILE,"",""), 0600);
+	fd = creat(USERFILE, 0600);
 	if (fd < 0) {
 		perror("Create User File");
 		return -1;
@@ -28,7 +28,7 @@
 int openuserfile(int flags)
 {
 	int x;
-	x=open(makepath(USERFILE,"",""),flags);
+	x=open(USERFILE,flags);
 	if (x>=0) return x;
 
 	if (errno != ENOENT || createuserfile())
@@ -37,7 +37,7 @@
 		exit(-1);
 	}
 
-	x=open(makepath(USERFILE,"",""),flags);
+	x=open(USERFILE,flags);
 	if (x>=0) return x;
 
 	perror("Open User File After Create");
@@ -48,7 +48,7 @@
 {
 	int file,found=FALSE;
 
-	if (access(makepath(USERFILE,"",""),00)) return(FALSE);
+	if (access(USERFILE,00)) return(FALSE);
 	file=openuserfile(O_RDONLY);
 	while (!found && get_person(file,usr))
 		if (stringcmp(usr->name,name,-1) && !u_del(usr->status))
@@ -63,7 +63,7 @@
 {
 	int outfile;
 	
-	if ((outfile=err_open(makepath(USERFILE,"",""),O_WRONLY|O_APPEND|O_CREAT,0600))<0)
+	if ((outfile=err_open(USERFILE,O_WRONLY|O_APPEND|O_CREAT,0600))<0)
 		exit(-1);
 	Lock_File(outfile);
 	write(outfile,record,sizeof(*record));
@@ -75,7 +75,7 @@
 int createwhofile()
 {
 	int fd;
-	fd = creat(makepath(WHOFILE,"",""), 0644);
+	fd = creat(WHOFILE, 0644);
 	if (fd < 0) {
 		perror("Create Who File");
 		return -1;
@@ -87,7 +87,7 @@
 int openwhofile(int flags)
 {
 	int x;
-	x=open(makepath(WHOFILE,"",""),flags);
+	x=open(WHOFILE,flags);
 	if (x>=0) return x;
 
 	if (errno != ENOENT || createwhofile())
@@ -96,7 +96,7 @@
 		return(-1);
 	}
 
-	x=open(makepath(WHOFILE,"",""),flags);
+	x=open(WHOFILE,flags);
 	if (x>=0) return x;
 
 	perror("Open Who File After Create");
@@ -108,7 +108,7 @@
 	struct who rec;
 	int wfile;
 
-	if ((wfile=err_open(makepath(WHOFILE,"",""),O_RDWR|O_CREAT,0600))<0)
+	if ((wfile=err_open(WHOFILE,O_RDWR|O_CREAT,0600))<0)
 		{exit(-1);}
 	Lock_File(wfile);
 	while(read(wfile,&rec,sizeof(rec))==sizeof(rec))
@@ -130,7 +130,7 @@
 int openfolderfile(int mode)
 {
 	int x;
-	x=open(makepath(FOLDERFILE,"",""),mode);
+	x=open(FOLDERFILE,mode);
 	if (x<0)
 	{
 		perror("Open Folder File");
@@ -143,7 +143,7 @@
 	int fd;
 	struct folder fol;
 
-	fd = open(makepath(FOLDERFILE,"",""), O_RDONLY);
+	fd = open(FOLDERFILE, O_RDONLY);
 	if (fd < 0) return 1;
 
 	if (read(fd,&fol,sizeof(struct folder)) < sizeof(struct folder))
@@ -163,7 +163,7 @@
 	
 	record=(struct folder *)malloc(sizeof(*record));
 	record->status=0;
-	file=open(makepath(FOLDERFILE,"",""),O_WRONLY|O_CREAT,0600);
+	file=open(FOLDERFILE,O_WRONLY|O_CREAT,0600);
 	Lock_File(file);
 	for (i=0;i<64;i++) 
 		if (write(file,record,sizeof(*record))<0)

Modified: trunk/src/files.h
===================================================================
--- trunk/src/files.h	2008-04-02 08:13:54 UTC (rev 1027)
+++ trunk/src/files.h	2008-04-02 12:08:46 UTC (rev 1028)
@@ -4,9 +4,9 @@
 /* For structs person, who, folder (which may eventually move to this file) */
 #include "bb.h"
 
-#define FOLDERFILE 	"folders.bb"
-#define USERFILE 	"users.bb"
-#define WHOFILE		"who.bb"
+#define FOLDERFILE  STATEDIR"/folders.bb"
+#define USERFILE    STATEDIR"/users.bb"
+#define WHOFILE     STATEDIR"/who.bb"
 
 int openfolderfile(int mode);
 int nofolders(void);

Modified: trunk/src/mod.c
===================================================================
--- trunk/src/mod.c	2008-04-02 08:13:54 UTC (rev 1027)
+++ trunk/src/mod.c	2008-04-02 12:08:46 UTC (rev 1028)
@@ -21,9 +21,8 @@
 	int f_file;
 	int tmpindex,tmptext;
 	
-	sprintf(fullpath,"%s/%s",HOMEPATH,FOLDERFILE);
-	if ((f_file=open(fullpath,O_RDWR))<0) 
-		{perror(fullpath);exit(-1);}
+	if ((f_file=open(FOLDERFILE,O_RDWR))<0) 
+		{perror(FOLDERFILE);exit(-1);}
 	while (get_folder_entry(f_file,&fold))
 	{
 	sprintf(oldpath,"%s/%s%s%s",HOMEPATH,fold.name,INDEX_END,MOD_END);





More information about the mw-devel mailing list