Commit c971349d authored by rswindell's avatar rswindell

Preparing for enabling XPDEV_LARGE_FILE_SUPPORT in the future, mainly just by

inserting (long) typedefs to prevent warnings, but in the case of the JS File()
class, actually supporting file lengths > 32-bit.
parent 64ba9bdc
......@@ -8,7 +8,7 @@
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* *
* Copyright 2009 Rob Swindell - http://www.synchro.net/copyright.html *
* Copyright 2010 Rob Swindell - http://www.synchro.net/copyright.html *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
......@@ -74,7 +74,7 @@ bool sbbs_t::bulkmail(uchar *ar)
return(false);
}
if((length=filelength(fileno(fp)))<=0) {
if((length=(long)filelength(fileno(fp)))<=0) {
fclose(fp);
return(false);
}
......
......@@ -8,7 +8,7 @@
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* *
* Copyright 2009 Rob Swindell - http://www.synchro.net/copyright.html *
* Copyright 2010 Rob Swindell - http://www.synchro.net/copyright.html *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
......@@ -87,12 +87,12 @@ void sbbs_t::multinodechat(int channel)
errormsg(WHERE,ERR_OPEN,str,O_RDONLY);
return;
}
if((gurubuf=(char *)malloc(filelength(file)+1))==NULL) {
if((gurubuf=(char *)malloc((size_t)filelength(file)+1))==NULL) {
close(file);
errormsg(WHERE,ERR_ALLOC,str,filelength(file)+1);
errormsg(WHERE,ERR_ALLOC,str,(size_t)filelength(file)+1);
return;
}
read(file,gurubuf,filelength(file));
read(file,gurubuf,(size_t)filelength(file));
gurubuf[filelength(file)]=0;
close(file);
}
......@@ -238,13 +238,13 @@ void sbbs_t::multinodechat(int channel)
errormsg(WHERE,ERR_OPEN,str,O_RDONLY);
break;
}
if((gurubuf=(char *)malloc(filelength(file)+1))==NULL) {
if((gurubuf=(char *)malloc((size_t)filelength(file)+1))==NULL) {
close(file);
errormsg(WHERE,ERR_ALLOC,str
,filelength(file)+1);
,(size_t)filelength(file)+1);
break;
}
read(file,gurubuf,filelength(file));
read(file,gurubuf,(size_t)filelength(file));
gurubuf[filelength(file)]=0;
close(file);
}
......@@ -581,12 +581,12 @@ bool sbbs_t::guru_page(void)
errormsg(WHERE,ERR_OPEN,path,O_RDONLY);
return(false);
}
if((gurubuf=(char *)malloc(filelength(file)+1))==NULL) {
if((gurubuf=(char *)malloc((size_t)filelength(file)+1))==NULL) {
close(file);
errormsg(WHERE,ERR_ALLOC,path,filelength(file)+1);
errormsg(WHERE,ERR_ALLOC,path,(size_t)filelength(file)+1);
return(false);
}
read(file,gurubuf,filelength(file));
read(file,gurubuf,(size_t)filelength(file));
gurubuf[filelength(file)]=0;
close(file);
localguru(gurubuf,i);
......
......@@ -8,7 +8,7 @@
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* *
* Copyright 2009 Rob Swindell - http://www.synchro.net/copyright.html *
* Copyright 2010 Rob Swindell - http://www.synchro.net/copyright.html *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
......@@ -51,7 +51,7 @@ uint sbbs_t::finduser(char *instr)
{
int file,i;
char str[128],str2[256],str3[256],ynq[25],c,pass=1;
ulong l,length;
long l,length;
FILE *stream;
i=atoi(instr);
......@@ -72,7 +72,7 @@ uint sbbs_t::finduser(char *instr)
SAFEPRINTF(ynq,"%.2s",text[YN]);
ynq[2]='Q';
ynq[3]=0;
length=filelength(file);
length=(long)filelength(file);
while(pass<3) {
fseek(stream,0L,SEEK_SET); /* seek to beginning for each pass */
for(l=0;l<length;l+=LEN_ALIAS+2) {
......
......@@ -8,7 +8,7 @@
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* *
* Copyright 2000 Rob Swindell - http://www.synchro.net/copyright.html *
* Copyright 2010 Rob Swindell - http://www.synchro.net/copyright.html *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
......@@ -53,11 +53,11 @@ void sbbs_t::getmsgptrs()
extern "C" BOOL DLLCALL getmsgptrs(scfg_t* cfg, uint usernumber, subscan_t* subscan)
{
char str[256];
uint i;
int file;
long length;
FILE *stream;
char str[256];
uint i;
int file;
long length;
FILE* stream;
/* Initialize to configured defaults */
for(i=0;i<cfg->total_subs;i++) {
......@@ -78,7 +78,7 @@ extern "C" BOOL DLLCALL getmsgptrs(scfg_t* cfg, uint usernumber, subscan_t* subs
if((stream=fnopen(&file,str,O_RDONLY))==NULL)
return(TRUE);
length=filelength(file);
length=(long)filelength(file);
for(i=0;i<cfg->total_subs;i++) {
if(length>=(cfg->sub[i]->ptridx+1)*10L) {
fseek(stream,(long)cfg->sub[i]->ptridx*10L,SEEK_SET);
......@@ -105,12 +105,12 @@ void sbbs_t::putmsgptrs()
/****************************************************************************/
extern "C" BOOL DLLCALL putmsgptrs(scfg_t* cfg, uint usernumber, subscan_t* subscan)
{
char str[256];
ushort idx;
uint16_t scancfg;
uint i,j;
int file;
ulong length;
char str[256];
ushort idx;
uint16_t scancfg;
uint i,j;
int file;
long length;
uint32_t l=0L;
if(!usernumber)
......
......@@ -8,7 +8,7 @@
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* *
* Copyright 2009 Rob Swindell - http://www.synchro.net/copyright.html *
* Copyright 2010 Rob Swindell - http://www.synchro.net/copyright.html *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
......@@ -44,12 +44,13 @@
/****************************************************************************/
void sbbs_t::downloadfile(file_t* f)
{
char str[256],fname[13];
char tmp[512];
int i,file;
long length,mod;
ulong l;
user_t uploader;
char str[256],fname[13];
char tmp[512];
int i,file;
long mod;
long length;
ulong l;
user_t uploader;
getfiledat(&cfg,f); /* Get current data - right after download */
if((length=f->size)<0L)
......@@ -106,7 +107,7 @@ void sbbs_t::downloadfile(file_t* f)
errormsg(WHERE,ERR_OPEN,str,O_RDWR);
return;
}
length=filelength(file);
length=(long)filelength(file);
if(length%F_IXBSIZE) {
close(file);
errormsg(WHERE,ERR_LEN,str,length);
......
......@@ -8,7 +8,7 @@
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* *
* Copyright 2009 Rob Swindell - http://www.synchro.net/copyright.html *
* Copyright 2010 Rob Swindell - http://www.synchro.net/copyright.html *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
......@@ -45,20 +45,22 @@
/****************************************************************************/
bool sbbs_t::email(int usernumber, const char *top, const char *subj, long mode)
{
char str[256],str2[256],msgpath[256],title[LEN_TITLE+1],ch
,buf[SDT_BLOCK_LEN];
char tmp[512];
char pid[128];
char* editor=NULL;
ushort msgattr=0;
uint16_t xlat=XLAT_NONE;
ushort nettype;
int i,j,x,file;
long l;
ulong length,offset,crc=0xffffffffUL;
FILE *instream;
node_t node;
smbmsg_t msg;
char str[256],str2[256],msgpath[256],title[LEN_TITLE+1],ch
,buf[SDT_BLOCK_LEN];
char tmp[512];
char pid[128];
char* editor=NULL;
ushort msgattr=0;
uint16_t xlat=XLAT_NONE;
ushort nettype;
int i,j,x,file;
long l;
long length;
ulong offset;
uint32_t crc=0xffffffffUL;
FILE* instream;
node_t node;
smbmsg_t msg;
SAFECOPY(title,subj);
......@@ -156,7 +158,7 @@ bool sbbs_t::email(int usernumber, const char *top, const char *subj, long mode)
sprintf(tmp,"%s%s",cfg.temp_dir,title);
if(!fexistcase(str2) && fexistcase(tmp))
mv(tmp,str2,0);
l=flength(str2);
l=(long)flength(str2);
if(l>0)
bprintf(text[FileNBytesReceived],title,ultoac(l,tmp));
else {
......@@ -201,7 +203,7 @@ bool sbbs_t::email(int usernumber, const char *top, const char *subj, long mode)
return(false);
}
length=flength(msgpath)+2; /* +2 for translation string */
length=(long)flength(msgpath)+2; /* +2 for translation string */
if(length&0xfff00000UL) {
smb_unlocksmbhdr(&smb);
......
......@@ -8,7 +8,7 @@
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* *
* Copyright 2009 Rob Swindell - http://www.synchro.net/copyright.html *
* Copyright 2010 Rob Swindell - http://www.synchro.net/copyright.html *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
......@@ -728,7 +728,7 @@ long sbbs_t::exec_bin(const char *cmdline, csi_t *csi)
memcpy(&bin,csi,sizeof(csi_t));
clearvars(&bin);
bin.length=filelength(file);
bin.length=(uint32_t)filelength(file);
if((bin.cs=(uchar *)malloc(bin.length))==NULL) {
close(file);
errormsg(WHERE,ERR_ALLOC,str,bin.length);
......
......@@ -8,7 +8,7 @@
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* *
* Copyright 2009 Rob Swindell - http://www.synchro.net/copyright.html *
* Copyright 2010 Rob Swindell - http://www.synchro.net/copyright.html *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
......@@ -821,7 +821,7 @@ int sbbs_t::exec_misc(csi_t* csi, char *path)
csi->ip+=4;
if(lp) {
if(pp && *pp)
*lp=flength(*pp);
*lp=(uint32_t)flength(*pp);
else
*lp=0;
}
......@@ -1259,7 +1259,7 @@ int sbbs_t::exec_misc(csi_t* csi, char *path)
lp2=getintvar(csi,*(int32_t *)csi->ip);
csi->ip+=4;
if(lp1 && (uint)*lp1<csi->files && lp2)
*lp2=filelength(fileno(csi->file[*lp1]));
*lp2=(uint32_t)filelength(fileno(csi->file[*lp1]));
return(0);
case FIO_GET_TIME:
lp1=getintvar(csi,*(int32_t *)csi->ip);
......@@ -1295,7 +1295,7 @@ int sbbs_t::exec_misc(csi_t* csi, char *path)
lp2=getintvar(csi,*(int32_t *)csi->ip);
csi->ip+=4;
if(lp1 && (uint)*lp1<csi->files && lp2)
*lp2=ftell(csi->file[*lp1]);
*lp2=(uint32_t)ftell(csi->file[*lp1]);
return(0);
case FIO_SEEK:
case FIO_SEEK_VAR:
......
......@@ -8,7 +8,7 @@
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* *
* Copyright 2009 Rob Swindell - http://www.synchro.net/copyright.html *
* Copyright 2010 Rob Swindell - http://www.synchro.net/copyright.html *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
......@@ -258,7 +258,7 @@ bool sbbs_t::netmail(const char *into, const char *title, long mode)
sprintf(tmp,"%s%s",cfg.temp_dir,title);
if(!fexistcase(subj) && fexistcase(tmp))
mv(tmp,subj,0);
l=flength(subj);
l=(long)flength(subj);
if(l>0)
bprintf(text[FileNBytesReceived],fname,ultoac(l,tmp));
else {
......@@ -303,7 +303,7 @@ bool sbbs_t::netmail(const char *into, const char *title, long mode)
errormsg(WHERE,ERR_OPEN,str,O_RDONLY);
return(false);
}
length=filelength(file);
length=(long)filelength(file);
if((buf=(char *)malloc(length))==NULL) {
close(file);
errormsg(WHERE,ERR_ALLOC,str,length);
......
......@@ -8,7 +8,7 @@
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* *
* Copyright 2009 Rob Swindell - http://www.synchro.net/copyright.html *
* Copyright 2010 Rob Swindell - http://www.synchro.net/copyright.html *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
......@@ -198,7 +198,7 @@ void sbbs_t::closefile(file_t* f)
errormsg(WHERE,ERR_OPEN,str1,O_RDONLY);
return;
}
length=filelength(file);
length=(long)filelength(file);
if((buf=(char *)malloc(length))==NULL) {
close(file);
errormsg(WHERE,ERR_ALLOC,str1,length);
......
......@@ -8,7 +8,7 @@
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* *
* Copyright 2009 Rob Swindell - http://www.synchro.net/copyright.html *
* Copyright 2010 Rob Swindell - http://www.synchro.net/copyright.html *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
......@@ -52,7 +52,7 @@ BOOL DLLCALL getfiledat(scfg_t* cfg, file_t* f)
if((file=sopen(str,O_RDONLY|O_BINARY,SH_DENYWR))==-1) {
return(FALSE);
}
length=filelength(file);
length=(long)filelength(file);
if(f->datoffset>length) {
close(file);
return(FALSE);
......@@ -74,7 +74,7 @@ BOOL DLLCALL getfiledat(scfg_t* cfg, file_t* f)
if(!f->size) { /* only read disk if this is null */
getfilepath(cfg,f,str);
if((f->size=flength(str))>=0)
if((f->size=(long)flength(str))>=0)
f->date=fdate(str);
/*
}
......@@ -130,7 +130,7 @@ BOOL DLLCALL putfiledat(scfg_t* cfg, file_t* f)
if((file=sopen(str,O_WRONLY|O_BINARY,SH_DENYRW))==-1) {
return(FALSE);
}
length=filelength(file);
length=(long)filelength(file);
if(length%F_LEN) {
close(file);
return(FALSE);
......@@ -144,7 +144,7 @@ BOOL DLLCALL putfiledat(scfg_t* cfg, file_t* f)
close(file);
return(FALSE);
}
length=filelength(file);
length=(long)filelength(file);
close(file);
if(length%F_LEN) {
return(FALSE);
......@@ -174,7 +174,7 @@ BOOL DLLCALL addfiledat(scfg_t* cfg, file_t* f)
if((file=sopen(str,O_RDWR|O_BINARY|O_CREAT,SH_DENYRW,DEFFILEMODE))==-1) {
return(FALSE);
}
length=filelength(file);
length=(long)filelength(file);
if(length==0L)
l=0L;
else {
......@@ -213,7 +213,7 @@ BOOL DLLCALL addfiledat(scfg_t* cfg, file_t* f)
close(file);
return(FALSE);
}
length=filelength(file);
length=(long)filelength(file);
close(file);
if(length%F_LEN) {
return(FALSE);
......@@ -240,7 +240,7 @@ BOOL DLLCALL addfiledat(scfg_t* cfg, file_t* f)
if((file=sopen(str,O_RDWR|O_CREAT|O_BINARY,SH_DENYRW,DEFFILEMODE))==-1) {
return(FALSE);
}
length=filelength(file);
length=(long)filelength(file);
if(length) { /* IXB file isn't empty */
if(length%F_IXBSIZE) {
close(file);
......@@ -316,7 +316,7 @@ BOOL DLLCALL addfiledat(scfg_t* cfg, file_t* f)
write(file,&f->dateuled,4);
write(file,&f->datedled,4);
}
length=filelength(file);
length=(long)filelength(file);
close(file);
return(TRUE);
}
......@@ -337,7 +337,7 @@ BOOL DLLCALL getfileixb(scfg_t* cfg, file_t* f)
if((file=sopen(str,O_RDONLY|O_BINARY,SH_DENYWR))==-1) {
return(FALSE);
}
length=filelength(file);
length=(long)filelength(file);
if(length%F_IXBSIZE) {
close(file);
return(FALSE);
......@@ -388,7 +388,7 @@ BOOL DLLCALL putfileixb(scfg_t* cfg, file_t* f)
if((file=sopen(str,O_RDWR|O_BINARY,SH_DENYRW))==-1) {
return(FALSE);
}
length=filelength(file);
length=(long)filelength(file);
if(length%F_IXBSIZE) {
close(file);
return(FALSE);
......@@ -444,7 +444,7 @@ BOOL DLLCALL removefiledat(scfg_t* cfg, file_t* f)
if((file=sopen(str,O_RDONLY|O_BINARY,SH_DENYWR))==-1) {
return(FALSE);
}
length=filelength(file);
length=(long)filelength(file);
if(!length) {
close(file);
return(FALSE);
......@@ -508,7 +508,7 @@ BOOL DLLCALL findfile(scfg_t* cfg, uint dirnum, char *filename)
fname[i]=fname[i+1];
SAFEPRINTF2(str,"%s%s.ixb",cfg->dir[dirnum]->data_dir,cfg->dir[dirnum]->code);
if((file=sopen(str,O_RDONLY|O_BINARY,SH_DENYWR))==-1) return(FALSE);
length=filelength(file);
length=(long)filelength(file);
if(!length) {
close(file);
return(FALSE);
......@@ -594,7 +594,7 @@ BOOL DLLCALL rmuserxfers(scfg_t* cfg, int fromuser, int destuser, char *fname)
if((file=sopen(str,O_RDONLY|O_BINARY,SH_DENYWR))==-1) {
return(FALSE);
}
length=filelength(file);
length=(long)filelength(file);
if((ixtbuf=(char *)malloc(length))==NULL) {
close(file);
return(FALSE);
......@@ -690,7 +690,7 @@ int DLLCALL update_uldate(scfg_t* cfg, file_t* f)
SAFEPRINTF2(str,"%s%s.ixb",cfg->dir[f->dir]->data_dir,cfg->dir[f->dir]->code);
if((file=nopen(str,O_RDWR))==-1)
return(errno);
length=filelength(file);
length=(long)filelength(file);
if(length%F_IXBSIZE) {
close(file);
return(-1);
......
......@@ -8,7 +8,7 @@
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* *
* Copyright 2009 Rob Swindell - http://www.synchro.net/copyright.html *
* Copyright 2010 Rob Swindell - http://www.synchro.net/copyright.html *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
......@@ -54,7 +54,7 @@ int DLLCALL getmail(scfg_t* cfg, int usernumber, BOOL sent)
sprintf(smb.file,"%smail",cfg->data_dir);
smb.retry_time=cfg->smb_retry_time;
sprintf(str,"%s.sid",smb.file);
l=flength(str);
l=(long)flength(str);
if(l<(long)sizeof(idxrec_t))
return(0);
if(!usernumber)
......
......@@ -8,7 +8,7 @@
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* *
* Copyright 2009 Rob Swindell - http://www.synchro.net/copyright.html *
* Copyright 2010 Rob Swindell - http://www.synchro.net/copyright.html *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
......@@ -255,7 +255,7 @@ ulong sbbs_t::getmsgnum(uint subnum, time_t t)
return(0);
}
total=filelength(fileno(smb.sid_fp))/sizeof(idxrec_t);
total=(long)filelength(fileno(smb.sid_fp))/sizeof(idxrec_t);
if(!total) { /* Empty base */
smb_close(&smb);
......@@ -416,7 +416,7 @@ ulong sbbs_t::getlastmsg(uint subnum, uint32_t *ptr, time_t *t)
errormsg(WHERE,ERR_READ,smb.file,i,smb.last_error);
return(0);
}
total=filelength(fileno(smb.sid_fp))/sizeof(idxrec_t);
total=(long)filelength(fileno(smb.sid_fp))/sizeof(idxrec_t);
smb_unlocksmbhdr(&smb);
smb_close(&smb);
if(ptr)
......
......@@ -8,7 +8,7 @@
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* *
* Copyright 2009 Rob Swindell - http://www.synchro.net/copyright.html *
* Copyright 2010 Rob Swindell - http://www.synchro.net/copyright.html *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
......@@ -220,7 +220,7 @@ int sbbs_t::getnmsg()
**/
return(errno);
}
length=filelength(file);
length=(long)filelength(file);
if(!length) {
close(file);
return(0);
......@@ -329,7 +329,7 @@ int sbbs_t::getsmsg(int usernumber)
errormsg(WHERE,ERR_OPEN,str,O_RDWR);
return(errno);
}
length=filelength(file);
length=(long)filelength(file);
if((buf=(char *)malloc(length+1))==NULL) {
close(file);
errormsg(WHERE,ERR_ALLOC,str,length+1);
......
......@@ -8,7 +8,7 @@
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* *
* Copyright 2003 Rob Swindell - http://www.synchro.net/copyright.html *
* Copyright 2010 Rob Swindell - http://www.synchro.net/copyright.html *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
......@@ -68,7 +68,7 @@ long DLLCALL getfiles(scfg_t* cfg, uint dirnum)
if(dirnum>=cfg->total_dirs) /* out of range */
return(0);
sprintf(str,"%s%s.ixb",cfg->dir[dirnum]->data_dir, cfg->dir[dirnum]->code);
l=flength(str);
l=(long)flength(str);
if(l>0L)
return(l/F_IXBSIZE);
return(0);
......@@ -83,7 +83,7 @@ ulong DLLCALL getposts(scfg_t* cfg, uint subnum)
ulong l;
sprintf(str,"%s%s.sid",cfg->sub[subnum]->data_dir,cfg->sub[subnum]->code);
l=flength(str);
l=(long)flength(str);
if((long)l==-1)
return(0);
return(l/sizeof(idxrec_t));
......
......@@ -8,7 +8,7 @@
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* *
* Copyright 2009 Rob Swindell - http://www.synchro.net/copyright.html *
* Copyright 2010 Rob Swindell - http://www.synchro.net/copyright.html *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
......@@ -295,8 +295,8 @@ js_read(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
return(JS_FALSE);
} else {
rc=JS_SUSPENDREQUEST(cx);
len=filelength(fileno(p->fp));
offset=ftell(p->fp);
len=(long)filelength(fileno(p->fp));
offset=(long)ftell(p->fp);
if(offset>0)
len-=offset;
JS_RESUMEREQUEST(cx, rc);
......@@ -1398,10 +1398,11 @@ js_writeall(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool
js_lock(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
int32 offset=0;
int32 len=0;
fileoff_t offset=0;
filelen_t len=0;
private_t* p;
jsrefcount rc;
jsdouble val;
*rval = JSVAL_FALSE;
......@@ -1415,14 +1416,16 @@ js_lock(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
/* offset */
if(argc) {
if(!JS_ValueToInt32(cx,argv[0],&offset))
if(!JS_ValueToNumber(cx,argv[0],&val))
return(JS_FALSE);
offset=(fileoff_t)val;
}
/* length */
if(argc>1) {
if(!JS_ValueToInt32(cx,argv[1],&len))
if(!JS_ValueToNumber(cx,argv[1],&val))
return(JS_FALSE);
len=(filelen_t)val;
}
rc=JS_SUSPENDREQUEST(cx);
......@@ -1439,10 +1442,11 @@ js_lock(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
static JSBool
js_unlock(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
int32 offset=0;
int32 len=0;
fileoff_t offset=0;
filelen_t len=0;