G:/ScriptBasic/source/commands/file.c File Reference

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/file.h>
#include "../command.h"
#include "../filesys.h"
#include "../match.h"
#include "../matchc.h"

Go to the source code of this file.

Data Structures

struct  _FileCommandObject
struct  _DirCommandObject

Defines

#define THISFILEP   pFCO->Descriptor[FileNumber].fp
#define THISSOCKET   pFCO->Descriptor[FileNumber].sp
#define MAXFILES   512
#define INITIALIZE   init(pEo)
#define SECUREFILE(x)   if( ! FileIsSecure(pEo,x) )ERROR(COMMAND_ERROR_FILE_CANNOT_BE_OPENED);
#define BUFFER_INCREASE   256
#define BUFFER_INCREASE   256
#define NOCOMMAND(XXX)
#define FILE_FUN(XXX, yyy)
#define FILE_BFUN(XXX, yyy)
#define MAXDIRS   512
#define FILES_INCREMENT   10
#define INITDIR   initdir(pEo)
#define COLLECT_DIRS   0x0001
#define COLLECT_DOTS   0x0002
#define COLLECT_RECU   0x0004
#define SORTBY_SIZE   0x0008
#define SORTBY_CRETI   0x0010
#define SORTBY_ACCTI   0x0020
#define SORTBY_MODTI   0x0040
#define SORTBY_NAME   0x0080
#define SORTBY_FNAME   0x0100
#define COLLECT_FULLP   0x0200
#define SORTBY_DESCEN   0x0400
#define MAX_FNLEN   1024
#define SWAP
#define SORTBY_SIZE   0x0008
#define SORTBY_CRETI   0x0010
#define SORTBY_ACCTI   0x0020
#define SORTBY_MODTI   0x0040
#define SORTBY_NAME   0x0080
#define SORTBY_FNAME   0x0100
#define MAXOWNERLEN   512

Typedefs

typedef _FileCommandObject FileCommandObject
typedef _FileCommandObjectpFileCommandObject
typedef _DirCommandObject DirCommandObject
typedef _DirCommandObjectpDirCommandObject

Functions

