Commit 2a525720 authored by rswindell's avatar rswindell
Browse files

get/putextdesc functions converted from C++ to C (for DLL exportability)

parent f653d78c
......@@ -37,37 +37,6 @@
#include "sbbs.h"
void sbbs_t::getextdesc(uint dirnum, ulong datoffset, char *ext)
{
char str[256];
int file;
memset(ext,0,513);
sprintf(str,"%s%s.exb",cfg.dir[dirnum]->data_dir,cfg.dir[dirnum]->code);
if((file=nopen(str,O_RDONLY))==-1)
return;
lseek(file,(datoffset/F_LEN)*512L,SEEK_SET);
read(file,ext,512);
close(file);
}
void sbbs_t::putextdesc(uint dirnum, ulong datoffset, char *ext)
{
char str[256],nulbuf[512];
int file;
memset(nulbuf,0,512);
sprintf(str,"%s%s.exb",cfg.dir[dirnum]->data_dir,cfg.dir[dirnum]->code);
if((file=nopen(str,O_WRONLY|O_CREAT))==-1)
return;
lseek(file,0L,SEEK_END);
while(filelength(file)<(long)(datoffset/F_LEN)*512L)
write(file,nulbuf,512);
lseek(file,(datoffset/F_LEN)*512L,SEEK_SET);
write(file,ext,512);
close(file);
}
/****************************************************************************/
/* Prints all information of file in file_t structure 'f' */
/****************************************************************************/
......@@ -108,7 +77,7 @@ void sbbs_t::fileinfo(file_t* f)
bprintf(text[InvalidAlternatePathN],f->altpath); }
CRLF;
if(f->misc&FM_EXTDESC) {
getextdesc(f->dir,f->datoffset,ext);
getextdesc(&cfg,f->dir,f->datoffset,ext);
CRLF;
putmsg(ext,P_NOATCODES);
CRLF; }
......
......@@ -637,3 +637,33 @@ BOOL DLLCALL rmuserxfers(scfg_t* cfg, int fromuser, int destuser, char *fname)
return(TRUE);
}
void DLLCALL getextdesc(scfg_t* cfg, uint dirnum, ulong datoffset, char *ext)
{
char str[256];
int file;
memset(ext,0,513);
sprintf(str,"%s%s.exb",cfg->dir[dirnum]->data_dir,cfg->dir[dirnum]->code);
if((file=nopen(str,O_RDONLY))==-1)
return;
lseek(file,(datoffset/F_LEN)*512L,SEEK_SET);
read(file,ext,512);
close(file);
}
void DLLCALL putextdesc(scfg_t* cfg, uint dirnum, ulong datoffset, char *ext)
{
char str[256],nulbuf[512];
int file;
memset(nulbuf,0,sizeof(nulbuf));
sprintf(str,"%s%s.exb",cfg->dir[dirnum]->data_dir,cfg->dir[dirnum]->code);
if((file=nopen(str,O_WRONLY|O_CREAT))==-1)
return;
lseek(file,0L,SEEK_END);
while(filelength(file)<(long)(datoffset/F_LEN)*512L)
write(file,nulbuf,512);
lseek(file,(datoffset/F_LEN)*512L,SEEK_SET);
write(file,ext,512);
close(file);
}
......@@ -548,8 +548,6 @@ public:
void fileinfo(file_t* f);
void openfile(file_t* f);
void closefile(file_t* f);
void putextdesc(uint dirnum, ulong datoffset, char *ext);
void getextdesc(uint dirnum, ulong datoffset, char *ext);
bool removefcdt(file_t* f);
bool movefile(file_t* f, int newdir);
char * getfilespec(char *str);
......@@ -729,6 +727,9 @@ extern "C" {
DLLEXPORT BOOL DLLCALL getfileixb(scfg_t* cfg, file_t* f);
DLLEXPORT BOOL DLLCALL getfiledat(scfg_t* cfg, file_t* f);
DLLEXPORT BOOL DLLCALL putfiledat(scfg_t* cfg, file_t* f);
DLLEXPORT void DLLCALL putextdesc(scfg_t* cfg, uint dirnum, ulong datoffset, char *ext);
DLLEXPORT void DLLCALL getextdesc(scfg_t* cfg, uint dirnum, ulong datoffset, char *ext);
DLLEXPORT BOOL DLLCALL removefiledat(scfg_t* cfg, file_t* f);
DLLEXPORT BOOL DLLCALL addfiledat(scfg_t* cfg, file_t* f);
DLLEXPORT BOOL DLLCALL findfile(scfg_t* cfg, uint dirnum, char *filename);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment