upgrade mbsetup for database init

This commit is contained in:
Michiel Broek 2001-10-19 14:25:14 +00:00
parent ab79ef6069
commit c5500c65fe
12 changed files with 169 additions and 77 deletions

View File

@ -2,7 +2,7 @@
* *
* File ..................: setup/m_archive.c * File ..................: setup/m_archive.c
* Purpose ...............: Setup Archive structure. * Purpose ...............: Setup Archive structure.
* Last modification date : 22-Jan-2001 * Last modification date : 19-Oct-2001
* *
***************************************************************************** *****************************************************************************
* Copyright (C) 1997-2001 * Copyright (C) 1997-2001
@ -53,12 +53,13 @@ int ArchUpdated = 0;
int CountArchive(void) int CountArchive(void)
{ {
FILE *fil; FILE *fil;
char ffile[81]; char ffile[PATH_MAX];
int count; int count;
sprintf(ffile, "%s/etc/archiver.data", getenv("MBSE_ROOT")); sprintf(ffile, "%s/etc/archiver.data", getenv("MBSE_ROOT"));
if ((fil = fopen(ffile, "r")) == NULL) { if ((fil = fopen(ffile, "r")) == NULL) {
if ((fil = fopen(ffile, "a+")) != NULL) { if ((fil = fopen(ffile, "a+")) != NULL) {
Syslog('+', "Created new %s", ffile);
archiverhdr.hdrsize = sizeof(archiverhdr); archiverhdr.hdrsize = sizeof(archiverhdr);
archiverhdr.recsize = sizeof(archiver); archiverhdr.recsize = sizeof(archiver);
fwrite(&archiverhdr, sizeof(archiverhdr), 1, fil); fwrite(&archiverhdr, sizeof(archiverhdr), 1, fil);
@ -168,10 +169,11 @@ int CountArchive(void)
* is changed it will be converted on the fly. All editing must be * is changed it will be converted on the fly. All editing must be
* done on the copied file. * done on the copied file.
*/ */
int OpenArchive(void);
int OpenArchive(void) int OpenArchive(void)
{ {
FILE *fin, *fout; FILE *fin, *fout;
char fnin[81], fnout[81]; char fnin[PATH_MAX], fnout[PATH_MAX];
long oldsize; long oldsize;
sprintf(fnin, "%s/etc/archiver.data", getenv("MBSE_ROOT")); sprintf(fnin, "%s/etc/archiver.data", getenv("MBSE_ROOT"));
@ -185,9 +187,10 @@ int OpenArchive(void)
* database must always be updated. * database must always be updated.
*/ */
oldsize = archiverhdr.recsize; oldsize = archiverhdr.recsize;
if (oldsize != sizeof(archiver)) if (oldsize != sizeof(archiver)) {
ArchUpdated = 1; ArchUpdated = 1;
else Syslog('+', "Format of %s changed, updateing", fnin);
} else
ArchUpdated = 0; ArchUpdated = 0;
archiverhdr.hdrsize = sizeof(archiverhdr); archiverhdr.hdrsize = sizeof(archiverhdr);
archiverhdr.recsize = sizeof(archiver); archiverhdr.recsize = sizeof(archiver);
@ -215,9 +218,10 @@ int OpenArchive(void)
void CloseArchive(void) void CloseArchive(int);
void CloseArchive(int force)
{ {
char fin[81], fout[81]; char fin[PATH_MAX], fout[PATH_MAX];
FILE *fi, *fo; FILE *fi, *fo;
st_list *arc = NULL, *tmp; st_list *arc = NULL, *tmp;
@ -225,7 +229,7 @@ void CloseArchive(void)
sprintf(fout,"%s/etc/archiver.temp", getenv("MBSE_ROOT")); sprintf(fout,"%s/etc/archiver.temp", getenv("MBSE_ROOT"));
if (ArchUpdated == 1) { if (ArchUpdated == 1) {
if (yes_no((char *)"Database is changed, save changes") == 1) { if (force || (yes_no((char *)"Database is changed, save changes") == 1)) {
working(1, 0, 0); working(1, 0, 0);
fi = fopen(fout, "r"); fi = fopen(fout, "r");
fo = fopen(fin, "w"); fo = fopen(fin, "w");
@ -260,7 +264,7 @@ void CloseArchive(void)
int AppendArchive(void) int AppendArchive(void)
{ {
FILE *fil; FILE *fil;
char ffile[81]; char ffile[PATH_MAX];
sprintf(ffile, "%s/etc/archiver.temp", getenv("MBSE_ROOT")); sprintf(ffile, "%s/etc/archiver.temp", getenv("MBSE_ROOT"));
if ((fil = fopen(ffile, "a")) != NULL) { if ((fil = fopen(ffile, "a")) != NULL) {
@ -281,7 +285,7 @@ int AppendArchive(void)
int EditArchRec(int Area) int EditArchRec(int Area)
{ {
FILE *fil; FILE *fil;
char mfile[81]; char mfile[PATH_MAX];
long offset; long offset;
int j; int j;
unsigned long crc, crc1; unsigned long crc, crc1;
@ -382,7 +386,7 @@ void EditArchive(void)
int records, i, x, y; int records, i, x, y;
char pick[12]; char pick[12];
FILE *fil; FILE *fil;
char temp[81]; char temp[PATH_MAX];
long offset; long offset;
clr_index(); clr_index();
@ -441,7 +445,7 @@ void EditArchive(void)
strcpy(pick, select_record(records, 20)); strcpy(pick, select_record(records, 20));
if (strncmp(pick, "-", 1) == 0) { if (strncmp(pick, "-", 1) == 0) {
CloseArchive(); CloseArchive(FALSE);
return; return;
} }
@ -462,13 +466,22 @@ void EditArchive(void)
void InitArchive(void)
{
CountArchive();
OpenArchive();
CloseArchive(TRUE);
}
char *PickArchive(char *shdr) char *PickArchive(char *shdr)
{ {
static char Arch[6] = ""; static char Arch[6] = "";
int records, i, x, y; int records, i, x, y;
char pick[12]; char pick[12];
FILE *fil; FILE *fil;
char temp[81]; char temp[PATH_MAX];
long offset; long offset;
@ -533,7 +546,7 @@ char *PickArchive(char *shdr)
int archive_doc(FILE *fp, FILE *toc, int page) int archive_doc(FILE *fp, FILE *toc, int page)
{ {
char temp[81]; char temp[PATH_MAX];
FILE *arch; FILE *arch;
int j; int j;

View File

@ -7,6 +7,7 @@
int CountArchive(void); int CountArchive(void);
void EditArchive(void); void EditArchive(void);
char *PickArchive(char *); char *PickArchive(char *);
void InitArchive(void);
int archive_doc(FILE *, FILE *, int); int archive_doc(FILE *, FILE *, int);
#endif #endif

View File

@ -2,10 +2,10 @@
* *
* File ..................: m_domain.c * File ..................: m_domain.c
* Purpose ...............: Domain Setup * Purpose ...............: Domain Setup
* Last modification date : 23-Aug-2000 * Last modification date : 19-Oct-2001
* *
***************************************************************************** *****************************************************************************
* Copyright (C) 1997-2000 * Copyright (C) 1997-2001
* *
* Michiel Broek FIDO: 2:280/2802 * Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10 * Beekmansbos 10
@ -52,12 +52,13 @@ int DomainUpdated;
int CountDomain(void) int CountDomain(void)
{ {
FILE *fil; FILE *fil;
char ffile[81]; char ffile[PATH_MAX];
int count; int count;
sprintf(ffile, "%s/etc/domain.data", getenv("MBSE_ROOT")); sprintf(ffile, "%s/etc/domain.data", getenv("MBSE_ROOT"));
if ((fil = fopen(ffile, "r")) == NULL) { if ((fil = fopen(ffile, "r")) == NULL) {
if ((fil = fopen(ffile, "a+")) != NULL) { if ((fil = fopen(ffile, "a+")) != NULL) {
Syslog('+', "Created new %s", ffile);
domainhdr.hdrsize = sizeof(domainhdr); domainhdr.hdrsize = sizeof(domainhdr);
domainhdr.recsize = sizeof(domtrans); domainhdr.recsize = sizeof(domtrans);
domainhdr.lastupd = time(NULL); domainhdr.lastupd = time(NULL);
@ -106,10 +107,11 @@ int CountDomain(void)
* is changed it will be converted on the fly. All editing must be * is changed it will be converted on the fly. All editing must be
* done on the copied file. * done on the copied file.
*/ */
int OpenDomain(void);
int OpenDomain(void) int OpenDomain(void)
{ {
FILE *fin, *fout; FILE *fin, *fout;
char fnin[81], fnout[81]; char fnin[PATH_MAX], fnout[PATH_MAX];
long oldsize; long oldsize;
sprintf(fnin, "%s/etc/domain.data", getenv("MBSE_ROOT")); sprintf(fnin, "%s/etc/domain.data", getenv("MBSE_ROOT"));
@ -123,9 +125,10 @@ int OpenDomain(void)
* database must always be updated. * database must always be updated.
*/ */
oldsize = domainhdr.recsize; oldsize = domainhdr.recsize;
if (oldsize != sizeof(domtrans)) if (oldsize != sizeof(domtrans)) {
DomainUpdated = 1; DomainUpdated = 1;
else Syslog('+', "Updated %s to new format", fnin);
} else
DomainUpdated = 0; DomainUpdated = 0;
domainhdr.hdrsize = sizeof(domainhdr); domainhdr.hdrsize = sizeof(domainhdr);
domainhdr.recsize = sizeof(domtrans); domainhdr.recsize = sizeof(domtrans);
@ -152,16 +155,17 @@ int OpenDomain(void)
void CloseDomain(void) void CloseDomain(int);
void CloseDomain(int force)
{ {
char fin[81], fout[81]; char fin[PATH_MAX], fout[PATH_MAX];
FILE *fi, *fo; FILE *fi, *fo;
sprintf(fin, "%s/etc/domain.data", getenv("MBSE_ROOT")); sprintf(fin, "%s/etc/domain.data", getenv("MBSE_ROOT"));
sprintf(fout,"%s/etc/domain.temp", getenv("MBSE_ROOT")); sprintf(fout,"%s/etc/domain.temp", getenv("MBSE_ROOT"));
if (DomainUpdated == 1) { if (DomainUpdated == 1) {
if (yes_no((char *)"Database is changed, save changes") == 1) { if (force || (yes_no((char *)"Database is changed, save changes") == 1)) {
working(1, 0, 0); working(1, 0, 0);
fi = fopen(fout, "r"); fi = fopen(fout, "r");
fo = fopen(fin, "w"); fo = fopen(fin, "w");
@ -189,7 +193,7 @@ void CloseDomain(void)
int AppendDomain(void) int AppendDomain(void)
{ {
FILE *fil; FILE *fil;
char ffile[81]; char ffile[PATH_MAX];
sprintf(ffile, "%s/etc/domain.temp", getenv("MBSE_ROOT")); sprintf(ffile, "%s/etc/domain.temp", getenv("MBSE_ROOT"));
if ((fil = fopen(ffile, "a")) != NULL) { if ((fil = fopen(ffile, "a")) != NULL) {
@ -227,7 +231,7 @@ void DomainScreen(void)
int EditDomainRec(int Area) int EditDomainRec(int Area)
{ {
FILE *fil; FILE *fil;
char mfile[81]; char mfile[PATH_MAX];
long offset; long offset;
unsigned long crc, crc1; unsigned long crc, crc1;
@ -298,7 +302,7 @@ void EditDomain(void)
int records, i, o, y, from, too; int records, i, o, y, from, too;
char pick[12]; char pick[12];
FILE *fil; FILE *fil;
char temp[81]; char temp[PATH_MAX];
long offset; long offset;
struct domrec tdomtrans; struct domrec tdomtrans;
@ -359,7 +363,7 @@ void EditDomain(void)
strcpy(pick, select_menurec(records)); strcpy(pick, select_menurec(records));
if (strncmp(pick, "-", 1) == 0) { if (strncmp(pick, "-", 1) == 0) {
CloseDomain(); CloseDomain(FALSE);
return; return;
} }
@ -445,9 +449,18 @@ void EditDomain(void)
void InitDomain(void)
{
CountDomain();
OpenDomain();
CloseDomain(TRUE);
}
int domain_doc(FILE *fp, FILE *toc, int page) int domain_doc(FILE *fp, FILE *toc, int page)
{ {
char temp[81]; char temp[PATH_MAX];
FILE *no; FILE *no;
int j; int j;

View File

@ -4,6 +4,7 @@
int CountDomain(void); int CountDomain(void);
void EditDomain(void); void EditDomain(void);
void InitDomain(void);
int domain_doc(FILE *, FILE *, int); int domain_doc(FILE *, FILE *, int);
#endif #endif

View File

@ -2,10 +2,10 @@
* *
* File ..................: m_farea.c * File ..................: m_farea.c
* Purpose ...............: File Setup Program * Purpose ...............: File Setup Program
* Last modification date : 28-Mar-2000 * Last modification date : 19-Oct-2001
* *
***************************************************************************** *****************************************************************************
* Copyright (C) 1997-2000 * Copyright (C) 1997-2001
* *
* Michiel Broek FIDO: 2:280/2802 * Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10 * Beekmansbos 10
@ -55,12 +55,13 @@ int FileUpdated = 0;
int CountFilearea(void) int CountFilearea(void)
{ {
FILE *fil; FILE *fil;
char ffile[81]; char ffile[PATH_MAX];
int count; int count;
sprintf(ffile, "%s/etc/fareas.data", getenv("MBSE_ROOT")); sprintf(ffile, "%s/etc/fareas.data", getenv("MBSE_ROOT"));
if ((fil = fopen(ffile, "r")) == NULL) { if ((fil = fopen(ffile, "r")) == NULL) {
if ((fil = fopen(ffile, "a+")) != NULL) { if ((fil = fopen(ffile, "a+")) != NULL) {
Syslog('+', "Created new %s", ffile);
areahdr.hdrsize = sizeof(areahdr); areahdr.hdrsize = sizeof(areahdr);
areahdr.recsize = sizeof(area); areahdr.recsize = sizeof(area);
fwrite(&areahdr, sizeof(areahdr), 1, fil); fwrite(&areahdr, sizeof(areahdr), 1, fil);
@ -88,7 +89,7 @@ int CountFilearea(void)
int OpenFilearea(void) int OpenFilearea(void)
{ {
FILE *fin, *fout; FILE *fin, *fout;
char fnin[81], fnout[81]; char fnin[PATH_MAX], fnout[PATH_MAX];
long oldsize; long oldsize;
sprintf(fnin, "%s/etc/fareas.data", getenv("MBSE_ROOT")); sprintf(fnin, "%s/etc/fareas.data", getenv("MBSE_ROOT"));
@ -102,9 +103,10 @@ int OpenFilearea(void)
* database must always be updated. * database must always be updated.
*/ */
oldsize = areahdr.recsize; oldsize = areahdr.recsize;
if (oldsize != sizeof(area)) if (oldsize != sizeof(area)) {
FileUpdated = 1; FileUpdated = 1;
else Syslog('+', "Updated %s to new format", fnin);
} else
FileUpdated = 0; FileUpdated = 0;
areahdr.hdrsize = sizeof(areahdr); areahdr.hdrsize = sizeof(areahdr);
areahdr.recsize = sizeof(area); areahdr.recsize = sizeof(area);
@ -131,15 +133,16 @@ int OpenFilearea(void)
void CloseFilearea(void) void CloseFilearea(int);
void CloseFilearea(int force)
{ {
char fin[81], fout[81]; char fin[PATH_MAX], fout[PATH_MAX];
sprintf(fin, "%s/etc/fareas.data", getenv("MBSE_ROOT")); sprintf(fin, "%s/etc/fareas.data", getenv("MBSE_ROOT"));
sprintf(fout,"%s/etc/fareas.temp", getenv("MBSE_ROOT")); sprintf(fout,"%s/etc/fareas.temp", getenv("MBSE_ROOT"));
if (FileUpdated == 1) { if (FileUpdated == 1) {
if (yes_no((char *)"Database is changed, save changes") == 1) { if (force || (yes_no((char *)"Database is changed, save changes") == 1)) {
working(1, 0, 0); working(1, 0, 0);
if ((rename(fout, fin)) == 0) if ((rename(fout, fin)) == 0)
unlink(fout); unlink(fout);
@ -156,7 +159,7 @@ void CloseFilearea(void)
int AppendFilearea(void) int AppendFilearea(void)
{ {
FILE *fil; FILE *fil;
char ffile[81]; char ffile[PATH_MAX];
sprintf(ffile, "%s/etc/fareas.temp", getenv("MBSE_ROOT")); sprintf(ffile, "%s/etc/fareas.temp", getenv("MBSE_ROOT"));
if ((fil = fopen(ffile, "a")) != NULL) { if ((fil = fopen(ffile, "a")) != NULL) {
@ -223,7 +226,7 @@ void FileScreen(void)
int EditFileRec(int Area) int EditFileRec(int Area)
{ {
FILE *fil; FILE *fil;
char mfile[81]; char mfile[PATH_MAX];
long offset; long offset;
unsigned long crc, crc1; unsigned long crc, crc1;
@ -345,7 +348,7 @@ void EditFilearea(void)
int records, i, o, x, y; int records, i, o, x, y;
char pick[12]; char pick[12];
FILE *fil; FILE *fil;
char temp[81]; char temp[PATH_MAX];
long offset; long offset;
clr_index(); clr_index();
@ -408,7 +411,7 @@ void EditFilearea(void)
strcpy(pick, select_record(records, 20)); strcpy(pick, select_record(records, 20));
if (strncmp(pick, "-", 1) == 0) { if (strncmp(pick, "-", 1) == 0) {
CloseFilearea(); CloseFilearea(FALSE);
return; return;
} }
@ -442,7 +445,7 @@ long PickFilearea(char *shdr)
int records, i, o = 0, x, y; int records, i, o = 0, x, y;
char pick[12]; char pick[12];
FILE *fil; FILE *fil;
char temp[81]; char temp[PATH_MAX];
long offset; long offset;
clr_index(); clr_index();
@ -526,9 +529,18 @@ long PickFilearea(char *shdr)
void InitFilearea(void)
{
CountFilearea();
OpenFilearea();
CloseFilearea(TRUE);
}
int bbs_file_doc(FILE *fp, FILE *toc, int page) int bbs_file_doc(FILE *fp, FILE *toc, int page)
{ {
char temp[81]; char temp[PATH_MAX];
FILE *no; FILE *no;
int i = 0, j = 0; int i = 0, j = 0;

View File

@ -5,6 +5,7 @@
int CountFilearea(void); int CountFilearea(void);
void EditFilearea(void); void EditFilearea(void);
long PickFilearea(char *); long PickFilearea(char *);
void InitFilearea(void);
int bbs_file_doc(FILE *, FILE *, int); int bbs_file_doc(FILE *, FILE *, int);
#endif #endif

View File

@ -2,10 +2,10 @@
* *
* File ..................: setup/m_fdb.c * File ..................: setup/m_fdb.c
* Purpose ...............: Edit Files DataBase. * Purpose ...............: Edit Files DataBase.
* Last modification date : 18-Mar-2000 * Last modification date : 19-Oct-2001
* *
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2000 * Copyright (C) 1999-2001
* *
* Michiel Broek FIDO: 2:280/2802 * Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10 * Beekmansbos 10
@ -120,7 +120,7 @@ void EditFile()
void E_F(long areanr) void E_F(long areanr)
{ {
FILE *fil; FILE *fil;
char temp[81]; char temp[PATH_MAX];
int i, y, o, records, Ondisk; int i, y, o, records, Ondisk;
char help[81]; char help[81];
static char *menu = (char *)"0"; static char *menu = (char *)"0";

View File

@ -2,10 +2,10 @@
* *
* File ..................: m_ff.c * File ..................: m_ff.c
* Purpose ...............: Filefind Setup * Purpose ...............: Filefind Setup
* Last modification date : 29-Oct-2000 * Last modification date : 19-Oct-2001
* *
***************************************************************************** *****************************************************************************
* Copyright (C) 1997-2000 * Copyright (C) 1997-2001
* *
* Michiel Broek FIDO: 2:280/2802 * Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10 * Beekmansbos 10
@ -54,12 +54,13 @@ int FilefindUpdated = 0;
int CountFilefind(void) int CountFilefind(void)
{ {
FILE *fil; FILE *fil;
char ffile[81]; char ffile[PATH_MAX];
int count; int count;
sprintf(ffile, "%s/etc/scanmgr.data", getenv("MBSE_ROOT")); sprintf(ffile, "%s/etc/scanmgr.data", getenv("MBSE_ROOT"));
if ((fil = fopen(ffile, "r")) == NULL) { if ((fil = fopen(ffile, "r")) == NULL) {
if ((fil = fopen(ffile, "a+")) != NULL) { if ((fil = fopen(ffile, "a+")) != NULL) {
Syslog('+', "Created new %s", ffile);
scanmgrhdr.hdrsize = sizeof(scanmgrhdr); scanmgrhdr.hdrsize = sizeof(scanmgrhdr);
scanmgrhdr.recsize = sizeof(scanmgr); scanmgrhdr.recsize = sizeof(scanmgr);
fwrite(&scanmgrhdr, sizeof(scanmgrhdr), 1, fil); fwrite(&scanmgrhdr, sizeof(scanmgrhdr), 1, fil);
@ -84,10 +85,11 @@ int CountFilefind(void)
* is changed it will be converted on the fly. All editing must be * is changed it will be converted on the fly. All editing must be
* done on the copied file. * done on the copied file.
*/ */
int OpenFilefind(void);
int OpenFilefind(void) int OpenFilefind(void)
{ {
FILE *fin, *fout; FILE *fin, *fout;
char fnin[81], fnout[81]; char fnin[PATH_MAX], fnout[PATH_MAX];
long oldsize; long oldsize;
sprintf(fnin, "%s/etc/scanmgr.data", getenv("MBSE_ROOT")); sprintf(fnin, "%s/etc/scanmgr.data", getenv("MBSE_ROOT"));
@ -101,9 +103,10 @@ int OpenFilefind(void)
* database must always be updated. * database must always be updated.
*/ */
oldsize = scanmgrhdr.recsize; oldsize = scanmgrhdr.recsize;
if (oldsize != sizeof(scanmgr)) if (oldsize != sizeof(scanmgr)) {
FilefindUpdated = 1; FilefindUpdated = 1;
else Syslog('+', "Updated %s to new format", fnin);
} else
FilefindUpdated = 0; FilefindUpdated = 0;
scanmgrhdr.hdrsize = sizeof(scanmgrhdr); scanmgrhdr.hdrsize = sizeof(scanmgrhdr);
scanmgrhdr.recsize = sizeof(scanmgr); scanmgrhdr.recsize = sizeof(scanmgr);
@ -130,9 +133,10 @@ int OpenFilefind(void)
void CloseFilefind(void) void CloseFilefind(int);
void CloseFilefind(int force)
{ {
char fin[81], fout[81]; char fin[PATH_MAX], fout[PATH_MAX];
FILE *fi, *fo; FILE *fi, *fo;
st_list *fff = NULL, *tmp; st_list *fff = NULL, *tmp;
@ -140,7 +144,7 @@ void CloseFilefind(void)
sprintf(fout,"%s/etc/scanmgr.temp", getenv("MBSE_ROOT")); sprintf(fout,"%s/etc/scanmgr.temp", getenv("MBSE_ROOT"));
if (FilefindUpdated == 1) { if (FilefindUpdated == 1) {
if (yes_no((char *)"Database is changed, save changes") == 1) { if (force || (yes_no((char *)"Database is changed, save changes") == 1)) {
working(1, 0, 0); working(1, 0, 0);
fi = fopen(fout, "r"); fi = fopen(fout, "r");
fo = fopen(fin, "w"); fo = fopen(fin, "w");
@ -175,7 +179,7 @@ void CloseFilefind(void)
int AppendFilefind(void) int AppendFilefind(void)
{ {
FILE *fil; FILE *fil;
char ffile[81]; char ffile[PATH_MAX];
sprintf(ffile, "%s/etc/scanmgr.temp", getenv("MBSE_ROOT")); sprintf(ffile, "%s/etc/scanmgr.temp", getenv("MBSE_ROOT"));
if ((fil = fopen(ffile, "a")) != NULL) { if ((fil = fopen(ffile, "a")) != NULL) {
@ -220,7 +224,7 @@ void FFScreen(void)
int EditFfRec(int Area) int EditFfRec(int Area)
{ {
FILE *fil; FILE *fil;
char mfile[81], temp1[2]; char mfile[PATH_MAX], temp1[2];
long offset; long offset;
unsigned long crc, crc1; unsigned long crc, crc1;
int i; int i;
@ -313,7 +317,7 @@ void EditFilefind(void)
int records, i, o, x, y; int records, i, o, x, y;
char pick[12]; char pick[12];
FILE *fil; FILE *fil;
char temp[81]; char temp[PATH_MAX];
long offset; long offset;
clr_index(); clr_index();
@ -376,7 +380,7 @@ void EditFilefind(void)
strcpy(pick, select_record(records, 20)); strcpy(pick, select_record(records, 20));
if (strncmp(pick, "-", 1) == 0) { if (strncmp(pick, "-", 1) == 0) {
CloseFilefind(); CloseFilefind(FALSE);
return; return;
} }
@ -405,9 +409,18 @@ void EditFilefind(void)
void InitFilefind(void)
{
CountFilefind();
OpenFilefind();
CloseFilefind(TRUE);
}
int ff_doc(FILE *fp, FILE *toc, int page) int ff_doc(FILE *fp, FILE *toc, int page)
{ {
char temp[81]; char temp[PATH_MAX];
FILE *no; FILE *no;
int j; int j;

View File

@ -4,6 +4,7 @@
int CountFilefind(void); int CountFilefind(void);
void EditFilefind(void); void EditFilefind(void);
void InitFilefind(void);
int ff_doc(FILE *, FILE *, int); int ff_doc(FILE *, FILE *, int);
#endif #endif

View File

@ -2,10 +2,10 @@
* *
* File ..................: setup/m_fgroups.c * File ..................: setup/m_fgroups.c
* Purpose ...............: Setup FGroups. * Purpose ...............: Setup FGroups.
* Last modification date : 29-Oct-2000 * Last modification date : 19-Oct-2001
* *
***************************************************************************** *****************************************************************************
* Copyright (C) 1997-2000 * Copyright (C) 1997-2001
* *
* Michiel Broek FIDO: 2:280/2802 * Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10 * Beekmansbos 10
@ -55,12 +55,13 @@ int FGrpUpdated = 0;
int CountFGroup(void) int CountFGroup(void)
{ {
FILE *fil; FILE *fil;
char ffile[81]; char ffile[PATH_MAX];
int count; int count;
sprintf(ffile, "%s/etc/fgroups.data", getenv("MBSE_ROOT")); sprintf(ffile, "%s/etc/fgroups.data", getenv("MBSE_ROOT"));
if ((fil = fopen(ffile, "r")) == NULL) { if ((fil = fopen(ffile, "r")) == NULL) {
if ((fil = fopen(ffile, "a+")) != NULL) { if ((fil = fopen(ffile, "a+")) != NULL) {
Syslog('+', "Created new %s", ffile);
fgrouphdr.hdrsize = sizeof(fgrouphdr); fgrouphdr.hdrsize = sizeof(fgrouphdr);
fgrouphdr.recsize = sizeof(fgroup); fgrouphdr.recsize = sizeof(fgroup);
fwrite(&fgrouphdr, sizeof(fgrouphdr), 1, fil); fwrite(&fgrouphdr, sizeof(fgrouphdr), 1, fil);
@ -87,10 +88,11 @@ int CountFGroup(void)
* is changed it will be converted on the fly. All editing must be * is changed it will be converted on the fly. All editing must be
* done on the copied file. * done on the copied file.
*/ */
int OpenFGroup(void);
int OpenFGroup(void) int OpenFGroup(void)
{ {
FILE *fin, *fout; FILE *fin, *fout;
char fnin[81], fnout[81]; char fnin[PATH_MAX], fnout[PATH_MAX];
long oldsize; long oldsize;
sprintf(fnin, "%s/etc/fgroups.data", getenv("MBSE_ROOT")); sprintf(fnin, "%s/etc/fgroups.data", getenv("MBSE_ROOT"));
@ -119,6 +121,9 @@ int OpenFGroup(void)
fgrouphdr.recsize = sizeof(fgroup); fgrouphdr.recsize = sizeof(fgroup);
fwrite(&fgrouphdr, sizeof(fgrouphdr), 1, fout); fwrite(&fgrouphdr, sizeof(fgrouphdr), 1, fout);
if (FGrpUpdated)
Syslog('+', "Updated %s, format changed", fnin);
/* /*
* The datarecord is filled with zero's before each * The datarecord is filled with zero's before each
* read, so if the format changed, the new fields * read, so if the format changed, the new fields
@ -141,9 +146,10 @@ int OpenFGroup(void)
void CloseFGroup(void) void CloseFGroup(int);
void CloseFGroup(int force)
{ {
char fin[81], fout[81]; char fin[PATH_MAX], fout[PATH_MAX];
FILE *fi, *fo; FILE *fi, *fo;
st_list *fgr = NULL, *tmp; st_list *fgr = NULL, *tmp;
@ -151,7 +157,7 @@ void CloseFGroup(void)
sprintf(fout,"%s/etc/fgroups.temp", getenv("MBSE_ROOT")); sprintf(fout,"%s/etc/fgroups.temp", getenv("MBSE_ROOT"));
if (FGrpUpdated == 1) { if (FGrpUpdated == 1) {
if (yes_no((char *)"Database is changed, save changes") == 1) { if (force || (yes_no((char *)"Database is changed, save changes") == 1)) {
working(1, 0, 0); working(1, 0, 0);
fi = fopen(fout, "r"); fi = fopen(fout, "r");
fo = fopen(fin, "w"); fo = fopen(fin, "w");
@ -186,7 +192,7 @@ void CloseFGroup(void)
int AppendFGroup(void) int AppendFGroup(void)
{ {
FILE *fil; FILE *fil;
char ffile[81]; char ffile[PATH_MAX];
sprintf(ffile, "%s/etc/fgroups.temp", getenv("MBSE_ROOT")); sprintf(ffile, "%s/etc/fgroups.temp", getenv("MBSE_ROOT"));
if ((fil = fopen(ffile, "a")) != NULL) { if ((fil = fopen(ffile, "a")) != NULL) {
@ -251,7 +257,7 @@ void FgScreen(void)
int EditFGrpRec(int Area) int EditFGrpRec(int Area)
{ {
FILE *fil; FILE *fil;
char mfile[81]; char mfile[PATH_MAX];
long offset; long offset;
int j, tmp; int j, tmp;
unsigned long crc, crc1; unsigned long crc, crc1;
@ -352,7 +358,7 @@ void EditFGroup(void)
int records, i, o, x, y; int records, i, o, x, y;
char pick[12]; char pick[12];
FILE *fil; FILE *fil;
char temp[81]; char temp[PATH_MAX];
long offset; long offset;
clr_index(); clr_index();
@ -415,7 +421,7 @@ void EditFGroup(void)
strcpy(pick, select_record(records, 20)); strcpy(pick, select_record(records, 20));
if (strncmp(pick, "-", 1) == 0) { if (strncmp(pick, "-", 1) == 0) {
CloseFGroup(); CloseFGroup(FALSE);
return; return;
} }
@ -444,13 +450,22 @@ void EditFGroup(void)
void InitFGroup(void)
{
CountFGroup();
OpenFGroup();
CloseFGroup(TRUE);
}
char *PickFGroup(char *shdr) char *PickFGroup(char *shdr)
{ {
static char FGrp[21] = ""; static char FGrp[21] = "";
int records, i, o = 0, x, y; int records, i, o = 0, x, y;
char pick[12]; char pick[12];
FILE *fil; FILE *fil;
char temp[81]; char temp[PATH_MAX];
long offset; long offset;
@ -537,7 +552,7 @@ char *PickFGroup(char *shdr)
int tic_group_doc(FILE *fp, FILE *toc, int page) int tic_group_doc(FILE *fp, FILE *toc, int page)
{ {
char temp[81]; char temp[PATH_MAX];
FILE *no; FILE *no;
int j; int j;

View File

@ -5,6 +5,7 @@
int CountFGroup(void); int CountFGroup(void);
void EditFGroup(void); void EditFGroup(void);
char *PickFGroup(char *); char *PickFGroup(char *);
void InitFGroup(void);
int tic_group_doc(FILE *, FILE *, int); int tic_group_doc(FILE *, FILE *, int);

View File

@ -2,7 +2,7 @@
* *
* File ..................: mbsetup.c * File ..................: mbsetup.c
* Purpose ...............: Setup Program * Purpose ...............: Setup Program
* Last modification date : 24-Jun-2001 * Last modification date : 19-Oct-2001
* *
***************************************************************************** *****************************************************************************
* Copyright (C) 1997-2001 * Copyright (C) 1997-2001
@ -39,6 +39,8 @@
#include "ledit.h" #include "ledit.h"
#include "m_global.h" #include "m_global.h"
#include "m_bbs.h" #include "m_bbs.h"
#include "m_farea.h"
#include "m_fgroup.h"
#include "m_mail.h" #include "m_mail.h"
#include "m_tic.h" #include "m_tic.h"
#include "m_fido.h" #include "m_fido.h"
@ -156,7 +158,7 @@ void site_docs(void);
void site_docs(void) void site_docs(void)
{ {
FILE *fp, *toc; FILE *fp, *toc;
char temp[81], temp1[81]; char temp[PATH_MAX], temp1[PATH_MAX];
int page = 0, line = 0; int page = 0, line = 0;
if (config_read() == -1) if (config_read() == -1)
@ -315,6 +317,24 @@ void site_docs(void)
void initdatabases(void)
{
clr_index();
working(1, 0, 0);
IsDoing("Init Databases");
InitArchive();
InitDomain();
InitFilearea();
InitFilefind();
InitFGroup();
working(0, 0, 0);
clr_index();
}
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
int loop = 1; int loop = 1;
@ -351,6 +371,7 @@ int main(int argc, char *argv[])
do_quiet = TRUE; do_quiet = TRUE;
Syslog(' ', " "); Syslog(' ', " ");
Syslog(' ', "MBSETUP v%s started by %s", VERSION, pw->pw_name); Syslog(' ', "MBSETUP v%s started by %s", VERSION, pw->pw_name);
initdatabases();
do { do {
IsDoing("Browsing Menu"); IsDoing("Browsing Menu");