unix/rexxutil.cpp File Reference
#include "oorexxapi.h"
#include <sys/ipc.h>
#include <memory.h>
#include <fcntl.h>
#include <ctype.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <limits.h>
#include <math.h>
#include <sys/stat.h>
#include <errno.h>
#include <stddef.h>
#include <sys/types.h>
#include <sys/syscall.h>
#include <sys/utsname.h>
#include <pthread.h>
#include <semaphore.h>
#include <signal.h>
#include <time.h>
#include <netdb.h>
#include <dirent.h>
#include <sys/time.h>
#include <utime.h>
#include <termios.h>
#include <fnmatch.h>
#include <libgen.h>
Include dependency graph for unix/rexxutil.cpp:

Go to the source code of this file.

Classes

union  semun
 
struct  RxTreeData
 
struct  _GetFileData
 
struct  RxStemData
 
struct  _SORT_MEM
 
struct  RxSemData
 
class  AutoClose
 
class  AutoFree
 

Macros

#define INVALID_ROUTINE   40
 
#define MAX_DIGITS   9
 
#define NO_UTIL_ERROR   "0" /* No error whatsoever */
 
#define VALID_ROUTINE   0 /* Successful completion */
 
#define MAX_LINE_LEN   4096 /* max line length */
 
#define MAX_READ   0x10000 /* full segment of buffer */
 
#define CH_EOF   0x1A /* end of file marker */
 
#define CH_CR   '\r' /* carriage return character */
 
#define CH_NL   '\n' /* new line character */
 
#define MAX   256 /* temporary buffer length */
 
#define IBUF_LEN   4096 /* Input buffer length */
 
#define CURRENT_DIR_FIRST   0 /* search flag 'C' */
 
#define ENVIRONMENT_ONLY   1 /* search flag 'N' */
 
#define OFFSET   1000 /* needed to prevent collision*/
 
#define MAXUSECOUNT   65535 /* max semaphore usecount */
 
#define REXXMESSAGEFILE   "rexx.cat"
 
#define FNAMESPEC_BUF_LEN   IBUF_LEN
 
#define FOUNDFILE_BUF_LEN   IBUF_LEN
 
#define FILETIME_BUF_LEN   64
 
#define FILEATTR_BUF_LEN   16
 
#define FOUNDFILELINE_BUF_LEN   FOUNDFILE_BUF_LEN + FILETIME_BUF_LEN + FILEATTR_BUF_LEN
 
#define SINE   0 /* trig function defines... */
 
#define COSINE   3 /* the ordering is important, */
 
#define TANGENT   1 /* as these get transformed */
 
#define COTANGENT   2 /* depending on the angle */
 
#define MAXTRIG   3 /* value */
 
#define ARCSINE   0 /* defines for arc trig */
 
#define ARCCOSINE   1 /* functions. Ordering is */
 
#define ARCTANGENT   2 /* not as important here */
 
#define pi   3.14159265358979323846l /* pi value */
 
#define DEGREES   'D' /* degrees option */
 
#define RADIANS   'R' /* radians option */
 
#define GRADES   'G' /* grades option */
 
#define DEFAULT_PRECISION   9 /* default precision to use */
 
#define MAX_PRECISION   16 /* maximum available precision*/
 
#define NO_UTIL_ERROR   "0" /* No error whatsoever */
 
#define ERROR_NOMEM   "2" /* Insufficient memory */
 
#define ERROR_FILEOPEN   "3" /* Error opening text file */
 
#define ERROR_RETSTR   "ERROR:"
 
#define INVALID_ROUTINE   40 /* Raise Rexx error */
 
#define VALID_ROUTINE   0 /* Successful completion */
 
#define SORT_CASESENSITIVE   0
 
#define SORT_CASEIGNORE   1
 
#define SORT_ASCENDING   0
 
#define SORT_DECENDING   1
 
#define SORT_NUMERIC   3
 
#define SORT_DEF_AVG_SIZE   20
 
#define BUILDRXSTRING(t, s)
 
#define RETVAL(retc)
 
#define RECURSE   0x0002
 
#define DO_DIRS   0x0004
 
#define DO_FILES   0x0008
 
#define NAME_ONLY   0x0010
 
#define EDITABLE_TIME   0x0020
 
#define LONG_TIME   0x0040
 
#define CASELESS   0x0080
 
#define IGNORE   2 /* Ignore attributes entirely */
 
#define stty(a, b)   (void)tcsetattr(a,TCSANOW,b) /* simple set attr. */
 
#define gtty(a, b)   (void)tcgetattr(a,b) /* simple get attr. */
 
#define discard_input(a)   tcflush(a,TCIFLUSH) /* simple flush */
 
#define restore_tty(a)   stty(ttyfd,a) /* new settings STDIN */
 
#define SEM_WAIT_PERIOD   100 /* POSIX says this should be 10ms */
 

Typedefs

typedef struct RxTreeData RXTREEDATA
 
typedef struct _GetFileData GetFileData
 
typedef struct RxStemData RXSTEMDATA
 
typedef struct _SORT_MEM SORTMEM
 
typedef struct _SORT_MEMPSORTMEM
 
typedef struct RxSemData RXSEMDATA
 

Enumerations

enum  TreeDataBuffers { FILESPEC_BUFFER , FOUNDFILE_BUFFER , FOUNDFILELINE_BUFFER }
 

Functions

char * resolve_tilde (const char *)
 
bool string2size_t (const char *string, size_t *number)
 
int ReadNextBuffer (GetFileData *filedata)
 
void strupr (char *string)
 
int OpenFile (const char *file, GetFileData *filedata)
 
void CloseFile (GetFileData *filedata)
 
int GetLine (char *line, size_t size, GetFileData *filedata)
 
const char * mystrstr (const char *haystack, const char *needle, size_t hlen, size_t nlen, bool sensitive)
 
int get_next_path (char **ppenv, char *path_buf)
 
int SearchPath (int SearchFlag, const char *path, const char *filename, char *buf, size_t buf_size)
 
bool string2int (const char *string, int *number)
 
void restore_terminal (int signal)
 
int getkey (char *ret, bool echo)
 
 RexxRoutine1 (int, SysSleep, RexxStringObject, delay)
 
size_t RexxEntry SysLoadFuncs (const char *name, size_t numargs, CONSTRXSTRING args[], const char *queuename, PRXSTRING retstr)
 
size_t RexxEntry SysDropFuncs (const char *name, size_t numargs, CONSTRXSTRING args[], const char *queuename, PRXSTRING retstr)
 
size_t RexxEntry SysCls (const char *name, size_t numargs, CONSTRXSTRING args[], const char *queuename, PRXSTRING retstr)
 
 RexxRoutine3 (int, SysAddRexxMacro, CSTRING, name, CSTRING, file, OPTIONAL_CSTRING, option)
 
 RexxRoutine2 (int, SysReorderRexxMacro, CSTRING, name, CSTRING, option)
 
 RexxRoutine1 (int, SysDropRexxMacro, CSTRING, name)
 
 RexxRoutine1 (CSTRING, SysQueryRexxMacro, CSTRING, name)
 
 RexxRoutine0 (int, SysClearRexxMacroSpace)
 
 RexxRoutine1 (int, SysSaveRexxMacroSpace, CSTRING, file)
 
 RexxRoutine1 (int, SysLoadRexxMacroSpace, CSTRING, file)
 
size_t RexxEntry SysMkDir (const char *name, size_t numargs, CONSTRXSTRING args[], const char *queuename, PRXSTRING retstr)
 
size_t RexxEntry SysRmDir (const char *name, size_t numargs, CONSTRXSTRING args[], const char *queuename, PRXSTRING retstr)
 
size_t RexxEntry SysFileDelete (const char *name, size_t numargs, CONSTRXSTRING args[], const char *queuename, PRXSTRING retstr)
 
size_t RexxEntry SysFileSearch (const char *name, size_t numargs, CONSTRXSTRING args[], const char *queuename, PRXSTRING retstr)
 