int stricmp (char *, char *)
static void close_all_files (pExecuteObject pEo)
static int init (pExecuteObject pEo)
static void prepare_directory (pExecuteObject pEo, char *pszFileName)
static int FileIsSecure (pExecuteObject pEo, VARIABLE vFileName)
 if (memory_IsUndef(vLEN))
 if (FileNumber< 1||FileNumber > MAXFILES) ERROR(COMMAND_ERROR_BAD_FILE_NUMBER)
 if (pFCO->mode[FileNumber]) ERROR(COMMAND_ERROR_FILE_NUMBER_IS_USED)
 if (memcpy(FileName==NULL)
else if (!stricmp(ModeString,"input"))
else if (!stricmp(ModeString,"input_binary"))
else if (!stricmp(ModeString,"output"))
else if (!stricmp(ModeString,"output_binary"))
else if (!stricmp(ModeString,"append"))
else if (!stricmp(ModeString,"append_binary"))
else if (!stricmp(ModeString,"random"))
else if (!stricmp(ModeString,"binary")||!stricmp(ModeString,"random_binary"))
 FREE (FileName)
 if (THISFILEP==NULL)
static END char * ReadFileLine (pExecuteObject pEo, FILE *fp, unsigned long *plCharactersRead, int(*pfExtIn)(void *))
static char * ReadSocketLine (pExecuteObject pEo, SOCKET sp, unsigned long *plCharactersRead)
 if (!pFCO->mode[FileNumber]) ERROR(COMMAND_ERROR_FILE_IS_NOT_OPENED)
 if (memcpy((Result) s==NULL)
 if (memory_IsUndef(vBTR))
 if (nItem)
else HOOK_FCLOSE (THISFILEP)
 for (FileNumber=0;FileNumber< MAXFILES;FileNumber++)
 fflush (THISFILEP)
 fseek (THISFILEP, Position, SEEK_SET)
 HOOK_TRUNCATE (THISFILEP, Position)
 fseek (THISFILEP, 0L, SEEK_SET)
 if (memory_IsUndef(Op1))
 LONGVALUE (RESULT) = (long)(ftell(THISFILEP) / pFCO->RecordSize[FileNumber])
 fseek (THISFILEP, 0, SEEK_END)
 fseek (THISFILEP, SavePosition, SEEK_SET)
 if (Range==-1)
 while (nItem)
 if (pFCO->mode![FileNumber]='s'&&fflush(THISFILEP)==EOF)
 if (!pFCO->mode[FileNumber]||pFCO->mode[FileNumber]== 's') RETURN
 if (!stricmp(ModeString,"read"))
else if (!stricmp(ModeString,"write"))
else if (!stricmp(ModeString,"release"))
else ERROR (COMMAND_ERROR_INVALID_LOCK)
 if ()
 FREE (s)
 if (HOOK_ISDIR(s))
 if (iResult==-1)
 CONVERT2ZCHAR (Op2, dfile)
 if (fs==NULL)
 for (i=0;dfile[i];i++)
 if (fd==NULL)
 while ((ch=HOOK_FGETC(fs))!=EOF)
 HOOK_FCLOSE (fs)
 HOOK_FCLOSE (fd)
 FREE (sfile)
 FREE (dfile)
 CONVERT2ZCHAR (Op1, sfile)
 if (!HOOK_EXISTS(sfile))
 rename (sfile, dfile)
 if (!HOOK_ISDIR(s))
static int store_file_name (pExecuteObject pEo, pDirList p, char *buffer, unsigned long ThisSortValue)
static void close_directory_list (pExecuteObject pEo, unsigned long i)
static void close_all_dirs (pExecuteObject pEo)
static int initdir (pExecuteObject pEo)
static int collect_dirs_r (pExecuteObject pEo, char *buffer, unsigned long fAction, pDirList pThisDirList, char *pattern, unsigned long StartCharIndex)
static int collect_dirs (pExecuteObject pEo, unsigned long fAction, pDirList pThisDirList, char *Directory, unsigned long cDirectory, char *pattern, unsigned long c_pattern)
static int sort_dirs (pExecuteObject pEo, unsigned long fAction, pDirList p)
 if (memory_IsUndef(vDirNumber))
 if (DirNumber< 1||DirNumber >=MAXDIRS)
 sort_dirs (pEo, fAction, pDCO->dp[DirNumber])
 memcpy (STRINGVALUE(RESULT), pDCO->dp[DirNumber]->ppszFileName[pDCO->dp[DirNumber]->FileIndex],(STRLEN(RESULT)=pDCO->dp[DirNumber]->cbFileName[pDCO->dp[DirNumber]->FileIndex]))
 while (HOOK_CURDIR(Buffer, cBuffer)==-1)
 memcpy (STRINGVALUE(RESULT), Buffer, cBuffer)
 if (memory_IsUndef(Op))
else if (!stricmp(pszAttributeSymbol,"createtime"))
else if (!stricmp(pszAttributeSymbol,"modifytime"))
else if (!stricmp(pszAttributeSymbol,"accesstime"))
 if (iErrorC)
 FREE (pszFileName)
 memcpy (STRINGVALUE(RESULT), pszOwnerBuffer, cbOwnerBuffer)
 if (memory_IsUndef(vString)||memory_IsUndef(vSalt))
 CONVERT2ZCHAR (vString, pszString)
 CONVERT2ZCHAR (vSalt, pszSalt)
 HOOK_FCRYPT (pszString, pszSalt, szResult)
 FREE (pszString)
 FREE (pszSalt)
 memcpy (STRINGVALUE(RESULT), szResult, 12)
 if (memory_IsUndef(vCommandLine))
 CONVERT2ZCHAR (vCommandLine, pszCommandLine)
 FREE (pszCommandLine)
 DEREFERENCE (LetThisVariable)
 if (iError==FILESYSE_TIMEOUT)
 ERROR (iError)
 if (memory_IsUndef(vPid))
if LetThisVariable memory_ReleaseVariable (pEo->pMo,*LetThisVariable)
if LetThisVariable ERROR (COMMAND_ERROR_MEMORY_LOW)

Variables

long FileNumber
long RecLen
char * FileName
char * ModeString
pFileCommandObject pFCO
VARIABLE Op1
VARIABLE FN
VARIABLE vLEN
 INITIALIZE
 pFCO = (pFileCommandObject)PARAMPTR(CMD_OPEN)
 Op1 = CONVERT2STRING(_EVALUATEEXPRESSION(PARAMETERNODE))
 ASSERTOKE
 NEXTPARAMETER
 ModeString = pEo->StringTable+pEo->CommandArray[_ActualNode-1].Parameter.CommandArgument.Argument.szStringValue
 NEXTPARAMETER
 FN = _EVALUATEEXPRESSION(PARAMETERNODE)
 ASSERTOKE
 NEXTPARAMETER
 vLEN = CONVERT2LONG(EVALUATEEXPRESSION(PARAMETERNODE))
 ASSERTOKE
 FileNumber = LONGVALUE(CONVERT2LONG(FN))
 FileNumber
 FileName = ALLOC(STRLEN(Op1)+1)
pFCO RecordSize [FileNumber] = RecLen
long FileNumber
pFileCommandObject pFCO
VARIABLE Result
LEFTVALUE LetThisVariable
unsigned long lCharactersRead
char * s
long refcount
 INITIALIZE
 pFCO = (pFileCommandObject)PARAMPTR(CMD_OPEN)
 FileNumber = LONGVALUE(CONVERT2LONG(EVALUATEEXPRESSION(PARAMETERNODE)))
 ASSERTOKE
 NEXTPARAMETER
 LetThisVariable = EVALUATELEFTVALUE(PARAMETERNODE)
 ASSERTOKE
 FileNumber
else s = ReadFileLine(pEo,THISFILEP,&lCharactersRead,NULL)
 BytesToRead
 CharsRead
pFileCommandObject pFCO
NODE nItem
FILE * fp
VARIABLE fpN
VARIABLE vBTR
char * s
int ch
int(* pfExtIn )(void *)
 INITIALIZE
 pFCO = (pFileCommandObject)PARAMPTR(CMD_OPEN)
 USE_CALLER_MORTALS
 nItem = PARAMETERLIST
 vBTR = EVALUATEEXPRESSION(CAR(nItem))
 ASSERTOKE
 BytesToRead = GETLONGVALUE(vBTR)
 nItem = CDR(nItem)
pFileCommandObject pFCO
 INITIALIZE
 pFCO = (pFileCommandObject)PARAMPTR(CMD_OPEN)
 FileNumber = LONGVALUE(CONVERT2LONG(EVALUATEEXPRESSION(PARAMETERNODE)))
 ASSERTOKE
 FileNumber
pFCO mode [FileNumber] = (char)0
 THISFILEP = NULL
END long FileNumber
pFileCommandObject pFCO
 INITIALIZE
 pFCO = (pFileCommandObject)PARAMPTR(CMD_OPEN)
END long FileNumber
END long Position
pFileCommandObject pFCO
 INITIALIZE
 pFCO = (pFileCommandObject)PARAMPTR(CMD_OPEN)
 FileNumber = LONGVALUE(CONVERT2LONG(EVALUATEEXPRESSION(PARAMETERNODE)))
 ASSERTOKE
 FileNumber
 NEXTPARAMETER
 Position = pFCO->RecordSize[FileNumber] * LONGVALUE(CONVERT2LONG(EVALUATEEXPRESSION(PARAMETERNODE)))
 ASSERTOKE
END long FileNumber
END long Position
pFileCommandObject pFCO
 INITIALIZE
 pFCO = (pFileCommandObject)PARAMPTR(CMD_OPEN)
 FileNumber = LONGVALUE(CONVERT2LONG(EVALUATEEXPRESSION(PARAMETERNODE)))
 ASSERTOKE
 FileNumber
 NEXTPARAMETER
 Position = pFCO->RecordSize[FileNumber] * LONGVALUE(CONVERT2LONG(EVALUATEEXPRESSION(PARAMETERNODE)))
 ASSERTOKE
END long FileNumber
pFileCommandObject pFCO
 INITIALIZE
 pFCO = (pFileCommandObject)PARAMPTR(CMD_OPEN)
 FileNumber = LONGVALUE(CONVERT2LONG(EVALUATEEXPRESSION(PARAMETERNODE)))
 ASSERTOKE
 FileNumber
END VARIABLE Op1
long FileNumber
pFileCommandObject pFCO
 INITIALIZE
 pFCO = (pFileCommandObject)PARAMPTR(CMD_OPEN)
 USE_CALLER_MORTALS
 Op1 = EVALUATEEXPRESSION(CAR(PARAMETERLIST))
 ASSERTOKE
 FileNumber = LONGVALUE(CONVERT2LONG(Op1))
 RESULT = NULL
 FileNumber
 RESULT = NEWMORTALLONG
END VARIABLE Op1
long FileNumber
long SavePosition
pFileCommandObject pFCO
 INITIALIZE
 pFCO = (pFileCommandObject)PARAMPTR(CMD_OPEN)
 USE_CALLER_MORTALS
 Op1 = EVALUATEEXPRESSION(CAR(PARAMETERLIST))
 ASSERTOKE
 FileNumber = LONGVALUE(CONVERT2LONG(Op1))
 RESULT = NULL
 FileNumber
 RESULT = NEWMORTALLONG
 SavePosition = ftell(THISFILEP)
END VARIABLE Op1
long FileNumber
long Range
pFileCommandObject pFCO
NODE nItem
 INITIALIZE
 pFCO = (pFileCommandObject)PARAMPTR(CMD_OPEN)
 USE_CALLER_MORTALS
else Range = -1
END char buffer [80]
NODE nItem
VARIABLE ItemResult
long FileNumber
pFileCommandObject pFCO
char * s
unsigned long slen
 INITIALIZE
 pFCO = (pFileCommandObject)PARAMPTR(CMD_OPEN)
 nItem = PARAMETERNODE
 FileNumber = LONGVALUE(CONVERT2LONG(EVALUATEEXPRESSION(nItem)))
 ASSERTOKE
 FileNumber
 NEXTPARAMETER
 nItem = PARAMETERNODE
long FileNumber
char * ModeString
pFileCommandObject pFCO
 INITIALIZE
 pFCO = (pFileCommandObject)PARAMPTR(CMD_OPEN)
 FileNumber = LONGVALUE(CONVERT2LONG(EVALUATEEXPRESSION(PARAMETERNODE)))
 ASSERTOKE
 FileNumber
 NEXTPARAMETER
 ModeString = pEo->StringTable+pEo->CommandArray[_ActualNode-1].Parameter.CommandArgument.Argument.szStringValue
END long FileNumber
END long lFrom
END long lTo
END long lSwap
char * ModeString
pFileCommandObject pFCO
 INITIALIZE
 pFCO = (pFileCommandObject)PARAMPTR(CMD_OPEN)
 FileNumber = LONGVALUE(CONVERT2LONG(EVALUATEEXPRESSION(PARAMETERNODE)))
 ASSERTOKE
 FileNumber
 NEXTPARAMETER
 lFrom = LONGVALUE(CONVERT2LONG(EVALUATEEXPRESSION(PARAMETERNODE)))
 ASSERTOKE
 NEXTPARAMETER
 ModeString = pEo->StringTable+pEo->CommandArray[_ActualNode-1].Parameter.CommandArgument.Argument.szStringValue
END VARIABLE Op
char * s
 Op = CONVERT2STRING(EVALUATEEXPRESSION(PARAMETERNODE))
 ASSERTOKE
 s = ALLOC(STRLEN(Op)+1)
END VARIABLE Op
char * s
int iResult
 Op = CONVERT2STRING(EVALUATEEXPRESSION(PARAMETERNODE))
 s = ALLOC(STRLEN(Op)+1)
 ASSERTOKE
 iResult = HOOK_REMOVE(s)
 NEXTPARAMETER
 Op2 = CONVERT2STRING(EVALUATEEXPRESSION(PARAMETERNODE))
 ASSERTOKE
 fs = HOOK_FOPEN(sfile,"rb")
 LastDSPos = 0
 fd = HOOK_FOPEN(dfile,"wb")
 RETURN
END VARIABLE Op1
END VARIABLE Op2
char * sfile
char * dfile
 Op1 = CONVERT2STRING(EVALUATEEXPRESSION(PARAMETERNODE))
 ASSERTOKE
 NEXTPARAMETER
 Op2 = CONVERT2STRING(EVALUATEEXPRESSION(PARAMETERNODE))
 ASSERTOKE
 RETURN
END VARIABLE Op
char * s
int iResult
 Op = CONVERT2STRING(EVALUATEEXPRESSION(PARAMETERNODE))
 ASSERTOKE
 s = ALLOC(STRLEN(Op)+1)
 iResult = HOOK_DELTREE(s)
 DirList
pDirList
long DirNumber
char * DirName
unsigned long i
pDirCommandObject pDCO
VARIABLE vDirName
VARIABLE vPattern
VARIABLE vDirNumber
VARIABLE vOption
unsigned long fAction
 INITDIR
 pDCO = (pDirCommandObject)PARAMPTR(CMD_OPENDIR)
 vDirName = CONVERT2STRING(_EVALUATEEXPRESSION(PARAMETERNODE))
 ASSERTOKE
 NEXTPARAMETER
 vPattern = CONVERT2STRING(_EVALUATEEXPRESSION(PARAMETERNODE))
 ASSERTOKE
 NEXTPARAMETER
 vOption = CONVERT2LONG(EVALUATEEXPRESSION(PARAMETERNODE))
 ASSERTOKE
 NEXTPARAMETER
 vDirNumber = _EVALUATEEXPRESSION(PARAMETERNODE)
 ASSERTOKE
 DirNumber = LONGVALUE(CONVERT2LONG(vDirNumber))
END VARIABLE Op1
pDirCommandObject pDCO
unsigned long DirNumber
 INITDIR
 pDCO = (pDirCommandObject)PARAMPTR(CMD_OPENDIR)
 USE_CALLER_MORTALS
 Op1 = CONVERT2LONG(EVALUATEEXPRESSION(CAR(PARAMETERLIST)))
 ASSERTOKE
 DirNumber = LONGVALUE(Op1)
 RESULT = NEWMORTALSTRING(pDCO->dp[DirNumber]->cbFileName[pDCO->dp[DirNumber]->FileIndex])
pDCO dp[DirNumberFileIndex
END VARIABLE Op1
pDirCommandObject pDCO
unsigned long DirNumber
 INITDIR
 pDCO = (pDirCommandObject)PARAMPTR(CMD_OPENDIR)
 USE_CALLER_MORTALS
 Op1 = CONVERT2LONG(EVALUATEEXPRESSION(CAR(PARAMETERLIST)))
 ASSERTOKE
 DirNumber = LONGVALUE(Op1)
 RESULT = NEWMORTALLONG
END VARIABLE Op1
pDirCommandObject pDCO
unsigned long DirNumber
 INITDIR
 pDCO = (pDirCommandObject)PARAMPTR(CMD_OPENDIR)
 Op1 = CONVERT2LONG(EVALUATEEXPRESSION(PARAMETERNODE))
 ASSERTOKE
 DirNumber = LONGVALUE(Op1)
 DirNumber = LONGVALUE(Op1)
else RESULT = NULL
END char * Buffer
long cBuffer
 USE_CALLER_MORTALS
 cBuffer = 256
 Buffer = ALLOC(cBuffer)
 cBuffer = strlen(Buffer)
 RESULT = NEWMORTALSTRING(cBuffer)
END VARIABLE Op
char * Buffer
int i
 Op = CONVERT2STRING(_EVALUATEEXPRESSION(PARAMETERNODE))
 ASSERTOKE
 RESULT = NEWMORTALSTRING(cbOwnerBuffer=strlen(pszOwnerBuffer))
END char * pszString
END char * pszSalt
char szResult [13]
VARIABLE vString
VARIABLE vSalt
NODE nItem
 USE_CALLER_MORTALS
 nItem = PARAMETERLIST
 vString = CONVERT2STRING(_EVALUATEEXPRESSION(CAR(nItem)))
 ASSERTOKE
 nItem = CDR(nItem)
 vSalt = CONVERT2STRING(_EVALUATEEXPRESSION(CAR(nItem)))
 ASSERTOKE
 RESULT = NEWMORTALSTRING(12)
END NOTIMPLEMENTED
END char * pszCommandLine
VARIABLE vCommandLine
long lPid
 USE_CALLER_MORTALS
 vCommandLine = CONVERT2STRING(_EVALUATEEXPRESSION(CAR(PARAMETERLIST)))
 ASSERTOKE
 lPid = HOOK_CREATEPROCESS(pszCommandLine)
 RESULT = NEWMORTALLONG
END char * pszCommandLine
VARIABLE vCommandLine
VARIABLE vTimeOut
unsigned long lPid
unsigned long lExitCode
NODE nItem
LEFTVALUE LetThisVariable
long refcount
int iError
 nItem = PARAMETERLIST
 USE_CALLER_MORTALS
 vCommandLine = CONVERT2STRING(_EVALUATEEXPRESSION(CAR(nItem)))
 ASSERTOKE
 nItem = CDR(nItem)
 vTimeOut = CONVERT2LONG(_EVALUATEEXPRESSION(CAR(nItem)))
 ASSERTOKE
 nItem = CDR(nItem)
 LetThisVariable = EVALUATELEFTVALUE(CAR(nItem))
 ASSERTOKE
 iError = HOOK_CREATEPROCESSEX(pszCommandLine,LONGVALUE(vTimeOut),&lPid,&lExitCode)
END VARIABLE vPid
NODE nItem
LEFTVALUE LetThisVariable
long refcount
long Result
long lExitCode
 nItem = PARAMETERLIST
 USE_CALLER_MORTALS
 vPid = CONVERT2LONG(_EVALUATEEXPRESSION(CAR(PARAMETERLIST)))
 ASSERTOKE
 nItem = CDR(nItem)
 LetThisVariable = EVALUATELEFTVALUE(CAR(nItem))
 ASSERTOKE
 Result = HOOK_WAITPID(LONGVALUE(vPid),&lExitCode)
LetThisVariable = NEWLONG


Define Documentation

#define BUFFER_INCREASE   256
 

#define BUFFER_INCREASE   256
 

Referenced by cgi_InitCgi(), ReadFileLine(), and ReadSocketLine().

#define COLLECT_DIRS   0x0001
 

Definition at line 1757 of file file.c.

#define COLLECT_DOTS   0x0002
 

Definition at line 1758 of file file.c.

Referenced by collect_dirs_r().

#define COLLECT_FULLP   0x0200
 

Definition at line 1766 of file file.c.

Referenced by collect_dirs().

#define COLLECT_RECU   0x0004
 

Definition at line 1759 of file file.c.

#define FILE_BFUN XXX,
yyy   ) 
 

Value:

COMMAND(XXX)\
\
  char *FileName;\
  VARIABLE Op;\
  long lRes;\
\
  USE_CALLER_MORTALS;\
\
  Op = _EVALUATEEXPRESSION(CAR(PARAMETERLIST));\
  ASSERTOKE;\
  if( memory_IsUndef(Op) ){\
    RESULT = NULL;\
    RETURN;\
    }\
\
  Op = CONVERT2STRING(Op);\
\
  FileName = ALLOC(STRLEN(Op)+1);\
  if( FileName == NULL )ERROR(COMMAND_ERROR_MEMORY_LOW);\
  memcpy(FileName,STRINGVALUE(Op),STRLEN(Op));\
  FileName[STRLEN(Op)] = (char)0;\
  lRes = yyy(FileName);\
  RESULT = NEWMORTALLONG;\
  ASSERTNULL(RESULT)\
  LONGVALUE(RESULT) = lRes;\
  FREE(FileName);\
\
END

Definition at line 1143 of file file.c.

#define FILE_FUN XXX,
yyy   ) 
 

Definition at line 1108 of file file.c.

#define FILES_INCREMENT   10
 

Definition at line 1658 of file file.c.

Referenced by store_file_name().

#define INITDIR   initdir(pEo)
 

#define INITIALIZE   init(pEo)
 

Referenced by if().

#define MAX_FNLEN   1024
 

Definition at line 1770 of file file.c.

Referenced by collect_dirs(), collect_dirs_r(), file_deltree(), and file_deltree_r().

#define MAXDIRS   512
 

Referenced by close_all_dirs(), and initdir().

#define MAXFILES   512
 

Definition at line 43 of file file.c.

Referenced by close_all_files(), and init().

#define MAXOWNERLEN   512
 

#define NOCOMMAND XXX   ) 
 

Value:

COMMAND(XXX)\
NOTIMPLEMENTED;\
END

Definition at line 1103 of file file.c.

#define SECUREFILE  )     if( ! FileIsSecure(pEo,x) )ERROR(COMMAND_ERROR_FILE_CANNOT_BE_OPENED);
 

Definition at line 122 of file file.c.

#define SORTBY_ACCTI   0x0020
 

Definition at line 1762 of file file.c.

#define SORTBY_ACCTI   0x0020
 

Definition at line 1762 of file file.c.

Referenced by collect_dirs_r().

#define SORTBY_CRETI   0x0010
 

Definition at line 1761 of file file.c.

#define SORTBY_CRETI   0x0010
 

Definition at line 1761 of file file.c.

Referenced by collect_dirs_r().

#define SORTBY_DESCEN   0x0400
 

Definition at line 1768 of file file.c.

Referenced by sort_dirs().

#define SORTBY_FNAME   0x0100
 

Definition at line 1765 of file file.c.

#define SORTBY_FNAME   0x0100
 

Definition at line 1765 of file file.c.

Referenced by sort_dirs().

#define SORTBY_MODTI   0x0040
 

Definition at line 1763 of file file.c.

#define SORTBY_MODTI   0x0040
 

Definition at line 1763 of file file.c.

Referenced by collect_dirs_r().

#define SORTBY_NAME   0x0080
 

Definition at line 1764 of file file.c.

#define SORTBY_NAME   0x0080
 

Definition at line 1764 of file file.c.

Referenced by collect_dirs_r().

#define SORTBY_SIZE   0x0008
 

Definition at line 1760 of file file.c.

#define SORTBY_SIZE   0x0008
 

Definition at line 1760 of file file.c.

Referenced by collect_dirs_r().

#define SWAP
 

Value:

do{\
                lSwap = p->cbFileName[i];\
                p->cbFileName[i] = p->cbFileName[j];\
                p->cbFileName[j] = lSwap;\
                lSwap = p->SortValue[i];\
                p->SortValue[i] = p->SortValue[j];\
                p->SortValue[j] = lSwap;\
                pszSwap = p->ppszFileName[i];\
                p->ppszFileName[i] = p->ppszFileName[j];\
                p->ppszFileName[j] = pszSwap;\
                }while(0)

Referenced by sort_dirs().

#define THISFILEP   pFCO->Descriptor[FileNumber].fp
 

Definition at line 32 of file file.c.

Referenced by close_all_files(), and if().

#define THISSOCKET   pFCO->Descriptor[FileNumber].sp
 

Definition at line 33 of file file.c.

Referenced by close_all_files(), if(), and while().


Typedef Documentation

typedef struct _DirCommandObject DirCommandObject
 

typedef struct _FileCommandObject FileCommandObject
 

typedef struct _DirCommandObject * pDirCommandObject
 

typedef struct _FileCommandObject * pFileCommandObject
 


Function Documentation

static void close_all_dirs pExecuteObject  pEo  )  [static]
 

Definition at line 1726 of file file.c.

References close_directory_list(), _DirCommandObject::dp, MAXDIRS, NULL, and pDCO.

Referenced by initdir().

static void close_all_files pExecuteObject  pEo  )  [static]
 

Definition at line 56 of file file.c.

References FileNumber, HOOK_FCLOSE(), MAXFILES, _FileCommandObject::mode, pFCO, THISFILEP, and THISSOCKET.

Referenced by init().

static void close_directory_list pExecuteObject  pEo,
unsigned long  i
[static]
 

Definition at line 1706 of file file.c.

References _DirCommandObject::dp, FREE, j, NULL, and pDCO.

Referenced by close_all_dirs().

static int collect_dirs pExecuteObject  pEo,
unsigned long  fAction,
pDirList  pThisDirList,
char *  Directory,
unsigned long  cDirectory,
char *  pattern,
unsigned long  c_pattern
[static]
 

Definition at line 1901 of file file.c.

References collect_dirs_r(), COLLECT_FULLP, initialize_like(), MAX_FNLEN, memcpy(), and strcpy().

static int collect_dirs_r pExecuteObject  pEo,
char *  buffer,
unsigned long  fAction,
pDirList  pThisDirList,
char *  pattern,
unsigned long  StartCharIndex
[static]
 

Definition at line 1774 of file file.c.

References ALLOC, COLLECT_DOTS, FREE, iError, match_count(), match_match(), MAX_FNLEN, NULL, pL, pLastResult, SORTBY_ACCTI, SORTBY_CRETI, SORTBY_MODTI, SORTBY_NAME, SORTBY_SIZE, store_file_name(), and strcpy().

Referenced by collect_dirs().

CONVERT2ZCHAR vCommandLine  ,
pszCommandLine 
 

CONVERT2ZCHAR vSalt  ,
pszSalt 
 

CONVERT2ZCHAR vString  ,
pszString 
 

CONVERT2ZCHAR Op1  ,
sfile 
 

CONVERT2ZCHAR Op2  ,
dfile 
 

DEREFERENCE LetThisVariable   ) 
 

if LetThisVariable ERROR COMMAND_ERROR_MEMORY_LOW   ) 
 

ERROR iError   ) 
 

else ERROR COMMAND_ERROR_INVALID_LOCK   ) 
 

fflush THISFILEP   ) 
 

Referenced by fork(), log_printf(), log_thread(), and logit().

static int FileIsSecure pExecuteObject  pEo,
VARIABLE  vFileName
[static]
 

Definition at line 113 of file file.c.

References STRINGVALUE(), and STRLEN().

for i  = 0 ; dfile[i] ; i++  ) 
 

Definition at line 1516 of file file.c.

for  ) 
 

Definition at line 672 of file file.c.

Referenced by categorize(), firstch(), freeset(), freezeset(), and nch().

FREE pszCommandLine   ) 
 

FREE pszSalt   ) 
 

FREE pszString   ) 
 

FREE pszFileName   ) 
 

FREE dfile   ) 
 

FREE sfile   ) 
 

FREE s   ) 
 

FREE FileName   ) 
 

fseek THISFILEP  ,
SavePosition  ,
SEEK_SET 
 

fseek THISFILEP  ,
,
SEEK_END 
 

fseek THISFILEP  ,
0L  ,
SEEK_SET 
 

fseek THISFILEP  ,
Position  ,
SEEK_SET 
 

Referenced by build_GetExeCodeOffset(), build_LoadCodeWithOffset(), and cgi_GetMultipartParameters().

HOOK_FCLOSE fd   ) 
 

HOOK_FCLOSE fs   ) 
 

else HOOK_FCLOSE THISFILEP   ) 
 

Referenced by close_all_files(), and if().

HOOK_FCRYPT pszString  ,
pszSalt  ,
szResult 
 

HOOK_TRUNCATE THISFILEP  ,
Position 
 

if memory_IsUndef(vPid  ) 
 

Definition at line 2836 of file file.c.

References RETURN.

if iError  = = FILESYSE_TIMEOUT  ) 
 

Definition at line 2789 of file file.c.

References ERROR(), LONGVALUE(), and memory_ReleaseVariable().

if memory_IsUndef(vCommandLine  ) 
 

Definition at line 2691 of file file.c.

References RETURN.

if memory_IsUndef(vString)||memory_IsUndef(vSalt  ) 
 

Definition at line 2623 of file file.c.

References RETURN.

if iErrorC   ) 
 

Definition at line 2514 of file file.c.

else if stricmp(pszAttributeSymbol,"accesstime")  ) 
 

Definition at line 2504 of file file.c.

References LONGVALUE().

else if stricmp(pszAttributeSymbol,"modifytime")  ) 
 

Definition at line 2500 of file file.c.

References LONGVALUE().

else if stricmp(pszAttributeSymbol,"createtime")  ) 
 

Definition at line 2496 of file file.c.

References LONGVALUE().

if memory_IsUndef(Op  ) 
 

Definition at line 2433 of file file.c.

if DirNumber< 1||DirNumber = MAXDIRS  ) 
 

Definition at line 2071 of file file.c.

if memory_IsUndef(vDirNumber  ) 
 

Definition at line 2062 of file file.c.

if HOOK_ISDIR(s)  ) 
 

Definition at line 1615 of file file.c.

References ERROR(), FREE, and RETURN.

if HOOK_EXISTS(sfile)  ) 
 

Definition at line 1569 of file file.c.

References FREE, and RETURN.

if fd  = NULL  ) 
 

Definition at line 1530 of file file.c.

References ERROR(), FREE, and HOOK_FCLOSE().

if fs  = NULL  ) 
 

Definition at line 1508 of file file.c.

References ERROR(), and FREE.

if iResult  = = -1  ) 
 

Definition at line 1466 of file file.c.

if HOOK_ISDIR(s  ) 
 

Definition at line 1458 of file file.c.

References ERROR(), FREE, and RETURN.

if  ) 
 

Definition at line 1361 of file file.c.

else if stricmp(ModeString,"release")  ) 
 

Definition at line 1325 of file file.c.

else if stricmp(ModeString,"write")  ) 
 

Definition at line 1322 of file file.c.

if stricmp(ModeString,"read")  ) 
 

Definition at line 1319 of file file.c.

if !pFCO->mode||pFCO->  mode[FileNumber][FileNumber] = = 's'  ) 
 

if pFCO->mode [FileNumber] = 's' && fflush(THISFILEP) == EOF  ) 
 

Definition at line 1066 of file file.c.

References INITIALIZE.

else if Range  = = -1  ) 
 

Definition at line 953 of file file.c.

References _FileCommandObject::mode, and pFCO.

if memory_IsUndef(Op1  ) 
 

Definition at line 848 of file file.c.

References NULL, RESULT, and RETURN.

if nItem  = PARAMETERLIST  ) 
 

Definition at line 573 of file file.c.

References ASSERTOKE, ERROR(), memory_IsUndef(), _FileCommandObject::mode, pFCO, _FileCommandObject::RecordSize, and THISFILEP.

if memory_IsUndef(vBTR  ) 
 

Definition at line 559 of file file.c.

References ASSERTOKE, NULL, RESULT, and RETURN.

if memcpy((Result s = NULL  ) 
 

Definition at line 422 of file file.c.

References INITIALIZE.

if !pFCO->  mode[FileNumber]  ) 
 

if THISFILEP  = NULL  ) 
 

Definition at line 291 of file file.c.

References COMMAND_ERROR_FILE_CANNOT_BE_OPENED, ERROR(), _FileCommandObject::mode, and pFCO.

else if stricmp(ModeString,"binary")||!stricmp(ModeString,"random_binary")  ) 
 

Definition at line 279 of file file.c.

