windows/rexxutil.cpp File Reference
#include "oorexxapi.h"
#include <memory.h>
#include <fcntl.h>
#include <ctype.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <limits.h>
#include <shlwapi.h>
#include <math.h>
#include <algorithm>
Include dependency graph for windows/rexxutil.cpp:

Go to the source code of this file.

Classes

struct  _GetFileData
 
struct  RxTreeData
 
struct  RxStemData
 

Macros

#define OM_WAKEUP   (WM_USER+10)
 
#define MAX_LABEL   13 /* max label length (sdrvinfo)*/
 
#define MAX_DIGITS   9 /* max digits in numeric arg */
 
#define MAX   264 /* temporary buffer length */
 
#define IBUF_LEN   4096 /* Input buffer 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 AllocFlag   PAG_COMMIT | PAG_WRITE /* for DosAllocMem */
 
#define RNDFACTOR   1664525L
 
#define MAX_ENVVAR   1024
 
#define MAX_LINE_LEN   4096 /* max line length */
 
#define MAX_CREATEPROCESS_CMDLINE   (32 * 1024)
 
#define USED   0
 
#define FREE   1
 
#define CDROM   2
 
#define REMOTE   3
 
#define LOCAL   4
 
#define RAMDISK   5
 
#define REMOVABLE   6
 
#define RECURSE   0x0002
 
#define DO_DIRS   0x0004
 
#define DO_FILES   0x0008
 
#define NAME_ONLY   0x0010
 
#define EDITABLE_TIME   0x0020
 
#define LONG_TIME   0x0040 /* long time format for SysFileTree */
 
#define CASELESS   0x0080
 
#define RXIGNORE   2 /* Ignore attributes entirely */
 
#define AllAtts
 
#define AllFiles
 
#define AllDirs
 
#define SORT_CASESENSITIVE   0
 
#define SORT_CASEIGNORE   1
 
#define SORT_ASCENDING   0
 
#define SORT_DECENDING   1
 
#define WC_ERR_INVALID_CHARS   0x00000080
 
#define FNAMESPEC_BUF_EXTRA   8
 
#define FNAMESPEC_BUF_LEN   MAX_PATH + FNAMESPEC_BUF_EXTRA
 
#define FOUNDFILE_BUF_LEN   MAX_PATH
 
#define FILETIME_BUF_LEN   64
 
#define FILEATTR_BUF_LEN   16
 
#define FOUNDFILELINE_BUF_LEN   FOUNDFILE_BUF_LEN + FILETIME_BUF_LEN + FILEATTR_BUF_LEN
 
#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 BUILDRXSTRING(t, s)
 
#define RETVAL(retc)
 
#define STATUS_SUCCESS   (0x00000000)
 

Typedefs

typedef struct _GetFileData GetFileData
 
typedef struct RxTreeData RXTREEDATA
 
typedef struct RxStemData RXSTEMDATA
 
typedef BOOL(WINAPI * P_GDFSE) (LPCTSTR, PULARGE_INTEGER, PULARGE_INTEGER, PULARGE_INTEGER)
 

Functions

VOID CALLBACK SleepTimerProc (HWND, UINT, UINT, DWORD)
 
void outOfMemoryException (RexxThreadContext *c)
 
void nullStringException (RexxThreadContext *c, CSTRING fName, size_t pos)
 
void safeLocalFree (void *p)
 
static void systemServiceExceptionCode (RexxThreadContext *c, CSTRING api, uint32_t rc)
 
static bool isWindowsVersion (DWORD major, DWORD minor, unsigned int sp, unsigned int type, unsigned int condition)
 
bool string2size_t (const char *string, size_t *number)
 
bool isAtLeastVista (void)
 
void memupper (char *location, size_t length)
 
bool ReadNextBuffer (GetFileData *filedata)
 
bool MyOpenFile (const char *file, GetFileData *filedata)
 
void CloseFile (GetFileData *filedata)
 
bool GetLine (char *line, size_t size, GetFileData *filedata)
 
bool SetFileMode (const char *file, size_t attr)
 
char * mystrstr (const char *haystack, const char *needle, size_t hlen, size_t nlen, bool sensitive)
 
const char * mystrstr (const char *haystack, const char *needle)
 
VOID GetUniqueFileName (CHAR *Template, CHAR Filler, CHAR *file)
 
size_t RexxEntry SysCls (const char *name, size_t numargs, CONSTRXSTRING args[], const char *queuename, PRXSTRING retstr)
 
 RexxRoutine2 (RexxStringObject, SysCurPos, OPTIONAL_stringsize_t, inrow, OPTIONAL_stringsize_t, incol)
 
 RexxRoutine1 (int, SysCurState, CSTRING, option)
 
size_t RexxEntry SysDriveInfo (const char *name, size_t numargs, CONSTRXSTRING args[], const char *queuename, PRXSTRING retstr)
 
size_t RexxEntry SysDriveMap (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)
 
 RexxRoutine1 (int, SysFileDelete, CSTRING, name)
 
size_t RexxEntry SysFileSearch (const char *name, size_t numargs, CONSTRXSTRING args[], const char *queuename, PRXSTRING retstr)
 
static void badSFTOptsException (RexxThreadContext *c, size_t pos, CSTRING actual)
 
static void badMaskException (RexxThreadContext *c, size_t pos, CSTRING actual)
 
size_t neededSize (size_t need, size_t have)
 
static bool getBiggerBuffer (RexxCallContext *c, char **dBuf, size_t *nBuf, size_t needed, size_t nStaticBuffer)
 
static bool sameAttr (int32_t *mask, uint32_t attr, uint32_t options)
 
static uint32_t newAttr (int32_t *mask, uint32_t attr)
 
static bool setAttr (const char *file, uint32_t attr)
 
static bool formatFile (RexxCallContext *c, char *path, RXTREEDATA *treeData, int32_t *newMask, uint32_t options, WIN32_FIND_DATA *wfd)
 
static bool recursiveFindFile (RexxCallContext *c, char *path, RXTREEDATA *treeData, int32_t *targetMask, int32_t *newMask, uint32_t options)
 
static char * adjustFSpec (char *fSpec)
 
static bool safeGetCurrentDirectory (RexxCallContext *c, char **pPath, size_t *pPathLen)
 
static bool expandNonPath2fullPath (RexxCallContext *c, char *fSpec, char **pPath, size_t *pPathLen, int *lastSlashPos)
 
static bool expandPath2fullPath (RexxCallContext *c, char *fSpec, size_t lastSlashPos, char **pPath, size_t *pPathLen)
 
static bool getPath (RexxCallContext *c, char *fSpec, char **path, char *filename, size_t *pathLen)
 
static bool goodOpts (RexxCallContext *c, char *opts, uint32_t *pOpts)
 
static bool goodMask (RexxCallContext *c, char *msk, int32_t *mask)
 
static bool getMaskFromArg (RexxCallContext *context, char *msk, int32_t *mask, size_t argPos)
 
static bool getOptionsFromArg (RexxCallContext *context, char *opts, uint32_t *options, size_t argPos)
 
static char * getFileSpecFromArg (RexxCallContext *context, CSTRING fSpec, size_t *fSpecLen, size_t *fSpecBufLen, size_t argPos)
 
static char * getPathBuffer (RexxCallContext *context, size_t fSpecLen, size_t *pathLen)
 
static bool illegalFileNameChars (char *fSpec)
 
 RexxRoutine5 (uint32_t, SysFileTree, CSTRING, fSpec, RexxStemObject, files, OPTIONAL_CSTRING, opts, OPTIONAL_CSTRING, targetAttr, OPTIONAL_CSTRING, newAttr)
 
size_t RexxEntry SysGetKey (const char *name, size_t numargs, CONSTRXSTRING args[], const char *queuename, PRXSTRING retstr)
 
size_t RexxEntry SysIni (const char *name, size_t numargs, CONSTRXSTRING args[], const char *queuename, PRXSTRING retstr)
 
size_t RexxEntry SysLoadFuncs (const char *name, size_t numargs, CONSTRXSTRING args[], const char *queuename, PRXSTRING retstr)
 
 RexxRoutine1 (int, SysMkDir, CSTRING, dir)
 
size_t RexxEntry SysGetErrortext (const char *name, size_t numargs, CONSTRXSTRING args[], const char *queuename, PRXSTRING retstr)
 
size_t RexxEntry SysWinEncryptFile (const char *name, size_t numargs, CONSTRXSTRING args[], const char *queuename, PRXSTRING retstr)
 
size_t RexxEntry SysWinDecryptFile (const char *name, size_t numargs, CONSTRXSTRING args[], const char *queuename, PRXSTRING retstr)
 
size_t RexxEntry SysWinVer (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)
 
 RexxRoutine1 (int, SysRmDir, CSTRING, dir)
 
size_t RexxEntry SysSearchPath (const char *name, size_t numargs, CONSTRXSTRING args[], const char *queuename, PRXSTRING retstr)
 
 RexxRoutine1 (int, SysSleep, RexxStringObject, delay)
 
size_t RexxEntry SysTempFileName (const char *name, size_t numargs, CONSTRXSTRING args[], const char *queuename, PRXSTRING retstr)
 
 RexxRoutine3 (RexxStringObject, SysTextScreenRead, int, row, int, col, OPTIONAL_int, len)
 
 RexxRoutine5 (RexxStringObject, SysTextScreenSize, OPTIONAL_CSTRING, optionString, OPTIONAL_stringsize_t, rows, OPTIONAL_stringsize_t, columns, OPTIONAL_stringsize_t, rows2, OPTIONAL_stringsize_t, columns2)
 
size_t RexxEntry RxWinExec (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 SysBootDrive (const char *name, size_t numargs, CONSTRXSTRING args[], const char *queuename, PRXSTRING retstr)
 
size_t RexxEntry SysSystemDirectory (const char *name, size_t numargs, CONSTRXSTRING args[], const char *queuename, PRXSTRING retstr)
 
size_t RexxEntry SysFileSystemType (const char *name, size_t numargs, CONSTRXSTRING args[], const char *queuename, PRXSTRING retstr)
 
size_t RexxEntry SysVolumeLabel (const char *name, size_t numargs, CONSTRXSTRING args[], const char *queuename, PRXSTRING retstr)
 
 RexxRoutine1 (RexxObjectPtr, SysCreateMutexSem, OPTIONAL_CSTRING, name)
 
 RexxRoutine1 (uintptr_t, SysOpenMutexSem, CSTRING, name)
 
 RexxRoutine1 (int, SysReleaseMutexSem, uintptr_t, h)
 
 RexxRoutine1 (int, SysCloseMutexSem, uintptr_t, h)
 
 RexxRoutine2 (int, SysRequestMutexSem, uintptr_t, h, OPTIONAL_int, timeout)
 
 RexxRoutine2 (RexxObjectPtr, SysCreateEventSem, OPTIONAL_CSTRING, name, OPTIONAL_CSTRING, reset)
 
 RexxRoutine1 (uintptr_t, SysOpenEventSem, CSTRING, name)
 
 RexxRoutine1 (int, SysPostEventSem, uintptr_t, h)
 
 RexxRoutine1 (int, SysResetEventSem, uintptr_t, h)
 
 RexxRoutine1 (int, SysPulseEventSem, uintptr_t, h)
 
 RexxRoutine1 (int, SysCloseEventSem, uintptr_t, h)
 
 RexxRoutine2 (int, SysWaitEventSem, uintptr_t, h, OPTIONAL_int, timeout)
 
 RexxRoutine2 (int, SysSetPriority, RexxObjectPtr, classArg, RexxObjectPtr, levelArg)
 
 RexxRoutine1 (RexxObjectPtr, SysQueryProcess, OPTIONAL_CSTRING, option)
 
 RexxRoutine5 (uint32_t, SysShutDownSystem, OPTIONAL_CSTRING, computer, OPTIONAL_CSTRING, message, OPTIONAL_uint32_t, timeout, OPTIONAL_logical_t, forceAppsClosed, OPTIONAL_logical_t, reboot)
 
 RexxRoutine1 (int, SysSwitchSession, CSTRING, name)
 
 RexxRoutine2 (int, SysWaitNamedPipe, CSTRING, name, OPTIONAL_int, timeout)
 
size_t RexxEntry SysDumpVariables (const char *name, size_t numargs, CONSTRXSTRING args[], const char *queuename, PRXSTRING retstr)
 
 RexxRoutine3 (int, SysSetFileDateTime, CSTRING, name, OPTIONAL_CSTRING, newdate, OPTIONAL_CSTRING, newtime)
 
 RexxRoutine2 (RexxObjectPtr, SysGetFileDateTime, CSTRING, name, OPTIONAL_CSTRING, selector)
 
RexxReturnCode 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)
 
 RexxRoutine0 (RexxStringObject, SysUtilVersion)
 
static bool canUseWideCharFlags (UINT cp)
 
 RexxRoutine5 (int, SysFromUniCode, RexxStringObject, sourceString, OPTIONAL_CSTRING, codePageOpt, OPTIONAL_CSTRING, mappingFlags, OPTIONAL_CSTRING, defaultChar, RexxStemObject, stem)
 
 RexxRoutine4 (int, SysToUniCode, RexxStringObject, source, OPTIONAL_CSTRING, codePageOpt, OPTIONAL_CSTRING, mappingFlags, RexxStemObject, stem)
 
 RexxRoutine1 (uint32_t, SysWinGetPrinters, RexxStemObject, stem)
 
 RexxRoutine0 (RexxStringObject, SysWinGetDefaultPrinter)
 
 RexxRoutine1 (int, SysWinSetDefaultPrinter, CSTRING, printer)
 
 RexxRoutine2 (int, SysFileCopy, CSTRING, fromFile, CSTRING, toFile)
 
 RexxRoutine2 (int, SysFileMove, CSTRING, fromFile, CSTRING, toFile)
 
 RexxRoutine1 (logical_t, SysIsFile, CSTRING, file)
 
 RexxRoutine1 (logical_t, SysIsFileDirectory, CSTRING, file)
 
 RexxRoutine1 (logical_t, SysIsFileLink, CSTRING, file)
 
 RexxRoutine1 (logical_t, SysIsFileCompressed, CSTRING, file)
 
 RexxRoutine1 (logical_t, SysIsFileEncrypted, CSTRING, file)
 
 RexxRoutine1 (logical_t, SysIsFileNotContentIndexed, CSTRING, file)
 
 RexxRoutine1 (logical_t, SysIsFileOffline, CSTRING, file)
 
 RexxRoutine1 (logical_t, SysIsFileSparse, CSTRING, file)
 
 RexxRoutine1 (logical_t, SysIsFileTemporary, CSTRING, file)
 
 RexxRoutine1 (logical_t, SysFileExists, CSTRING, file)
 
 RexxRoutine1 (RexxStringObject, SysGetLongPathName, CSTRING, path)
 
 RexxRoutine1 (RexxStringObject, SysGetShortPathName, CSTRING, path)
 
 OOREXX_GET_PACKAGE (rexxutil)
 

Variables

static int ExtendedFlag = 0
 
static char ExtendedChar
 
static P_GDFSE pGetDiskFreeSpaceEx = NULL
 
RexxRoutineEntry rexxutil_routines []
 
RexxPackageEntry rexxutil_package_entry
 

Macro Definition Documentation

◆ AllAtts

#define AllAtts
Value:
FILE_NORMAL | FILE_READONLY | FILE_HIDDEN | \
FILE_SYSTEM | FILE_DIRECTORY | FILE_ARCHIVED

Definition at line 227 of file windows/rexxutil.cpp.

◆ AllDirs

#define AllDirs
Value:
FILE_READONLY | FILE_HIDDEN | \
FILE_SYSTEM | FILE_ARCHIVED | MUST_HAVE_DIRECTORY | FILE_DIRECTORY

Definition at line 231 of file windows/rexxutil.cpp.

◆ AllFiles

#define AllFiles
Value:
FILE_NORMAL | FILE_READONLY | FILE_HIDDEN | \
FILE_SYSTEM | FILE_ARCHIVED

Definition at line 229 of file windows/rexxutil.cpp.

◆ AllocFlag

#define AllocFlag   PAG_COMMIT | PAG_WRITE /* for DosAllocMem */

Definition at line 197 of file windows/rexxutil.cpp.

◆ BUILDRXSTRING

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

Definition at line 354 of file windows/rexxutil.cpp.

◆ CASELESS

#define CASELESS   0x0080

Definition at line 225 of file windows/rexxutil.cpp.

◆ CDROM

#define CDROM   2

Definition at line 209 of file windows/rexxutil.cpp.

◆ CH_CR

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

Definition at line 195 of file windows/rexxutil.cpp.

◆ CH_EOF

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

Definition at line 194 of file windows/rexxutil.cpp.

◆ CH_NL

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

Definition at line 196 of file windows/rexxutil.cpp.

◆ DO_DIRS

#define DO_DIRS   0x0004

Definition at line 220 of file windows/rexxutil.cpp.

◆ DO_FILES

#define DO_FILES   0x0008

Definition at line 221 of file windows/rexxutil.cpp.

◆ EDITABLE_TIME

#define EDITABLE_TIME   0x0020

Definition at line 223 of file windows/rexxutil.cpp.

◆ ERROR_FILEOPEN

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

Definition at line 335 of file windows/rexxutil.cpp.

◆ ERROR_NOMEM

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

Definition at line 334 of file windows/rexxutil.cpp.

◆ ERROR_RETSTR

#define ERROR_RETSTR   "ERROR:"

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

◆ FILEATTR_BUF_LEN

#define FILEATTR_BUF_LEN   16

Definition at line 256 of file windows/rexxutil.cpp.

◆ FILETIME_BUF_LEN

#define FILETIME_BUF_LEN   64

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

◆ FNAMESPEC_BUF_EXTRA

#define FNAMESPEC_BUF_EXTRA   8

Definition at line 252 of file windows/rexxutil.cpp.

◆ FNAMESPEC_BUF_LEN

#define FNAMESPEC_BUF_LEN   MAX_PATH + FNAMESPEC_BUF_EXTRA

Definition at line 253 of file windows/rexxutil.cpp.

◆ FOUNDFILE_BUF_LEN

#define FOUNDFILE_BUF_LEN   MAX_PATH

Definition at line 254 of file windows/rexxutil.cpp.

◆ FOUNDFILELINE_BUF_LEN

#define FOUNDFILELINE_BUF_LEN   FOUNDFILE_BUF_LEN + FILETIME_BUF_LEN + FILEATTR_BUF_LEN

Definition at line 257 of file windows/rexxutil.cpp.

◆ FREE

#define FREE   1

Definition at line 208 of file windows/rexxutil.cpp.

◆ IBUF_LEN

#define IBUF_LEN   4096 /* Input buffer length */

Definition at line 192 of file windows/rexxutil.cpp.

◆ INVALID_ROUTINE

#define INVALID_ROUTINE   40 /* Raise Rexx error */

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

◆ LOCAL

#define LOCAL   4

Definition at line 211 of file windows/rexxutil.cpp.

◆ LONG_TIME

#define LONG_TIME   0x0040 /* long time format for SysFileTree */

Definition at line 224 of file windows/rexxutil.cpp.

◆ MAX

#define MAX   264 /* temporary buffer length */

Definition at line 191 of file windows/rexxutil.cpp.

◆ MAX_CREATEPROCESS_CMDLINE

#define MAX_CREATEPROCESS_CMDLINE   (32 * 1024)

Definition at line 201 of file windows/rexxutil.cpp.

◆ MAX_DIGITS

#define MAX_DIGITS   9 /* max digits in numeric arg */

Definition at line 190 of file windows/rexxutil.cpp.

◆ MAX_ENVVAR

#define MAX_ENVVAR   1024

Definition at line 199 of file windows/rexxutil.cpp.

◆ MAX_LABEL

#define MAX_LABEL   13 /* max label length (sdrvinfo)*/

Definition at line 189 of file windows/rexxutil.cpp.

◆ MAX_LINE_LEN

#define MAX_LINE_LEN   4096 /* max line length */

Definition at line 200 of file windows/rexxutil.cpp.

◆ MAX_READ

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

Definition at line 193 of file windows/rexxutil.cpp.

◆ NAME_ONLY

#define NAME_ONLY   0x0010

Definition at line 222 of file windows/rexxutil.cpp.

◆ NO_UTIL_ERROR

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

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

◆ OM_WAKEUP

#define OM_WAKEUP   (WM_USER+10)

Definition at line 182 of file windows/rexxutil.cpp.

◆ RAMDISK

#define RAMDISK   5

Definition at line 212 of file windows/rexxutil.cpp.

◆ RECURSE

#define RECURSE   0x0002

Definition at line 219 of file windows/rexxutil.cpp.

◆ REMOTE

#define REMOTE   3

Definition at line 210 of file windows/rexxutil.cpp.

◆ REMOVABLE

#define REMOVABLE   6

Definition at line 213 of file windows/rexxutil.cpp.

◆ RETVAL

#define RETVAL (   retc)
Value:
{ \
retstr->strlength = strlen(itoa(retc, retstr->strptr,10)); \
return VALID_ROUTINE; \
}
#define VALID_ROUTINE

Definition at line 359 of file windows/rexxutil.cpp.

◆ RNDFACTOR

#define RNDFACTOR   1664525L

Definition at line 198 of file windows/rexxutil.cpp.

◆ RXIGNORE

#define RXIGNORE   2 /* Ignore attributes entirely */

Definition at line 226 of file windows/rexxutil.cpp.

◆ SORT_ASCENDING

#define SORT_ASCENDING   0

Definition at line 240 of file windows/rexxutil.cpp.

◆ SORT_CASEIGNORE

#define SORT_CASEIGNORE   1

Definition at line 238 of file windows/rexxutil.cpp.

◆ SORT_CASESENSITIVE

#define SORT_CASESENSITIVE   0

Definition at line 237 of file windows/rexxutil.cpp.

◆ SORT_DECENDING

#define SORT_DECENDING   1

Definition at line 241 of file windows/rexxutil.cpp.

◆ STATUS_SUCCESS

#define STATUS_SUCCESS   (0x00000000)

◆ USED

#define USED   0

Definition at line 207 of file windows/rexxutil.cpp.

◆ VALID_ROUTINE

#define VALID_ROUTINE   0 /* Successful completion */

Definition at line 348 of file windows/rexxutil.cpp.

◆ WC_ERR_INVALID_CHARS

#define WC_ERR_INVALID_CHARS   0x00000080

Definition at line 248 of file windows/rexxutil.cpp.

Typedef Documentation

◆ GetFileData

typedef struct _GetFileData GetFileData

◆ P_GDFSE

typedef BOOL(WINAPI * P_GDFSE) (LPCTSTR, PULARGE_INTEGER, PULARGE_INTEGER, PULARGE_INTEGER)

Definition at line 325 of file windows/rexxutil.cpp.

◆ RXSTEMDATA

typedef struct RxStemData RXSTEMDATA

◆ RXTREEDATA

typedef struct RxTreeData RXTREEDATA

Function Documentation

◆ adjustFSpec()

static char* adjustFSpec ( char *  fSpec)
static

This is a SysFileTree() specific function. It is only called, indirectly through getPath(), from SysFileTree().

This function mimics the old IBM code.

Leading spaces are stripped, in some cases. A file specification of "." is changed to "*.*" and a file specification of ".." is changed to "..\*.*"

Leading spaces in fSpec are stripped IFF the first character(s) after the leading spaces:

  is '\' or '/'
or
  is '.\' or './'
or
  is '..\' or '../'
or
   is z:  (i.e., a drive letter)
Parameters
fSpecThe SysFileTree search specification
Returns
A pointer to fSpec, possibly adjust to point to the first non-space character in the string.

@side effects: fSpec may be changed from "." to "*.*" or may be changed from ".." to "..\*.*"

@assumes: The buffer for fSpec is large enough for the possible changes.

Definition at line 2176 of file windows/rexxutil.cpp.

Referenced by getPath().

◆ badMaskException()

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

This is a SysFile specific function.

Parameters
c
pos
actual

Definition at line 1589 of file windows/rexxutil.cpp.

References Rexx_Error_Incorrect_call_user_defined.

Referenced by getMaskFromArg().

◆ 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 1572 of file windows/rexxutil.cpp.

References Rexx_Error_Incorrect_call_user_defined.

Referenced by getOptionsFromArg().

◆ canUseWideCharFlags()

static bool canUseWideCharFlags ( UINT  cp)
static

Check if the dwFlags arguement to WideCharToMultiByte() can be used by the specified code page. See MSDN documentation for WideCharToMultiByte() for clarification. This is used by SysFromUnicode()

Parameters
cpCode page to check.
Returns
Return true if dwFlags can be non-zero, return false if dwFlags must be zero.

Definition at line 5986 of file windows/rexxutil.cpp.

Referenced by RexxRoutine5().

◆ CloseFile()

void CloseFile ( GetFileData filedata)

Definition at line 617 of file windows/rexxutil.cpp.

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

Referenced by SysFileSearch().

◆ expandNonPath2fullPath()

static bool expandNonPath2fullPath ( RexxCallContext c,
char *  fSpec,
char **  pPath,
size_t *  pPathLen,
int *  lastSlashPos 
)
static

◆ expandPath2fullPath()

static bool expandPath2fullPath ( RexxCallContext c,
char *  fSpec,
size_t  lastSlashPos,
char **  pPath,
size_t *  pPathLen 
)
static

Splits the path portion off from fSpec and returns it in the path buffer.

When this function is called, there is always at least one slash in fSpec.

Parameters
c
fSpec
lastSlashPos
pPath
pPathLen
Returns
bool
Remarks
The size of the path buffer is guarenteed to be at least the string length of fSpec + FNAMESPEC_BUF_EXTRA (8) in size. Or MAX (264) bytes in size. Whichever is larger. So path is big enough to contain all of fSpec + 7 characters.

We may have to enlarge the passed in path buffer. If we do, we need to be sure and update the path buffer pointer and the path length. As long as we keep pPath and pPathLen correct, the caller will take care of freeing any memory.

But if we do change pPath, we need to free the buffer it was pointing to.

Definition at line 2378 of file windows/rexxutil.cpp.

References getBiggerBuffer().

Referenced by getPath().

◆ formatFile()

static bool formatFile ( RexxCallContext c,
char *  path,
RXTREEDATA treeData,
int32_t newMask,
uint32_t  options,
WIN32_FIND_DATA *  wfd 
)
static

This function is used by SysFileTree only.

Formats the line for a found file and adds it to the stem containing all the found files.

Parameters
c@parm path
treeData
newMask
options
wfd
Returns
True on success, false on error.
Remarks
We try to use the static buffers in treeData, but if they are not big enough, we allocate memory. If we do allocate memory, we have to free it of course. We can determine if the memory needs to be freed by checking that either nFoundFile, or nFoundFileLine, are the same size as they are originally set to, or not.

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 1826 of file windows/rexxutil.cpp.

References RxTreeData::count, EDITABLE_TIME, RxTreeData::fileAttr, RxTreeData::files, RxTreeData::fileTime, RxTreeData::foundFile, RxTreeData::foundFileLine, LONG_TIME, NAME_ONLY, newAttr(), outOfMemoryException(), setAttr(), and RexxCallContext_::threadContext.

Referenced by recursiveFindFile().

◆ getBiggerBuffer()

static bool getBiggerBuffer ( RexxCallContext c,
char **  dBuf,
size_t *  nBuf,
size_t  needed,
size_t  nStaticBuffer 
)
static

Allocates a buffer that is at least twice as big as the buffer passed in.

Parameters
cCall context we are operating in.
dBufPointer to the buffer to reallocate
nBufSize of current dBuf buffer. Will be updated on return to size of newly allocated buffer.
neededMinimum size needed.
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 1628 of file windows/rexxutil.cpp.

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

Referenced by expandPath2fullPath(), and RexxRoutine5().

◆ getFileSpecFromArg()

static char* getFileSpecFromArg ( RexxCallContext context,
CSTRING  fSpec,
size_t *  fSpecLen,
size_t *  fSpecBufLen,
size_t  argPos 
)
static

This is a SysFileTree specific helper function.

Allocates and returns a buffer containing the file specification to search for.

The file specification consists of the search string as sent by the Rexx user, with possibly some glob characters added. The returned buffer is bigger than the original string to accommodate these, possible, added characters. The number of bytes added to the buffer is 8, which is what the original IBM code used. 8 is probably 1 byte more than needed, but there is no reason that this needs to be exact, better too long than too short.

If the file speicfication ends in a slash ('\') or a period ('.') or two periods ('..'), then a wild card specification ('*.*') is appended.

However, note that there is also the case where a single '.' at the end of the file specification is not used as a directory specifier, but rather is tacked on to the end of a file name.

Windows has a sometimes used convention that a '.' at the end of a file name can be used to indicate the file has no extension. For example, given a file named: MyFile a command of "dir MyFile." will produce a listing of "MyFile".

In this case we want to leave the file specification alone. that is, do not append a "*.*". A command of "dir *." will produce a directory listing of all files that do not have an extension.

Parameters
context
fSpec
fSpecLen[returned] The length of the original fSpec argument, not the length of the allocated buffer.
fSpecBufLen[returned] The length of the length of the allocated fSpec buffer.
argPos
Returns
A string specifying the file pattern to search for. The buffer holding the string is larger than the original input specify.
Remarks
Caller is responsible for freeing memory. Memory is allocated using LocalAlloc(), not malloc().

If the returned buffer is null, a condition has been raised.

FNAMESPEC_BUF_EXTRA (8) is sized to contain the terminating NULL. So the allocated buffer has room to concatenate 7 characters.

Definition at line 2824 of file windows/rexxutil.cpp.

References FNAMESPEC_BUF_EXTRA, nullStringException(), outOfMemoryException(), and RexxCallContext_::threadContext.

Referenced by RexxRoutine5().

◆ GetLine()

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

◆ getMaskFromArg()

static bool getMaskFromArg ( RexxCallContext context,
char *  msk,
int32_t mask,
size_t  argPos 
)
static

This is a SysFileTree specific helper function.

Checks the validity of an attribute mask argument and converts the character based mask into an integer based mask.

Parameters
context
msk
mask
argPos
Returns
bool

Definition at line 2718 of file windows/rexxutil.cpp.

References argumentExists, badMaskException(), goodMask(), RXIGNORE, and RexxCallContext_::threadContext.

Referenced by RexxRoutine5().

◆ getOptionsFromArg()

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

This is a SysFileTree specific helper function.

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

Parameters
context
opts
options
argPos
Returns
bool

Definition at line 2755 of file windows/rexxutil.cpp.

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

Referenced by RexxRoutine5().

◆ getPath()

static bool getPath ( RexxCallContext c,
char *  fSpec,
char **  path,
char *  filename,
size_t *  pathLen 
)
static

This is a SysFileTree() specific function..

This function expands the file spec passed in to the funcition 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 then returned in path and the file name portion is returned in fileName.

The path portion will end with the '\' char if fSpec contains a path.

Parameters
fSpec
pathPointer to path buffer. Path buffer is allocated memory, not a static buffer.
filename
pathLenPointer to size of the path buffer.
Remarks
On entry, the buffer pointed to by fSpec is guaranteed to be at least strlen(fSpec) + FNAMESPEC_BUF_EXTRA (8). So, we can strcat to it at least 7 characters and still have it null terminated.

In addition, the path buffer is guarenteed to be at least that size also.

Definition at line 2537 of file windows/rexxutil.cpp.

References adjustFSpec(), expandNonPath2fullPath(), and expandPath2fullPath().

Referenced by RexxRoutine5().

◆ getPathBuffer()

static char* getPathBuffer ( RexxCallContext context,
size_t  fSpecLen,
size_t *  pathLen 
)
static

This is a SysFileTree specific helper function.

Allocates and returns a buffer large enough to contain the path to search along.

We need a minimum size for the path buffer of at least MAX (264). But the old code seemed to think fileSpecLen + FNAMESPEC_BUF_EXTRA could be longer than that. I guess it could if the user put in a non-existent long file path.

The old code of checking fSpecLen is still used, but I'm unsure of its exact purpose.

Parameters
context
fSpecLen
pathLen
Returns
A buffer the larger of MAX or fSpecLen + FNAMESPEC_BUF_EXTRA bytes in size. Returns NULL on failure.
Remarks
The caller is resposible for freeing the allocated memory.
      LocalAlloc(), not malloc() is used for memory allocation.

      Note that the path buffer is guarenteed to be FNAMESPEC_BUF_EXTRA
      (8) bytes larger than the fNameSpec buffer in the caller.  This is
      important in later checks for buffer overflow.

Definition at line 2892 of file windows/rexxutil.cpp.

References FNAMESPEC_BUF_EXTRA, MAX, outOfMemoryException(), and RexxCallContext_::threadContext.

Referenced by RexxRoutine5().

◆ GetUniqueFileName()

VOID GetUniqueFileName ( CHAR *  Template,
CHAR  Filler,
CHAR *  file 
)

Determine number of filler characters *

Return NULL string if less than 1 or greater than 4 *

Get a random number in the appropriate range

Do until a unique name is found

Generate string which represents the number

Subsitute filler characters with numeric string

See if the file exists

Make sure we are not wasting our time

Definition at line 903 of file windows/rexxutil.cpp.

References RNDFACTOR.

Referenced by SysTempFileName().

◆ goodMask()

static bool goodMask ( RexxCallContext c,
char *  msk,
int32_t mask 
)
static

This is a SysFileTree() specific helper function.

Set a mask of unsigned ints to what is specified by a mask of chars.

Parameters
c
msk
mask
Returns
True on success, false on error.
Remarks
If a character in position N is a '+' then the unsigned int at position N is set to 1. This is turning it on.

If a character in position N is a '-' then the unsigned int at position N is set to -1. This is turning it off.

If a character in position N is a '*' then the unsigned int at position N is set to 0. This is saying ignore it, it doesn't matter what the attribute is.

Definition at line 2675 of file windows/rexxutil.cpp.

Referenced by getMaskFromArg().

◆ goodOpts()

static bool goodOpts ( RexxCallContext c,
char *  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 2602 of file windows/rexxutil.cpp.

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

Referenced by getOptionsFromArg().

◆ illegalFileNameChars()

static bool illegalFileNameChars ( char *  fSpec)
static

Tests for illegal file name characters in fSpec.

Parameters
fSpec
Returns
bool
Note
Double quotes in the file spec is not valid, spaces in file names do not need to be within quotes in the string passed to the Windows API.

A ':' is only valid if it is the second character. Technically a '*' and a '?' are not valid characters for a file name, but they are okay for fSpec. Same thing for '\' and '/', they are not valid in a file name, but they are valid in fSpec. A '/' is iffy. The Windows API accepts '/' as a directory separator, but most Rexx programmers probably don't know that. Not sure if we should flag that as illegal or not.

Definition at line 2930 of file windows/rexxutil.cpp.

Referenced by RexxRoutine5().

◆ isAtLeastVista()

bool isAtLeastVista ( void  )
inline

Definition at line 511 of file windows/rexxutil.cpp.

References isWindowsVersion().

Referenced by RexxRoutine5().

◆ isWindowsVersion()

static bool isWindowsVersion ( DWORD  major,
DWORD  minor,
unsigned int  sp,
unsigned int  type,
unsigned int  condition 
)
static

Tests if the the current operating system version meets the specified requirements. Really a front end to VerifyVersionInfo(). See MSDN docs for type and condition flags.

Parameters
majorOS major number.
minorOS minor number.
spService pack level.
typeFurther refines the test. See MSDN for all the flags, but for example there is VER_NT_WORKSTATION to differentiate between NT desktop and NT server.
conditionThe test condition. Typical flags would be VER_EQUAL or VER_GREATER_EQUAL.
Returns
True if the condition is met by the current operating system, or false if not.

Definition at line 430 of file windows/rexxutil.cpp.

References type.

Referenced by isAtLeastVista().

◆ memupper()

void memupper ( char *  location,
size_t  length 
)

Definition at line 529 of file windows/rexxutil.cpp.

Referenced by SysFileSearch(), and SysIni().

◆ MyOpenFile()

bool MyOpenFile ( const char *  file,
GetFileData filedata 
)

◆ mystrstr() [1/2]

const char* mystrstr ( const char *  haystack,
const char *  needle 
)

Definition at line 867 of file windows/rexxutil.cpp.

◆ mystrstr() [2/2]

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

Definition at line 828 of file windows/rexxutil.cpp.

References line, and MAX_LINE_LEN.

Referenced by RexxRoutine4(), and 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 1603 of file windows/rexxutil.cpp.

Referenced by getBiggerBuffer().

◆ newAttr()

static uint32_t newAttr ( int32_t mask,
uint32_t  attr 
)
static

Returns a new file attribute value given a mask of attributes to be changed and the current attribute value.

Parameters
mask
attr
Returns
New attribute value.

Definition at line 1724 of file windows/rexxutil.cpp.

References RXIGNORE.

Referenced by formatFile(), and RexxRoutine5().

◆ 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 384 of file windows/rexxutil.cpp.

References Rexx_Error_Incorrect_call_null.

Referenced by getFileSpecFromArg(), and getOptionsFromArg().

◆ OOREXX_GET_PACKAGE()

OOREXX_GET_PACKAGE ( rexxutil  )

◆ 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 631 of file windows/rexxutil.cpp.

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

Referenced by GetLine(), and MyOpenFile().

◆ recursiveFindFile()

static bool recursiveFindFile ( RexxCallContext c,
char *  path,
RXTREEDATA treeData,
int32_t targetMask,
int32_t newMask,
uint32_t  options 
)
static

Finds all files matching a file specification, formats a file name line and adds the formatted line to a stem. Much of the data to complete this operation is contained in the treeData struct.

This is a recursive function that may search through subdirectories if the recurse option is used.

Parameters
cCall context we are operating in.
pathCurrent directory we are searching.
treeDataStruct containing data pertaining to the search, such as the file specification we are searching for, the stem to put the results in, etc..
targetMaskAn array of integers which describe the source attribute mask. Only files with attributes matching this mask will be found.
newMaskAn array of integers which describe the target attribute mask. Attributes of all found files will be changed / set to the values specified by this mask.
options
Returns
uint32_t
Remarks
For both targetMask and newMask, each index of the mask corresponds to a different file attribute. Each index and its associated attribute are as follows:
         mask[0] = FILE_ARCHIVED
         mask[1] = FILE_DIRECTORY
         mask[2] = FILE_HIDDEN
         mask[3] = FILE_READONLY
         mask[4] = FILE_SYSTEM
A negative value at a given index indicates that the attribute bit of the file is not set. A positive number indicates that the attribute should be set. A value of 0 indicates a "Don't Care" setting.

A close reading of MSDN seems to indicate that as long as we are compiled for ANSI, which we are, that MAX_PATH is sufficiently large. But, we will code for the possibility that it is not large enough, by mallocing dynamic memory if _snprintf indicates a failure.

We point dTmpFileName at the static buffer and nTmpFileName is set to the size of the buffer. If we have to allocate memory, nTmpFileName will be set to the size we allocate and if nTmpFileName does not equal what it is originally set to, we know we have to free the allocated memory.

Definition at line 2029 of file windows/rexxutil.cpp.

References RxTreeData::dFNameSpec, FNAMESPEC_BUF_LEN, formatFile(), outOfMemoryException(), RECURSE, safeLocalFree(), sameAttr(), and RexxCallContext_::threadContext.

Referenced by RexxRoutine5().

◆ RexxRoutine0() [1/3]

RexxRoutine0 ( int  ,
SysClearRexxMacroSpace   
)

Definition at line 4398 of file windows/rexxutil.cpp.

References RexxClearMacroSpace().

◆ RexxRoutine0() [2/3]

RexxRoutine0 ( RexxStringObject  ,
SysUtilVersion   
)

Definition at line 5968 of file windows/rexxutil.cpp.

◆ RexxRoutine0() [3/3]

RexxRoutine0 ( RexxStringObject  ,
SysWinGetDefaultPrinter   
)

Definition at line 6499 of file windows/rexxutil.cpp.

◆ RexxRoutine1() [1/34]

RexxRoutine1 ( CSTRING  ,
SysQueryRexxMacro  ,
CSTRING  ,
name   
)

Definition at line 4369 of file windows/rexxutil.cpp.

References RexxQueryMacro(), and RXMACRO_SEARCH_BEFORE.

◆ RexxRoutine1() [2/34]

RexxRoutine1 ( int  ,
SysCloseEventSem  ,
uintptr_t  ,
 
)

Definition at line 4857 of file windows/rexxutil.cpp.

◆ RexxRoutine1() [3/34]

RexxRoutine1 ( int  ,
SysCloseMutexSem  ,
uintptr_t  ,
 
)

Definition at line 4699 of file windows/rexxutil.cpp.

◆ RexxRoutine1() [4/34]

RexxRoutine1 ( int  ,
SysCurState  ,
CSTRING  ,
option   
)

Definition at line 1110 of file windows/rexxutil.cpp.

◆ RexxRoutine1() [5/34]

RexxRoutine1 ( int  ,
SysDropRexxMacro  ,
CSTRING  ,
name   
)

Definition at line 4354 of file windows/rexxutil.cpp.

References RexxDropMacro().

◆ RexxRoutine1() [6/34]

RexxRoutine1 ( int  ,
SysFileDelete  ,
CSTRING  ,
name   
)

Definition at line 1422 of file windows/rexxutil.cpp.

◆ RexxRoutine1() [7/34]

RexxRoutine1 ( int  ,
SysLoadRexxMacroSpace  ,
CSTRING  ,
file   
)

Definition at line 4428 of file windows/rexxutil.cpp.

References RexxLoadMacroSpace().

◆ RexxRoutine1() [8/34]

RexxRoutine1 ( int  ,
SysMkDir  ,
CSTRING  ,
dir   
)

Definition at line 3458 of file windows/rexxutil.cpp.

◆ RexxRoutine1() [9/34]

RexxRoutine1 ( int  ,
SysPostEventSem  ,
uintptr_t  ,
 
)

Definition at line 4810 of file windows/rexxutil.cpp.

◆ RexxRoutine1() [10/34]

RexxRoutine1 ( int  ,
SysPulseEventSem  ,
uintptr_t  ,
 
)

Definition at line 4841 of file windows/rexxutil.cpp.

◆ RexxRoutine1() [11/34]

RexxRoutine1 ( int  ,
SysReleaseMutexSem  ,
uintptr_t  ,
 
)

Definition at line 4684 of file windows/rexxutil.cpp.

◆ RexxRoutine1() [12/34]

RexxRoutine1 ( int  ,
SysResetEventSem  ,
uintptr_t  ,
 
)

Definition at line 4825 of file windows/rexxutil.cpp.

◆ RexxRoutine1() [13/34]

RexxRoutine1 ( int  ,
SysRmDir  ,
CSTRING  ,
dir   
)

Definition at line 3666 of file windows/rexxutil.cpp.

◆ RexxRoutine1() [14/34]

RexxRoutine1 ( int  ,
SysSaveRexxMacroSpace  ,
CSTRING  ,
file   
)

Definition at line 4413 of file windows/rexxutil.cpp.

References RexxSaveMacroSpace().

◆ RexxRoutine1() [15/34]

RexxRoutine1 ( int  ,
SysSleep  ,
RexxStringObject  ,
delay   
)

Using Sleep with a long timeout risks sleeping on a thread with a message queue, which can make the system sluggish, or possibly deadlocked. If the sleep is longer than 333 milliseconds use a window timer to avoid this risk.

Definition at line 3804 of file windows/rexxutil.cpp.

References isnan, OM_WAKEUP, Rexx_Error_Invalid_argument_number, Rexx_Error_Invalid_argument_range, Rexx_Error_System_resources_user_defined, and SleepTimerProc().

◆ RexxRoutine1() [16/34]

RexxRoutine1 ( int  ,
SysSwitchSession  ,
CSTRING  ,
name   
)

Definition at line 5230 of file windows/rexxutil.cpp.

◆ RexxRoutine1() [17/34]

RexxRoutine1 ( int  ,
SysWinSetDefaultPrinter  ,
CSTRING  ,
printer   
)

Definition at line 6518 of file windows/rexxutil.cpp.

◆ RexxRoutine1() [18/34]

RexxRoutine1 ( logical_t  ,
SysFileExists  ,
CSTRING  ,
file   
)

Definition at line 6772 of file windows/rexxutil.cpp.

◆ RexxRoutine1() [19/34]

RexxRoutine1 ( logical_t  ,
SysIsFile  ,
CSTRING  ,
file   
)

Definition at line 6624 of file windows/rexxutil.cpp.

◆ RexxRoutine1() [20/34]

RexxRoutine1 ( logical_t  ,
SysIsFileCompressed  ,
CSTRING  ,
file   
)

Definition at line 6673 of file windows/rexxutil.cpp.

◆ RexxRoutine1() [21/34]

RexxRoutine1 ( logical_t  ,
SysIsFileDirectory  ,
CSTRING  ,
file   
)

Definition at line 6641 of file windows/rexxutil.cpp.

◆ RexxRoutine1() [22/34]

RexxRoutine1 ( logical_t  ,
SysIsFileEncrypted  ,
CSTRING  ,
file   
)

Definition at line 6689 of file windows/rexxutil.cpp.

◆ RexxRoutine1() [23/34]

RexxRoutine1 ( logical_t  ,
SysIsFileLink  ,
CSTRING  ,
file   
)

Definition at line 6657 of file windows/rexxutil.cpp.

◆ RexxRoutine1() [24/34]

RexxRoutine1 ( logical_t  ,
SysIsFileNotContentIndexed  ,
CSTRING  ,
file   
)

Definition at line 6706 of file windows/rexxutil.cpp.

◆ RexxRoutine1() [25/34]

RexxRoutine1 ( logical_t  ,
SysIsFileOffline  ,
CSTRING  ,
file   
)

Definition at line 6722 of file windows/rexxutil.cpp.

◆ RexxRoutine1() [26/34]

RexxRoutine1 ( logical_t  ,
SysIsFileSparse  ,
CSTRING  ,
file   
)

Definition at line 6738 of file windows/rexxutil.cpp.

◆ RexxRoutine1() [27/34]

RexxRoutine1 ( logical_t  ,
SysIsFileTemporary  ,
CSTRING  ,
file   
)

Definition at line 6755 of file windows/rexxutil.cpp.

◆ RexxRoutine1() [28/34]

RexxRoutine1 ( RexxObjectPtr  ,
SysCreateMutexSem  ,
OPTIONAL_CSTRING  ,
name   
)

Definition at line 4627 of file windows/rexxutil.cpp.

◆ RexxRoutine1() [29/34]

RexxRoutine1 ( RexxObjectPtr  ,
SysQueryProcess  ,
OPTIONAL_CSTRING  ,
option   
)

Definition at line 5021 of file windows/rexxutil.cpp.

References NULLOBJECT.

◆ RexxRoutine1() [30/34]

RexxRoutine1 ( RexxStringObject  ,
SysGetLongPathName  ,
CSTRING  ,
path   
)

Definition at line 6791 of file windows/rexxutil.cpp.

References MAX.

◆ RexxRoutine1() [31/34]

RexxRoutine1 ( RexxStringObject  ,
SysGetShortPathName  ,
CSTRING  ,
path   
)

Definition at line 6818 of file windows/rexxutil.cpp.

References MAX.

◆ RexxRoutine1() [32/34]

RexxRoutine1 ( uint32_t  ,
SysWinGetPrinters  ,
RexxStemObject  ,
stem   
)

Definition at line 6445 of file windows/rexxutil.cpp.

◆ RexxRoutine1() [33/34]

RexxRoutine1 ( uintptr_t  ,
SysOpenEventSem  ,
CSTRING  ,
name   
)

Definition at line 4792 of file windows/rexxutil.cpp.

◆ RexxRoutine1() [34/34]

RexxRoutine1 ( uintptr_t  ,
SysOpenMutexSem  ,
CSTRING  ,
name   
)

Definition at line 4666 of file windows/rexxutil.cpp.

◆ RexxRoutine2() [1/10]

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

Definition at line 6593 of file windows/rexxutil.cpp.

◆ RexxRoutine2() [2/10]

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

Definition at line 6609 of file windows/rexxutil.cpp.

References MoveFile().

◆ RexxRoutine2() [3/10]

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

◆ RexxRoutine2() [4/10]

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

Definition at line 4714 of file windows/rexxutil.cpp.

References argumentOmitted.

◆ RexxRoutine2() [5/10]

RexxRoutine2 ( int  ,
SysSetPriority  ,
RexxObjectPtr  ,
classArg  ,
RexxObjectPtr  ,
levelArg   
)

Definition at line 4901 of file windows/rexxutil.cpp.

◆ RexxRoutine2() [6/10]

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

Definition at line 4872 of file windows/rexxutil.cpp.

References argumentExists.

◆ RexxRoutine2() [7/10]

RexxRoutine2 ( int  ,
SysWaitNamedPipe  ,
CSTRING  ,
name  ,
OPTIONAL_int  ,
timeout   
)

Definition at line 5262 of file windows/rexxutil.cpp.

References argumentOmitted.

◆ RexxRoutine2() [8/10]

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

Definition at line 4744 of file windows/rexxutil.cpp.

◆ RexxRoutine2() [9/10]

RexxRoutine2 ( RexxObjectPtr  ,
SysGetFileDateTime  ,
CSTRING  ,
name  ,
OPTIONAL_CSTRING  ,
selector   
)

Definition at line 5504 of file windows/rexxutil.cpp.

References NULLOBJECT.

◆ RexxRoutine2() [10/10]

RexxRoutine2 ( RexxStringObject  ,
SysCurPos  ,
OPTIONAL_stringsize_t  ,
inrow  ,
OPTIONAL_stringsize_t  ,
incol   
)

Definition at line 1063 of file windows/rexxutil.cpp.

References argumentExists, and argumentOmitted.

◆ RexxRoutine3() [1/5]

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

◆ RexxRoutine3() [2/5]

RexxRoutine3 ( int  ,
SysSetFileDateTime  ,
CSTRING  ,
name  ,
OPTIONAL_CSTRING  ,
newdate  ,
OPTIONAL_CSTRING  ,
newtime   
)

Definition at line 5428 of file windows/rexxutil.cpp.

◆ RexxRoutine3() [3/5]

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

Definition at line 5719 of file windows/rexxutil.cpp.

References argumentOmitted, and NULLOBJECT.

◆ RexxRoutine3() [4/5]

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

Definition at line 5782 of file windows/rexxutil.cpp.

References NULLOBJECT.

◆ RexxRoutine3() [5/5]

RexxRoutine3 ( RexxStringObject  ,
SysTextScreenRead  ,
int  ,
row  ,
int  ,
col  ,
OPTIONAL_int  ,
len   
)

Definition at line 3941 of file windows/rexxutil.cpp.

References argumentOmitted, and NULLOBJECT.

◆ RexxRoutine4()

RexxRoutine4 ( int  ,
SysToUniCode  ,
RexxStringObject  ,
source  ,
OPTIONAL_CSTRING  ,
codePageOpt  ,
OPTIONAL_CSTRING  ,
mappingFlags  ,
RexxStemObject  ,
stem   
)

Definition at line 6326 of file windows/rexxutil.cpp.

References mystrstr().

◆ RexxRoutine5() [1/4]

RexxRoutine5 ( int  ,
SysFromUniCode  ,
RexxStringObject  ,
sourceString  ,
OPTIONAL_CSTRING  ,
codePageOpt  ,
OPTIONAL_CSTRING  ,
mappingFlags  ,
OPTIONAL_CSTRING  ,
defaultChar  ,
RexxStemObject  ,
stem   
)

◆ RexxRoutine5() [2/4]

RexxRoutine5 ( RexxStringObject  ,
SysTextScreenSize  ,
OPTIONAL_CSTRING  ,
optionString  ,
OPTIONAL_stringsize_t  ,
rows  ,
OPTIONAL_stringsize_t  ,
columns  ,
OPTIONAL_stringsize_t  ,
rows2  ,
OPTIONAL_stringsize_t  ,
columns2   
)

Definition at line 4035 of file windows/rexxutil.cpp.

References argumentExists, and argumentOmitted.

◆ RexxRoutine5() [3/4]

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 matching the specified search pattern.

Parameters
fSpec[required] The search pattern, may contain glob characters and full or partial path informattion. E.g., *.bat, or ../../*.txt, or C:\temp. May not contain illegal file name characters which are: ", <, >, |, and : The semicolon is only legal if it is exactly the second character. Do not use a double quote in fSpec, it is not needed and is taken as a character in a file name, which is an illegal character.
files[required] A stem to contain the returned results. On return, files.0 contains the count N of found files and files.1 through files.N will contain the found files.
opts[optional] Any combination of the following letters that specify how the search takes place, or how the returned found file line is formatted. Case is not significant:

'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.

The defualt is 'B' using normal time (neither 'T' nor 'L'.) The 'I'option is meaningless on Windows.

Parameters
targetAttr[optional] Target attribute mask. Only files with these attributes will be searched for. The default is to ignore the attributes of the files found, so all files found are returned.
newAttr[optional] New attribute mask. Each found file will have its attributes set (changed) to match this mask. The default is to not change any attributes.
Returns
0 on success, non-zero on error. For all errors, a condition is raised.
Remarks
The original IBM code passed in fileSpec to recursiveFindFile(), but then never used it in recursiveFineFile. So, that has been eliminated.

Definition at line 3006 of file windows/rexxutil.cpp.

References RxTreeData::count, RxTreeData::dFNameSpec, RxTreeData::files, RxTreeData::fNameSpec, FNAMESPEC_BUF_LEN, getBiggerBuffer(), getFileSpecFromArg(), getMaskFromArg(), getOptionsFromArg(), getPath(), getPathBuffer(), illegalFileNameChars(), newAttr(), RxTreeData::nFNameSpec, recursiveFindFile(), and safeLocalFree().

◆ RexxRoutine5() [4/4]

RexxRoutine5 ( uint32_t  ,
SysShutDownSystem  ,
OPTIONAL_CSTRING  ,
computer  ,
OPTIONAL_CSTRING  ,
message  ,
OPTIONAL_uint32_t  ,
timeout  ,
OPTIONAL_logical_t  ,
forceAppsClosed  ,
OPTIONAL_logical_t  ,
reboot   
)

SysShutDownSystem()

Interface to the InitiateSystemShutdown() API on Windows.

Parameters
computerThe name of the computer to shut down. If omitted or the empty string, the local machine is shut down. Otherwise this is the name of a remote machine to shut down.
messageIf timout is not 0, a shut down dialog is displayed on the machine being shut down, naming the user who initiated the shut down, a timer counting down the seconds until the machine is shut down, and prompting the local user to log off. This parametr can be an additional message to add to the dialog box. It can be ommitted if no additional message is desired.
timeoutNumber of seconds to display the shut down dialog. If this is 0 no dialog is displayed. The default is 30 seconds, see the remarks below. The user can force a 0 timeout by explicitly specifying 0.
forceAppsClosedIf true applications with unsaved data are forcibly closed. If false, the user is presented with a dialog telling the user to close the applcation(s).
rebootIf true, the system is rebooted, if false the system is shut down.
Remarks
Note that prior to 4.0.0, the defaults for all arguments were exactly what the value of each parameter is if omitted.

machine == NULL message == NULL timeout == 0 forceAppsClosed == false reboot == false

Because of this, there would be no need to check if any argument is ommitted or not. However, the consequences of having a 0 timeout value are severe if the system has an application open with unsaved data. Therefore for 4.0.0 and on the default time out value is changed to 30 (seconds.)

Definition at line 5157 of file windows/rexxutil.cpp.

References argumentOmitted.

◆ 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 5837 of file windows/rexxutil.cpp.

References argumentExists, argumentOmitted, and NULLOBJECT.

◆ RexxStemSort()

RexxReturnCode 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 413 of file InterpreterAPI.cpp.

References NativeContextBlock::self, RexxNativeActivation::stemSort(), and type.

Referenced by SysStemSort().

◆ RxWinExec()

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

◆ safeGetCurrentDirectory()

static bool safeGetCurrentDirectory ( RexxCallContext c,
char **  pPath,
size_t *  pPathLen 
)
static

◆ safeLocalFree()

void safeLocalFree ( void *  p)
inline

Definition at line 389 of file windows/rexxutil.cpp.

Referenced by expandNonPath2fullPath(), recursiveFindFile(), and RexxRoutine5().

◆ sameAttr()

static bool sameAttr ( int32_t mask,
uint32_t  attr,
uint32_t  options 
)
static

Checks that attr is the same as that specified by the mask.

Parameters
mask
attr
options
Returns
True for a match, otherwise false.

Definition at line 1656 of file windows/rexxutil.cpp.

References DO_DIRS, DO_FILES, and RXIGNORE.

Referenced by recursiveFindFile().

◆ setAttr()

static bool setAttr ( const char *  file,
uint32_t  attr 
)
static

Changes the file attributes of the specified file to those specified by attr.

Parameters
fileFile to change the attributes of.
attrNew file attributes.
Returns
True on success, false on error.
Remarks
Note that this function was named SetFileMode() in the old IBM code.

Definition at line 1787 of file windows/rexxutil.cpp.

Referenced by formatFile().

◆ SetFileMode()

bool SetFileMode ( const char *  file,
size_t  attr 
)

Definition at line 792 of file windows/rexxutil.cpp.

◆ SleepTimerProc()

VOID CALLBACK SleepTimerProc ( HWND  hwnd,
UINT  uMsg,
UINT  idEvent,
DWORD  dwTime 
)

Definition at line 3875 of file windows/rexxutil.cpp.

References OM_WAKEUP.

Referenced by RexxRoutine1().

◆ string2size_t()

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

Definition at line 480 of file windows/rexxutil.cpp.

References MAX_DIGITS.

Referenced by SysStemSort().

◆ SysBootDrive()

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

◆ SysCls()

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

Definition at line 1029 of file windows/rexxutil.cpp.

References BUILDRXSTRING, INVALID_ROUTINE, NO_UTIL_ERROR, and VALID_ROUTINE.

◆ SysDriveInfo()

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

◆ SysDriveMap()

size_t RexxEntry SysDriveMap ( 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 1405 of file windows/rexxutil.cpp.

References _RXSTRING::strlength, and VALID_ROUTINE.

◆ SysDumpVariables()

◆ SysFileSearch()

◆ SysFileSystemType()

size_t RexxEntry SysFileSystemType ( 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 
)

◆ SysGetKey()

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

◆ SysIni()

◆ SysLoadFuncs()

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

Definition at line 3439 of file windows/rexxutil.cpp.

References _RXSTRING::strlength, and VALID_ROUTINE.

◆ SysSearchPath()

size_t RexxEntry SysSearchPath ( 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 
)

◆ SysSystemDirectory()

size_t RexxEntry SysSystemDirectory ( 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 
)

◆ systemServiceExceptionCode()

static void systemServiceExceptionCode ( RexxThreadContext c,
CSTRING  api,
uint32_t  rc 
)
static

Raises an exception for an unrecoverable system API failure.

Parameters
cCall context we are operating in.
apiSystem API name.
rcReturn code from calling the API.

Definition at line 404 of file windows/rexxutil.cpp.

References Rexx_Error_System_service_user_defined.

Referenced by expandNonPath2fullPath(), and safeGetCurrentDirectory().

◆ SysVersion()

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

Definition at line 3648 of file windows/rexxutil.cpp.

References SysWinVer().

◆ SysVolumeLabel()

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

◆ SysWinDecryptFile()

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

◆ SysWinEncryptFile()

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

◆ SysWinVer()

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

Variable Documentation

◆ ExtendedChar

char ExtendedChar
static

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

Referenced by SysGetKey().

◆ ExtendedFlag

int ExtendedFlag = 0
static

Definition at line 319 of file windows/rexxutil.cpp.

Referenced by SysGetKey().

◆ pGetDiskFreeSpaceEx

P_GDFSE pGetDiskFreeSpaceEx = NULL
static

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

Referenced by SysDriveInfo().

◆ 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 6920 of file windows/rexxutil.cpp.

◆ rexxutil_routines

RexxRoutineEntry rexxutil_routines[]

Definition at line 6834 of file windows/rexxutil.cpp.