size_t RexxEntry SysSearchPath (const char *name, size_t numargs, CONSTRXSTRING args[], const char *queuename, PRXSTRING retstr)
 
size_t RexxEntry SysVersion (const char *name, size_t numargs, CONSTRXSTRING args[], const char *queuename, PRXSTRING retstr)
 
 RexxRoutine2 (RexxObjectPtr, SysCreateEventSem, OPTIONAL_CSTRING, name, OPTIONAL_CSTRING, reset)
 
 RexxRoutine1 (uintptr_t, SysOpenEventSem, CSTRING, name)
 
 RexxRoutine1 (int, SysResetEventSem, uintptr_t, vhandle)
 
 RexxRoutine1 (int, SysPostEventSem, uintptr_t, vhandle)
 
 RexxRoutine1 (int, SysCloseEventSem, uintptr_t, vhandle)
 
 RexxRoutine2 (int, SysWaitEventSem, uintptr_t, vhandle, OPTIONAL_int, timeout)
 
 RexxRoutine1 (RexxObjectPtr, SysCreateMutexSem, OPTIONAL_CSTRING, name)
 
 RexxRoutine1 (uintptr_t, SysOpenMutexSem, CSTRING, name)
 
 RexxRoutine2 (int, SysRequestMutexSem, uintptr_t, vhandle, OPTIONAL_int, timeout)
 
 RexxRoutine1 (int, SysReleaseMutexSem, uintptr_t, vhandle)
 
 RexxRoutine1 (int, SysCloseMutexSem, uintptr_t, vhandle)
 
size_t neededSize (size_t need, size_t have)
 
void outOfMemoryException (RexxThreadContext *c)
 
void nullStringException (RexxThreadContext *c, CSTRING fName, size_t pos)
 
static void stringTooLongException (RexxThreadContext *c, CSTRING funcName, size_t pos, size_t len, size_t realLen)
 
static void badSFTOptsException (RexxThreadContext *c, size_t pos, CSTRING actual)
 
static bool increaseBuffer (RexxCallContext *c, size_t need, RXTREEDATA *treeData, TreeDataBuffers whichBuffer)
 
static bool getBiggerBuffer (RexxCallContext *c, char **dPath, size_t *nPath, size_t nStaticBuffer)
 
bool isAcceptableFile (mode_t m)
 
char typeOfEntry (mode_t m)
 
bool linFindNextFile (RexxCallContext *c, const char *fileSpec, const char *path, DIR *dir_handle, struct stat *finfo, char **d_name, bool caseless)
 
bool linFindNextDir (RexxCallContext *c, const char *fileSpec, const char *path, DIR *dir_handle, struct stat *finfo, char **d_name, bool caseless)
 
static bool goodOpts (RexxCallContext *c, CSTRING opts, uint32_t *pOpts)
 
static bool getOptionsFromArg (RexxCallContext *context, CSTRING opts, uint32_t *options, size_t argPos)
 
static bool getFileSpecFromArg (RexxCallContext *context, CSTRING fSpec, char *fileSpec, size_t bufLen, size_t argPos)
 
static bool getFileNameSegment (RexxCallContext *c, char *fileSpec, RXTREEDATA *treeData, int *lastSlashPos)
 
static bool getPathSegment (RexxCallContext *c, char *fileSpec, char **path, size_t *pathLen, int lastSlashPos)
 
static bool getPath (RexxCallContext *c, char *fileSpec, char **path, size_t *pathLen, RXTREEDATA *treeData)
 
bool formatFile (RexxCallContext *c, RXTREEDATA *treeData, uint32_t options, struct stat *finfo)
 
static bool recursiveFindFile (RexxCallContext *c, const char *path, RXTREEDATA *treeData, uint32_t options)
 
void initTreeData (RXTREEDATA *treeData, RexxStemObject files)
 
void uninitTreeData (RXTREEDATA *treeData)
 
 RexxRoutine5 (uint32_t, SysFileTree, CSTRING, fSpec, RexxStemObject, files, OPTIONAL_CSTRING, opts, OPTIONAL_CSTRING, targetAttr, OPTIONAL_CSTRING, newAttr)
 
size_t RexxEntry SysTempFileName (const char *name, size_t numargs, CONSTRXSTRING args[], const char *queuename, PRXSTRING retstr)
 
size_t RexxEntry SysSetPriority (const char *name, size_t numargs, CONSTRXSTRING args[], const char *queuename, PRXSTRING retstr)
 
size_t RexxEntry SysGetMessage (const char *name, size_t numargs, CONSTRXSTRING args[], const char *queuename, PRXSTRING retstr)
 
size_t RexxEntry SysGetMessageX (const char *name, size_t numargs, CONSTRXSTRING args[], const char *queuename, PRXSTRING retstr)
 
size_t RexxEntry SysGetKey (const char *name, size_t numargs, CONSTRXSTRING args[], const char *queuename, PRXSTRING retstr)
 
size_t RexxEntry SysFork (const char *name, size_t numargs, CONSTRXSTRING args[], const char *queuename, PRXSTRING retstr)
 
size_t RexxEntry SysWait (const char *name, size_t numargs, CONSTRXSTRING args[], const char *queuename, PRXSTRING retstr)
 
size_t RexxEntry SysCreatePipe (const char *name, size_t numargs, CONSTRXSTRING args[], const char *queuename, PRXSTRING retstr)
 
size_t RexxEntry SysDumpVariables (const char *name, size_t numargs, CONSTRXSTRING args[], const char *queuename, PRXSTRING retstr)
 
size_t RexxEntry SysGetFileDateTime (const char *name, size_t numargs, CONSTRXSTRING args[], const char *queuename, PRXSTRING retstr)
 
size_t RexxEntry SysSetFileDateTime (const char *name, size_t numargs, CONSTRXSTRING args[], const char *queuename, PRXSTRING retstr)
 
size_t RexxEntry RexxStemSort (const char *stemname, int order, int type, size_t start, size_t end, size_t firstcol, size_t lastcol)
 
size_t RexxEntry SysStemSort (const char *name, size_t numargs, CONSTRXSTRING args[], const char *queuename, PRXSTRING retstr)
 
 RexxRoutine3 (int, SysStemDelete, RexxStemObject, toStem, stringsize_t, start, OPTIONAL_stringsize_t, count)
 
 RexxRoutine3 (int, SysStemInsert, RexxStemObject, toStem, stringsize_t, position, RexxObjectPtr, newValue)
 
 RexxRoutine6 (int, SysStemCopy, RexxStemObject, fromStem, RexxStemObject, toStem, OPTIONAL_stringsize_t, from, OPTIONAL_stringsize_t, to, OPTIONAL_stringsize_t, count, OPTIONAL_CSTRING, option)
 
size_t RexxEntry SysQueryProcess (const char *name, size_t numargs, CONSTRXSTRING args[], const char *queuename, PRXSTRING retstr)
 
size_t RexxEntry SysGetErrortext (const char *name, size_t numargs, CONSTRXSTRING args[], const char *queuename, PRXSTRING retstr)
 
size_t RexxEntry SysUtilVersion (const char *name, size_t numargs, CONSTRXSTRING args[], const char *queuename, PRXSTRING retstr)
 
bool SamePaths (CSTRING path1, CSTRING path2)
 
char * TemporaryFilename (CSTRING filename, int &errInfo)
 
int CopyFile_DereferenceSymbolicLinks (CSTRING fromFile, CSTRING toFile, bool preserveTimestamps, bool preserveMode, bool *timestampsPreserved=NULL, bool *modePreserved=NULL)
 
int CopyFile_DontDereferenceSymbolicLinks (CSTRING fromFile, CSTRING toFile, bool force, bool preserveTimestamps, bool preserveMode, bool *timestampsPreserved=NULL, bool *modePreserved=NULL)
 
 RexxRoutine2 (int, SysFileCopy, CSTRING, fromFile, CSTRING, toFile)
 