References _FileCommandObject::mode, NULL, pEo, pFCO, prepare_directory(), and THISFILEP.

else if stricmp(ModeString,"random")  ) 
 

Definition at line 268 of file file.c.

References _FileCommandObject::mode, NULL, pEo, pFCO, prepare_directory(), and THISFILEP.

else if stricmp(ModeString,"append_binary")  ) 
 

Definition at line 259 of file file.c.

References _FileCommandObject::mode, NULL, pEo, pFCO, prepare_directory(), and THISFILEP.

else if stricmp(ModeString,"append")  ) 
 

Definition at line 250 of file file.c.

References _FileCommandObject::mode, NULL, pEo, pFCO, prepare_directory(), and THISFILEP.

else if stricmp(ModeString,"output_binary")  ) 
 

Definition at line 241 of file file.c.

References _FileCommandObject::mode, NULL, pEo, pFCO, prepare_directory(), and THISFILEP.

else if stricmp(ModeString,"output")  ) 
 

Definition at line 232 of file file.c.

References _FileCommandObject::mode, NULL, pEo, pFCO, prepare_directory(), and THISFILEP.

else if stricmp(ModeString,"input_binary")  ) 
 

Definition at line 225 of file file.c.

References _FileCommandObject::mode, NULL, pFCO, and THISFILEP.

else if stricmp(ModeString,"input")  ) 
 

Definition at line 218 of file file.c.

References _FileCommandObject::mode, NULL, pFCO, and THISFILEP.

if memcpy(  FileName = NULL  ) 
 

Definition at line 202 of file file.c.

if pFCO->  mode[FileNumber]  ) 
 

Definition at line 416 of file file.c.

References pFCO, ReadSocketLine(), _FileCommandObject::SocketState, and THISSOCKET.

if FileNumber< 1||FileNumber MAXFILES  ) 
 

if memory_IsUndef(vLEN  ) 
 

Definition at line 183 of file file.c.

static int init pExecuteObject  pEo  )  [static]
 

Definition at line 72 of file file.c.

References ALLOC, close_all_files(), COMMAND_ERROR_MEMORY_LOW, i, MAXFILES, _FileCommandObject::mode, NULL, and pFCO.

static int initdir pExecuteObject  pEo  )  [static]
 

Definition at line 1737 of file file.c.

References ALLOC, close_all_dirs(), _DirCommandObject::dp, MAXDIRS, NULL, and pDCO.

LONGVALUE RESULT   )  = (long)(ftell(THISFILEP) / pFCO->RecordSize[FileNumber])
 

Referenced by basext_GetArgsF(), besFUNCTION(), if(), IsTrue(), memory_ReplaceVariable(), scriba_CallArg(), scriba_CallArgEx(), serconv(), serconvXML(), SPrintVariable(), switch(), varcmp(), varhashpjw(), and while().

