mbsetup now moves JAM message bases

This commit is contained in:
Michiel Broek
2002-03-03 12:10:13 +00:00
parent 42b41acfa6
commit dafcf5dabe
3 changed files with 83 additions and 6 deletions

View File

@@ -668,6 +668,7 @@ void test_jam(char *base)
if (access(temp, W_OK)) {
if (mkdirs(base, 0770)) {
if (yes_no((char *)"Messagebase doesn't exist, create")) {
Syslog('+', "Created JAM base %s", base);
if (Msg_Open(base))
Msg_Close();
}
@@ -682,11 +683,83 @@ void test_jam(char *base)
char *edit_jam(int y, int x, int l, char *line, char *help)
{
static char s[256];
static char s[256];
char *from, *too;
int rc = 0;
showhelp(help);
memset((char *)s, 0, 256);
strcpy(s, edit_field(y, x, l, 'X', line));
if (strlen(s) && strlen(line) && strcmp(s, line)) {
/*
* Old and new paths did exist and are different.
* Test if we are doing a message base move.
*/
from = calloc(PATH_MAX, sizeof(char));
too = calloc(PATH_MAX, sizeof(char));
sprintf(from, "%s.jhr", line);
if (access(from, R_OK | W_OK) == 0) {
/*
* Old message base does exist, copy message base.
*/
if (mkdirs(s, 0770)) {
sprintf(too, "%s.jhr", s);
rc = file_cp(from, too);
if (rc == 0) {
sprintf(from, "%s.jdt", line);
sprintf(too, "%s.jdt", s);
rc = file_cp(from, too);
}
if (rc == 0) {
sprintf(from, "%s.jdx", line);
sprintf(too, "%s.jdx", s);
rc = file_cp(from, too);
}
if (rc == 0) {
sprintf(from, "%s.jlr", line);
sprintf(too, "%s.jlr", s);
rc = file_cp(from, too);
}
if (rc == 0) {
/*
* All files copied successfull
*/
file_rm(from);
sprintf(from, "%s.jdx", line);
file_rm(from);
sprintf(from, "%s.jdt", line);
file_rm(from);
sprintf(from, "%s.jhr", line);
file_rm(from);
Syslog('+', "JAM message base moved to %s", s);
} else {
/*
* Copy failed
*/
file_rm(too);
sprintf(too, "%s.jdx", s);
file_rm(too);
sprintf(too, "%s.jdt", s);
file_rm(too);
sprintf(too, "%s.jhr", s);
file_rm(too);
errmsg((char *)"Can't move JAM message base");
strcpy(s, line);
}
} else {
errmsg((char *)"Can't create destination directory");
strcpy(s, line);
}
}
free(from);
free(too);
} else if (strlen(s) == 0) {
/*
* If no new path, report
*/
errmsg((char *)"Empty path for JAM messagebase");
}
test_jam(s);
set_color(WHITE, BLACK);
show_str(y, x, l, s);

View File

@@ -49,7 +49,7 @@ int MsgUpdated = 0;
unsigned long MsgCrc;
FILE *tfil = NULL;
extern int exp_golded;
int MailForced = FALSE;
/*
@@ -1013,7 +1013,7 @@ int EditMsgRec(int);
int EditMsgRec(int Area)
{
unsigned long crc1;
int tmp, i, connections = 0, changed = FALSE, Active;
int tmp, i, connections = 0, changed = FALSE, Active, Forced = FALSE;
sysconnect System;
char *temp;
@@ -1092,7 +1092,7 @@ int EditMsgRec(int Area)
(msgs.Type == ECHOMAIL || msgs.Type == NEWS || msgs.Type == LIST)) {
errmsg((char *)"Message area has no group assigned");
break;
} else if (yes_no((char *)"Record is changed, save") == 1) {
} else if (Forced || yes_no((char *)"Record is changed, save") == 1) {
if (SaveMsgRec(Area, TRUE) == -1)
return -1;
MsgUpdated = 1;
@@ -1152,7 +1152,10 @@ int EditMsgRec(int Area)
SetScreen();
break;
case 4: E_STR( 9,16,64,msgs.Newsgroup, "The ^Newsgroup^ name of this area")
case 5: E_JAM( 10,16,64,msgs.Base, "The path to the ^JAM Message Base^")
case 5: strcpy(msgs.Base, edit_jam(10,16,64,msgs.Base ,(char *)"The path to the ^JAM Message Base^"));
Forced = TRUE;
MailForced = TRUE;
break;
case 6: E_STR( 11,16,64,msgs.Origin, "The ^Origin line^ to append to Echomail messages")
case 7: tmp = PickAka((char *)"9.2.7", TRUE);
if (tmp != -1)
@@ -1313,7 +1316,7 @@ void EditMsgarea(void)
strcpy(pick, select_area(records, 10));
if (strncmp(pick, "-", 1) == 0) {
CloseMsgarea(FALSE);
CloseMsgarea(MailForced);
return;
}