int MoveFile (CSTRING fromFile, CSTRING toFile)
 
 RexxRoutine2 (int, SysFileMove, CSTRING, fromFile, CSTRING, toFile)
 
 RexxRoutine1 (logical_t, SysIsFile, CSTRING, filename)
 
 RexxRoutine1 (logical_t, SysIsFileDirectory, CSTRING, filename)
 
 RexxRoutine1 (logical_t, SysIsFileLink, CSTRING, filename)
 
 RexxRoutine1 (logical_t, SysFileExists, CSTRING, filename)
 
 OOREXX_GET_PACKAGE (rexxutil)
 

Variables

struct termios in_orig
 
RexxRoutineEntry rexxutil_routines []
 
RexxPackageEntry rexxutil_package_entry
 

Macro Definition Documentation

◆ ARCCOSINE

#define ARCCOSINE   1 /* functions. Ordering is */

Definition at line 293 of file unix/rexxutil.cpp.

◆ ARCSINE

#define ARCSINE   0 /* defines for arc trig */

Definition at line 292 of file unix/rexxutil.cpp.

◆ ARCTANGENT

#define ARCTANGENT   2 /* not as important here */

Definition at line 294 of file unix/rexxutil.cpp.

◆ BUILDRXSTRING

#define BUILDRXSTRING (   t,
 
)
Value:
{ \
strcpy((t)->strptr,(s));\
(t)->strlength = strlen((s)); \
}

Definition at line 347 of file unix/rexxutil.cpp.

◆ CASELESS

#define CASELESS   0x0080

Definition at line 369 of file unix/rexxutil.cpp.

◆ CH_CR

#define CH_CR   '\r' /* carriage return character */

Definition at line 265 of file unix/rexxutil.cpp.

◆ CH_EOF

#define CH_EOF   0x1A /* end of file marker */

Definition at line 264 of file unix/rexxutil.cpp.

◆ CH_NL

#define CH_NL   '\n' /* new line character */

Definition at line 266 of file unix/rexxutil.cpp.

◆ COSINE

#define COSINE   3 /* the ordering is important, */

Definition at line 288 of file unix/rexxutil.cpp.

◆ COTANGENT

#define COTANGENT   2 /* depending on the angle */

Definition at line 290 of file unix/rexxutil.cpp.

◆ CURRENT_DIR_FIRST

#define CURRENT_DIR_FIRST   0 /* search flag 'C' */

Definition at line 269 of file unix/rexxutil.cpp.

◆ DEFAULT_PRECISION

#define DEFAULT_PRECISION   9 /* default precision to use */

Definition at line 303 of file unix/rexxutil.cpp.

◆ DEGREES

#define DEGREES   'D' /* degrees option */

Definition at line 299 of file unix/rexxutil.cpp.

◆ discard_input

#define discard_input (   a)    tcflush(a,TCIFLUSH) /* simple flush */

Definition at line 379 of file unix/rexxutil.cpp.

◆ DO_DIRS

#define DO_DIRS   0x0004

Definition at line 364 of file unix/rexxutil.cpp.

◆ DO_FILES

#define DO_FILES   0x0008

Definition at line 365 of file unix/rexxutil.cpp.

◆ EDITABLE_TIME

#define EDITABLE_TIME   0x0020

Definition at line 367 of file unix/rexxutil.cpp.

◆ ENVIRONMENT_ONLY

#define ENVIRONMENT_ONLY   1 /* search flag 'N' */

Definition at line 270 of file unix/rexxutil.cpp.

◆ ERROR_FILEOPEN

#define ERROR_FILEOPEN   "3" /* Error opening text file */

Definition at line 314 of file unix/rexxutil.cpp.

◆ ERROR_NOMEM

#define ERROR_NOMEM   "2" /* Insufficient memory */

Definition at line 313 of file unix/rexxutil.cpp.

◆ ERROR_RETSTR

#define ERROR_RETSTR   "ERROR:"

Definition at line 320 of file unix/rexxutil.cpp.

◆ FILEATTR_BUF_LEN

#define FILEATTR_BUF_LEN   16

Definition at line 280 of file unix/rexxutil.cpp.

◆ FILETIME_BUF_LEN

#define FILETIME_BUF_LEN   64

Definition at line 279 of file unix/rexxutil.cpp.

◆ FNAMESPEC_BUF_LEN

#define FNAMESPEC_BUF_LEN   IBUF_LEN

Definition at line 277 of file unix/rexxutil.cpp.

◆ FOUNDFILE_BUF_LEN

#define FOUNDFILE_BUF_LEN   IBUF_LEN

Definition at line 278 of file unix/rexxutil.cpp.

◆ FOUNDFILELINE_BUF_LEN

#define FOUNDFILELINE_BUF_LEN   FOUNDFILE_BUF_LEN + FILETIME_BUF_LEN + FILEATTR_BUF_LEN

Definition at line 281 of file unix/rexxutil.cpp.

◆ GRADES

#define GRADES   'G' /* grades option */

Definition at line 301 of file unix/rexxutil.cpp.

◆ gtty

#define gtty (   a,
 
)    (void)tcgetattr(a,b) /* simple get attr. */

Definition at line 378 of file unix/rexxutil.cpp.

◆ IBUF_LEN

#define IBUF_LEN   4096 /* Input buffer length */

Definition at line 268 of file unix/rexxutil.cpp.

◆ IGNORE

#define IGNORE   2 /* Ignore attributes entirely */

Definition at line 370 of file unix/rexxutil.cpp.

◆ INVALID_ROUTINE [1/2]

#define INVALID_ROUTINE   40

Definition at line 326 of file unix/rexxutil.cpp.

◆ INVALID_ROUTINE [2/2]

#define INVALID_ROUTINE   40 /* Raise Rexx error */

Definition at line 326 of file unix/rexxutil.cpp.

◆ LONG_TIME

#define LONG_TIME   0x0040

Definition at line 368 of file unix/rexxutil.cpp.

◆ MAX

#define MAX   256 /* temporary buffer length */

Definition at line 267 of file unix/rexxutil.cpp.

◆ MAX_DIGITS

#define MAX_DIGITS   9

Definition at line 258 of file unix/rexxutil.cpp.

◆ MAX_LINE_LEN

#define MAX_LINE_LEN   4096 /* max line length */

Definition at line 262 of file unix/rexxutil.cpp.

◆ MAX_PRECISION

#define MAX_PRECISION   16 /* maximum available precision*/

Definition at line 304 of file unix/rexxutil.cpp.

◆ MAX_READ

#define MAX_READ   0x10000 /* full segment of buffer */

Definition at line 263 of file unix/rexxutil.cpp.

◆ MAXTRIG

#define MAXTRIG   3 /* value */

Definition at line 291 of file unix/rexxutil.cpp.

◆ MAXUSECOUNT

#define MAXUSECOUNT   65535 /* max semaphore usecount */

Definition at line 273 of file unix/rexxutil.cpp.

◆ NAME_ONLY

#define NAME_ONLY   0x0010

Definition at line 366 of file unix/rexxutil.cpp.

◆ NO_UTIL_ERROR [1/2]

#define NO_UTIL_ERROR   "0" /* No error whatsoever */

Definition at line 312 of file unix/rexxutil.cpp.

◆ NO_UTIL_ERROR [2/2]

#define NO_UTIL_ERROR   "0" /* No error whatsoever */

Definition at line 312 of file unix/rexxutil.cpp.

◆ OFFSET

#define OFFSET   1000 /* needed to prevent collision*/

Definition at line 271 of file unix/rexxutil.cpp.

◆ pi

#define pi   3.14159265358979323846l /* pi value */

Definition at line 297 of file unix/rexxutil.cpp.

◆ RADIANS

#define RADIANS   'R' /* radians option */

Definition at line 300 of file unix/rexxutil.cpp.

◆ RECURSE

#define RECURSE   0x0002

Definition at line 363 of file unix/rexxutil.cpp.

◆ restore_tty

#define restore_tty (   a)    stty(ttyfd,a) /* new settings STDIN */

Definition at line 380 of file unix/rexxutil.cpp.

◆ RETVAL

