[mw-devel] MW3 r1032 - trunk/src
welshbyte at sucs.org
welshbyte at sucs.org
Thu Apr 3 10:20:53 BST 2008
Author: welshbyte
Date: 2008-04-03 10:20:53 +0100 (Thu, 03 Apr 2008)
New Revision: 1032
Modified:
trunk/src/add.c
trunk/src/edit.c
trunk/src/mod.c
trunk/src/new.c
trunk/src/read.c
trunk/src/tidyup.c
trunk/src/topten.c
Log:
Put all the .i, .t and .m files in the same dir as folders.bb.
All of the variable files should now be under /var. Test away.
Modified: trunk/src/add.c
===================================================================
--- trunk/src/add.c 2008-04-03 00:26:50 UTC (rev 1031)
+++ trunk/src/add.c 2008-04-03 09:20:53 UTC (rev 1032)
@@ -72,7 +72,7 @@
long posn,tmppos;
int headfile;
- if ((headfile=err_open(makepath(fol->name,INDEX_END,""),O_RDONLY,0))<0)
+ if ((headfile=err_open(buildpath(STATEDIR,fol->name,INDEX_END,""),O_RDONLY,0))<0)
{
free(fol);
free(new);
@@ -310,11 +310,11 @@
/* open files ready for saveing */
- if ((index=err_open(makepath(fol->name,INDEX_END,is_moderated(fol,user)?MOD_END:""),O_CREAT|O_RDWR,0600))<0)
+ if ((index=err_open(buildpath(STATEDIR,fol->name,INDEX_END,is_moderated(fol,user)?MOD_END:""),O_CREAT|O_RDWR,0600))<0)
{
exit(-1);
}
- if ((data=err_open(makepath(fol->name,TEXT_END,is_moderated(fol,user)?MOD_END:""),O_APPEND|O_CREAT|O_WRONLY,0600))<0)
+ if ((data=err_open(buildpath(STATEDIR,fol->name,TEXT_END,is_moderated(fol,user)?MOD_END:""),O_APPEND|O_CREAT|O_WRONLY,0600))<0)
{
exit(-1);
}
Modified: trunk/src/edit.c
===================================================================
--- trunk/src/edit.c 2008-04-03 00:26:50 UTC (rev 1031)
+++ trunk/src/edit.c 2008-04-03 09:20:53 UTC (rev 1032)
@@ -581,19 +581,19 @@
char oldpath[PATHSIZE];
mwlog("FOLDER(RENAME) of %s to %s", fold.name, tmp);
- sprintf(oldpath,"%s/%s%s",HOMEPATH,fold.name,INDEX_END);
- sprintf(fullpath,"%s/%s%s",HOMEPATH,tmp,INDEX_END);
+ sprintf(oldpath,"%s/%s%s",STATEDIR,fold.name,INDEX_END);
+ sprintf(fullpath,"%s/%s%s",STATEDIR,tmp,INDEX_END);
if (!access(oldpath,00)) rename(oldpath,fullpath);
- sprintf(oldpath,"%s/%s%s",HOMEPATH,fold.name,TEXT_END);
- sprintf(fullpath,"%s/%s%s",HOMEPATH,tmp,TEXT_END);
+ sprintf(oldpath,"%s/%s%s",STATEDIR,fold.name,TEXT_END);
+ sprintf(fullpath,"%s/%s%s",STATEDIR,tmp,TEXT_END);
if (!access(oldpath,00)) rename(oldpath,fullpath);
if (f_moderated(fold.status)||f_moderated(fold.g_status))
{
- sprintf(oldpath,"%s/%s%s%s",HOMEPATH,fold.name,INDEX_END,MOD_END);
- sprintf(fullpath,"%s/%s%s%s",HOMEPATH,tmp,INDEX_END,MOD_END);
+ sprintf(oldpath,"%s/%s%s%s",STATEDIR,fold.name,INDEX_END,MOD_END);
+ sprintf(fullpath,"%s/%s%s%s",STATEDIR,tmp,INDEX_END,MOD_END);
if (!access(oldpath,00)) rename(oldpath,fullpath);
- sprintf(oldpath,"%s/%s%s%s",HOMEPATH,fold.name,TEXT_END,MOD_END);
- sprintf(fullpath,"%s/%s%s%s",HOMEPATH,tmp,TEXT_END,MOD_END);
+ sprintf(oldpath,"%s/%s%s%s",STATEDIR,fold.name,TEXT_END,MOD_END);
+ sprintf(fullpath,"%s/%s%s%s",STATEDIR,tmp,TEXT_END,MOD_END);
if (!access(oldpath,00)) rename(oldpath,fullpath);
}
@@ -651,15 +651,15 @@
get_str(tmp,4);
if (stringcmp(tmp,"yes",-1))
{
- sprintf(fullpath,"%s/%s%s",HOMEPATH,fold.name,INDEX_END);
+ sprintf(fullpath,"%s/%s%s",STATEDIR,fold.name,INDEX_END);
if (!access(fullpath,00)) if (unlink(fullpath)) {perror(fullpath);exit(-1);}
- sprintf(fullpath,"%s/%s%s",HOMEPATH,fold.name,TEXT_END);
+ sprintf(fullpath,"%s/%s%s",STATEDIR,fold.name,TEXT_END);
if (!access(fullpath,00)) if (unlink(fullpath)) {perror(fullpath);exit(-1);}
if (f_moderated(fold.status)||f_moderated(fold.g_status))
{
- sprintf(fullpath,"%s/%s%s%s",HOMEPATH,fold.name,INDEX_END,MOD_END);
+ sprintf(fullpath,"%s/%s%s%s",STATEDIR,fold.name,INDEX_END,MOD_END);
if (!access(fullpath,00)) if (unlink(fullpath)) {perror(fullpath);exit(-1);}
- sprintf(fullpath,"%s/%s%s%s",HOMEPATH,fold.name,TEXT_END,MOD_END);
+ sprintf(fullpath,"%s/%s%s%s",STATEDIR,fold.name,TEXT_END,MOD_END);
if (!access(fullpath,00)) if (unlink(fullpath)) {perror(fullpath);exit(-1);}
}
fold.status=0;
@@ -711,9 +711,9 @@
struct Header head;
char *buff;
- if ((index=err_open(makepath(foldername,INDEX_END,""),O_RDWR,0))<0)
+ if ((index=err_open(buildpath(STATEDIR,foldername,INDEX_END,""),O_RDWR,0))<0)
return;
- if ((text=err_open(makepath(foldername,TEXT_END,""),O_RDWR,0))<0)
+ if ((text=err_open(buildpath(STATEDIR,foldername,TEXT_END,""),O_RDWR,0))<0)
return;
/* go and get message */
Modified: trunk/src/mod.c
===================================================================
--- trunk/src/mod.c 2008-04-03 00:26:50 UTC (rev 1031)
+++ trunk/src/mod.c 2008-04-03 09:20:53 UTC (rev 1032)
@@ -25,22 +25,22 @@
{perror(FOLDERFILE);exit(-1);}
while (get_folder_entry(f_file,&fold))
{
- sprintf(oldpath,"%s/%s%s%s",HOMEPATH,fold.name,INDEX_END,MOD_END);
+ sprintf(oldpath,"%s/%s%s%s",STATEDIR,fold.name,INDEX_END,MOD_END);
if (!access(oldpath,00))
{
printf(_("Changing to folder %s\n"),fold.name);
/* move the unmoderated messages to a temporary file */
- sprintf(fullpath,"%s/%s%s%s",HOMEPATH,fold.name,INDEX_END,".tmp");
+ sprintf(fullpath,"%s/%s%s%s",STATEDIR,fold.name,INDEX_END,".tmp");
rename(oldpath,fullpath);
- sprintf(oldpath,"%s/%s%s%s",HOMEPATH,fold.name,TEXT_END,MOD_END);
- sprintf(fullpath,"%s/%s%s%s",HOMEPATH,fold.name,TEXT_END,".tmp");
+ sprintf(oldpath,"%s/%s%s%s",STATEDIR,fold.name,TEXT_END,MOD_END);
+ sprintf(fullpath,"%s/%s%s%s",STATEDIR,fold.name,TEXT_END,".tmp");
rename(oldpath,fullpath);
/* files containing messages to be approved */
- sprintf(fullpath,"%s/%s%s%s",HOMEPATH,fold.name,INDEX_END,".tmp");
+ sprintf(fullpath,"%s/%s%s%s",STATEDIR,fold.name,INDEX_END,".tmp");
if ((tmpindex=open(fullpath,O_RDONLY))<0)
{perror(fullpath);exit(-1);}
- sprintf(fullpath,"%s/%s%s%s",HOMEPATH,fold.name,TEXT_END,".tmp");
+ sprintf(fullpath,"%s/%s%s%s",STATEDIR,fold.name,TEXT_END,".tmp");
if ((tmptext=open(fullpath,O_RDONLY))<0)
{perror(fullpath);exit(-1);}
while (get_data(tmpindex,&head))
@@ -83,9 +83,9 @@
printf(_("End of folder %s\n"),fold.name);
close(tmpindex);
close(tmptext);
- sprintf(fullpath,"%s/%s%s%s",HOMEPATH,fold.name,INDEX_END,".tmp");
+ sprintf(fullpath,"%s/%s%s%s",STATEDIR,fold.name,INDEX_END,".tmp");
if (unlink(fullpath)) {perror(fullpath);exit(-1);}
- sprintf(fullpath,"%s/%s%s%s",HOMEPATH,fold.name,TEXT_END,".tmp");
+ sprintf(fullpath,"%s/%s%s%s",STATEDIR,fold.name,TEXT_END,".tmp");
if (unlink(fullpath)) {perror(fullpath);exit(-1);}
}
}
@@ -98,10 +98,10 @@
int newindex,newtext;
/* files to put messages to be approved later */
- sprintf(fullpath,"%s/%s%s%s",HOMEPATH,fold->name,INDEX_END,MOD_END);
+ sprintf(fullpath,"%s/%s%s%s",STATEDIR,fold->name,INDEX_END,MOD_END);
if ((newindex=open(fullpath,O_WRONLY|O_APPEND|O_CREAT,0600))<0)
{perror(fullpath);exit(-1);}
- sprintf(fullpath,"%s/%s%s%s",HOMEPATH,fold->name,TEXT_END,MOD_END);
+ sprintf(fullpath,"%s/%s%s%s",STATEDIR,fold->name,TEXT_END,MOD_END);
if ((newtext=open(fullpath,O_WRONLY|O_APPEND|O_CREAT,0600))<0)
{perror(fullpath);exit(-1);}
Lock_File(newindex);
@@ -122,10 +122,10 @@
int modindex,modtext;
/* files for general public to read */
- sprintf(fullpath,"%s/%s%s",HOMEPATH,fold->name,INDEX_END);
+ sprintf(fullpath,"%s/%s%s",STATEDIR,fold->name,INDEX_END);
if ((modindex=open(fullpath,O_WRONLY|O_APPEND|O_CREAT,0600))<0)
{perror(fullpath);exit(-1);}
- sprintf(fullpath,"%s/%s%s",HOMEPATH,fold->name,TEXT_END);
+ sprintf(fullpath,"%s/%s%s",STATEDIR,fold->name,TEXT_END);
if ((modtext=open(fullpath,O_WRONLY|O_CREAT,0600))<0)
{perror(fullpath);exit(-1);}
Lock_File(modindex);
@@ -148,7 +148,7 @@
char fullpath[PATHSIZE];
time_t head_date;
- sprintf(fullpath,"%s/%s",HOMEPATH,"mod.save");
+ sprintf(fullpath,"%s/%s",STATEDIR,"mod.save");
head_date = (time_t)head->date;
if ((afile=open(fullpath,O_WRONLY|O_APPEND|O_CREAT,0600))<0)
{perror(fullpath);exit(-1);}
Modified: trunk/src/new.c
===================================================================
--- trunk/src/new.c 2008-04-03 00:26:50 UTC (rev 1031)
+++ trunk/src/new.c 2008-04-03 09:20:53 UTC (rev 1032)
@@ -112,13 +112,13 @@
struct Header head;
char tmp[80];
- if (access(makepath(data->name,INDEX_END,""),0))
+ if (access(buildpath(STATEDIR,data->name,INDEX_END,""),0))
{printf(_("Error: cannot find index file for folder %s\n"),data->name);return(-1);}
- if (access(makepath(data->name,TEXT_END,""),0))
+ if (access(buildpath(STATEDIR,data->name,TEXT_END,""),0))
{printf(_("Error: cannot find text file for folder %s\n"),data->name); return(-1);}
- if ((indexfile=err_open(makepath(data->name,INDEX_END,""),O_RDONLY,0))<0)
+ if ((indexfile=err_open(buildpath(STATEDIR,data->name,INDEX_END,""),O_RDONLY,0))<0)
{exit(-1);}
- if ((datafile=err_open(makepath(data->name,TEXT_END,""),O_RDONLY,0))<0)
+ if ((datafile=err_open(buildpath(STATEDIR,data->name,TEXT_END,""),O_RDONLY,0))<0)
{exit(-1);}
/* try jumping to expected location */
@@ -225,7 +225,7 @@
time_t now, then;
struct tm *t_then;
- x=makepath(fold.name,INDEX_END,"");
+ x=buildpath(STATEDIR,fold.name,INDEX_END,"");
printf("%*s ",FOLNAMESIZE,fold.name);
if (access(x,00))
printf(_(" <empty>\n"));
Modified: trunk/src/read.c
===================================================================
--- trunk/src/read.c 2008-04-03 00:26:50 UTC (rev 1031)
+++ trunk/src/read.c 2008-04-03 09:20:53 UTC (rev 1032)
@@ -115,7 +115,7 @@
if ( !u_god(user->status) && !allowed_r(&data,user))
{printf("You are not permitted to read this folder.\n");return(FALSE);}
- x=makepath(data.name,INDEX_END,"");
+ x=buildpath(STATEDIR,data.name,INDEX_END,"");
if (access(x,0))
{
printf("Error: cannot find index file for folder %s\n",data.name);
@@ -124,7 +124,7 @@
if ((headfile=err_open(x,O_RDONLY,0))<0)
{exit(-1);}
- x=makepath(data.name,TEXT_END,"");
+ x=buildpath(STATEDIR,data.name,TEXT_END,"");
if (access(x,0))
{
printf("Error: cannot find text file for folder %s\n",data.name);
@@ -179,7 +179,7 @@
if (!get_folder_number(&fold,folnum))
return;
- sprintf(tmp,"%s/%s%s",HOMEPATH,fold.name,INDEX_END);
+ sprintf(tmp,"%s/%s%s",STATEDIR,fold.name,INDEX_END);
if ((afile=open(tmp,O_RDONLY))<0)
{
printf("There are no messages in folder %s\n",fold.name);
@@ -289,7 +289,7 @@
/* empty folder */
if (data->last < data->first || data->last == 0) return(FALSE);
- x=makepath(data->name,INDEX_END,"");
+ x=buildpath(STATEDIR,data->name,INDEX_END,"");
/* no data file */
if (access(x,0)) return(FALSE);
/* cant open file */
Modified: trunk/src/tidyup.c
===================================================================
--- trunk/src/tidyup.c 2008-04-03 00:26:50 UTC (rev 1031)
+++ trunk/src/tidyup.c 2008-04-03 09:20:53 UTC (rev 1032)
@@ -61,7 +61,7 @@
}
/* open relevant folder index */
- snprintf(fullpath,PATHSIZE-1,"%s/%s%s",HOMEPATH,info.name,INDEX_END);
+ snprintf(fullpath,PATHSIZE-1,"%s/%s%s",STATEDIR,info.name,INDEX_END);
if (access(fullpath,00))
{
printf("Folder %s not found.\n",info.name);
@@ -75,7 +75,7 @@
Lock_File(indexin);
/* open relevant folder text */
- snprintf(fullpath,PATHSIZE-1,"%s/%s%s",HOMEPATH,info.name,TEXT_END);
+ snprintf(fullpath,PATHSIZE-1,"%s/%s%s",STATEDIR,info.name,TEXT_END);
if (access(fullpath,00))
{
printf("Folder %s text file not found.\n",info.name);
@@ -88,7 +88,7 @@
}
Lock_File(textin);
- snprintf(fullpath,PATHSIZE-1,"%s/%s%s%s",HOMEPATH,info.name,INDEX_END,NEW_END);
+ snprintf(fullpath,PATHSIZE-1,"%s/%s%s%s",STATEDIR,info.name,INDEX_END,NEW_END);
if ((indexout=open(fullpath,O_WRONLY|O_CREAT,0600))<0)
{
perror(fullpath);
@@ -96,7 +96,7 @@
}
Lock_File(indexout);
- snprintf(fullpath,PATHSIZE-1,"%s/%s%s%s",HOMEPATH,info.name,TEXT_END,NEW_END);
+ snprintf(fullpath,PATHSIZE-1,"%s/%s%s%s",STATEDIR,info.name,TEXT_END,NEW_END);
if ((textout=open(fullpath,O_WRONLY|O_CREAT,0600))<0)
{
perror(fullpath);
@@ -126,15 +126,15 @@
printf("Updating Real Folder...\n");
close(indexout);
- snprintf(fullpath,PATHSIZE-1,"%s/%s%s",HOMEPATH,info.name,INDEX_END);
- snprintf(fullpath2,PATHSIZE-1,"%s/%s%s%s",HOMEPATH,info.name,INDEX_END,NEW_END);
+ snprintf(fullpath,PATHSIZE-1,"%s/%s%s",STATEDIR,info.name,INDEX_END);
+ snprintf(fullpath2,PATHSIZE-1,"%s/%s%s%s",STATEDIR,info.name,INDEX_END,NEW_END);
if (rename(fullpath2,fullpath)) perror("rename");
Unlock_File(indexin);
close(indexin);
close(textout);
- snprintf(fullpath,PATHSIZE-1,"%s/%s%s",HOMEPATH,info.name,TEXT_END);
- snprintf(fullpath2,PATHSIZE-1,"%s/%s%s%s",HOMEPATH,info.name,TEXT_END,NEW_END);
+ snprintf(fullpath,PATHSIZE-1,"%s/%s%s",STATEDIR,info.name,TEXT_END);
+ snprintf(fullpath2,PATHSIZE-1,"%s/%s%s%s",STATEDIR,info.name,TEXT_END,NEW_END);
if (rename(fullpath2,fullpath)) perror("rename");
Unlock_File(textin);
close(textin);
Modified: trunk/src/topten.c
===================================================================
--- trunk/src/topten.c 2008-04-03 00:26:50 UTC (rev 1031)
+++ trunk/src/topten.c 2008-04-03 09:20:53 UTC (rev 1032)
@@ -28,7 +28,7 @@
return;
}
- sprintf(fullpath,"%s/%s%s",HOMEPATH,argv[1],INDEX_END);
+ sprintf(fullpath,"%s/%s%s",STATEDIR,argv[1],INDEX_END);
if (access(fullpath,00))
{
printf("Folder %s not found.\n",argv[1]);
More information about the mw-devel
mailing list