memcpy STRINGVALUE(RESULT ,
szResult  ,
12 
 

memcpy STRINGVALUE(RESULT ,
pszOwnerBuffer  ,
cbOwnerBuffer 
 

memcpy STRINGVALUE(RESULT ,
Buffer  ,
cBuffer 
 

memcpy STRINGVALUE(RESULT ,
pDCO->dp->ppszFileName->FileIndex [DirNumber][pDCO->dp[DirNumber],
(STRLEN(RESULT)=pDCO->dp[DirNumber]->cbFileName[pDCO->dp[DirNumber]->FileIndex]) 
 

if LetThisVariable memory_ReleaseVariable pEo->  pMo,
LetThisVariable
 

Referenced by COMMAND_EXTERNAL(), execute_Evaluate(), if(), memory_ReleaseMortals(), memory_ReleaseVariable(), memory_ReplaceVariable(), modu_Init(), scriba_CallArg(), scriba_ResetVariables(), scriba_SetVariable(), and while().

static void prepare_directory pExecuteObject  pEo,
char *  pszFileName
[static]
 

Definition at line 90 of file file.c.

References i, and s.

Referenced by if().

static END char* ReadFileLine pExecuteObject  pEo,
FILE *  fp,
unsigned long *  plCharactersRead,
int(*)(void *)  pfExtIn
[static]
 

Definition at line 299 of file file.c.

References ALLOC, BUFFER_INCREASE, ch, FREE, memcpy(), NULL, pfExtIn, r, and s.

static char* ReadSocketLine pExecuteObject  pEo,
SOCKET  sp,
unsigned long *  plCharactersRead
[static]
 

Definition at line 331 of file file.c.

References ALLOC, BUFFER_INCREASE, ch, FREE, memcpy(), NULL, r, and s.

Referenced by if().

rename sfile  ,
dfile 
 

sort_dirs pEo  ,
fAction  ,
pDCO->  dp[DirNumber]
 

static int sort_dirs pExecuteObject  pEo,
unsigned long  fAction,
pDirList  p
[static]
 

Definition at line 1941 of file file.c.

References j, SORTBY_DESCEN, SORTBY_FNAME, and SWAP.

static int store_file_name pExecuteObject  pEo,
pDirList  p,
char *  buffer,
unsigned long  ThisSortValue
[static]
 

Definition at line 1659 of file file.c.

References ALLOC, FILES_INCREMENT, FREE, and NULL.

Referenced by collect_dirs_r().

int stricmp char *  ,
char * 
 

Definition at line 117 of file reader.c.

Referenced by cgi_Header(), F_LibraryLoaded(), lex_ReadInput(), and lex_RemoveComments().

while HOOK_CURDIR(Buffer, cBuffer = = -1  ) 
 

Definition at line 2395 of file file.c.

References ALLOC, ERROR(), and FREE.

while (ch=HOOK_FGETC(fs))!  = EOF  ) 
 

Definition at line 1536 of file file.c.

while nItem   ) 
 

Definition at line 1026 of file file.c.

References ASSERTOKE, LONGVALUE(), memory_IsUndef(), _FileCommandObject::mode, pFCO, sprintf(), STRINGVALUE(), STRLEN(), and THISSOCKET.


Variable Documentation

ASSERTOKE
 

Definition at line 2843 of file file.c.

ASSERTOKE
 

Definition at line 2835 of file file.c.

ASSERTOKE
 

Definition at line 2783 of file file.c.

ASSERTOKE
 

Definition at line 2779 of file file.c.

ASSERTOKE
 

Definition at line 2767 of file file.c.

ASSERTOKE
 

Definition at line 2690 of file file.c.

ASSERTOKE
 

Definition at line 2621 of file file.c.

ASSERTOKE
 

Definition at line 2618 of file file.c.

ASSERTOKE
 

Definition at line 2432 of file file.c.

ASSERTOKE
 

Definition at line 2244 of file file.c.

ASSERTOKE
 

Definition at line 2202 of file file.c.

ASSERTOKE
 

Definition at line 2155 of file file.c.

ASSERTOKE
 

Definition at line 2061 of file file.c.

ASSERTOKE
 

Definition at line 2058 of file file.c.

ASSERTOKE
 

Definition at line 2055 of file file.c.

ASSERTOKE
 

Definition at line 2052 of file file.c.

ASSERTOKE
 

Definition at line 1606 of file file.c.

ASSERTOKE
 

Definition at line 1575 of file file.c.

ASSERTOKE
 

Definition at line 1566 of file file.c.

ASSERTOKE
 

Definition at line 1505 of file file.c.

ASSERTOKE
 

Definition at line 1450 of file file.c.

ASSERTOKE
 

Definition at line 1416 of file file.c.

ASSERTOKE
 

Definition at line 1360 of file file.c.

ASSERTOKE
 

Definition at line 1353 of file file.c.

ASSERTOKE
 

Definition at line 1311 of file file.c.

ASSERTOKE
 

Definition at line 1017 of file file.c.

ASSERTOKE
 

Definition at line 895 of file file.c.

ASSERTOKE
 

Definition at line 846 of file file.c.

ASSERTOKE
 

Definition at line 795 of file file.c.

ASSERTOKE
 

Definition at line 768 of file file.c.

ASSERTOKE
 

Definition at line 761 of file file.c.

ASSERTOKE
 

Definition at line 725 of file file.c.

ASSERTOKE
 

Definition at line 718 of file file.c.

ASSERTOKE
 

Definition at line 642 of file file.c.

ASSERTOKE
 

Definition at line 558 of file file.c.

ASSERTOKE
 

Definition at line 409 of file file.c.

ASSERTOKE
 

Definition at line 405 of file file.c.

ASSERTOKE
 

Definition at line 181 of file file.c.

ASSERTOKE
 

Definition at line 178 of file file.c.

ASSERTOKE
 

Definition at line 173 of file file.c.

char* Buffer
 

Definition at line 2428 of file file.c.

Buffer = ALLOC(cBuffer)
 

Definition at line 2394 of file file.c.

END char* Buffer
 

CURDIR =title CURDIR() =displax CURDIR() =section misc

This function does not accept argument and returns the current working directory as a string.

Definition at line 2388 of file file.c.

Referenced by HandleFtpHit(), and HandleHttpHit().

END char buffer[80]
 

PRINT =section file =title PRINT [ # fn , ] print_list

This command prints the elements of the T<print_list>. The argument T<print_list> is a comma separated list of expressions. The expressions are evaluated one after the other and are printed to the standard output or to the file.

The command prints the T<print_list> to an opened file given by the file number T<fn>. If T<fn> (along with the T<#> character) is not specified the command prints to the standard output. The file has to be opened to some "output" mode otherwise the command fails to print anything into the file. The command can also print into an opened socket (a file opened for mode socket). If the file is not opened then the expressions in the list T<print_list> are not evaluated and the command actually does nothing. If the file is opened, but not for a kind of "output" mode then the expressions in the T<print_list> are evaluated but the printing does not happen. Neither printing to a non-opened file number nor printing to a file opened for some read-only mode generates error.

If there is no T<print_list> specified the command prints a new line. In other words if the keyword T<PRINT> stands on the command with the optional T<#> and the file number but without anything to print then the command will print a new line character.

Note that unlike other BASIC implementations the command T<PRINT> does not accept print list formatters, like T<AT> or semicolons and does not tabify the output. The arguments are printed to the file or to the standard output one after the other without any intrinsic space or tab added. Also the print statements does not print a new line at the end of the print list unless the new line character is explicitly defined or if there is no print list at all following the command.

Definition at line 1003 of file file.c.

BytesToRead = GETLONGVALUE(vBTR)
 

Definition at line 571 of file file.c.

BytesToRead
 

Definition at line 542 of file file.c.

cBuffer = strlen(Buffer)
 

Definition at line 2401 of file file.c.

cBuffer = 256
 

Definition at line 2393 of file file.c.

long cBuffer
 

Definition at line 2389 of file file.c.

int ch
 

Definition at line 548 of file file.c.

Referenced by _readexpr(), build_IsFileBinaryFormat(), build_LoadCore(), build_SaveECode(), c_readexpr(), c_readlist(), comm_GetCommand(), fork(), getC(), if(), lex_ReadInput(), readcons(), reader_gets(), ReadFileLine(), ReadSocketLine(), and stack_base().

CharsRead
 

Definition at line 542 of file file.c.

char * dfile
 

Definition at line 1563 of file file.c.

DirList
 

Definition at line 1656 of file file.c.

Referenced by file_deltree_r().

char* DirName
 

Definition at line 2041 of file file.c.

DirNumber = LONGVALUE(Op1)
 

Definition at line 2282 of file file.c.

DirNumber = LONGVALUE(Op1)
 

Definition at line 2249 of file file.c.

unsigned long DirNumber
 

Definition at line 2238 of file file.c.

DirNumber = LONGVALUE(Op1)
 

Definition at line 2207 of file file.c.

unsigned long DirNumber
 

Definition at line 2193 of file file.c.

DirNumber = LONGVALUE(Op1)
 

Definition at line 2160 of file file.c.

unsigned long DirNumber
 

Definition at line 2146 of file file.c.

DirNumber = LONGVALUE(CONVERT2LONG(vDirNumber))
 

Definition at line 2069 of file file.c.

long DirNumber
 

OPENDIR =display OPEN DIRECTORY =title OPEN DIRECTORY dir_name PATTERN pattern OPTION option AS dn

Open a directory to retrieve the list of files.

=itemize =item T<dir_name> is the name of the directory. =item T<pattern> is a wild card pattern to filter the file list. =item T<option> is an integer value that can be composed AND-ing some of the following values =itemize =item T<SbCollectDirectories> Collect the directory names as well as file names into the file list. =item T<SbCollectDots> Collect the virtual . and .. directory names into the list. =item T<SbCollectRecursively> Collect the files from the directory and from all the directories below. =item T<SbCollectFullPath> The list will contain the full path to the file names. This means that the file names returned by the function R<NextFile> will contain the directory path specified in the open directory statement and therefore can be used as argument to file handling commands and functions. =item T<SbCollectFiles> Collect the files. This is the default behavior. =item T<SbSortBySize> The files will be sorted by file size. =item T<SbSortByCreateTime> The files will be sorted by creation time. =item T<SbSortByAccessTime> The files will be sorted by access time. =item T<SbSortByModifyTime> The files will be sorted by modify time. =item T<SbSortByName> The files will be sorted by name. The name used for sorting is the bare file name without any path. =item T<SbSortByPath> The files will be sorted by name including the path. The path is the relative to the directory, which is currently opened. This sorting option is different from the value T<sbSortByName> only when the value T<sbCollectRecursively> is also used. =item T<SbSortAscending> Sort the file names in ascending order. This is the default behavior. =item T<SbSortDescending> Sort the file names in descending order. =item T<SbSortByNone> Do not sort. Specify this value if you do not need sorting. In this case directory opening can be much faster especially for large directories. =noitemize =item T<dn> is the directory number used in later references to the opened directory. =noitemize

Note that this command can execute for a long time and consuming a lot of memory especially when directory listing is requested recursively. When the command is executed it collects the names of the files in the directory or directories as requested and builds up an internal list of the file names in the memory. The command R<NEXTFILE> uses the list to retrieve the next file name from the list.

This implies to facts:

=itemize =item The function T<NEXTFILE> will not ever return a file name that the file was created after, and did not exist when the command T<OPEN DIRECTORY> was executed. =item Using R<CLOSEDIR> after the list of the files is not needed as soon as possible is a good idea. =noitemize

Using a directory number that was already used and not released calling R<CLOSEDIR> raises an error.

If the list of the files in the directory can not be collected the command raises error.

See also R<CLOSEDIR> and R<NEXTFILE>.

Definition at line 2040 of file file.c.

unsigned long fAction
 

Definition at line 2045 of file file.c.

fd = HOOK_FOPEN(dfile,"wb")
 

Definition at line 1529 of file file.c.

pDCO dp [DirNumber] FileIndex
 

Definition at line 2172 of file file.c.

FileName = ALLOC(STRLEN(Op1)+1)
 

Definition at line 201 of file file.c.

char* FileName
 

Definition at line 164 of file file.c.

FileNumber
 

Definition at line 1355 of file file.c.

FileNumber = LONGVALUE(CONVERT2LONG(EVALUATEEXPRESSION(PARAMETERNODE)))
 

Definition at line 1352 of file file.c.

END long FileNumber
 

LOCKR =display LOCK REGION =title LOCK REGION # fn FROM start TO end FOR mode Lock a region of a file. The region starts with the record T<start> and ends with the record T<end> including both end positions. The length of a record in the file is given when the file is opened using the statement R<OPEN>.

The mode can be T<read>, T<write> and T<release>. The command works similar as whole file locking, thus it is recommended that you read the differences of the operating systems handling locking in the section of file locking for the command T<LOCK>.

Definition at line 1345 of file file.c.

FileNumber
 

Definition at line 1313 of file file.c.

FileNumber = LONGVALUE(CONVERT2LONG(EVALUATEEXPRESSION(PARAMETERNODE)))
 

Definition at line 1310 of file file.c.

long FileNumber
 

LOCKF =section file =display LOCK =title LOCK # fn, mode Lock a file or release a lock on a file. The T<mode> parameter can be T<read>, T<write> or T<release>.

When a file is locked to T<read> no other program is allowed to write the file. This ensures that the program reading the file gets consistent data from the file. If a program locks a file to read using the lock value T<read> other programs may also get the T<read> lock, but no program can get the R<write> lock. This means that any program trying to write the file and issuing the command T<LOCK> with the parameter T<write> will stop and wait until all read locks are released.

When a program write locks a file no other program can read the file or write the file.

Note that the different operating systems and therefore ScriptBasic running on different operating systems implement file lock in different ways. UNIX operating systems implement so called advisory locking, while Windows NT implements mandatory lock.

This means that a program under UNIX can write a file while another program has a read or write lock on the file if the other program is not good behaving and does not ask for a write lock. Therefore this command under UNIX does not guarantee that any other program is not accessing the file simultaneously.

Contrary Windows NT does lock the file in a hard way, and this means that no other process can access the file in prohibited way while the file is locked.

This different behavior usually does not make harm, but in some rare cases knowing it may help in debugging some problems. Generally you should not have a headache because of this.

You should use this command to synchronize the BASIC programs running parallel and accessing the same file.

You can also use the command T<LOCK REGION> to lock a part of the file while leaving other parts of the file accessible to other programs.

If you heavily use record oriented files and file locks you may consider using some data base module to store the data in database instead of plain files.

Definition at line 1302 of file file.c.

FileNumber
 

Definition at line 1019 of file file.c.

FileNumber = LONGVALUE(CONVERT2LONG(EVALUATEEXPRESSION(nItem)))
 

Definition at line 1016 of file file.c.

long FileNumber
 

Definition at line 1007 of file file.c.

long FileNumber
 

Definition at line 933 of file file.c.

FileNumber
 

Definition at line 905 of file file.c.

FileNumber = LONGVALUE(CONVERT2LONG(Op1))
 

Definition at line 902 of file file.c.

long FileNumber
 

Definition at line 884 of file file.c.

FileNumber
 

Definition at line 856 of file file.c.

FileNumber = LONGVALUE(CONVERT2LONG(Op1))
 

Definition at line 853 of file file.c.

long FileNumber
 

Definition at line 835 of file file.c.

FileNumber
 

Definition at line 797 of file file.c.

FileNumber = LONGVALUE(CONVERT2LONG(EVALUATEEXPRESSION(PARAMETERNODE)))
 

Definition at line 794 of file file.c.

END long FileNumber
 

REWIND =section file =title REWIND [ # ]fn Positions the file cursor to the start of the file. This is the same as T<SEEK fn,0> or T<SEEK fn,0>

The argument to the statement is the file number used in the R<OPEN> statement to open the file. The character T<#> is optional and can only be used for compatibility reasons.

Definition at line 789 of file file.c.

FileNumber
 

Definition at line 763 of file file.c.

FileNumber = LONGVALUE(CONVERT2LONG(EVALUATEEXPRESSION(PARAMETERNODE)))
 

Definition at line 760 of file file.c.

END long FileNumber
 

TRUNCATE =section file =title TRUNCATE fn,new_length Truncate an opened file to the specified size. The first argument Has to be the file number used in the R<OPEN> statement opening the file. The second argument is the number of records to be in the file after it is truncated.

The size of a record has to be specified when the file is opened. If the size Of a record is not specified in number of bytes then the command T<TRUNCATE> Does truncate the file to the number of specified bytes instead of records. (In other words the record length is one byte.)

When the file is actually shorter than the length specified by the command argument the command T<TRUNCATE> automatically extends the file padding with bytes containing the value 0.

Definition at line 755 of file file.c.

FileNumber
 

Definition at line 720 of file file.c.

FileNumber = LONGVALUE(CONVERT2LONG(EVALUATEEXPRESSION(PARAMETERNODE)))
 

Definition at line 717 of file file.c.

END long FileNumber
 

SEEK =section file =title SEEK fn,position Go to a specified position in an open file. You can use this command to position the file pointer to a specific position. The next read or write operation performed on the file will be performed on that very position that was set using the command T<SEEK>. The first argument is the file number that was used in the statement T<OPEN> to open the file. The second argument is the position where the file pointer is to be set.

The position is counted from the start of the file counting records. The actual file pointer will be set B<after> the record T<position>. This means that if for example you want to set the file pointer To the start of the file then you have to T<SEEK fn,0>. This will set the File pointer before the first record.

If there was no record length specified when the file was opened the counting takes bytes. There is no special "record" structure of a file as it is usually under UNIX or Windows NT. The record is merely the number of bytes treated as a single unit specified during file opening.

Definition at line 712 of file file.c.

END long FileNumber
 

RESET =section file =title RESET

This command closes all files opened by the current BASIC program. This command usually exists in most BASIC implementation. There is no need to close a file before a BASIC program finishes, because the interpreter automatically closes all files that were opened by the program.

Definition at line 667 of file file.c.

FileNumber
 

Definition at line 645 of file file.c.

FileNumber = LONGVALUE(CONVERT2LONG(EVALUATEEXPRESSION(PARAMETERNODE)))
 

Definition at line 641 of file file.c.

FileNumber
 

Definition at line 413 of file file.c.

FileNumber = LONGVALUE(CONVERT2LONG(EVALUATEEXPRESSION(PARAMETERNODE)))
 

Definition at line 404 of file file.c.

long FileNumber
 

LINEINPUT =section file =display LINE INPUT =title LINE INPUT Read a line from a file or from the standard input.

The syntax of the command is =verbatim LINE INPUT [# i , ] variable =noverbatim

The parameter T is the file number used in the open statement. If this is not specified the standard input is read.

The T<variable> will hold a single line from the file read containing the possible new line character terminating the line. If the last line of a file is not terminated by a new line character then the T<variable> will not contain any new line character. Thus this command does return only the characters that are really in the file and does not append extra new line character at the end of the last line if that lacks it.

On the other hand you should not rely on the missing new line character from the end of the last line because it may and usually it happens to be there. Use rather the function R<EOF> to determine if a file reading has reached the end of the file or not.

See also R<CHOMP>

You can also read from sockets using this command but you should be careful because data in a socket comes from programs generated on the fly. This means that the socket pipe may not contain the line terminating new line and not finished as well unlike a file. Therefore the command may start infinitely long when trying to read from a socket until the application on the other end of the line sends a new line character or closes the socket. When you read from a file this may not happen.

Definition at line 393 of file file.c.

FileNumber
 

Definition at line 198 of file file.c.

FileNumber = LONGVALUE(CONVERT2LONG(FN))
 

Definition at line 195 of file file.c.

long FileNumber
 

OPEN =section file =title OPEN file_name FOR mode AS [ # ] i [ LEN=record_length ] Open or create and open a file. The syntax of the line is

=verbatim OPEN file_name FOR mode AS [ # ] i [ LEN=record_length ] =noverbatim

The parameters: =itemize =item T<file_name> if the name of the file to be opened. If the mode allows the file to be written the file is created if it did not existed before. If needed, directory is created for the file.

=item T<mode> is the mode the file is opened. It can be: =itemize =item T<input> open the file for reading. In this mode the file is opened in read only mode and can not be altered using the file number associated with the open file. Using any function or command that tries to write the file will result in error. In this mode the file has to exist already to open successfully. If the file to be opened for T<input> does not exist the command T<OPEN> raises an error. =item T<output> open the file for writing. If the file existed it's content is deleted first and a freshly opened empty file is ready to accept commands and functions to write into the file. When a file is opened this way no function or command trying to read from the file can be used using the file number associated with the file. The file is opened in ASCII mode but the handling mode can be changed to binary any time. =item T<append> open a possibly existing file and write after the current content. The same conditions apply as in the mode T<output>, thus you can not read the file, only write. The file is opened in ASCII mode but the handling mode can be changed to binary any time. =item T<random> open the file for reading and writing (textual mode). When you open a file using this mode the file can be written and the content of the existing file can be read. The file pointer can be moved back and forth any time using the command R<SEEK> and thus quite complex file handling functions can be implemented. If the file did not exist it is created. =item T<binary> open the file for reading and writing (binary mode). This mode is the same as T<random> with the exception that the file is opened in binary mode. =item T<socket> open a socket. In this case the file name is NOT a file name, but rather an Internet machine name and a port separated by colon, like T<www.digital.com:80> You should not specify any method, like T<http://> in front of the machine name, as this command opens a TCP socket to the machine's port and the protocol has to be implemented by the BASIC program. =noitemize

=item T<i> is the file number. After the file has been opened this number has to be used in later file handling functions and commands, like R<CLOSE> to refer to the file. The T<#> character is optional and is allowed for compatibility with other BASIC languages. The number can be between 1 and 512. This number is quite big for most of the applications and provides compatibility with VisualBasic.

=item T<record_length> is optional and specify the length of a record in the file. The default record length is 1 byte. File pointer setting commands usually work on records, thus R<SEEK>, R<TRUNCATE> and other commands and functions accept arguments or return values as number of records. The actual record length is not recorded anywhere thus the BASIC program has to remember the actual length of a record in a file. This is not a BASIC program error to open a file with a different record size than it was created, although this may certainly be a programming error. =noitemize

If the file number is specified as a variable and the variable value is set to integer zero then the command will automatically find a usable file number and set the variable to hold that value. Using any other expression of value integer zero is an error.

Definition at line 163 of file file.c.

Referenced by close_all_files().

FN = _EVALUATEEXPRESSION(PARAMETERNODE)
 

Definition at line 177 of file file.c.

VARIABLE FN
 

Definition at line 167 of file file.c.

FILE* fp
 

Definition at line 545 of file file.c.

Referenced by __pprint(), _ex_printVAR(), AppStart(), build_GetExeCodeOffset(), build_IsFileBinaryFormat(), build_LoadCodeWithOffset(), build_SaveCCode(), build_SaveCode(), build_SaveECode(), c_flatc(), c_nthsassoc(), cft_DumbConfig(), cft_DumpConfig(), cft_GetConfigFileName(), cft_ReadConfig(), cft_ReadTextConfig(), cft_WriteConfig(), FtpProc(), GetExtensionVersion(), GuardThread(), if(), InstallScriptBasic(), mcsub(), MyFiles(), reader_ProcessIncludeFiles(), and reader_ReadLines_r().

VARIABLE fpN
 

Definition at line 546 of file file.c.

fs = HOOK_FOPEN(sfile,"rb")
 

Definition at line 1507 of file file.c.

Referenced by ex_IsSymbolValidLval().

int i
 

Definition at line 2429 of file file.c.

unsigned long i
 

Definition at line 2042 of file file.c.

Referenced by _ex_PopLabel(), _ex_pprint(), _GetParam(), _GetServerVariable(), _ReadClient(), _readexpr(), _ScriptName(), _State(), _WriteClient(), _WriteClientText(), AllocFileName(), allocset(), app(), AppInit(), brushup(), brushupinline(), build_pprint(), build_SaveCCode(), c_symcmp(), cft_DumbConfig(), cft_FindNode(), cft_GetConfigFileName(), cgi_GetMultipartParameters(), cgi_ReadHeader(), cgi_ShiftBuffer(), cgi_SkipAfterBoundary(), cnumeric(), comm_GetCommand(), comm_Init(), COMMAND_EXTERNAL(), COMMAND_FUNCTIONARG(), convert_error(), Decode(), DeleteFromPath(), doinsert(), DynaCall(), Encode(), epreproc(), ex_CleanNamePath(), ex_Command_r(), ex_ConvertName(), ex_init(), execute_Convert2Double(), execute_Convert2Long(), execute_ExecuteFunction(), execute_FinishExecute(), execute_GetDoubleValue(), execute_GetLongValue(), execute_InitExecute(), file_exists(), file_flock(), file_isdir(), file_isreg(), file_lock(), file_MakeDirectory(), file_size(), file_time_accessed(), file_time_created(), file_time_modified(), findmust(), firstch(), freeset(), freezeset(), GetSourceLineNumber(), GuardThread(), handle_GetHandle(), hook_CallScribaFunction(), httpd(), HttpProc(), init(), isinsets(), lex_ReadInput(), main(), maskip(), match_index(), match_ModifySet(), MD5_memcpy(), MD5_memset(), MD5Update(), memory_DupImmortal(), memory_NewArray(), memory_ReDimArray(), modu_LoadModule(), MultiJokerSet(), MyExecBefore(), nch(), p_b_term(), p_bracket(), p_simp_re(), pow10(), prepare_directory(), preproc(), PushStackItem(), reader_gets(), regcomp(), return(), samesets(), scriba_CallArg(), scriba_CallArgEx(), scriba_DestroySbArgs(), scriba_LoadInternalPreprocessor(), scriba_NewSbArgs(), serconv(), serconvXML(), SingleJokerSet(), SPrintVarByName(), SPrintVariable(), stndlone(), sym_FreeSymbolTable(), sym_NewSymbolTable(), sym_TraverseSymbolTable(), thread_CreateThread(), uniqfnam(), and unserconv().

iError = HOOK_CREATEPROCESSEX(pszCommandLine,LONGVALUE(vTimeOut),&lPid,&lExitCode)
 

Definition at line 2786 of file file.c.

int iError
 

Definition at line 2760 of file file.c.

Referenced by AppInit(), AppStart(), cft_DumpConfig(), cft_ReadTextConfig(), cft_start(), collect_dirs_r(), CountSubTree(), execute_InitStructure(), hook_CallScribaFunction(), HttpExtensionProc(), if(), ipreproc_LoadInternalPreprocessor(), ipreproc_Process(), main(), modu_ShutdownModule(), reader_LoadPreprocessors(), scriba_Call(), scriba_CallArg(), scriba_CallArgEx(), scriba_DoSyntaxAnalysis(), scriba_GetConfigFileName(), scriba_LoadConfiguration(), scriba_LoadInternalPreprocessor(), scriba_LoadProgramString(), scriba_LoadSourceProgram(), scriba_NoRun(), scriba_PreRun(), scriba_Run(), scriba_RunExternalPreprocessor(), scriba_SetProcessSbObject(), scriba_UseCacheFile(), and stndlone().

INITDIR
 

Definition at line 2240 of file file.c.

INITDIR
 

Definition at line 2195 of file file.c.

INITDIR
 

Definition at line 2148 of file file.c.

INITDIR
 

Definition at line 2047 of file file.c.

INITIALIZE
 

Definition at line 1349 of file file.c.

INITIALIZE
 

Definition at line 1307 of file file.c.

INITIALIZE
 

Definition at line 1012 of file file.c.

INITIALIZE
 

Definition at line 937 of file file.c.

INITIALIZE
 

Definition at line 887 of file file.c.

INITIALIZE
 

Definition at line 838 of file file.c.

INITIALIZE
 

Definition at line 792 of file file.c.

INITIALIZE
 

Definition at line 758 of file file.c.

INITIALIZE
 

Definition at line 715 of file file.c.

INITIALIZE
 

Definition at line 670 of file file.c.

INITIALIZE
 

Definition at line 639 of file file.c.

INITIALIZE
 

Definition at line 551 of file file.c.

INITIALIZE
 

Definition at line 401 of file file.c.

INITIALIZE
 

Definition at line 169 of file file.c.

iResult = HOOK_DELTREE(s)
 

Definition at line 1623 of file file.c.

int iResult
 

Definition at line 1603 of file file.c.

iResult = HOOK_REMOVE(s)
 

Definition at line 1464 of file file.c.

int iResult
 

Definition at line 1446 of file file.c.

Referenced by COMMAND_EXTERNAL(), COMMAND_EXTERNAM(), file_MakeDirectory(), lex_ReadInput(), modu_LoadModule(), and reader_ReadLines().

VARIABLE ItemResult
 

Definition at line 1005 of file file.c.

Referenced by COMMAND_FUNCTIONARG().

LastDSPos = 0
 

Definition at line 1515 of file file.c.

unsigned long lCharactersRead
 

Definition at line 397 of file file.c.

* LetThisVariable = NEWLONG
 

Definition at line 2850 of file file.c.

LetThisVariable = EVALUATELEFTVALUE(CAR(nItem))
 

Definition at line 2842 of file file.c.

LEFTVALUE LetThisVariable
 

Definition at line 2825 of file file.c.

LetThisVariable = EVALUATELEFTVALUE(CAR(nItem))
 

Definition at line 2782 of file file.c.

LEFTVALUE LetThisVariable
 

Definition at line 2758 of file file.c.

LetThisVariable = EVALUATELEFTVALUE(PARAMETERNODE)
 

Definition at line 408 of file file.c.

LEFTVALUE LetThisVariable
 

Definition at line 396 of file file.c.

long lExitCode
 

Definition at line 2828 of file file.c.

unsigned long lExitCode
 

Definition at line 2756 of file file.c.

lFrom = LONGVALUE(CONVERT2LONG(EVALUATEEXPRESSION(PARAMETERNODE)))
 

Definition at line 1359 of file file.c.

END long lFrom
 

Definition at line 1345 of file file.c.

unsigned long lPid
 

Definition at line 2756 of file file.c.

lPid = HOOK_CREATEPROCESS(pszCommandLine)
 

Definition at line 2699 of file file.c.

long lPid
 

Definition at line 2685 of file file.c.

END long lSwap
 

Definition at line 1345 of file file.c.

END long lTo
 

Definition at line 1345 of file file.c.

pFCO mode[FileNumber] = (char)0
 

Definition at line 651 of file file.c.

ModeString = pEo->StringTable+pEo->CommandArray[_ActualNode-1].Parameter.CommandArgument.Argument.szStringValue
 

Definition at line 1373 of file file.c.

char* ModeString
 

Definition at line 1346 of file file.c.

ModeString = pEo->StringTable+pEo->CommandArray[_ActualNode-1].Parameter.CommandArgument.Argument.szStringValue
 

Definition at line 1317 of file file.c.

char* ModeString
 

Definition at line 1303 of file file.c.

ModeString = pEo->StringTable+pEo->CommandArray[_ActualNode-1].Parameter.CommandArgument.Argument.szStringValue
 

Definition at line 175 of file file.c.

char* ModeString
 

Definition at line 165 of file file.c.

NEXTPARAMETER
 

Definition at line 2059 of file file.c.

NEXTPARAMETER
 

Definition at line 2056 of file file.c.

NEXTPARAMETER
 

Definition at line 2053 of file file.c.

NEXTPARAMETER
 

Definition at line 1573 of file file.c.

NEXTPARAMETER
 

Definition at line 1503 of file file.c.

NEXTPARAMETER
 

Definition at line 1372 of file file.c.

NEXTPARAMETER
 

Definition at line 1358 of file file.c.

NEXTPARAMETER
 

Definition at line 1316 of file file.c.

NEXTPARAMETER
 

Definition at line 1023 of file file.c.

NEXTPARAMETER
 

Definition at line 766 of file file.c.

NEXTPARAMETER
 

Definition at line 723 of file file.c.

NEXTPARAMETER
 

Definition at line 406 of file file.c.

NEXTPARAMETER
 

Definition at line 179 of file file.c.

NEXTPARAMETER
 

Definition at line 176 of file file.c.

NEXTPARAMETER
 

Definition at line 174 of file file.c.

Referenced by COMMAND_EXTERNAL(), COMMAND_EXTERNAM(), and while().

nItem = CDR(nItem)
 

Definition at line 2841 of file file.c.

nItem = PARAMETERLIST
 

Definition at line 2830 of file file.c.

NODE nItem
 

Definition at line 2824 of file file.c.

nItem = CDR(nItem)
 

Definition at line 2781 of file file.c.

nItem = CDR(nItem)
 

Definition at line 2777 of file file.c.

nItem = PARAMETERLIST
 

Definition at line 2762 of file file.c.

NODE nItem
 

Definition at line 2757 of file file.c.

nItem = CDR(nItem)
 

Definition at line 2619 of file file.c.

nItem = PARAMETERLIST
 

Definition at line 2615 of file file.c.

NODE nItem
 

Definition at line 2611 of file file.c.

nItem = PARAMETERNODE
 

Definition at line 1024 of file file.c.

nItem = PARAMETERNODE
 

Definition at line 1015 of file file.c.

NODE nItem
 

Definition at line 1004 of file file.c.

NODE nItem
 

Definition at line 935 of file file.c.

nItem = CDR(nItem)
 

Definition at line 572 of file file.c.

nItem = PARAMETERLIST
 

Definition at line 556 of file file.c.

NODE nItem
 

Definition at line 544 of file file.c.

END NOTIMPLEMENTED
 

FORK =section process =display FORK() =title FORK() =subtitle NOT IMPLEMENTED

This function is supposed to perform process forking just as the native UNIX function T<fork> does. However this function is not implemented in ScriptBasic (yet). Until this function is implemented in ScriptBasic you can use the UX module fork function.

Definition at line 2656 of file file.c.

Referenced by COMMAND_EXTERNAL(), and COMMAND_EXTERNAM().

Op = CONVERT2STRING(_EVALUATEEXPRESSION(PARAMETERNODE))
 

Definition at line 2431 of file file.c.

END VARIABLE Op
 

CHDIR =section misc =title CHDIR directory

Change the current working directory (CWD). This command accepts one argument, the directory which has to be the CWD after the command is executed. If the CWD can not be changed to that directory then an error is raised.

Pay careful attention when you use this command in your code. Note that there is only one CWD for each process and not one for each thread. When an application embeds the BASIC interpreter in a multi-thread environment, like in the Eszter SB Application Engine this command may alter the CWD for all the threads.

For this reason the Eszter SB Application Engine switches off this command, raising error if ever a program executed in the engine calls this command whatever argument is given.

Thus usually BASIC programs should avoid calling this command unless the programmer is certain that the BASIC program will only be executed in a single thread environment (command line).

Definition at line 2427 of file file.c.

Op = CONVERT2STRING(EVALUATEEXPRESSION(PARAMETERNODE))
 

Definition at line 1605 of file file.c.

END VARIABLE Op
 

DELTREE =title DELTREE file/directory_name =section file

Delete a file or a directory. You can use this command to delete a file the same way as you do use the command R<DELETE>. The difference between the two commands R<DLETE> and T<DELTREE> comes into place when the program deletes directories.

This command, T<DELTREE> forcefully tries to delete a directory even if the directory is not empty. If the directory is not empty then the command tries to delete the files in the directory and the subdirectories recursively.

If the file or the directory cannot be deleted then the command raises error. However even in this case some of the files and subdirectories may already been deleted.

Definition at line 1601 of file file.c.

Op = CONVERT2STRING(EVALUATEEXPRESSION(PARAMETERNODE))
 

Definition at line 1448 of file file.c.

END VARIABLE Op
 

DELETE =title DELETE file/directory_name =section file

This command deletes a file or an B<empty> directory. You can not delete a directory which contains files or subdirectories.

If the file or the directory can not be deleted an error is raised. This may happen for example if the program trying to delete the file or directory does not have enough permission.

See R<DELTREE> for a more powerful and dangerous delete.

Definition at line 1444 of file file.c.

Op = CONVERT2STRING(EVALUATEEXPRESSION(PARAMETERNODE))
 

Definition at line 1415 of file file.c.

END VARIABLE Op
 

MKDIR =section file =title MKDIR directory_name

This command creates a new directory. If it is needed then the command attempts to create all directories automatically that are needed to create the final directory. For example if you want to create T<public_html/cgi-bin> but the directory T<public_html> does not exist then the command

=verbatim MKDIR "public_html/cgi-bin" =noverbatim

will first create the directory T<public_html> and then T<cgi-bin> under that directory.

If the directory can not be created for some reason an error is raised.

This is not an error if the directory does already exist.

You need not call this function when you want to create a file using the command R<OPEN>. The command R<OPEN> automatically creates the needed directory when a file is opened to be written.

The created directory can be erased calling the command R<DELETE> or calling the dangerous command R<DELTREE>.

Definition at line 1412 of file file.c.

Op1 = CONVERT2LONG(EVALUATEEXPRESSION(PARAMETERNODE))
 

Definition at line 2243 of file file.c.

END VARIABLE Op1
 

RESETDIR =section file =title RESET DIRECTORY [#] dn =display RESET DIRECTORY

Reset the directory file name list and start from the first file name when the next call to R<NEXTFILE> is performed.

See also R<OPENDIR>, R<CLOSEDIR>, R<NEXTFILE>, R<EOD>.

Definition at line 2236 of file file.c.

Op1 = CONVERT2LONG(EVALUATEEXPRESSION(CAR(PARAMETERLIST)))
 

Definition at line 2201 of file file.c.

END VARIABLE Op1
 

EOD =display EOD() =title EOD(dn) =section file

Checks if there is still some file names in the directory opened for reading using the directory number T<dn>.

See also R<NEXTFILE>.

Definition at line 2191 of file file.c.

Op1 = CONVERT2LONG(EVALUATEEXPRESSION(CAR(PARAMETERLIST)))
 

Definition at line 2154 of file file.c.

END VARIABLE Op1
 

NEXTFILE =section file =title NEXTFILE(dn) =display NEXTFILE()

Retrieve the next file name from an opened directory list. If there is no more file names it returns T<undef>.

See also R<OPENDIR> and R<CLOSEDIR>.

Definition at line 2144 of file file.c.

Op1 = CONVERT2STRING(EVALUATEEXPRESSION(PARAMETERNODE))
 

Definition at line 1565 of file file.c.

END VARIABLE Op1
 

NAME =title NAME filename,filename =section file

Rename a file. The first file is the existing one, the second is the new name of the file. You can not move filed from one disk to another using this command. This command merely renames a single file. Also you can not use wild characters in the source or destination file name.

If you can not rename a file for some reason, you can try to use the command R<FileCopy> and then delete the old file. This is successful in some of the cases when T<NAME> fails, but it is a slower method.

If the file can not be renamed then the command raises error.

Definition at line 1562 of file file.c.

END VARIABLE Op1
 

FREEFILE =section file =title FREEFILE() This function returns a free file number, which is currently not associated with any opened file. If there is no such file number it returns T<undef>.

The returned value can be used in a consecutive R<OPEN> statement to specify a file number. Another way to get a free file number is to set a variable to hold the integer value zero and use the variable as file number in the statement R<OPEN>. For more information on this method see the documentation of the statement R<OPEN>.

Definition at line 932 of file file.c.

Op1 = EVALUATEEXPRESSION(CAR(PARAMETERLIST))
 

Definition at line 894 of file file.c.

END VARIABLE Op1
 

LOF =section file =display LOF() =title LOF() This function returns the length of an opened file in number of records. The argument of the function has to be the file number that was used by the statement R<OPEN> to open the file.

The actual number of records is calculated using the record size specified when the command R<OPEN> was used. The returned number is the number of records that fit in the file. If the file is longer containing a fractional record at the end the fractional record is not counted.

If there was no record length specified when the file was opened the length of the file is returned in number of bytes. In this case fractional record has no meaning.

Definition at line 883 of file file.c.

Op1 = EVALUATEEXPRESSION(CAR(PARAMETERLIST))
 

Definition at line 845 of file file.c.

END VARIABLE Op1
 

LOC =display LOC() =title LOC() =section file Return current file pointer position of the opened file. The argument of the function is the file number that was used by the statement R<OPEN> opening the file.

This function is the counter part of the statement R<SEEK> that sets the file pointer position.

The file position is counted in record size. This means that the file pointer stands after the record returned by the function. This is not necessarily stands right after the record at the start of the next record actually. It may happen that the file pointer stands somewhere in the middle of the next record. Therefore the command

=verbatim SEEK fn,LOC(fn) =noverbatim

may alter the actual file position and can be used to set the file pointer to a safe record boundary position.

If there was no record size defined when the file was opened the location is counted in bytes. In this case the returned value precisely defines where the file pointer is.

Definition at line 834 of file file.c.

Op1 = CONVERT2STRING(_EVALUATEEXPRESSION(PARAMETERNODE))
 

Definition at line 172 of file file.c.

VARIABLE Op1
 

Definition at line 167 of file file.c.

Op2 = CONVERT2STRING(EVALUATEEXPRESSION(PARAMETERNODE))
 

Definition at line 1574 of file file.c.

END VARIABLE Op2
 

Definition at line 1562 of file file.c.

Op2 = CONVERT2STRING(EVALUATEEXPRESSION(PARAMETERNODE))
 

Definition at line 1504 of file file.c.

pDCO = (pDirCommandObject)PARAMPTR(CMD_OPENDIR)
 

Definition at line 2241 of file file.c.

pDirCommandObject pDCO
 

Definition at line 2237 of file file.c.

pDCO = (pDirCommandObject)PARAMPTR(CMD_OPENDIR)
 

Definition at line 2196 of file file.c.

pDirCommandObject pDCO
 

Definition at line 2192 of file file.c.

pDCO = (pDirCommandObject)PARAMPTR(CMD_OPENDIR)
 

Definition at line 2149 of file file.c.

pDirCommandObject pDCO
 

Definition at line 2145 of file file.c.

pDCO = (pDirCommandObject)PARAMPTR(CMD_OPENDIR)
 

Definition at line 2048 of file file.c.

pDirCommandObject pDCO
 

Definition at line 2043 of file file.c.

Referenced by close_all_dirs(), close_directory_list(), and initdir().

* pDirList
 

Definition at line 1656 of file file.c.

Referenced by file_deltree_r().

pFCO = (pFileCommandObject)PARAMPTR(CMD_OPEN)
 

Definition at line 1350 of file file.c.

pFileCommandObject pFCO
 

Definition at line 1347 of file file.c.

pFCO = (pFileCommandObject)PARAMPTR(CMD_OPEN)
 

Definition at line 1308 of file file.c.

pFileCommandObject pFCO
 

Definition at line 1304 of file file.c.

pFCO = (pFileCommandObject)PARAMPTR(CMD_OPEN)
 

Definition at line 1013 of file file.c.

pFileCommandObject pFCO
 

Definition at line 1008 of file file.c.

pFCO = (pFileCommandObject)PARAMPTR(CMD_OPEN)
 

Definition at line 938 of file file.c.

pFileCommandObject pFCO
 

Definition at line 934 of file file.c.

pFCO = (pFileCommandObject)PARAMPTR(CMD_OPEN)
 

Definition at line 888 of file file.c.

pFileCommandObject pFCO
 

Definition at line 885 of file file.c.

pFCO = (pFileCommandObject)PARAMPTR(CMD_OPEN)
 

Definition at line 839 of file file.c.

pFileCommandObject pFCO
 

Definition at line 836 of file file.c.

pFCO = (pFileCommandObject)PARAMPTR(CMD_OPEN)
 

Definition at line 793 of file file.c.

pFileCommandObject pFCO
 

Definition at line 790 of file file.c.

pFCO = (pFileCommandObject)PARAMPTR(CMD_OPEN)
 

Definition at line 759 of file file.c.

pFileCommandObject pFCO
 

Definition at line 756 of file file.c.

pFCO = (pFileCommandObject)PARAMPTR(CMD_OPEN)
 

Definition at line 716 of file file.c.

pFileCommandObject pFCO
 

Definition at line 713 of file file.c.

pFCO = (pFileCommandObject)PARAMPTR(CMD_OPEN)
 

Definition at line 671 of file file.c.

pFileCommandObject pFCO
 

Definition at line 668 of file file.c.

pFCO = (pFileCommandObject)PARAMPTR(CMD_OPEN)
 

Definition at line 640 of file file.c.

pFileCommandObject pFCO
 

Definition at line 636 of file file.c.

pFCO = (pFileCommandObject)PARAMPTR(CMD_OPEN)
 

Definition at line 552 of file file.c.

pFileCommandObject pFCO
 

Definition at line 543 of file file.c.

pFCO = (pFileCommandObject)PARAMPTR(CMD_OPEN)
 

Definition at line 402 of file file.c.

pFileCommandObject pFCO
 

Definition at line 394 of file file.c.

pFCO = (pFileCommandObject)PARAMPTR(CMD_OPEN)
 

Definition at line 170 of file file.c.

pFileCommandObject pFCO
 

Definition at line 166 of file file.c.

Referenced by close_all_files(), if(), init(), and while().

int(* pfExtIn)(void *)
 

Definition at line 549 of file file.c.

Referenced by ReadFileLine().

Position = pFCO->RecordSize[FileNumber] * LONGVALUE(CONVERT2LONG(EVALUATEEXPRESSION(PARAMETERNODE)))
 

Definition at line 767 of file file.c.

END long Position
 

Definition at line 755 of file file.c.

Position = pFCO->RecordSize[FileNumber] * LONGVALUE(CONVERT2LONG(EVALUATEEXPRESSION(PARAMETERNODE)))
 

Definition at line 724 of file file.c.

END long Position
 

Definition at line 712 of file file.c.

END char* pszCommandLine
 

EXECUTE =section process =title EXECUTE("executable_program", time_out,pid_v) =display EXECUTE()

This function should be used to start an external program and wait for it to finish.

The first argument of the function is the executable command line to start. The second argument is the number of seconds that the BASIC program should wait for the external program to finish. If the external program finishes during this period the function returns and the return value is the exit code of the external program. If the argument specifying how many seconds the BASIC program has to wait is T<-1> then the BASIC program will wait infinitely.

If the program does not finish during the specified period then the function alters the third argument, which has to be a variable and raises error. In this case the argument T<pid_v> will hold the PID of the external program. This value can be used in the error handling code to terminate the external program.

=details

The function can be used to start a program synchronous and asynchronous mode as well. When the timeout value passed to the function is zero the function starts the new process, but does not wait it to finish, but raises an error. In this case the BASIC program can catch this error using the T<ON ERROR GOTO> structure and get the pid of the started process from the variable T<pid_v>. In this case the function does not "return" any value because a BASIC error happened. For example:

=verbatim ON ERROR GOTO NoError a = EXECUTE("ls",0,PID) NoError: print "The program 'ls' is running under the pid: ",PID,"\n" =noverbatim

If the argument T<time_out> is T<-1> the function will wait for the subprocess to finish whatever long it takes to run. For example:

=verbatim a = EXECUTE("ls",-1,PID) print "ls was executed and the exit code was:",a =noverbatim

Note that the string passed as first argument containing the executable program name and the arguments (the command line) should not contain zero character (a character with ASCII code 0) for security reasons. If the command line string contains zero character an error is raised.

Definition at line 2754 of file file.c.

END char* pszCommandLine
 

SYSTEM =section process =title SYSTEM(executable_program) =display SYSTEM()

This function should be used to start an external program in a separate process in asynchronous mode. In other words you can start a process and let it run by itself and not wait for the process to finish. After starting the new process the BASIC program goes on parallel with the started external program.

The return value of the function is the PID of the newly created process.

If the program specified by the argument can not be started then the return value is zero. Under UNIX the program may return a valid PID even in this case. This is because UNIX first makes a copy of the process that wants to start another and then replaces the new process image with the program image to be started. In this case the new process is created and the command T<SYSTEM> has no information on the fact that the new process was not able to replace the executable image of itself. In this case, however, the child process has a very short life.

Definition at line 2683 of file file.c.

END char * pszSalt
 

Definition at line 2608 of file file.c.

END char* pszString
 

CRYPT =section file misc =display CRYPT() =title CRYPT(string,salt)

This function returns the encoded DES digest of the string using the salt as it is used to encrypt passwords under UNIX.

Note that only the first 8 characters of the string are taken into account.

Definition at line 2608 of file file.c.

else Range = -1
 

Definition at line 951 of file file.c.

long Range
 

Definition at line 933 of file file.c.

long RecLen
 

Definition at line 163 of file file.c.

pFCO RecordSize[FileNumber] = RecLen
 

Definition at line 295 of file file.c.

long refcount
 

Definition at line 2826 of file file.c.

long refcount
 

Definition at line 2759 of file file.c.

long refcount
 

Definition at line 399 of file file.c.

Referenced by execute_Dereference(), execute_Evaluate(), memory_SetRef(), and SPrintVariable().

Result = HOOK_WAITPID(LONGVALUE(vPid),&lExitCode)
 

Definition at line 2846 of file file.c.

long Result
 

Definition at line 2827 of file file.c.

RESULT = NEWMORTALLONG
 

Definition at line 2703 of file file.c.

RESULT = NEWMORTALSTRING(12)
 

Definition at line 2636 of file file.c.

RESULT = NEWMORTALSTRING(cbOwnerBuffer=strlen(pszOwnerBuffer))
 

Definition at line 2586 of file file.c.

RESULT = NEWMORTALSTRING(cBuffer)
 

Definition at line 2402 of file file.c.

else RESULT = NULL
 

Definition at line 2372 of file file.c.

RESULT = NEWMORTALLONG
 

Definition at line 2215 of file file.c.

RESULT = NEWMORTALSTRING(pDCO->dp[DirNumber]->cbFileName[pDCO->dp[DirNumber]->FileIndex])
 

Definition at line 2168 of file file.c.

RESULT = NEWMORTALLONG
 

Definition at line 909 of file file.c.

RESULT = NULL
 

Definition at line 903 of file file.c.

RESULT = NEWMORTALLONG
 

Definition at line 860 of file file.c.

RESULT = NULL
 

Definition at line 854 of file file.c.

VARIABLE Result
 

Definition at line 395 of file file.c.

Referenced by preproc().

RETURN
 

Definition at line 1582 of file file.c.

RETURN
 

Definition at line 1543 of file file.c.

Referenced by besCOMMAND(), besFUNCTION(), if(), switch(), and while().

s = ALLOC(STRLEN(Op)+1)
 

Definition at line 1607 of file file.c.

char* s
 

Definition at line 1602 of file file.c.

s = ALLOC(STRLEN(Op)+1)
 

Definition at line 1449 of file file.c.

char* s
 

Definition at line 1445 of file file.c.

s = ALLOC(STRLEN(Op)+1)
 

Definition at line 1417 of file file.c.

char* s
 

Definition at line 1413 of file file.c.

char* s
 

Definition at line 1009 of file file.c.

char* s
 

Definition at line 547 of file file.c.

else s = ReadFileLine(pEo,THISFILEP,&lCharactersRead,NULL)
 

Definition at line 421 of file file.c.

char* s
 

Definition at line 398 of file file.c.

SavePosition = ftell(THISFILEP)
 

Definition at line 911 of file file.c.

long SavePosition
 

Definition at line 884 of file file.c.

char* sfile
 

Definition at line 1563 of file file.c.

unsigned long slen
 

Definition at line 1010 of file file.c.

Referenced by CreateJunction(), DeleteFromPath(), epreproc(), execute_Evaluate(), scriba_CallArg(), and SPrintVariable().

char szResult[13]
 

Definition at line 2609 of file file.c.

THISFILEP = NULL
 

Definition at line 652 of file file.c.

USE_CALLER_MORTALS
 

Definition at line 2832 of file file.c.

USE_CALLER_MORTALS
 

Definition at line 2764 of file file.c.

USE_CALLER_MORTALS
 

Definition at line 2687 of file file.c.

USE_CALLER_MORTALS
 

Definition at line 2613 of file file.c.

USE_CALLER_MORTALS
 

Definition at line 2391 of file file.c.

USE_CALLER_MORTALS
 

Definition at line 2199 of file file.c.

USE_CALLER_MORTALS
 

Definition at line 2152 of file file.c.

USE_CALLER_MORTALS
 

Definition at line 941 of file file.c.

USE_CALLER_MORTALS
 

Definition at line 891 of file file.c.

USE_CALLER_MORTALS
 

Definition at line 842 of file file.c.

USE_CALLER_MORTALS
 

Definition at line 554 of file file.c.

vBTR = EVALUATEEXPRESSION(CAR(nItem))
 

Definition at line 557 of file file.c.

VARIABLE vBTR
 

Definition at line 546 of file file.c.

vCommandLine = CONVERT2STRING(_EVALUATEEXPRESSION(CAR(nItem)))
 

Definition at line 2766 of file file.c.

VARIABLE vCommandLine
 

Definition at line 2755 of file file.c.

vCommandLine = CONVERT2STRING(_EVALUATEEXPRESSION(CAR(PARAMETERLIST)))
 

Definition at line 2689 of file file.c.

VARIABLE vCommandLine
 

Definition at line 2684 of file file.c.

vDirName = CONVERT2STRING(_EVALUATEEXPRESSION(PARAMETERNODE))
 

Definition at line 2051 of file file.c.

VARIABLE vDirName
 

Definition at line 2044 of file file.c.

vDirNumber = _EVALUATEEXPRESSION(PARAMETERNODE)
 

Definition at line 2060 of file file.c.

VARIABLE vDirNumber
 

Definition at line 2044 of file file.c.

vLEN = CONVERT2LONG(EVALUATEEXPRESSION(PARAMETERNODE))
 

Definition at line 180 of file file.c.

VARIABLE vLEN
 

Definition at line 167 of file file.c.

vOption = CONVERT2LONG(EVALUATEEXPRESSION(PARAMETERNODE))
 

Definition at line 2057 of file file.c.

VARIABLE vOption
 

Definition at line 2044 of file file.c.

vPattern = CONVERT2STRING(_EVALUATEEXPRESSION(PARAMETERNODE))
 

Definition at line 2054 of file file.c.

VARIABLE vPattern
 

Definition at line 2044 of file file.c.

vPid = CONVERT2LONG(_EVALUATEEXPRESSION(CAR(PARAMETERLIST)))
 

Definition at line 2834 of file file.c.

END VARIABLE vPid
 

WAITPID =section process =title WAITPID(PID,ExitCode) =display WAITPID()

This function should be used to test for the existence of a process.

The return value of the function is 0 if the process is still running. If the process has exited (or failed in some way) the return value is T<1> and the exit code of the process is stored in T<ExitCode>.

Definition at line 2823 of file file.c.

vSalt = CONVERT2STRING(_EVALUATEEXPRESSION(CAR(nItem)))
 

Definition at line 2620 of file file.c.

VARIABLE vSalt
 

Definition at line 2610 of file file.c.

vString = CONVERT2STRING(_EVALUATEEXPRESSION(CAR(nItem)))
 

Definition at line 2617 of file file.c.

VARIABLE vString
 

Definition at line 2610 of file file.c.

Referenced by if().

vTimeOut = CONVERT2LONG(_EVALUATEEXPRESSION(CAR(nItem)))
 

Definition at line 2778 of file file.c.

VARIABLE vTimeOut
 

Definition at line 2755 of file file.c.


Generated on Sun Mar 12 23:56:33 2006 for ScriptBasic by  doxygen 1.4.6-NO