#define RETVAL (   retc)
Value:
{ \
sprintf(retstr->strptr, "%d", retc); \
retstr->strlength = strlen(retstr->strptr); \
return VALID_ROUTINE; \
}
#define VALID_ROUTINE

Definition at line 353 of file unix/rexxutil.cpp.

◆ REXXMESSAGEFILE

#define REXXMESSAGEFILE   "rexx.cat"

Definition at line 274 of file unix/rexxutil.cpp.

◆ SEM_WAIT_PERIOD

#define SEM_WAIT_PERIOD   100 /* POSIX says this should be 10ms */

Definition at line 1984 of file unix/rexxutil.cpp.

◆ SINE

#define SINE   0 /* trig function defines... */

Definition at line 287 of file unix/rexxutil.cpp.

◆ SORT_ASCENDING

#define SORT_ASCENDING   0

Definition at line 336 of file unix/rexxutil.cpp.

◆ SORT_CASEIGNORE

#define SORT_CASEIGNORE   1

Definition at line 333 of file unix/rexxutil.cpp.

◆ SORT_CASESENSITIVE

#define SORT_CASESENSITIVE   0

Definition at line 332 of file unix/rexxutil.cpp.

◆ SORT_DECENDING

#define SORT_DECENDING   1

Definition at line 337 of file unix/rexxutil.cpp.

◆ SORT_DEF_AVG_SIZE

#define SORT_DEF_AVG_SIZE   20

Definition at line 341 of file unix/rexxutil.cpp.

◆ SORT_NUMERIC

#define SORT_NUMERIC   3

Definition at line 339 of file unix/rexxutil.cpp.

◆ stty

#define stty (   a,
 
)    (void)tcsetattr(a,TCSANOW,b) /* simple set attr. */

Definition at line 377 of file unix/rexxutil.cpp.

◆ TANGENT

#define TANGENT   1 /* as these get transformed */

Definition at line 289 of file unix/rexxutil.cpp.

◆ VALID_ROUTINE [1/2]

#define VALID_ROUTINE   0 /* Successful completion */

Definition at line 327 of file unix/rexxutil.cpp.

◆ VALID_ROUTINE [2/2]

#define VALID_ROUTINE   0 /* Successful completion */

Definition at line 327 of file unix/rexxutil.cpp.

Typedef Documentation

◆ GetFileData

typedef struct _GetFileData GetFileData

◆ PSORTMEM

typedef struct _SORT_MEM * PSORTMEM

◆ RXSEMDATA

typedef struct RxSemData RXSEMDATA

◆ RXSTEMDATA

typedef struct RxStemData RXSTEMDATA

◆ RXTREEDATA

typedef struct RxTreeData RXTREEDATA

◆ SORTMEM

typedef struct _SORT_MEM SORTMEM

Enumeration Type Documentation

◆ TreeDataBuffers

Enumerator
FILESPEC_BUFFER 
FOUNDFILE_BUFFER 
FOUNDFILELINE_BUFFER 

Definition at line 2232 of file unix/rexxutil.cpp.

Function Documentation

◆ badSFTOptsException()

static void badSFTOptsException ( RexxThreadContext c,
size_t  pos,
CSTRING  actual 
)
static

This is a SysFileTree specific function.

Parameters
c
pos
actual

Definition at line 2301 of file unix/rexxutil.cpp.

References Rexx_Error_Incorrect_call_user_defined.

Referenced by getOptionsFromArg().

◆ CloseFile()

void CloseFile ( GetFileData filedata)

Definition at line 638 of file unix/rexxutil.cpp.

References _GetFileData::buffer, and _GetFileData::handle.

Referenced by SysFileSearch().

◆ CopyFile_DereferenceSymbolicLinks()

int CopyFile_DereferenceSymbolicLinks ( CSTRING  fromFile,
CSTRING  toFile,
bool  preserveTimestamps,
bool  preserveMode,
bool *  timestampsPreserved = NULL,
bool *  modePreserved = NULL 
)

Definition at line 5484 of file unix/rexxutil.cpp.

References AutoClose::close(), IBUF_LEN, and SamePaths().

Referenced by CopyFile_DontDereferenceSymbolicLinks(), and RexxRoutine2().

◆ CopyFile_DontDereferenceSymbolicLinks()

int CopyFile_DontDereferenceSymbolicLinks ( CSTRING  fromFile,
CSTRING  toFile,
bool  force,
bool  preserveTimestamps,
bool  preserveMode,
bool *  timestampsPreserved = NULL,
bool *  modePreserved = NULL 
)

Definition at line 5540 of file unix/rexxutil.cpp.

References CopyFile_DereferenceSymbolicLinks(), SamePaths(), and TemporaryFilename().

Referenced by MoveFile().

◆ formatFile()

bool formatFile ( RexxCallContext c,
RXTREEDATA treeData,
uint32_t  options,
struct stat *  finfo 
)

This is a SysFileTree() specific function..

Formats a found file entry according to the specified options and adds it to the stem containing the found files.

Parameters
cCall context we are operating in.
treeDataStruct with data related to finding the files.
optionsOptions specifying how the found file line is to be formatted.
finfoFile info structure.
Returns
False on error, otherwise true.
Remarks
If the options specify name only, we just need to copy over the found file name. Otherwise we need to format a line with the time stamp and file attributes, plus the found file name.

We use the buffers in the treeData structure to format the found file line. snprintf() is used to prevent and detect buffer overflows. We start off trying to use the large static buffers in the struct, each time a buffer is found to be too small in size, it is doubled in size by dynamically allocated memory.. Code at the top level detects and frees any allocated memory.

Note that we can count the characters used for both the time data and attribute data, so we know the buffers are large enough.

If the file search is a very deep recursion in the host file system, a very large number of String objects may be created in the single Call context of SysFileTree. A reference to each created object is saved in a hash table to protect it from garbage collection, which can lead to a very large hash table. To prevent the creation of a very large hash table, we create a temp object, pass that object to the interpreter, and then tell the interpreter the object no longer needs to be protected in this call context.

Definition at line 3127 of file unix/rexxutil.cpp.

References RxTreeData::count, RxTreeData::dFoundFile, RxTreeData::dFoundFileLine, EDITABLE_TIME, RxTreeData::fileAttr, RxTreeData::files, RxTreeData::fileTime, RxTreeData::foundFile, RxTreeData::foundFileLine, FOUNDFILELINE_BUFFER, increaseBuffer(), LONG_TIME, NAME_ONLY, RxTreeData::nFoundFile, RxTreeData::nFoundFileLine, and typeOfEntry().

Referenced by recursiveFindFile().

◆ get_next_path()

int get_next_path ( char **  ppenv,
char *  path_buf 
)

Definition at line 834 of file unix/rexxutil.cpp.

References MAX_LINE_LEN.

Referenced by SearchPath().

◆ getBiggerBuffer()

static bool getBiggerBuffer ( RexxCallContext c,
char **  dPath,
size_t *  nPath,
size_t  nStaticBuffer 
)
static

Allocates a buffer twice as big as the buffer passed in.

Parameters
cCall context we are operating in.
dPathPointer to the buffer to reallocate
nPathSize of dPath buffer.
nStaticBufferSize of original static buffer.
Returns
True on success, false on memory allocation failure.
Remarks
NOTE: that the pointer to the buffer to reallocate, may, or may not, be a pointer to a static buffer. We must NOT try to free a static buffer and we MUST free a non-static buffer.

Definition at line 2397 of file unix/rexxutil.cpp.

References outOfMemoryException(), and RexxCallContext_::threadContext.

Referenced by getPathSegment(), linFindNextFile(), and recursiveFindFile().

◆ getFileNameSegment()

static bool getFileNameSegment ( RexxCallContext c,
char *  fileSpec,
RXTREEDATA treeData,
int *  lastSlashPos 
)
static

Used to retrieve the file name portion of the search file specification the user sent to SysFileTree.

Parameters
c
fileSpec
treeData
lastSlashPos
Returns
True on success, false on a memory allocation error.

