#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 _FileCommandObject * | pFileCommandObject |
typedef _DirCommandObject | DirCommandObject |
typedef _DirCommandObject * | pDirCommandObject |
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[DirNumber] | FileIndex |
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 |
|
|
|
Referenced by cgi_InitCgi(), ReadFileLine(), and ReadSocketLine(). |
|
|
|
Definition at line 1758 of file file.c. Referenced by collect_dirs_r(). |
|
Definition at line 1766 of file file.c. Referenced by collect_dirs(). |
|
|
|
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 1658 of file file.c. Referenced by store_file_name(). |
|
|
|
Referenced by if(). |
|
Definition at line 1770 of file file.c. Referenced by collect_dirs(), collect_dirs_r(), file_deltree(), and file_deltree_r(). |
|
Referenced by close_all_dirs(), and initdir(). |
|
Definition at line 43 of file file.c. Referenced by close_all_files(), and init(). |
|
|
|
Value: COMMAND(XXX)\ NOTIMPLEMENTED;\ END |
|
|
|
|
|
Definition at line 1762 of file file.c. Referenced by collect_dirs_r(). |
|
|
|
Definition at line 1761 of file file.c. Referenced by collect_dirs_r(). |
|
Definition at line 1768 of file file.c. Referenced by sort_dirs(). |
|
|
|
Definition at line 1765 of file file.c. Referenced by sort_dirs(). |
|
|
|
Definition at line 1763 of file file.c. Referenced by collect_dirs_r(). |
|
|
|
Definition at line 1764 of file file.c. Referenced by collect_dirs_r(). |
|
|
|
Definition at line 1760 of file file.c. Referenced by collect_dirs_r(). |
|
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(). |
|
Definition at line 32 of file file.c. Referenced by close_all_files(), and if(). |
|
Definition at line 33 of file file.c. Referenced by close_all_files(), if(), and while(). |
|
|
|
|
|
|
|
|
|
Definition at line 1726 of file file.c. References close_directory_list(), _DirCommandObject::dp, MAXDIRS, NULL, and pDCO. Referenced by initdir(). |
|
Definition at line 56 of file file.c. References FileNumber, HOOK_FCLOSE(), MAXFILES, _FileCommandObject::mode, pFCO, THISFILEP, and THISSOCKET. Referenced by init(). |
|
Definition at line 1706 of file file.c. References _DirCommandObject::dp, FREE, j, NULL, and pDCO. Referenced by close_all_dirs(). |
|
Definition at line 1901 of file file.c. References collect_dirs_r(), COLLECT_FULLP, initialize_like(), MAX_FNLEN, memcpy(), and strcpy(). |
|
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(). |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Referenced by fork(), log_printf(), log_thread(), and logit(). |
|
Definition at line 113 of file file.c. References STRINGVALUE(), and STRLEN(). |
|
|
|
Definition at line 672 of file file.c. Referenced by categorize(), firstch(), freeset(), freezeset(), and nch(). |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Referenced by build_GetExeCodeOffset(), build_LoadCodeWithOffset(), and cgi_GetMultipartParameters(). |
|
|
|
|
|
Referenced by close_all_files(), and if(). |
|
|
|
|
|
Definition at line 2836 of file file.c. References RETURN. |
|
Definition at line 2789 of file file.c. References ERROR(), LONGVALUE(), and memory_ReleaseVariable(). |
|
Definition at line 2691 of file file.c. References RETURN. |
|
Definition at line 2623 of file file.c. References RETURN. |
|
|
|
Definition at line 2504 of file file.c. References LONGVALUE(). |
|
Definition at line 2500 of file file.c. References LONGVALUE(). |
|
Definition at line 2496 of file file.c. References LONGVALUE(). |
|
|
|
|
|
|
|
|
|
|
|
Definition at line 1530 of file file.c. References ERROR(), FREE, and HOOK_FCLOSE(). |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Definition at line 1066 of file file.c. References INITIALIZE. |
|
Definition at line 953 of file file.c. References _FileCommandObject::mode, and pFCO. |
|
|
|
Definition at line 573 of file file.c. References ASSERTOKE, ERROR(), memory_IsUndef(), _FileCommandObject::mode, pFCO, _FileCommandObject::RecordSize, and THISFILEP. |
|
|
|
Definition at line 422 of file file.c. References INITIALIZE. |
|
|
|
Definition at line 291 of file file.c. References COMMAND_ERROR_FILE_CANNOT_BE_OPENED, ERROR(), _FileCommandObject::mode, and pFCO. |
|
Definition at line 279 of file file.c. References _FileCommandObject::mode, NULL, pEo, pFCO, prepare_directory(), and THISFILEP. |
|
Definition at line 268 of file file.c. References _FileCommandObject::mode, NULL, pEo, pFCO, prepare_directory(), and THISFILEP. |
|
Definition at line 259 of file file.c. References _FileCommandObject::mode, NULL, pEo, pFCO, prepare_directory(), and THISFILEP. |
|
Definition at line 250 of file file.c. References _FileCommandObject::mode, NULL, pEo, pFCO, prepare_directory(), and THISFILEP. |
|
Definition at line 241 of file file.c. References _FileCommandObject::mode, NULL, pEo, pFCO, prepare_directory(), and THISFILEP. |
|
Definition at line 232 of file file.c. References _FileCommandObject::mode, NULL, pEo, pFCO, prepare_directory(), and THISFILEP. |
|
Definition at line 225 of file file.c. References _FileCommandObject::mode, NULL, pFCO, and THISFILEP. |
|
Definition at line 218 of file file.c. References _FileCommandObject::mode, NULL, pFCO, and THISFILEP. |
|
|
|
Definition at line 416 of file file.c. References pFCO, ReadSocketLine(), _FileCommandObject::SocketState, and THISSOCKET. |
|
|
|
|
|
Definition at line 72 of file file.c. References ALLOC, close_all_files(), COMMAND_ERROR_MEMORY_LOW, i, MAXFILES, _FileCommandObject::mode, NULL, and pFCO. |
|
Definition at line 1737 of file file.c. References ALLOC, close_all_dirs(), _DirCommandObject::dp, MAXDIRS, NULL, and pDCO. |
|
Referenced by basext_GetArgsF(), besFUNCTION(), if(), IsTrue(), memory_ReplaceVariable(), scriba_CallArg(), scriba_CallArgEx(), serconv(), serconvXML(), SPrintVariable(), switch(), varcmp(), varhashpjw(), and while(). |
|
|
|
|
|
|
|
|
|
|
Definition at line 90 of file file.c. Referenced by if(). |
|
Definition at line 299 of file file.c. References ALLOC, BUFFER_INCREASE, ch, FREE, memcpy(), NULL, pfExtIn, r, and s. |
|
Definition at line 331 of file file.c. References ALLOC, BUFFER_INCREASE, ch, FREE, memcpy(), NULL, r, and s. Referenced by if(). |
|
|
|
|
|
Definition at line 1941 of file file.c. References j, SORTBY_DESCEN, SORTBY_FNAME, and SWAP. |
|
Definition at line 1659 of file file.c. References ALLOC, FILES_INCREMENT, FREE, and NULL. Referenced by collect_dirs_r(). |
|
Definition at line 117 of file reader.c. Referenced by cgi_Header(), F_LibraryLoaded(), lex_ReadInput(), and lex_RemoveComments(). |
|
|
|
|
|
Definition at line 1026 of file file.c. References ASSERTOKE, LONGVALUE(), memory_IsUndef(), _FileCommandObject::mode, pFCO, sprintf(), STRINGVALUE(), STRLEN(), and THISSOCKET. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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(). |
|
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 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(). |
|
|
|
|
|
Definition at line 1656 of file file.c. Referenced by file_deltree_r(). |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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>. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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>. |
|
|
|
|
|
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. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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. |
|
|
|
|
|
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. |
|
|
|
|
|
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. |
|
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. |
|
|
|
|
|
|
|
|
|
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. |
|
|
|
|
|
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(). |
|
|
|
|
|
|
|
|
Definition at line 1507 of file file.c. Referenced by ex_IsSymbolValidLval(). |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Definition at line 1446 of file file.c. Referenced by COMMAND_EXTERNAL(), COMMAND_EXTERNAM(), file_MakeDirectory(), lex_ReadInput(), modu_LoadModule(), and reader_ReadLines(). |
|
Definition at line 1005 of file file.c. Referenced by COMMAND_FUNCTIONARG(). |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Definition at line 174 of file file.c. Referenced by COMMAND_EXTERNAL(), COMMAND_EXTERNAM(), and while(). |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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(). |
|
|
|
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). |
|
|
|
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. |
|
|
|
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. |
|
|
|
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>. |
|
|
|
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>. |
|
|
|
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>. |
|
|
|
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>. |
|
|
|
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. |
|
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>. |
|
|
|
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. |
|
|
|
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 2043 of file file.c. Referenced by close_all_dirs(), close_directory_list(), and initdir(). |
|
Definition at line 1656 of file file.c. Referenced by file_deltree_r(). |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Definition at line 166 of file file.c. Referenced by close_all_files(), if(), init(), and while(). |
|
Definition at line 549 of file file.c. Referenced by ReadFileLine(). |
|
|
|
|
|
|
|
|
|
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. |
|
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. |
|
|
|
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 399 of file file.c. Referenced by execute_Dereference(), execute_Evaluate(), memory_SetRef(), and SPrintVariable(). |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Definition at line 395 of file file.c. Referenced by preproc(). |
|
|
|
Definition at line 1543 of file file.c. Referenced by besCOMMAND(), besFUNCTION(), if(), switch(), and while(). |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Definition at line 1010 of file file.c. Referenced by CreateJunction(), DeleteFromPath(), epreproc(), execute_Evaluate(), scriba_CallArg(), and SPrintVariable(). |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 2610 of file file.c. Referenced by if(). |
|
|
|
|