Definition at line 2856 of file unix/rexxutil.cpp.

References RxTreeData::dFNameSpec, FILESPEC_BUFFER, increaseBuffer(), and RxTreeData::nFNameSpec.

Referenced by getPath().

◆ getFileSpecFromArg()

static bool getFileSpecFromArg ( RexxCallContext context,
CSTRING  fSpec,
char *  fileSpec,
size_t  bufLen,
size_t  argPos 
)
static

Checks the file specification as input by the user for validity and expands / redoes the value if needed. For example if the the specification starts with the ~ character, the file spec is expanded to include the full path to the home directory.

Parameters
contextCall context we are operating in.
fSpecThe file specification as passed by the user. Can not be the empty string and must be 494 chars or less.
fileSpecBuffer to contain the expanded file specification. At this time the buffer is 4096 in length, which seems more than sufficient. However, we check the length when copying into it anyway.
bufLenLength of fileSpec buffer.
argPosArgument position, use for raising conditions.
Returns
True if no error, otherwise false. False is only returned if an exception has been raised.
Remarks
The fileSpec buffer is IBUF_LEN, or 4096 bytes. Theoretically, if fSpec starts with the tilde, '~', the string could be too long after expanding the home directoy.

Definition at line 2793 of file unix/rexxutil.cpp.

References nullStringException(), outOfMemoryException(), resolve_tilde(), stringTooLongException(), and RexxCallContext_::threadContext.

Referenced by RexxRoutine5().

◆ getkey()

int getkey ( char *  ret,
bool  echo 
)

Definition at line 995 of file unix/rexxutil.cpp.

References gtty, in_orig, restore_terminal(), restore_tty, and stty.

Referenced by SysGetKey().

◆ GetLine()

int GetLine ( char *  line,
size_t  size,
GetFileData filedata 
)

◆ getOptionsFromArg()

static bool getOptionsFromArg ( RexxCallContext context,
CSTRING  opts,
uint32_t options,
size_t  argPos 
)
static

This is a SysFileTree specific helper function.

Checks the validity of the options argument to SysFileTree, sets the default options, and converts the character based argument to the proper set of flags.

Parameters
context
opts
options
argPos
Returns
bool

Definition at line 2743 of file unix/rexxutil.cpp.

References argumentExists, badSFTOptsException(), DO_DIRS, DO_FILES, goodOpts(), nullStringException(), and RexxCallContext_::threadContext.

Referenced by RexxRoutine5().

◆ getPath()

static bool getPath ( RexxCallContext c,
char *  fileSpec,
char **  path,
size_t *  pathLen,
RXTREEDATA treeData 
)
static

This is a SysFileTree() specific function..

This function expands the file spec passed in to the function into its full path name. The full path name is then split into the path portion and the file name portion. The path portion is returned in path and the file name portion is returned in the RXTREEDATA structure.

The path portion will end with the '\' character.

Parameters
cCall context we are operating in.
fSpecFile specification to search for.
pathPointer to the buffer for the returned full path of expanded file specification. This buffer may be reallocated if it is not big enough
pathLenPointer to the size of the passed in path buffer. This value will be reset if the path buffer is reallocated.
treeDataThe file name portion of the full path is copied into the dFNameSpec field in this struct.
Returns
True on success, false on error. The only error would be if memory allocation failed, in which case a condition has been raised. It seems highly unlikely that this function could fail.
Remarks
Both the path and the file name destination buffers are checked to be sure they are big enough. If either is not big enough, a larger buffer is allocated.

Definition at line 3057 of file unix/rexxutil.cpp.

References getFileNameSegment(), and getPathSegment().

Referenced by RexxRoutine5().

◆ getPathSegment()

static bool getPathSegment ( RexxCallContext c,
char *  fileSpec,
char **  path,
size_t *  pathLen,
int  lastSlashPos 
)
static
Parameters
c
fileSpec
path
pathLen
lastSlashPos
Returns
bool

Definition at line 2922 of file unix/rexxutil.cpp.

References FOUNDFILE_BUF_LEN, getBiggerBuffer(), neededSize(), outOfMemoryException(), and RexxCallContext_::threadContext.

Referenced by getPath().

◆ goodOpts()

static bool goodOpts ( RexxCallContext c,
CSTRING  opts,
uint32_t pOpts 
)
static

This is a SysFileTree specific function.

Determines the options by converting the character based argument to the correct set of flags.

Parameters
c
opts
pOpts
Returns
bool

Definition at line 2676 of file unix/rexxutil.cpp.

References CASELESS, DO_DIRS, DO_FILES, EDITABLE_TIME, LONG_TIME, NAME_ONLY, and RECURSE.

Referenced by getOptionsFromArg().

◆ increaseBuffer()

static bool increaseBuffer ( RexxCallContext c,
size_t  need,
RXTREEDATA treeData,
TreeDataBuffers  whichBuffer 
)
static

Dynamically allocates memory for a buffer in the RXTREEDATA structure so that it is bigger than the size specified.

Parameters
needThe allocated buffer size must be greater than this.
treeDataPointer to the RXTREEDATA struct.
whichBufferIdentifies the buffer to increase.
Returns
True on success, false if memory allocation fails.
Remarks
For SysFileTree() we start out with very large static buffers to use for full path names and the maniupulation of path names. But, on unixes, directories can be nested to any arbitary depth.

It is unlikely, but possible, that a static buffer will be too small. If this happens, we double the size of the buffer until it is large enough by allocating a new buffer.

Definition at line 2329 of file unix/rexxutil.cpp.

References RxTreeData::dFNameSpec, RxTreeData::dFoundFile, RxTreeData::dFoundFileLine, FILESPEC_BUFFER, FNAMESPEC_BUF_LEN, FOUNDFILE_BUF_LEN, FOUNDFILE_BUFFER, FOUNDFILELINE_BUFFER, neededSize(), RxTreeData::nFNameSpec, RxTreeData::nFoundFile, RxTreeData::nFoundFileLine, outOfMemoryException(), and RexxCallContext_::threadContext.

Referenced by formatFile(), getFileNameSegment(), and recursiveFindFile().

◆ initTreeData()

void initTreeData ( RXTREEDATA treeData,
RexxStemObject  files 
)
inline

◆ isAcceptableFile()

bool isAcceptableFile ( mode_t  m)
inline

This is a SysFileTree specific function.

Test if struct stat.st_mode field is a file for the purpose of SysFileTree.

Parameters
m
Returns
True if a file, otherwise

Definition at line 2425 of file unix/rexxutil.cpp.

Referenced by linFindNextFile().

◆ linFindNextDir()

bool linFindNextDir ( RexxCallContext c,
const char *  fileSpec,
const char *  path,
DIR *  dir_handle,
struct stat *  finfo,
char **  d_name,
bool  caseless 
)

This is a SysFileTree specific function.

Find the next directory in the directory pointed to by dir_handle that matches fileSpec. The needed information is returnd in finfo and d_name.

Parameters
fileSpecSearch specification.
pathCurrent path we are searching.
dir_handleDirectory handle.
finfoReturned file info buffer.
d_nameReturned name of the directory found.
caselessDo case insensitive matching, or not.
Returns
True if a directory is found, outherwise false.
Remarks
The '?' glob character is not currently supported. Old notes said add the implementation here.

Definition at line 2589 of file unix/rexxutil.cpp.

References FOUNDFILE_BUF_LEN, IBUF_LEN, neededSize(), outOfMemoryException(), and RexxCallContext_::threadContext.

Referenced by recursiveFindFile().

◆ linFindNextFile()

bool linFindNextFile ( RexxCallContext c,
const char *  fileSpec,
const char *  path,
DIR *  dir_handle,
struct stat *  finfo,
char **  d_name,
bool  caseless 
)

This is a SysFileTree specific function.

Find the next file in the directory pointed to by dir_handle that matches fileSpec. The needed information is returnd in finfo and d_name.

Parameters
fileSpecSearch specification.
pathCurrent path we are searching.
dir_handleDirectory handle.
finfoReturned file info buffer.
d_nameReturned name of the file found
caselessDo case insensitive matching, or not.
Returns
True if a file is found, outherwise false.
Remarks
The '?' glob character is not currently supported. Old notes said add the implementation here.

Definition at line 2485 of file unix/rexxutil.cpp.

References getBiggerBuffer(), IBUF_LEN, isAcceptableFile(), outOfMemoryException(), and RexxCallContext_::threadContext.

Referenced by recursiveFindFile().

◆ MoveFile()

int MoveFile ( CSTRING  fromFile,
CSTRING  toFile 
)

◆ mystrstr()

const char* mystrstr ( const char *  haystack,
const char *  needle,
size_t  hlen,
size_t  nlen,
bool  sensitive 
)

Definition at line 782 of file unix/rexxutil.cpp.

References line, and MAX_LINE_LEN.

Referenced by SysFileSearch().

◆ neededSize()

size_t neededSize ( size_t  need,
size_t  have 
)
inline

Returns a value that is greater than 'need' by doubling 'have' until that value is reached.

Definition at line 2243 of file unix/rexxutil.cpp.

Referenced by getPathSegment(), increaseBuffer(), and linFindNextDir().

◆ nullStringException()

void nullStringException ( RexxThreadContext c,
CSTRING  fName,
size_t  pos 
)
inline

<routineName> argument <argPos> must not be a null string

SysFileTree argument 2 must not be a null string

Parameters
cThreade context we are operating in.
fNameRoutine name.
posArgument position.

Definition at line 2266 of file unix/rexxutil.cpp.

References Rexx_Error_Incorrect_call_null.

Referenced by getFileSpecFromArg(), and getOptionsFromArg().

◆ OOREXX_GET_PACKAGE()

OOREXX_GET_PACKAGE ( rexxutil  )

◆ OpenFile()

int OpenFile ( const char *  file,
GetFileData filedata 
)

◆ outOfMemoryException()

◆ ReadNextBuffer()

bool ReadNextBuffer ( GetFileData filedata)

Reads the next buffer of data.

Parameters
filedataGlobal file information.
Returns
0, buffer was read. 1, an error occurred reading buffer.

Definition at line 527 of file unix/rexxutil.cpp.

References _GetFileData::buffer, CH_EOF, _GetFileData::data, _GetFileData::handle, MAX_READ, _GetFileData::residual, and _GetFileData::scan.

Referenced by GetLine(), and OpenFile().

◆ recursiveFindFile()

static bool recursiveFindFile ( RexxCallContext c,
const char *  path,
RXTREEDATA treeData,
uint32_t  options 
)
static

Finds all files matching treeData->fNameSpec starting path, recursing into sub-directories if requested.

Parameters
cCall context we are operating in.
pathPath to the directory to start in.
treeDataStruct containing data pertaining to the search and used to return the found files.
optionsOptions defining the search. Some comination of the following.

RECURSE - Indicates that function should search all child subdirectories recursively. DO_DIRS - Indicates that directories should be included in the search. DO_FILES - Indicates that files should be included in the search. NAME_ONLY - Indicates that the output should be restricted to matched file names only. EDITABLE_TIME - Indicates time and date fields should be output as one timestamp. LONG_TIME - Indicates time and date fields should be output as one long formatted timestamp CASELESS - Indicates do a case insensitive check for file names.

Returns
True on no error, otherwise false.
Remarks
The IBM recursive find file passed in fileSpec as the first argument, but never used it. Instead it used fNameSpec in RXTREEDATA. So, that argument is eliminated here and fNameSpec is used.

snprintf() note:

snprintf() doe not write more than size bytes (including the terminating null byte ('\0')). If the output was truncated due to this limit then the return value is the number of characters (excluding the terminating null byte) which would have been written to the final string if enough space had been available. Thus, a return value of size or more means that the output was truncated.

Therefore, unlike windows, there is no possibility of having an unterminated string. If we detect that the buffers in use are too small, rather than truncate data, we allocate dynamic memory that is big enough. Actually we allocate a buffer twice as big as the current buffer.

We start with big static buffers, so we need to keep track of whether memory was allocated or not. This is done by tracking the size of the buffers. If a buffer size does not equal the original size of the static buffer, then it needs to be freed.

Definition at line 3285 of file unix/rexxutil.cpp.

References CASELESS, RxTreeData::dFNameSpec, RxTreeData::dFoundFile, DO_DIRS, DO_FILES, formatFile(), FOUNDFILE_BUF_LEN, FOUNDFILE_BUFFER, getBiggerBuffer(), increaseBuffer(), linFindNextDir(), linFindNextFile(), RxTreeData::nFoundFile, and RECURSE.

Referenced by RexxRoutine5().

◆ resolve_tilde()

char* resolve_tilde ( const char *  path)

◆ restore_terminal()

void restore_terminal ( int  signal)

Definition at line 983 of file unix/rexxutil.cpp.

References in_orig, and stty.

Referenced by getkey().

◆ RexxRoutine0()

RexxRoutine0 ( int  ,
SysClearRexxMacroSpace   
)

Definition at line 1293 of file unix/rexxutil.cpp.

References RexxClearMacroSpace().

◆ RexxRoutine1() [1/17]

RexxRoutine1 ( CSTRING  ,
SysQueryRexxMacro  ,
CSTRING  ,
name   
)

Definition at line 1264 of file unix/rexxutil.cpp.

References RexxQueryMacro(), and RXMACRO_SEARCH_BEFORE.

◆ RexxRoutine1() [2/17]

RexxRoutine1 ( int  ,
SysCloseEventSem  ,
uintptr_t  ,
vhandle   
)

Definition at line 1953 of file unix/rexxutil.cpp.

References RxSemData::handle, and RxSemData::named.

◆ RexxRoutine1() [3/17]

RexxRoutine1 ( int  ,
SysCloseMutexSem  ,
uintptr_t  ,
vhandle   
)

Definition at line 2194 of file unix/rexxutil.cpp.

References RxSemData::handle, and RxSemData::named.

◆ RexxRoutine1() [4/17]

RexxRoutine1 ( int  ,
SysDropRexxMacro  ,
CSTRING  ,
name   
)

Definition at line 1249 of file unix/rexxutil.cpp.

References RexxDropMacro().

◆ RexxRoutine1() [5/17]

RexxRoutine1 ( int  ,
SysLoadRexxMacroSpace  ,
CSTRING  ,
file   
)

Definition at line 1323 of file unix/rexxutil.cpp.

References RexxLoadMacroSpace().

◆ RexxRoutine1() [6/17]

RexxRoutine1 ( int  ,
SysPostEventSem  ,
uintptr_t  ,
vhandle   
)

Definition at line 1930 of file unix/rexxutil.cpp.

References RxSemData::handle.

◆ RexxRoutine1() [7/17]

RexxRoutine1 ( int  ,
SysReleaseMutexSem  ,
uintptr_t  ,
vhandle   
)

Definition at line 2158 of file unix/rexxutil.cpp.

References RxSemData::handle.

◆ RexxRoutine1() [8/17]

RexxRoutine1 ( int  ,
SysResetEventSem  ,
uintptr_t  ,
vhandle   
)

Definition at line 1911 of file unix/rexxutil.cpp.

References RxSemData::handle.

◆ RexxRoutine1() [9/17]

RexxRoutine1 ( int  ,
SysSaveRexxMacroSpace  ,
CSTRING  ,
file   
)

Definition at line 1308 of file unix/rexxutil.cpp.

References RexxSaveMacroSpace().

◆ RexxRoutine1() [10/17]

RexxRoutine1 ( int  ,
SysSleep  ,
RexxStringObject  ,
delay   
)

◆ RexxRoutine1() [11/17]

RexxRoutine1 ( logical_t  ,
SysFileExists  ,
CSTRING  ,
filename   
)

Definition at line 5717 of file unix/rexxutil.cpp.

◆ RexxRoutine1() [12/17]

RexxRoutine1 ( logical_t  ,
SysIsFile  ,
CSTRING  ,
filename   
)

Definition at line 5662 of file unix/rexxutil.cpp.

◆ RexxRoutine1() [13/17]

RexxRoutine1 ( logical_t  ,
SysIsFileDirectory  ,
CSTRING  ,
filename   
)

Definition at line 5681 of file unix/rexxutil.cpp.

◆ RexxRoutine1() [14/17]

RexxRoutine1 ( logical_t  ,
SysIsFileLink  ,
CSTRING  ,
filename   
)

Definition at line 5699 of file unix/rexxutil.cpp.

◆ RexxRoutine1() [15/17]

RexxRoutine1 ( RexxObjectPtr  ,
SysCreateMutexSem  ,
OPTIONAL_CSTRING  ,
name   
)

Definition at line 2044 of file unix/rexxutil.cpp.

References RxSemData::handle, and RxSemData::named.

◆ RexxRoutine1() [16/17]

RexxRoutine1 ( uintptr_t  ,
SysOpenEventSem  ,
CSTRING  ,
name   
)

Definition at line 1884 of file unix/rexxutil.cpp.

References RxSemData::handle, and RxSemData::named.

◆ RexxRoutine1() [17/17]

RexxRoutine1 ( uintptr_t  ,
SysOpenMutexSem  ,
CSTRING  ,
name   
)

Definition at line 2087 of file unix/rexxutil.cpp.

References RxSemData::handle, and RxSemData::named.

◆ RexxRoutine2() [1/6]

RexxRoutine2 ( int  ,
SysFileCopy  ,
CSTRING  ,
fromFile  ,
CSTRING  ,
toFile   
)

Definition at line 5602 of file unix/rexxutil.cpp.

References CopyFile_DereferenceSymbolicLinks().

◆ RexxRoutine2() [2/6]

RexxRoutine2 ( int  ,
SysFileMove  ,
CSTRING  ,
fromFile  ,
CSTRING  ,
toFile   
)

Definition at line 5647 of file unix/rexxutil.cpp.

References MoveFile().

◆ RexxRoutine2() [3/6]

RexxRoutine2 ( int  ,
SysReorderRexxMacro  ,
CSTRING  ,
name  ,
CSTRING  ,
option   
)

◆ RexxRoutine2() [4/6]

RexxRoutine2 ( int  ,
SysRequestMutexSem  ,
uintptr_t  ,
vhandle  ,
OPTIONAL_int  ,
timeout   
)

Definition at line 2114 of file unix/rexxutil.cpp.

References RxSemData::handle, and SEM_WAIT_PERIOD.

◆ RexxRoutine2() [5/6]

RexxRoutine2 ( int  ,
SysWaitEventSem  ,
uintptr_t  ,
vhandle  ,
OPTIONAL_int  ,
timeout   
)

Definition at line 1997 of file unix/rexxutil.cpp.

References RxSemData::handle, and SEM_WAIT_PERIOD.

◆ RexxRoutine2() [6/6]

RexxRoutine2 ( RexxObjectPtr  ,
SysCreateEventSem  ,
OPTIONAL_CSTRING  ,
name  ,
OPTIONAL_CSTRING  ,
reset   
)

Definition at line 1841 of file unix/rexxutil.cpp.

References RxSemData::handle, and RxSemData::named.

◆ RexxRoutine3() [1/3]

RexxRoutine3 ( int  ,
SysAddRexxMacro  ,
CSTRING  ,
name  ,
CSTRING  ,
file  ,
OPTIONAL_CSTRING  ,
option   
)

Definition at line 1175 of file unix/rexxutil.cpp.

References RexxAddMacro(), RXMACRO_SEARCH_AFTER, and RXMACRO_SEARCH_BEFORE.

◆ RexxRoutine3() [2/3]

RexxRoutine3 ( int  ,
SysStemDelete  ,
RexxStemObject  ,
toStem  ,
stringsize_t  ,
start  ,
OPTIONAL_stringsize_t  ,
count   
)

Definition at line 4943 of file unix/rexxutil.cpp.

References argumentOmitted, and NULLOBJECT.

◆ RexxRoutine3() [3/3]

RexxRoutine3 ( int  ,
SysStemInsert  ,
RexxStemObject  ,
toStem  ,
stringsize_t  ,
position  ,
RexxObjectPtr  ,
newValue   
)

Definition at line 5006 of file unix/rexxutil.cpp.

References NULLOBJECT.

◆ RexxRoutine5()

RexxRoutine5 ( uint32_t  ,
SysFileTree  ,
CSTRING  ,
fSpec  ,
RexxStemObject  ,
files  ,
OPTIONAL_CSTRING  ,
opts  ,
OPTIONAL_CSTRING  ,
targetAttr  ,
OPTIONAL_CSTRING  ,
newAttr   
)

SysFileTree() implementation. Searches for files in a directory tree.

Parameters
fSpec[required] The search pattern, may contain glob characters. E.g., .sh
files[required] A stem to contain the returned results.
opts[optional] Any combination of the following:
             'B' - Search for files and directories.
             'D' - Search for directories only.
             'F' - Search for files only.
             'O' - Only output file names.
             'S' - Recursively scan subdirectories.
             'T' - Combine time & date fields into one.
             'L' - Long time format
             'I' - Case Insensitive search.
targetAttr[optional] Target attribute mask. This is not used in the Unix version of SysFileTree(), was never used. But, the doc never noted that fact. It is left here to avoid breaking any program that may have used it.
newAttr[optional] New attribute mask. This is not used in the Unix version of SysFileTree(), was never used. But, the doc never noted that fact. It is left here to avoid breaking any program that may have used it.
Returns
0 on success, non-zero on error. For all errors a condition is raised.

Definition at line 3517 of file unix/rexxutil.cpp.

References CASELESS, RxTreeData::count, RxTreeData::files, RxTreeData::fNameSpec, FNAMESPEC_BUF_LEN, FOUNDFILE_BUF_LEN, getFileSpecFromArg(), getOptionsFromArg(), getPath(), initTreeData(), recursiveFindFile(), and uninitTreeData().

◆ RexxRoutine6()

RexxRoutine6 ( int  ,
SysStemCopy  ,
RexxStemObject  ,
fromStem  ,
RexxStemObject  ,
toStem  ,
OPTIONAL_stringsize_t  ,
from  ,
OPTIONAL_stringsize_t  ,
to  ,
OPTIONAL_stringsize_t  ,
count  ,
OPTIONAL_CSTRING  ,
option   
)

Definition at line 5061 of file unix/rexxutil.cpp.

References argumentExists, argumentOmitted, and NULLOBJECT.

◆ RexxStemSort()

size_t RexxEntry RexxStemSort ( const char *  stemname,
int  order,
int  type,
size_t  start,
size_t  end,
size_t  firstcol,
size_t  lastcol 
)

Process a stemsort call for the rexxutil SysStemSort function.

Parameters
stemnameThe name of the stem.
orderThe sort order.
typeThe type of sort (case sensitivity).
startThe starting element number.
endThe end element number.
firstcolThe first sort column.
lastcolThe last sort column.
Returns
The sort return code result.

Definition at line 412 of file InterpreterAPI.cpp.

Referenced by SysStemSort().

◆ SamePaths()

bool SamePaths ( CSTRING  path1,
CSTRING  path2 
)

◆ SearchPath()

int SearchPath ( int  SearchFlag,
const char *  path,
const char *  filename,
char *  buf,
size_t  buf_size 
)

Definition at line 866 of file unix/rexxutil.cpp.

References get_next_path(), and IBUF_LEN.

Referenced by SysFileSystem::searchPath(), SysSearchPath(), and systemCommandHandler().

◆ string2int()

bool string2int ( const char *  string,
int *  number 
)

Definition at line 948 of file unix/rexxutil.cpp.

References MAX_DIGITS.

Referenced by SysGetMessage(), SysGetMessageX(), SysMkDir(), and SysSetPriority().

◆ string2size_t()

bool string2size_t ( const char *  string,
size_t *  number 
)

Definition at line 482 of file unix/rexxutil.cpp.

References MAX_DIGITS.

Referenced by SysStemSort().

◆ stringTooLongException()

static void stringTooLongException ( RexxThreadContext c,
CSTRING  funcName,
size_t  pos,
size_t  len,
size_t  realLen 
)
static

<routineName>() argument <argPos> must be less than <len> characters in length; length is <realLen>

SysFileTree() argument 2 must be less than 4095 characters in length; length is 5000

Raises 88.900

Parameters
cThread context we are executing in.
posArgumet position
lenFixed length
realLenActual length

Definition at line 2285 of file unix/rexxutil.cpp.

References Rexx_Error_Incorrect_call_user_defined.

Referenced by getFileSpecFromArg().

◆ strupr()

void strupr ( char *  string)

Definition at line 561 of file unix/rexxutil.cpp.

Referenced by main(), SysFileSearch(), and SysSearchPath().

◆ SysCls()

size_t RexxEntry SysCls ( const char *  name,
size_t  numargs,
CONSTRXSTRING  args[],
const char *  queuename,
PRXSTRING  retstr 
)

Definition at line 1153 of file unix/rexxutil.cpp.

References BUILDRXSTRING, INVALID_ROUTINE, NO_UTIL_ERROR, and VALID_ROUTINE.

◆ SysCreatePipe()

size_t RexxEntry SysCreatePipe ( const char *  name,
size_t  numargs,
CONSTRXSTRING  args[],
const char *  queuename,
PRXSTRING  retstr 
)

◆ SysDropFuncs()

size_t RexxEntry SysDropFuncs ( const char *  name,
size_t  numargs,
CONSTRXSTRING  args[],
const char *  queuename,
PRXSTRING  retstr 
)

Definition at line 1137 of file unix/rexxutil.cpp.

References _RXSTRING::strlength, and VALID_ROUTINE.

◆ SysDumpVariables()

◆ SysFileDelete()

size_t RexxEntry SysFileDelete ( const char *  name,
size_t  numargs,
CONSTRXSTRING  args[],
const char *  queuename,
PRXSTRING  retstr 
)

◆ SysFileSearch()

◆ SysFork()

size_t RexxEntry SysFork ( const char *  name,
size_t  numargs,
CONSTRXSTRING  args[],
const char *  queuename,
PRXSTRING  retstr 
)

◆ SysGetErrortext()

size_t RexxEntry SysGetErrortext ( const char *  name,
size_t  numargs,
CONSTRXSTRING  args[],
const char *  queuename,
PRXSTRING  retstr 
)

◆ SysGetFileDateTime()

size_t RexxEntry SysGetFileDateTime ( const char *  name,
size_t  numargs,
CONSTRXSTRING  args[],
const char *  queuename,
PRXSTRING  retstr 
)

◆ SysGetKey()

size_t RexxEntry SysGetKey ( const char *  name,
size_t  numargs,
CONSTRXSTRING  args[],
const char *  queuename,
PRXSTRING  retstr 
)

◆ SysGetMessage()

size_t RexxEntry SysGetMessage ( const char *  name,
size_t  numargs,
CONSTRXSTRING  args[],
const char *  queuename,
PRXSTRING  retstr 
)

◆ SysGetMessageX()

size_t RexxEntry SysGetMessageX ( const char *  name,
size_t  numargs,
CONSTRXSTRING  args[],
const char *  queuename,
PRXSTRING  retstr 
)

◆ SysLoadFuncs()

size_t RexxEntry SysLoadFuncs ( const char *  name,
size_t  numargs,
CONSTRXSTRING  args[],
const char *  queuename,
PRXSTRING  retstr 
)

Definition at line 1121 of file unix/rexxutil.cpp.

References _RXSTRING::strlength, and VALID_ROUTINE.

◆ SysMkDir()

size_t RexxEntry SysMkDir ( const char *  name,
size_t  numargs,
CONSTRXSTRING  args[],
const char *  queuename,
PRXSTRING  retstr 
)

◆ SysQueryProcess()

size_t RexxEntry SysQueryProcess ( const char *  name,
size_t  numargs,
CONSTRXSTRING  args[],
const char *  queuename,
PRXSTRING  retstr 
)

◆ SysRmDir()

size_t RexxEntry SysRmDir ( const char *  name,
size_t  numargs,
CONSTRXSTRING  args[],
const char *  queuename,
PRXSTRING  retstr 
)

◆ SysSearchPath()

size_t RexxEntry SysSearchPath ( const char *  name,
size_t  numargs,
CONSTRXSTRING  args[],
const char *  queuename,
PRXSTRING  retstr 
)

◆ SysSetFileDateTime()

size_t RexxEntry SysSetFileDateTime ( const char *  name,
size_t  numargs,
CONSTRXSTRING  args[],
const char *  queuename,
PRXSTRING  retstr 
)

◆ SysSetPriority()

size_t RexxEntry SysSetPriority ( const char *  name,
size_t  numargs,
CONSTRXSTRING  args[],
const char *  queuename,
PRXSTRING  retstr 
)

◆ SysStemSort()

size_t RexxEntry SysStemSort ( const char *  name,
size_t  numargs,
CONSTRXSTRING  args[],
const char *  queuename,
PRXSTRING  retstr 
)

◆ SysTempFileName()

size_t RexxEntry SysTempFileName ( const char *  name,
size_t  numargs,
CONSTRXSTRING  args[],
const char *  queuename,
PRXSTRING  retstr 
)

◆ SysUtilVersion()

size_t RexxEntry SysUtilVersion ( const char *  name,
size_t  numargs,
CONSTRXSTRING  args[],
const char *  queuename,
PRXSTRING  retstr 
)

◆ SysVersion()

size_t RexxEntry SysVersion ( const char *  name,
size_t  numargs,
CONSTRXSTRING  args[],
const char *  queuename,
PRXSTRING  retstr 
)

◆ SysWait()

size_t RexxEntry SysWait ( const char *  name,
size_t  numargs,
CONSTRXSTRING  args[],
const char *  queuename,
PRXSTRING  retstr 
)

◆ TemporaryFilename()

char* TemporaryFilename ( CSTRING  filename,
int &  errInfo 
)

Definition at line 5461 of file unix/rexxutil.cpp.

Referenced by CopyFile_DontDereferenceSymbolicLinks(), and MoveFile().

◆ typeOfEntry()

char typeOfEntry ( mode_t  m)
inline

Definition at line 2435 of file unix/rexxutil.cpp.

Referenced by formatFile().

◆ uninitTreeData()

void uninitTreeData ( RXTREEDATA treeData)
inline

Frees any allocated memory in the RXTREEDATA struct, if needed, on return from SysFileTree()

Parameters
treeData

Definition at line 3465 of file unix/rexxutil.cpp.

References RxTreeData::dFNameSpec, RxTreeData::dFoundFile, RxTreeData::dFoundFileLine, FNAMESPEC_BUF_LEN, FOUNDFILE_BUF_LEN, FOUNDFILELINE_BUF_LEN, RxTreeData::nFNameSpec, RxTreeData::nFoundFile, and RxTreeData::nFoundFileLine.

Referenced by RexxRoutine5().

Variable Documentation

◆ in_orig

struct termios in_orig

Definition at line 255 of file unix/rexxutil.cpp.

Referenced by getkey(), and restore_terminal().

◆ rexxutil_package_entry

RexxPackageEntry rexxutil_package_entry
Initial value:
=
{
"REXXUTIL",
"4.0",
NULL,
NULL,
NULL
}
#define REXX_INTERPRETER_4_0_0
Definition: oorexxapi.h:216
#define STANDARD_PACKAGE_HEADER
Definition: oorexxapi.h:230
RexxRoutineEntry rexxutil_routines[]

Definition at line 5798 of file unix/rexxutil.cpp.

◆ rexxutil_routines

RexxRoutineEntry rexxutil_routines[]

Definition at line 5731 of file unix/rexxutil.cpp.