182 #define OM_WAKEUP (WM_USER+10)
192 #define IBUF_LEN 4096
193 #define MAX_READ 0x10000
197 #define AllocFlag PAG_COMMIT | PAG_WRITE
198 #define RNDFACTOR 1664525L
199 #define MAX_ENVVAR 1024
200 #define MAX_LINE_LEN 4096
201 #define MAX_CREATEPROCESS_CMDLINE (32 * 1024)
219 #define RECURSE 0x0002
220 #define DO_DIRS 0x0004
221 #define DO_FILES 0x0008
222 #define NAME_ONLY 0x0010
223 #define EDITABLE_TIME 0x0020
224 #define LONG_TIME 0x0040
225 #define CASELESS 0x0080
227 #define AllAtts FILE_NORMAL | FILE_READONLY | FILE_HIDDEN | \
228 FILE_SYSTEM | FILE_DIRECTORY | FILE_ARCHIVED
229 #define AllFiles FILE_NORMAL | FILE_READONLY | FILE_HIDDEN | \
230 FILE_SYSTEM | FILE_ARCHIVED
231 #define AllDirs FILE_READONLY | FILE_HIDDEN | \
232 FILE_SYSTEM | FILE_ARCHIVED | MUST_HAVE_DIRECTORY | FILE_DIRECTORY
237 #define SORT_CASESENSITIVE 0
238 #define SORT_CASEIGNORE 1
240 #define SORT_ASCENDING 0
241 #define SORT_DECENDING 1
247 #ifndef WC_ERR_INVALID_CHARS
248 #define WC_ERR_INVALID_CHARS 0x00000080
252 #define FNAMESPEC_BUF_EXTRA 8
253 #define FNAMESPEC_BUF_LEN MAX_PATH + FNAMESPEC_BUF_EXTRA
254 #define FOUNDFILE_BUF_LEN MAX_PATH
255 #define FILETIME_BUF_LEN 64
256 #define FILEATTR_BUF_LEN 16
257 #define FOUNDFILELINE_BUF_LEN FOUNDFILE_BUF_LEN + FILETIME_BUF_LEN + FILEATTR_BUF_LEN
325 typedef BOOL (WINAPI *
P_GDFSE)(LPCTSTR, PULARGE_INTEGER, PULARGE_INTEGER,
333 #define NO_UTIL_ERROR "0"
334 #define ERROR_NOMEM "2"
335 #define ERROR_FILEOPEN "3"
341 #define ERROR_RETSTR "ERROR:"
347 #define INVALID_ROUTINE 40
348 #define VALID_ROUTINE 0
354 #define BUILDRXSTRING(t, s) { \
355 strcpy((t)->strptr,(s));\
356 (t)->strlength = strlen((s)); \
359 #define RETVAL(retc) { \
360 retstr->strlength = strlen(itoa(retc, retstr->strptr,10)); \
361 return VALID_ROUTINE; \
407 _snprintf(buf,
sizeof(buf),
408 "system API %s() failed; rc: %d last error code: %d", api, rc, GetLastError());
430 static bool isWindowsVersion(DWORD major, DWORD minor,
unsigned int sp,
unsigned int type,
unsigned int condition)
434 DWORD testForMask = VER_MAJORVERSION | VER_MINORVERSION;
436 ZeroMemory(&ver,
sizeof(OSVERSIONINFOEX));
438 ver.dwOSVersionInfoSize =
sizeof(OSVERSIONINFOEX);
439 ver.dwMajorVersion = major;
440 ver.dwMinorVersion = minor;
442 VER_SET_CONDITION(mask, VER_MAJORVERSION, condition);
443 VER_SET_CONDITION(mask, VER_MINORVERSION, condition);
445 if ( condition != VER_EQUAL )
447 ver.wServicePackMajor = sp;
448 testForMask |= VER_SERVICEPACKMAJOR;
449 VER_SET_CONDITION(mask, VER_SERVICEPACKMAJOR, condition);
454 ver.wProductType =
type;
455 testForMask |= VER_PRODUCT_TYPE;
456 VER_SET_CONDITION(mask, VER_PRODUCT_TYPE, condition);
459 if ( VerifyVersionInfo(&ver, testForMask, mask) )
487 length = strlen(
string);
498 if (!isdigit(*
string))
503 accumulator = accumulator * 10 + (*
string -
'0');
507 *number = accumulator;
533 for (; length--; location++)
535 *location = toupper(*location);
556 if ((filedata->
handle = CreateFile(file, GENERIC_READ,
557 FILE_SHARE_READ | FILE_SHARE_WRITE, 0, OPEN_EXISTING,
558 FILE_FLAG_WRITE_THROUGH, 0))
559 == INVALID_HANDLE_VALUE)
563 dwSize = GetFileSize(filedata->
handle, NULL);
566 if (dwSize == 0xffffffff || !dwSize) {
567 CloseHandle(filedata->
handle);
573 if (!(filedata->
buffer = (
char *)GlobalAlloc(GMEM_ZEROINIT |
574 GMEM_FIXED, dwSize))) {
575 CloseHandle(filedata->
handle);
578 filedata->
size = dwSize;
581 if (!ReadFile(filedata->
handle, filedata->
buffer, dwSize, &bytesRead, NULL)) {
582 GlobalFree(filedata->
buffer);
583 CloseHandle(filedata->
handle);
589 filedata->
data = bytesRead;
593 if (!(filedata->
buffer = (
char *)GlobalAlloc(GMEM_ZEROINIT |
595 CloseHandle(filedata->
handle);
599 filedata->
size = dwSize;
604 GlobalFree(filedata->
buffer);
605 CloseHandle(filedata->
handle);
620 CloseHandle(filedata->
handle);
621 GlobalFree(filedata->
buffer);
640 if ( !ReadFile(filedata->
handle, filedata->
buffer, (DWORD)size, &bytesRead, NULL) )
644 filedata->
data = bytesRead;
646 if ( filedata->
data != size )
692 if (!(filedata->
data)) {
702 scan = (
char *)memchr(filedata->
scan,
CH_NL, filedata->
data);
705 length = scan - filedata->
scan;
706 copylength =
std::min(length, size);
708 memcpy(
line, filedata->
scan, copylength);
709 line[copylength] =
'\0';
713 line[copylength - 1] =
'\0';
716 filedata->
data -= length + 1;
717 filedata->
scan = scan + 1;
719 if (!filedata->
data) {
744 if (size > filedata->
data)
746 copylength = filedata->
data;
748 memcpy(
line, filedata->
scan, copylength);
749 line[copylength] =
'\0';
752 filedata->
data -= copylength;
754 filedata->
scan += copylength;
760 return GetLine(
line + copylength, size - copylength, filedata);
766 memcpy(
line, filedata->
scan, copylength);
767 line[copylength] =
'\0';
800 if ((dwfileattrib = GetFileAttributes(file)) != 0xffffffff) {
803 if ((dwfileattrib = SetFileAttributes(file, (DWORD)attr)) != 0)
829 const char *haystack,
842 for (p = 0; p < hlen; p++)
844 if (haystack[p] ==
'\0')
847 line[p] = haystack[p];
848 else line[p] = (char)toupper(haystack[p]);
854 for (p = 0; p < nlen; p++) {
856 if (needle[p] ==
'\0')
859 target[p] = needle[p];
860 else target[p] = (char)toupper(needle[p]);
864 return strstr(
line, target);
867 const char *
mystrstr(
const char *haystack,
const char *needle)
869 size_t hlen = strlen(haystack);
870 size_t nlen = strlen(haystack);
872 char *haystackCopy = strdup(haystack);
873 for (
size_t i = 0; i < hlen; i++)
875 haystackCopy[i] = toupper(haystackCopy[i]);
878 const char *result = strstr(haystackCopy, needle);
921 WIN32_FIND_DATA wfdFinfo;
929 for (x = 0; Template[x] != 0; x++)
931 if (Template[x] == Filler) {
938 if (j == 0 || j > 5) {
949 seed = DT.wHour*60 + DT.wMinute;
950 seed = seed*60 + DT.wSecond;
951 seed = seed*100 + ( DT.wMilliseconds / (UINT)10 );
953 num = (ULONG)seed % max;
964 wsprintf(numstr,
"%01u", num);
967 wsprintf(numstr,
"%02u", num);
970 wsprintf(numstr,
"%03u", num);
973 wsprintf(numstr,
"%04u", num);
976 wsprintf(numstr,
"%05u", num);
984 for (x = 0; Template[x] != 0; x++)
986 if (Template[x] == Filler)
987 file[x] = numstr[i++];
990 file[x] = Template[x];
995 fuErrorMode = SetErrorMode(SEM_NOOPENFILEERRORBOX);
996 hSearch = FindFirstFile(file, &wfdFinfo);
998 if (hSearch == INVALID_HANDLE_VALUE)
1002 SetErrorMode(fuErrorMode);
1008 if (num == start && !Unique) {
1033 COORD Home = {0, 0};
1034 CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
1039 hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
1041 if (GetConsoleScreenBufferInfo(hStdout, &csbiInfo)) {
1042 FillConsoleOutputCharacter( hStdout,
' ',
1043 csbiInfo.dwSize.X * csbiInfo.dwSize.Y,
1045 SetConsoleCursorPosition(hStdout, Home);
1065 CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
1070 context->InvalidRoutine();
1074 HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
1079 if (GetConsoleScreenBufferInfo(hStdout, &csbiInfo))
1083 sprintf(buffer,
"%d %d", csbiInfo.dwCursorPosition.Y, csbiInfo.dwCursorPosition.X);
1088 newHome.Y = (short)inrow;
1089 newHome.X = (short)incol;
1091 SetConsoleCursorPosition(hStdout, newHome);
1094 return context->NewStringFromAsciiz(buffer);
1097 return context->NullString();
1112 CONSOLE_CURSOR_INFO CursorInfo;
1114 HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
1116 GetConsoleCursorInfo(hStdout,&CursorInfo);
1119 if (stricmp(option,
"ON") == 0)
1121 CursorInfo.bVisible =
true;
1123 else if (stricmp(option,
"OFF") == 0)
1125 CursorInfo.bVisible =
false;
1130 context->InvalidRoutine();
1134 SetConsoleCursorInfo(hStdout,&CursorInfo);
1151 CHAR chFileSysType[MAX_PATH],
1152 chVolumeName[MAX_PATH],
1157 DWORD dwSectorsPerCluster, dwBytesPerSector;
1158 DWORD dwFreeClusters, dwClusters;
1163 unsigned __int64 i64FreeBytesToCaller,
1169 args[0].strlength > 2 ||
1170 args[0].strlength == 0)
1173 const char *arg = args[0].
strptr;
1175 if (strlen(arg) == 2 &&
1183 if (strlen(arg) == 1){
1184 chDriveLetter[0]=arg[0];
1185 chDriveLetter[1]=
':';
1186 chDriveLetter[2]=
'\\';
1187 chDriveLetter[3]=
'\0';
1191 strcpy(chDriveLetter, args[0].strptr);
1192 chDriveLetter[2]=
'\\';
1193 chDriveLetter[3]=
'\0';
1200 "GetDiskFreeSpaceExA");
1203 errorMode = SetErrorMode(SEM_FAILCRITICALERRORS);
1205 bGVIrc=GetVolumeInformation(chDriveLetter,
1214 dwgle=GetLastError();
1220 (PULARGE_INTEGER) &i64FreeBytesToCaller,
1221 (PULARGE_INTEGER) &i64TotalBytes,
1222 (PULARGE_INTEGER) &i64FreeBytes);
1227 bGDFSrc=GetDiskFreeSpace( chDriveLetter,
1228 &dwSectorsPerCluster,
1234 i64TotalBytes = (__int64)dwClusters * dwSectorsPerCluster * dwBytesPerSector;
1235 i64FreeBytes = (__int64)dwFreeClusters * dwSectorsPerCluster * dwBytesPerSector;
1238 dwgle=GetLastError();
1239 SetErrorMode(errorMode);
1241 if (bGVIrc && bGDFSrc) {
1245 "%c%c %-12I64u %-12I64u %-13s",
1246 chDriveLetter[0], chDriveLetter[1],
1247 i64FreeBytes, i64TotalBytes, chVolumeName);
1290 Ordinal = (ULONG )0;
1297 if (numargs >= 1 && args[0].strptr) {
1299 if ((strlen(args[0].strptr) == 2 &&
1300 args[0].strptr[1] !=
':') ||
1301 strlen(args[0].strptr) > 2 ||
1302 strlen(args[0].strptr) == 0)
1304 start = toupper(args[0].strptr[0])-
'A'+1;
1310 if (numargs == 2 && args[1].strlength != 0) {
1312 if (!stricmp(args[1].strptr,
"FREE"))
1314 else if (!stricmp(args[1].strptr,
"USED"))
1316 else if (!stricmp(args[1].strptr,
"RAMDISK"))
1318 else if (!stricmp(args[1].strptr,
"REMOTE"))
1320 else if (!stricmp(args[1].strptr,
"LOCAL"))
1322 else if (!stricmp(args[1].strptr,
"REMOVABLE"))
1324 else if (!stricmp(args[1].strptr,
"CDROM"))
1330 DriveMap = GetLogicalDrives();
1334 for (dnum = start; dnum <= 26; dnum++) {
1337 if (!(DriveMap&(DWORD)1) && Mode ==
FREE) {
1338 sprintf(tmpstr,
"%c: ", dnum+
'A'-1);
1339 strcat(temp, tmpstr);
1342 else if ((DriveMap&(DWORD)1) && Mode ==
USED) {
1343 sprintf(tmpstr,
"%c: ", dnum+
'A'-1);
1344 strcat(temp, tmpstr);
1347 else if (DriveMap&(DWORD)1) {
1348 sprintf(DeviceName,
"%c:\\", dnum+
'A'-1);
1350 errorMode = SetErrorMode(SEM_FAILCRITICALERRORS);
1351 rc = (LONG)GetDriveType(DeviceName);
1352 SetErrorMode(errorMode);
1354 DataBufferLen =
sizeof DataBuffer;
1355 DosQueryFSAttach(DeviceName, Ordinal, FSAInfoLevel,
1356 &DataBuffer, &DataBufferLen);
1357 rc = DosQueryFSInfo(dnum, 2, buf,
sizeof(buf));
1360 if (rc == DRIVE_REMOVABLE && Mode ==
REMOVABLE) {
1363 sprintf(tmpstr,
"%c: ", dnum+
'A'-1);
1364 strcat(temp, tmpstr);
1367 else if (rc == DRIVE_CDROM && Mode ==
CDROM) {
1368 sprintf(tmpstr,
"%c: ", dnum+
'A'-1);
1369 strcat(temp, tmpstr);
1372 else if (rc == DRIVE_FIXED && Mode ==
LOCAL) {
1373 sprintf(tmpstr,
"%c: ", dnum+
'A'-1);
1374 strcat(temp, tmpstr);
1377 else if (rc == DRIVE_REMOTE && Mode ==
REMOTE) {
1378 sprintf(tmpstr,
"%c: ", dnum+
'A'-1);
1379 strcat(temp, tmpstr);
1382 else if (rc == DRIVE_RAMDISK && Mode ==
RAMDISK) {
1383 sprintf(tmpstr,
"%c: ", dnum+
'A'-1);
1384 strcat(temp, tmpstr);
1424 return !DeleteFile(name) ? GetLastError() : 0;
1454 bool linenums =
false;
1456 bool sensitive =
false;
1459 char *buffer_pointer;
1464 if (numargs < 3 || numargs > 4 ||
1470 buffer_pointer = NULL;
1472 const char *target = args[0].
strptr;
1473 const char *file = args[1].
strptr;
1476 const char *opts = args[3].
strptr;
1477 if (strstr(opts,
"N") || strstr(opts,
"n"))
1480 if (strstr(opts,
"C") || strstr(opts,
"c"))
1503 ptr =
mystrstr(
line, target, len, args[0].strlength, sensitive);
1508 wsprintf(ldp.
ibuf,
"%d ", num);
1509 len2 = strlen(ldp.
ibuf);
1574 char buf[256] = {0};
1575 _snprintf(buf,
sizeof(buf),
1576 "SysFileTree argument %zd must be a combination of F, D, B, S, T, L, I, or O; found \"%s\"",
1591 char buf[256] = {0};
1592 _snprintf(buf,
sizeof(buf),
1593 "SysFileTree argument %zd must be 5 characters or less in length containing only '+', '-', or '*'; found \"%s\"",
1605 while ( have < need )
1630 if ( *nBuf != nStaticBuffer )
1636 *dBuf = (
char *)LocalAlloc(LPTR, *nBuf *
sizeof(
char));
1638 if ( *dBuf == NULL )
1658 if ( (options &
DO_DIRS) && ! (options &
DO_FILES) && ! (attr & FILE_ATTRIBUTE_DIRECTORY) )
1662 if ( ! (options &
DO_DIRS) && (options &
DO_FILES) && (attr & FILE_ATTRIBUTE_DIRECTORY) )
1671 if ( mask[0] < 0 && attr & FILE_ATTRIBUTE_ARCHIVE )
1675 if ( mask[0] > 0 && ! (attr & FILE_ATTRIBUTE_ARCHIVE) )
1679 if ( mask[1] < 0 && attr & FILE_ATTRIBUTE_DIRECTORY )
1683 if ( mask[1] > 0 && ! (attr & FILE_ATTRIBUTE_DIRECTORY) )
1687 if ( mask[2] < 0 && attr & FILE_ATTRIBUTE_HIDDEN )
1691 if (mask[2] > 0 && ! (attr & FILE_ATTRIBUTE_HIDDEN) )
1695 if (mask[3] < 0 && attr & FILE_ATTRIBUTE_READONLY )
1699 if (mask[3] > 0 && ! (attr & FILE_ATTRIBUTE_READONLY) )
1703 if (mask[4] < 0 && attr & FILE_ATTRIBUTE_SYSTEM )
1707 if (mask[4] > 0 && ! (attr & FILE_ATTRIBUTE_SYSTEM) )
1733 attr &= ~FILE_ATTRIBUTE_ARCHIVE;
1737 attr |= FILE_ATTRIBUTE_ARCHIVE;
1741 attr &= ~FILE_ATTRIBUTE_DIRECTORY;
1745 attr |= FILE_ATTRIBUTE_DIRECTORY;
1749 attr &= ~FILE_ATTRIBUTE_HIDDEN;
1753 attr |= FILE_ATTRIBUTE_HIDDEN;
1757 attr &= ~FILE_ATTRIBUTE_READONLY;
1761 attr |= FILE_ATTRIBUTE_READONLY;
1765 attr &= ~FILE_ATTRIBUTE_SYSTEM;
1769 attr |= FILE_ATTRIBUTE_SYSTEM;
1789 if ( SetFileAttributes(file, attr) == 0 )
1827 uint32_t options, WIN32_FIND_DATA *wfd)
1833 size_t nFoundFile =
sizeof(treeData->
foundFile);
1835 int len = _snprintf(dFoundFile, nFoundFile,
"%s%s", path, wfd->cFileName);
1836 if ( len < 0 || len == nFoundFile )
1838 nFoundFile = strlen(path) + strlen(wfd->cFileName) + 1;
1839 dFoundFile = (
char *)LocalAlloc(LPTR, nFoundFile);
1840 if ( dFoundFile == NULL )
1847 _snprintf(dFoundFile, nFoundFile,
"%s%s", path, wfd->cFileName);
1856 c->SetStemArrayElement(treeData->
files, treeData->
count, t);
1857 c->ReleaseLocalReference(t);
1859 if ( nFoundFile !=
sizeof(treeData->
foundFile) )
1861 LocalFree(dFoundFile);
1870 if ( changedAttr != wfd->dwFileAttributes )
1873 if ( !
setAttr(treeData->
foundFile, changedAttr & ~FILE_ATTRIBUTE_DIRECTORY) )
1875 changedAttr = wfd->dwFileAttributes;
1880 FileTimeToLocalFileTime(&wfd->ftLastWriteTime, &ftLocal);
1881 FileTimeToSystemTime(&ftLocal, &systime);
1889 sprintf(treeData->
fileTime,
"%4d-%02d-%02d %02d:%02d:%02d %10lu ",
1902 sprintf(treeData->
fileTime,
"%02d/%02d/%02d/%02d/%02d %10lu ",
1903 (systime.wYear + 100) % 100,
1912 sprintf(treeData->
fileTime,
"%2d/%02d/%02d %2d:%02d%c %10lu ",
1915 (systime.wYear + 100) % 100,
1916 (systime.wHour < 13 && systime.wHour != 0 ?
1917 systime.wHour : (abs(systime.wHour - (SHORT)12))),
1919 (systime.wHour < 12 || systime.wHour == 24) ?
'a' :
'p',
1924 sprintf(treeData->
fileAttr,
"%c%c%c%c%c ",
1925 (changedAttr & FILE_ATTRIBUTE_ARCHIVE) ?
'A' :
'-',
1926 (changedAttr & FILE_ATTRIBUTE_DIRECTORY) ?
'D' :
'-',
1927 (changedAttr & FILE_ATTRIBUTE_HIDDEN) ?
'H' :
'-',
1928 (changedAttr & FILE_ATTRIBUTE_READONLY) ?
'R' :
'-',
1929 (changedAttr & FILE_ATTRIBUTE_SYSTEM) ?
'S' :
'-');
1936 len = _snprintf(dFoundFileLine, nFoundFileLine,
"%s%s%s",
1938 if ( len < 0 || len == nFoundFileLine )
1940 nFoundFileLine = strlen(treeData->
fileTime) + strlen(treeData->
fileAttr) + nFoundFile + 1;
1941 dFoundFileLine = (
char *)LocalAlloc(LPTR, nFoundFileLine);
1943 if ( dFoundFileLine == NULL )
1946 if ( nFoundFile !=
sizeof(treeData->
foundFile) )
1948 LocalFree(dFoundFile);
1953 _snprintf(dFoundFileLine, nFoundFileLine,
"%s%s%s", treeData->
fileTime, treeData->
fileAttr, dFoundFile);
1960 c->SetStemArrayElement(treeData->
files, treeData->
count, t);
1961 c->ReleaseLocalReference(t);
1963 if ( nFoundFile !=
sizeof(treeData->
foundFile) )
1965 LocalFree(dFoundFile);
1969 LocalFree(dFoundFileLine);
2032 WIN32_FIND_DATA wfd;
2035 char *dTmpFileName = tmpFileName;
2040 len = _snprintf(dTmpFileName, nTmpFileName,
"%s%s", path, treeData->
dFNameSpec);
2041 if ( len < 0 || len == nTmpFileName )
2043 nTmpFileName = strlen(path) + strlen(treeData->
dFNameSpec) + 1;
2044 dTmpFileName = (
char *)LocalAlloc(LPTR, nTmpFileName);
2045 if ( dTmpFileName == NULL )
2052 _snprintf(dTmpFileName, nTmpFileName,
"%s%s", path, treeData->
dFNameSpec);
2055 fHandle = FindFirstFile(dTmpFileName, &wfd);
2056 if ( fHandle != INVALID_HANDLE_VALUE )
2061 if ( strcmp(wfd.cFileName,
".") == 0 || strcmp(wfd.cFileName,
"..") == 0 )
2066 if (
sameAttr(targetMask, wfd.dwFileAttributes, options) )
2068 if ( !
formatFile(c, path, treeData, newMask, options, &wfd) )
2075 }
while ( FindNextFile(fHandle, &wfd) );
2084 sprintf(dTmpFileName,
"%s*", path);
2086 fHandle = FindFirstFile(dTmpFileName, &wfd);
2087 if ( fHandle != INVALID_HANDLE_VALUE )
2092 if ( ! (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ||
2093 strcmp(wfd.cFileName,
".") == 0 || strcmp(wfd.cFileName,
"..") == 0 )
2099 len = _snprintf(dTmpFileName, nTmpFileName,
"%s%s\\", path, wfd.cFileName);
2100 if ( len < 0 || len == nTmpFileName )
2106 LocalFree(dTmpFileName);
2109 nTmpFileName = strlen(path) + strlen(wfd.cFileName) + 2;
2110 dTmpFileName = (
char *)LocalAlloc(LPTR, nTmpFileName);
2111 if ( dTmpFileName == NULL )
2120 _snprintf(dTmpFileName, nTmpFileName,
"%s%s\\", path, wfd.cFileName);
2124 if ( !
recursiveFindFile(c, tmpFileName, treeData, targetMask, newMask, options) )
2131 while (FindNextFile(fHandle, &wfd));
2181 while ( fSpec[i] ==
' ' )
2188 size_t len = strlen(fSpec);
2192 if ( fSpec[i] ==
'\\' || fSpec[i] ==
'/' )
2196 else if ( fSpec[i] ==
'.' )
2200 if ( fSpec[i + 1] ==
'\\' || fSpec[i + 1] ==
'/' )
2204 else if ( i + 2 < len )
2206 if ( fSpec[i + 1] ==
'.' &&
2207 (fSpec[i + 2] ==
'\\' || fSpec[i + 2] ==
'/') )
2214 else if ( i + 1 < len && fSpec[i + 1] ==
':' )
2220 if ( strcmp(fSpec,
".") == 0 )
2223 strcpy(fSpec,
"*.*");
2225 else if ( strcmp(fSpec,
"..") == 0 )
2228 strcpy(fSpec,
"..\\*.*");
2236 size_t pathLen = *pPathLen;
2237 char *path = *pPath;
2241 uint32_t ret = GetCurrentDirectory(0, 0);
2251 path = (
char *)LocalAlloc(LPTR, ret);
2264 ret = GetCurrentDirectory(ret, path);
2279 bool result =
false;
2282 if ( fSpec[1] ==
':' )
2285 ret = GetCurrentDirectory(0, 0);
2292 buf = (
char *)LocalAlloc(LPTR, ret);
2299 ret = GetCurrentDirectory(ret, buf);
2308 memcpy(drv, fSpec, 2);
2312 SetCurrentDirectory(drv);
2315 SetCurrentDirectory(buf);
2338 char *path = *pPath;
2339 if ( path[strlen(path) - 1] !=
'\\' )
2382 char *path = *pPath;
2383 size_t pathLen = *pPathLen;
2387 if (fSpec[1] ==
':')
2389 l = lastSlashPos + 1;
2390 memcpy(path, fSpec, l);
2395 char fpath[MAX_PATH];
2396 char drive[_MAX_DRIVE];
2398 char fname[_MAX_FNAME];
2405 char *dFPath = fpath;
2406 size_t nFPath = MAX_PATH;
2408 if ( lastSlashPos == 0 )
2411 _fullpath(dFPath,
"\\", nFPath);
2413 l = strlen(dFPath) + strlen(&fSpec[1]) + 1;
2422 strcat(dFPath, &fSpec[1]);
2428 fSpec[lastSlashPos] =
'\0';
2429 if ( _fullpath(dFPath, fSpec, nFPath) == NULL )
2441 if ( nFPath != MAX_PATH )
2446 fSpec[lastSlashPos] =
'\\';
2449 }
while ( _fullpath(dFPath, fSpec, nFPath) == NULL );
2452 fSpec[lastSlashPos] =
'\\';
2454 lastChar = dFPath[strlen(dFPath) - 1];
2455 if (lastChar !=
'\\' && lastChar !=
'/')
2457 l = strlen(dFPath) + strlen(&fSpec[lastSlashPos]) + 1;
2463 if ( nFPath != MAX_PATH )
2471 strcat(dFPath, &fSpec[lastSlashPos]);
2475 _splitpath(dFPath, drive, dir, fname, ext);
2477 l = strlen(drive) + strlen(dir) + 1;
2487 *pPathLen = pathLen;
2490 strcpy(path, drive);
2497 if ( strlen(path) == 0 )
2499 memcpy(path, fSpec, lastSlashPos + 1);
2500 path[lastSlashPos + 1] =
'\0';
2505 if (path[strlen(path) - 1] !=
'\\')
2545 len = strlen(fSpec);
2548 lastSlashPos = (int)len;
2551 while ( fSpec[lastSlashPos] !=
'\\' && fSpec[lastSlashPos] !=
'/' && lastSlashPos >= 0 )
2558 if ( lastSlashPos < 0 )
2574 if ( fSpec[lastSlashPos + 1] !=
'\0' )
2578 strcpy(filename, &fSpec[lastSlashPos + 1]);
2584 strcpy(filename,
"*.*");
2608 switch( toupper(*opts) )
2685 else if ( *msk ==
'-' )
2689 else if (*msk ==
'*')
2722 if ( strlen(msk) > 5 )
2728 if ( !
goodMask(context, msk, mask) )
2761 if ( strlen(opts) == 0 )
2767 if ( !
goodOpts(context, opts, options) )
2825 size_t *fSpecBufLen,
size_t argPos)
2827 size_t len = strlen(fSpec);
2835 if ( fileSpec == NULL )
2843 memcpy(fileSpec, fSpec, len);
2845 if ( fileSpec[len - 1] ==
'\\' )
2847 strcat(fileSpec,
"*.*");
2849 else if ( fileSpec[len - 1] ==
'.')
2852 (len > 1 && (fileSpec[len - 2] ==
'\\' || fileSpec[len - 2] ==
'.')) )
2854 strcat(fileSpec,
"\\*.*");
2894 size_t bufLen =
MAX;
2903 char *path = (
char *)LocalAlloc(LPTR, bufLen);
2932 static char illegal[] =
"<>|\"";
2934 for (
size_t i = 0; i < 4; i++ )
2936 if ( strchr(fSpec, illegal[i]) != NULL )
2942 char *pos = strchr(fSpec,
':');
2945 if ( ((
int32_t)(pos - fSpec + 1)) != 2 )
2949 if ( strchr(pos + 1,
':') != NULL )
3007 OPTIONAL_CSTRING, targetAttr, OPTIONAL_CSTRING,
newAttr)
3010 char *fileSpec = NULL;
3011 size_t fSpecLen = 0;
3012 size_t fSpecBufLen = 0;
3017 context->SetStemArrayElement(files, 0, context->WholeNumber(0));
3019 treeData.
files = files;
3024 if ( fileSpec == NULL )
3031 result = ERROR_INVALID_NAME;
3061 if ( !
getMaskFromArg(context, (
char *)targetAttr, targetMask, 4) )
3079 if (
recursiveFindFile(context, path, &treeData, targetMask, newMask, options) )
3081 context->SetStemArrayElement(treeData.
files, 0, context->WholeNumber(treeData.
count));
3119 if (!_stricmp(args[0].strptr,
"NOECHO"))
3121 else if (_stricmp(args[0].strptr,
"ECHO"))
3132 if ((tmp == 0x00) || (tmp == 0xe0)) {
3142 wsprintf(retstr->
strptr,
"%c", tmp);
3192 bool WildCard =
false;
3196 bool terminate =
true;
3203 const char *Key =
"";
3210 const char *IniFile = args[0].
strptr;
3212 IniFile =
"WIN.INI";
3213 const char *App = args[1].
strptr;
3215 if (numargs >= 3 && args[2].strptr)
3218 const char *Val = NULL;
3223 if (!_stricmp(App,
"ALL:"))
3235 else if (!_stricmp(Key,
"ALL:"))
3252 if (WildCard ==
true)
3265 char *returnVal = NULL;
3267 if ((numargs == 3 && _stricmp(Key,
"DELETE:")) ||
3270 lSize = 0x0000ffffL;
3272 returnVal = (
char *)GlobalAlloc(GPTR, lSize);
3273 if (returnVal == NULL)
3279 if (WildCard && QueryApps)
3282 lSize = GetPrivateProfileString(NULL, NULL,
"", returnVal, (DWORD)lSize, IniFile);
3283 else if (WildCard && !QueryApps)
3286 lSize = GetPrivateProfileString(App, NULL,
"", returnVal, (DWORD)lSize, IniFile);
3289 lSize = GetPrivateProfileString(App, Key,
"", returnVal, (DWORD)lSize, IniFile);
3296 else if (WildCard ==
false)
3298 if (lSize > buffersize)
3299 retstr->
strptr = (PCH)GlobalAlloc(GMEM_FIXED, lSize);
3300 if (retstr->
strptr == NULL)
3302 GlobalFree(returnVal);
3306 memcpy(retstr->
strptr, returnVal, lSize);
3313 if (!_stricmp(Key,
"DELETE:") || (numargs == 2) || !
RXVALIDSTRING(args[2]))
3316 Error = !WritePrivateProfileString(App, NULL, NULL, IniFile);
3317 else if (!_stricmp(Val,
"DELETE:") ||
3320 Error = !WritePrivateProfileString(App, Key, NULL, IniFile);
3325 Error = !WritePrivateProfileString(App, Key, Val, IniFile);
3342 if (WildCard ==
true)
3356 const char *next = &returnVal[x];
3364 strcpy(ldp.
ibuf, next);
3382 if (returnVal != NULL)
3384 GlobalFree(returnVal);
3391 while (returnVal[x] !=
'\0');
3397 if (returnVal != NULL)
3399 GlobalFree(returnVal);
3420 if (returnVal != NULL)
3422 GlobalFree(returnVal);
3460 return CreateDirectory(dir, NULL) != 0 ? 0 : GetLastError();
3487 errnum = atoi(args[0].strptr);
3488 if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM,NULL,errnum,0,(LPSTR)&errmsg,64,NULL) == 0)
3490 retstr->
strptr[0] = 0x00;
3494 length = strlen(errmsg);
3497 if (length >= 1 && errmsg[length - 1] == 0x0a)
3499 errmsg[length - 1] = 0x00;
3502 if (length >= 1 && errmsg[length - 1] == 0x0d)
3504 errmsg[length - 1] = 0x00;
3510 retstr->
strptr = (PCH)GlobalAlloc(GMEM_ZEROINIT | GMEM_FIXED, strlen(errmsg+1));
3512 strcpy(retstr->
strptr,errmsg);
3542 rc = EncryptFile(args[0].strptr);
3545 sprintf(retstr->
strptr,
"%d", 0);
3549 sprintf(retstr->
strptr,
"%d", GetLastError());
3576 rc = DecryptFile(args[0].strptr,0);
3579 sprintf(retstr->
strptr,
"%d", 0);
3581 sprintf(retstr->
strptr,
"%d", GetLastError());
3606 #define STATUS_SUCCESS (0x00000000)
3607 typedef LONG NTSTATUS;
3608 typedef NTSTATUS (WINAPI* RtlGetVersionPtr)(PRTL_OSVERSIONINFOW);
3610 HMODULE hMod = ::GetModuleHandleW(L
"ntdll.dll");
3613 RtlGetVersionPtr fxPtr = (RtlGetVersionPtr)::GetProcAddress(hMod,
"RtlGetVersion");
3616 RTL_OSVERSIONINFOW rovi;
3617 rovi.dwOSVersionInfoSize =
sizeof(rovi);
3623 wsprintf(retstr->
strptr,
"Windows %d.%d.%d",
3624 rovi.dwMajorVersion, rovi.dwMinorVersion, rovi.dwBuildNumber);
3633 wsprintf(retstr->
strptr,
"");
3651 return SysWinVer(name, numargs, args, queuename, retstr);
3668 return RemoveDirectory(dir) != 0 ? 0 : GetLastError();
3690 char szFullPath[_MAX_PATH];
3691 char szCurDir[_MAX_PATH];
3692 char *szEnvStr = NULL;
3694 LPTSTR pszOnlyFileName;
3695 LPTSTR lpPath = NULL;
3699 if (numargs < 2 || numargs > 3 ||
3709 opt = toupper(args[2].strptr[0]);
3710 if (opt !=
'C' && opt !=
'N')
3716 szEnvStr = (LPTSTR) malloc(
sizeof(
char) *
MAX_ENVVAR);
3717 if (szEnvStr != NULL)
3719 DWORD charCount = GetEnvironmentVariable(args[0].strptr, szEnvStr,
MAX_ENVVAR);
3726 szEnvStr = (LPTSTR) realloc(szEnvStr,
sizeof(
char) * charCount);
3727 if (szEnvStr != NULL)
3729 DWORD charCount2 = GetEnvironmentVariable(args[0].strptr, szEnvStr, charCount);
3730 if (charCount2 == 0 || charCount2 > charCount)
3740 lpPath = (szEnvStr == NULL) ? NULL : strdup(szEnvStr);
3742 else if (opt ==
'C')
3745 DWORD charCount = GetCurrentDirectory(_MAX_PATH, szCurDir);
3746 if (charCount == 0 || charCount > _MAX_PATH)
3751 if (szEnvStr != NULL)
3753 lpPath = (LPTSTR) malloc(
sizeof(
char) * (strlen(szCurDir) + 1 + strlen(szEnvStr) + 1));
3756 strcpy(lpPath, szCurDir);
3757 strcat(lpPath,
";");
3758 strcat(lpPath, szEnvStr);
3763 lpPath = strdup(szCurDir);
3769 DWORD charCount = 0;
3772 errorMode = SetErrorMode(SEM_FAILCRITICALERRORS);
3775 (LPCTSTR)args[1].strptr,
3780 SetErrorMode(errorMode);
3782 if (charCount == 0 || charCount > _MAX_PATH)
3808 if (context->ObjectToDouble(delay, &seconds) == 0 ||
3809 isnan(seconds) || seconds == HUGE_VAL || seconds == -HUGE_VAL)
3818 if (seconds < 0.0 || seconds > 2147483.0)
3822 context->ArrayOfFive(context->String(
"positional"), context->String(
"delay"),
3823 context->String(
"0"), context->String(
"2147483"), delay));
3828 LONG milliseconds = (LONG) (seconds * 1000);
3835 if ( milliseconds > 333 )
3837 if ( !(SetTimer(NULL, 0, milliseconds, (TIMERPROC)
SleepTimerProc)) )
3841 context->String(
"System resources exhausted: cannot start timer"));
3846 while ( GetMessage (&msg, NULL, 0, 0) )
3850 TranslateMessage( &msg );
3851 DispatchMessage ( &msg );
3856 Sleep(milliseconds);
3877 KillTimer(NULL, idEvent);
3878 ThreadId = GetCurrentThreadId();
3879 PostThreadMessage(ThreadId,
OM_WAKEUP, 0 , 0L);
3905 args[0].strlength > 512)
3911 if (args[1].strlength != 1)
3913 filler = args[1].
strptr[0];
3943 int lPos,lPosOffSet;
3945 int lBufferLen = 16000;
3949 DWORD dwCharsRead,dwSumCharsRead;
3951 CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
3953 hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
3955 if (!GetConsoleScreenBufferInfo(hStdout, &csbiInfo))
3957 context->InvalidRoutine();
3963 len = csbiInfo.dwSize.Y * csbiInfo.dwSize.X;
3966 coordLine.X = (short)col;
3967 coordLine.Y = (short)row;
3972 if (len >
sizeof(buffer))
3975 ptr = (
char *)malloc(len);
3978 context->InvalidRoutine();
3983 if (len < lBufferLen)
3989 lPosOffSet = row * csbiInfo.dwSize.X + col;
3995 if (!ReadConsoleOutputCharacter(hStdout, &ptr[lPos], lBufferLen, coordLine, &dwCharsRead))
3997 if (ptr != buffer) {
4000 context->InvalidRoutine();
4005 lPos = lPos + lBufferLen;
4006 coordLine.Y = (short)((lPos + lPosOffSet) / csbiInfo.dwSize.X);
4007 coordLine.X = (short)((lPos + lPosOffSet) % csbiInfo.dwSize.X);
4008 dwSumCharsRead = dwSumCharsRead + dwCharsRead;
4012 if (ptr != buffer) {
4036 OPTIONAL_CSTRING, optionString,
4037 OPTIONAL_stringsize_t, rows, OPTIONAL_stringsize_t, columns,
4038 OPTIONAL_stringsize_t, rows2, OPTIONAL_stringsize_t, columns2)
4041 typedef enum { BUFFERSIZE, WINDOWRECT, MAXWINDOWSIZE } console_option;
4042 console_option option;
4043 if (optionString == NULL || stricmp(optionString,
"BUFFERSIZE") == 0)
4045 option = BUFFERSIZE;
4047 else if (stricmp(optionString,
"WINDOWRECT") == 0)
4049 option = WINDOWRECT;
4051 else if (stricmp(optionString,
"MAXWINDOWSIZE") == 0)
4053 option = MAXWINDOWSIZE;
4057 context->InvalidRoutine();
4069 else if (exists23 && omitted45)
4079 context->InvalidRoutine();
4084 if (!(setArgs == 0 ||
4085 (setArgs == 2 && rows <= SHRT_MAX && columns <= SHRT_MAX) ||
4086 (setArgs == 4 && rows <= SHRT_MAX && columns <= SHRT_MAX && rows2 <= SHRT_MAX && columns2 <= SHRT_MAX)))
4088 context->InvalidRoutine();
4093 CONSOLE_SCREEN_BUFFER_INFO csbi;
4096 HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
4101 if (GetConsoleScreenBufferInfo(hStdout, &csbi) == NULL)
4104 return context->NewStringFromAsciiz(option == WINDOWRECT ?
"0 0 0 0" :
"0 0");
4108 if (option == BUFFERSIZE && setArgs == 0)
4111 sprintf(buffer,
"%d %d", csbi.dwSize.Y, csbi.dwSize.X);
4113 else if (option == WINDOWRECT && setArgs == 0)
4116 sprintf(buffer,
"%d %d %d %d", csbi.srWindow.Top, csbi.srWindow.Left, csbi.srWindow.Bottom, csbi.srWindow.Right);
4118 else if (option == MAXWINDOWSIZE && setArgs == 0)
4121 sprintf(buffer,
"%d %d", csbi.dwMaximumWindowSize.Y, csbi.dwMaximumWindowSize.X);
4123 else if (option == BUFFERSIZE && setArgs == 2)
4126 COORD consoleBuffer;
4127 consoleBuffer.Y = (SHORT)rows;
4128 consoleBuffer.X = (SHORT)columns;
4129 BOOL code = SetConsoleScreenBufferSize(hStdout, consoleBuffer);
4130 sprintf(buffer,
"%d", code == 0 ? GetLastError() : 0);
4132 else if (option == WINDOWRECT && setArgs == 4)
4135 SMALL_RECT consoleWindow;
4136 consoleWindow.Top = (SHORT)rows;
4137 consoleWindow.Left = (SHORT)columns;
4138 consoleWindow.Bottom = (SHORT)rows2;
4139 consoleWindow.Right = (SHORT)columns2;
4140 BOOL code = SetConsoleWindowInfo(hStdout, 1, &consoleWindow);
4141 sprintf(buffer,
"%d", code == 0 ? GetLastError() : 0);
4145 context->InvalidRoutine();
4150 return context->NewStringFromAsciiz(buffer);
4177 PROCESS_INFORMATION procInfo;
4192 ULONG show_flags[] =
4206 if ( numargs < 1 || numargs > 2 || !
RXVALIDSTRING(args[0]) ||
4213 if ( numargs < 2 || args[1].strptr == NULL )
4215 CmdShow = SW_SHOWNORMAL;
4221 for ( index = 0; index <
sizeof(show_styles)/
sizeof(PSZ); index++ )
4223 if ( length == strlen(show_styles[index]) && memicmp(args[1].strptr, show_styles[index], length) == 0 )
4225 CmdShow = show_flags[index];
4230 if ( index ==
sizeof(show_styles)/
sizeof(PSZ) )
4237 ZeroMemory(&procInfo,
sizeof(procInfo));
4238 ZeroMemory(&si,
sizeof(si));
4240 si.dwFlags = STARTF_USESHOWWINDOW;
4241 si.wShowWindow = (WORD)CmdShow;
4243 if ( CreateProcess(NULL, (LPSTR)args[0].
strptr, NULL, NULL, FALSE, 0, NULL,
4244 NULL, &si, &procInfo ) )
4246 pid = procInfo.dwProcessId;
4250 pid = GetLastError();
4254 pid = (ULONG)-((
int)pid);
4259 sprintf(retstr->
strptr,
"%d", pid);
4263 CloseHandle(procInfo.hProcess);
4264 CloseHandle(procInfo.hThread);
4302 context->InvalidRoutine();
4338 context->InvalidRoutine();
4371 unsigned short position;
4449 if (GetSystemDirectory(retstr->
strptr, 255) > 0)
4451 retstr->
strptr[2] =
'\0';
4475 if (GetSystemDirectory(retstr->
strptr, 255) > 0)
4501 CHAR chDriveLetter[4];
4505 if (numargs > 1 || ((numargs == 1) &&
4506 (args[0].strlength > 2 ||
4507 args[0].strlength == 0)))
4511 if ((numargs == 1) && (strlen(args[0].strptr) == 2 && args[0].strptr[1] !=
':'))
4516 if (args[0].strlength == 1)
4518 chDriveLetter[0]=args[0].
strptr[0];
4519 chDriveLetter[1]=
':';
4520 chDriveLetter[2]=
'\\';
4521 chDriveLetter[3]=
'\0';
4525 strcpy(chDriveLetter, args[0].strptr);
4526 chDriveLetter[2]=
'\\';
4527 chDriveLetter[3]=
'\0';
4529 drive = chDriveLetter;
4530 }
else drive = NULL;
4532 errorMode = SetErrorMode(SEM_FAILCRITICALERRORS);
4534 if (GetVolumeInformation(
4548 SetErrorMode(errorMode);
4567 CHAR chDriveLetter[4];
4570 if (numargs > 1 || ((numargs == 1) &&
4571 (args[0].strlength > 2 ||
4572 args[0].strlength == 0)))
4576 if ((numargs == 1) && (strlen(args[0].strptr) == 2 && args[0].strptr[1] !=
':'))
4581 if (args[0].strlength == 1)
4583 chDriveLetter[0]=args[0].
strptr[0];
4584 chDriveLetter[1]=
':';
4585 chDriveLetter[2]=
'\\';
4586 chDriveLetter[3]=
'\0';
4590 strcpy(chDriveLetter, args[0].strptr);
4591 chDriveLetter[2]=
'\\';
4592 chDriveLetter[3]=
'\0';
4594 drive = chDriveLetter;
4595 }
else drive = NULL;
4597 if (GetVolumeInformation(
4630 SECURITY_ATTRIBUTES sa={
sizeof(SECURITY_ATTRIBUTES), NULL,
true};
4636 handle = CreateMutex(&sa,
false, name);
4640 handle = OpenMutex(MUTEX_ALL_ACCESS,
true, name);
4645 handle = CreateMutex(&sa,
false, NULL);
4648 if (handle == NULL) {
4649 return context->NullString();
4652 return context->Uintptr((
uintptr_t)handle);
4668 SECURITY_ATTRIBUTES sa={
sizeof(SECURITY_ATTRIBUTES), NULL,
true};
4671 return (
uintptr_t) OpenMutex(MUTEX_ALL_ACCESS,
true, name);
4686 return !ReleaseMutex((HANDLE)h) ? GetLastError() : 0;
4701 return !ReleaseMutex((HANDLE)h) ? GetLastError() : 0;
4720 int rc = WaitForSingleObject((HANDLE)h, timeout);
4721 if (rc == WAIT_FAILED)
4723 return GetLastError();
4747 SECURITY_ATTRIBUTES sa={
sizeof(SECURITY_ATTRIBUTES), NULL,
true};
4763 handle = CreateEvent(&sa, manual,
false, name);
4767 handle = OpenEvent(EVENT_ALL_ACCESS,
true, name);
4772 handle = CreateEvent(&sa, manual,
false, NULL);
4775 if (handle == NULL) {
4776 return context->NullString();
4779 return context->Uintptr((
uintptr_t)handle);
4794 SECURITY_ATTRIBUTES sa={
sizeof(SECURITY_ATTRIBUTES), NULL,
true};
4797 return (
uintptr_t)OpenEvent(EVENT_ALL_ACCESS,
true, name);
4812 return !SetEvent((HANDLE)h) ? GetLastError() : 0;
4827 return !ResetEvent((HANDLE)h) ? GetLastError() : 0;
4843 return !PulseEvent((HANDLE)h) ? GetLastError() : 0;
4859 return !CloseHandle((HANDLE)h) ? GetLastError() : 0;
4879 int rc = WaitForSingleObject((HANDLE)h, timeout);
4880 if (rc == WAIT_FAILED)
4882 return GetLastError();
4903 HANDLE process = GetCurrentProcess();
4904 HANDLE thread = GetCurrentThread();
4908 if (context->WholeNumber(classArg, &classLevel))
4912 case 0: iclass = IDLE_PRIORITY_CLASS;
4914 case 1: iclass = NORMAL_PRIORITY_CLASS;
4916 case 2: iclass = HIGH_PRIORITY_CLASS;
4918 case 3: iclass = REALTIME_PRIORITY_CLASS;
4920 context->InvalidRoutine();
4926 const char *classStr = context->ObjectToStringValue(classArg);
4928 if (stricmp(classStr,
"REALTIME") == 0)
4930 iclass = REALTIME_PRIORITY_CLASS;
4932 else if (stricmp(classStr,
"HIGH") == 0)
4934 iclass = HIGH_PRIORITY_CLASS;
4936 else if (!stricmp(classStr,
"NORMAL") == 0)
4938 iclass = NORMAL_PRIORITY_CLASS;
4940 else if (stricmp(classStr,
"IDLE") == 0)
4942 iclass = IDLE_PRIORITY_CLASS;
4946 context->InvalidRoutine();
4953 if (context->WholeNumber(levelArg, &level))
4955 if (level < -15 || level > 15)
4957 context->InvalidRoutine();
4963 const char *levelStr = context->ObjectToStringValue(levelArg);
4965 if (stricmp(levelStr,
"ABOVE_NORMAL") == 0)
4967 level = THREAD_PRIORITY_ABOVE_NORMAL;
4969 else if (stricmp(levelStr,
"BELOW_NORMAL") == 0)
4971 level = THREAD_PRIORITY_BELOW_NORMAL;
4973 else if (stricmp(levelStr,
"HIGHEST") == 0)
4975 level = THREAD_PRIORITY_HIGHEST;
4977 else if (stricmp(levelStr,
"LOWEST") == 0)
4979 level = THREAD_PRIORITY_LOWEST;
4981 else if (stricmp(levelStr,
"NORMAL") == 0)
4983 level = THREAD_PRIORITY_NORMAL;
4985 else if (stricmp(levelStr,
"IDLE") == 0)
4987 level = THREAD_PRIORITY_IDLE;
4989 else if (stricmp(levelStr,
"TIME_CRITICAL") == 0)
4991 level = THREAD_PRIORITY_TIME_CRITICAL;
4995 context->InvalidRoutine();
5000 int rc = SetPriorityClass(process, iclass);
5003 rc = SetThreadPriority(thread, (
int)level);
5006 return rc != 0 ? 0 : GetLastError();
5023 if (option == NULL || stricmp(option,
"PID") == 0)
5025 return context->WholeNumber(GetCurrentProcessId());
5027 if (stricmp(option,
"TID") == 0)
5029 return context->WholeNumber(GetCurrentThreadId());
5031 if (stricmp(option,
"PPRIO") == 0)
5034 p = GetPriorityClass(GetCurrentProcess());
5038 case HIGH_PRIORITY_CLASS:
5039 return context->String(
"HIGH");
5040 case IDLE_PRIORITY_CLASS:
5041 return context->String(
"IDLE");
5042 case NORMAL_PRIORITY_CLASS:
5043 return context->String(
"NORMAL");
5044 case REALTIME_PRIORITY_CLASS:
5045 return context->String(
"REALTIME");
5047 return context->String(
"UNKNOWN");
5050 if (stricmp(option,
"TPRIO") == 0)
5053 p = GetThreadPriority(GetCurrentThread());
5057 case THREAD_PRIORITY_ABOVE_NORMAL:
5058 return context->String(
"ABOVE_NORMAL");
5059 case THREAD_PRIORITY_BELOW_NORMAL:
5060 return context->String(
"BELOW_NORMAL");
5061 case THREAD_PRIORITY_HIGHEST:
5062 return context->String(
"HIGHEST");
5063 case THREAD_PRIORITY_IDLE:
5064 return context->String(
"IDLE");
5065 case THREAD_PRIORITY_LOWEST:
5066 return context->String(
"LOWEST");
5068 case THREAD_PRIORITY_NORMAL:
5069 return context->String(
"NORMAL");
5071 case THREAD_PRIORITY_TIME_CRITICAL:
5072 return context->String(
"TIME_CRITICAL");
5074 return context->String(
"UNKNOWN");
5077 if (stricmp(option,
"PTIME") == 0 || stricmp(option,
"TTIME") == 0)
5079 FILETIME createT, kernelT, userT, dummy;
5080 SYSTEMTIME createST, kernelST, userST;
5083 if (*option ==
'T' || *option ==
't')
5085 ok = GetThreadTimes(GetCurrentThread(), &createT,&dummy,&kernelT, &userT);
5089 ok = GetProcessTimes(GetCurrentProcess(), &createT,&dummy,&kernelT, &userT);
5094 FileTimeToLocalFileTime(&createT, &createT);
5095 FileTimeToSystemTime(&createT, &createST);
5096 FileTimeToSystemTime(&kernelT, &kernelST);
5097 FileTimeToSystemTime(&userT, &userST);
5101 wsprintf(buffer,
"Create: %4.4d/%2.2d/%2.2d %d:%2.2d:%2.2d:%3.3d "\
5102 "Kernel: %d:%2.2d:%2.2d:%3.3d User: %d:%2.2d:%2.2d:%3.3d",
5103 createST.wYear,createST.wMonth,createST.wDay,createST.wHour,createST.wMinute,
5104 createST.wSecond,createST.wMilliseconds,
5105 kernelST.wHour,kernelST.wMinute,kernelST.wSecond,kernelST.wMilliseconds,
5106 userST.wHour,userST.wMinute,userST.wSecond,userST.wMilliseconds);
5108 return context->String(buffer);
5111 context->InvalidRoutine();
5157 RexxRoutine5(
uint32_t, SysShutDownSystem, OPTIONAL_CSTRING, computer, OPTIONAL_CSTRING, message, OPTIONAL_uint32_t, timeout,
5158 OPTIONAL_logical_t, forceAppsClosed, OPTIONAL_logical_t, reboot)
5162 HANDLE hToken = NULL;
5163 TOKEN_PRIVILEGES tkp;
5167 if ( OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken) == 0 )
5169 result = GetLastError();
5175 LPCTSTR privilegeName = (computer == NULL || *computer ==
'\0') ? SE_SHUTDOWN_NAME : SE_REMOTE_SHUTDOWN_NAME;
5176 if ( LookupPrivilegeValue(NULL, privilegeName, &tkp.Privileges[0].Luid) == 0 )
5178 result = GetLastError();
5183 tkp.PrivilegeCount = 1;
5184 tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
5189 AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, NULL, 0);
5190 result = GetLastError();
5191 if ( result != ERROR_SUCCESS )
5203 if ( InitiateSystemShutdown((LPSTR)computer, (LPSTR)message, timeout, (BOOL)forceAppsClosed, (BOOL)reboot) == 0 )
5205 result = GetLastError();
5209 tkp.Privileges[0].Attributes = 0;
5210 AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, NULL, 0);
5213 if ( hToken != NULL )
5215 CloseHandle(hToken);
5232 HWND hwnd = FindWindow(NULL, name);
5236 if (!SetForegroundWindow(hwnd))
5238 return GetLastError();
5266 timeout = NMPWAIT_USE_DEFAULT_WAIT;
5272 context->InvalidRoutine();
5277 timeout = NMPWAIT_USE_DEFAULT_WAIT;
5279 else if (timeout == -1)
5281 timeout = NMPWAIT_WAIT_FOREVER;
5285 if (WaitNamedPipe(name, timeout))
5291 return GetLastError();
5312 HANDLE outFile = NULL;
5313 bool fCloseFile =
false;
5314 DWORD dwBytesWritten = 0;
5315 char *buffer = NULL;
5316 char *current, *end;
5317 size_t buffer_size = 10240;
5320 if ( (numargs > 1) ||
5327 outFile = CreateFile(args[0].strptr, GENERIC_WRITE | GENERIC_READ,
5328 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL |
5329 FILE_FLAG_WRITE_THROUGH, NULL);
5335 SetFilePointer(outFile, 0, 0, FILE_END);
5339 outFile = GetStdHandle(STD_OUTPUT_HANDLE);
5344 buffer = (
char*) calloc(buffer_size,1);
5348 end = current + buffer_size;
5370 if (current + new_size >= end) {
5371 size_t offset = current - buffer;
5374 if (buffer_size - offset < new_size) {
5375 buffer_size = new_size + offset;
5377 buffer = (
char *)realloc(buffer,buffer_size);
5378 current = buffer + offset;
5379 end = buffer + buffer_size;
5381 sprintf(current,
"Name=");
5384 current += shvb.
shvname.strlength;
5385 sprintf(current,
", Value='");
5389 sprintf(current,
"'\r\n");
5402 WriteFile(outFile, buffer, (DWORD)(current - buffer), &dwBytesWritten, NULL);
5406 CloseHandle(outFile);
5432 FILETIME sLocalFileTime;
5433 SYSTEMTIME sLocalSysTime;
5436 HANDLE setFile = CreateFile(name, GENERIC_WRITE | GENERIC_READ,
5437 FILE_SHARE_READ | FILE_SHARE_WRITE,
5438 NULL, OPEN_EXISTING, FILE_FLAG_WRITE_THROUGH |
5439 FILE_FLAG_BACKUP_SEMANTICS, NULL);
5440 if (setFile && (setFile != INVALID_HANDLE_VALUE))
5442 fOk = GetFileTime(setFile, NULL, NULL, &sFileTime);
5443 fOk &= FileTimeToLocalFileTime(&sFileTime, &sLocalFileTime);
5444 fOk &= FileTimeToSystemTime(&sLocalFileTime, &sLocalSysTime);
5448 if (newdate != NULL)
5451 if (sscanf(newdate,
"%4hu-%2hu-%2hu", &sLocalSysTime.wYear,
5452 &sLocalSysTime.wMonth, &sLocalSysTime.wDay) != 3)
5457 if (sLocalSysTime.wYear < 1800)
5463 if (newtime != NULL)
5466 if (sscanf(newtime,
"%2hu:%2hu:%2hu", &sLocalSysTime.wHour,
5467 &sLocalSysTime.wMinute, &sLocalSysTime.wSecond) != 3)
5473 if (newdate == NULL && newtime == NULL)
5476 GetLocalTime(&sLocalSysTime);
5481 fOk &= SystemTimeToFileTime(&sLocalSysTime, &sLocalFileTime);
5482 fOk &= LocalFileTimeToFileTime(&sLocalFileTime, &sFileTime);
5483 fOk &= SetFileTime(setFile, NULL, NULL, &sFileTime);
5487 CloseHandle(setFile);
5507 FILETIME sLocalFileTime;
5508 FILETIME *psFileCreated = NULL;
5509 FILETIME *psFileAccessed = NULL;
5510 FILETIME *psFileWritten = NULL;
5511 SYSTEMTIME sLocalSysTime;
5513 if (selector != NULL)
5515 switch (selector[0])
5519 psFileCreated = &sFileTime;
5523 psFileAccessed = &sFileTime;
5527 psFileWritten = &sFileTime;
5530 context->InvalidRoutine();
5536 psFileWritten = &sFileTime;
5540 HANDLE setFile = CreateFile(name, FILE_READ_ATTRIBUTES,
5541 FILE_SHARE_READ | FILE_SHARE_WRITE,
5542 NULL, OPEN_EXISTING, FILE_FLAG_WRITE_THROUGH |
5543 FILE_FLAG_BACKUP_SEMANTICS, NULL);
5544 if (setFile != INVALID_HANDLE_VALUE)
5546 BOOL fOk = GetFileTime(setFile, psFileCreated, psFileAccessed, psFileWritten);
5547 CloseHandle(setFile);
5548 fOk &= FileTimeToLocalFileTime(&sFileTime, &sLocalFileTime);
5549 fOk &= FileTimeToSystemTime(&sLocalFileTime, &sLocalSysTime);
5554 sprintf(buffer,
"%4d-%02d-%02d %02d:%02d:%02d",
5555 sLocalSysTime.wYear,
5556 sLocalSysTime.wMonth,
5558 sLocalSysTime.wHour,
5559 sLocalSysTime.wMinute,
5560 sLocalSysTime.wSecond);
5561 return context->String(buffer);
5564 return context->WholeNumber(-1);
5570 size_t start,
size_t end,
size_t firstcol,
size_t lastcol);
5595 size_t firstCol = 0;
5601 if ( (numargs < 1) || (numargs > 7) || !
RXVALIDSTRING(args[0]) )
5607 memset(stemName, 0,
sizeof(stemName));
5608 strcpy(stemName, args[0].strptr);
5609 if ( stemName[args[0].strlength-1] !=
'.' )
5617 switch ( args[1].strptr[0] )
5634 switch ( args[2].strptr[0] )
5685 if ( lastCol < firstCol )
5693 if ( !
RexxStemSort(stemName, sortOrder, sortType, first, last, firstCol, lastCol) )
5695 sprintf(retstr->
strptr,
"-1");
5700 sprintf(retstr->
strptr,
"0");
5729 RexxObjectPtr temp = context->GetStemArrayElement(toStem, 0);
5730 if (temp ==
NULLOBJECT || !context->StringSize(temp, &items))
5732 context->InvalidRoutine();
5737 if (start + count - 1 > items)
5739 context->InvalidRoutine();
5745 for ( index = start; index + count <= items; index++)
5748 RexxObjectPtr value = context->GetStemArrayElement(toStem, index + count);
5755 context->SetStemArrayElement(toStem, index, value);
5759 for (index = items - count + 1; index <= items; index++)
5761 context->DropStemArrayElement(toStem, index);
5764 context->SetStemArrayElement(toStem, 0, context->StringSize(items - count));
5786 RexxObjectPtr temp = context->GetStemArrayElement(toStem, 0);
5787 if (temp ==
NULLOBJECT || !context->StringSize(temp, &count))
5789 context->InvalidRoutine();
5794 if (position == 0 || (position > count + 1))
5796 context->InvalidRoutine();
5800 for (
size_t index = count; index >= position; index--)
5803 RexxObjectPtr value = context->GetStemArrayElement(toStem, index);
5810 context->SetStemArrayElement(toStem, index + 1, value);
5814 context->SetStemArrayElement(toStem, position, newValue);
5815 context->SetStemArrayElement(toStem, 0, context->WholeNumber(count + 1));
5838 OPTIONAL_stringsize_t, from, OPTIONAL_stringsize_t, to, OPTIONAL_stringsize_t, count,
5839 OPTIONAL_CSTRING, option)
5841 bool inserting =
false;
5858 context->InvalidRoutine();
5866 RexxObjectPtr temp = context->GetStemArrayElement(fromStem, 0);
5867 if (temp ==
NULLOBJECT || !context->StringSize(temp, &fromCount))
5869 context->InvalidRoutine();
5888 if ((count > (fromCount - from + 1)) || (fromCount == 0))
5890 context->InvalidRoutine();
5897 count = fromCount - from + 1;
5902 temp = context->GetStemArrayElement(toStem, 0);
5903 if (temp !=
NULLOBJECT && !context->StringSize(temp, &toCount))
5905 context->InvalidRoutine();
5910 if (to > toCount + 1)
5912 context->InvalidRoutine();
5919 for (
size_t index = toCount; index >= to; index--)
5922 RexxObjectPtr value = context->GetStemArrayElement(toStem, index);
5929 context->SetStemArrayElement(toStem, index + count, value);
5935 context->SetStemArrayElement(toStem, 0, context->StringSize(toCount));
5938 for (
size_t index = 0; index < count; index++)
5941 RexxObjectPtr value = context->GetStemArrayElement(fromStem, from + index);
5948 context->SetStemArrayElement(toStem, to + index, value);
5952 if (to + count - 1 > toCount)
5954 context->SetStemArrayElement(toStem, 0, context->StringSize(to + count - 1));
5972 sprintf(buffer,
"%d.%d.%d", ORX_VER, ORX_REL, ORX_MOD);
5973 return context->String(buffer);
5988 if ( cp == CP_SYMBOL || cp == CP_UTF7 || cp == CP_UTF8 )
5992 if ( 50220 <= cp && cp <= 50222 )
5996 if ( cp == 50225 || cp == 50227 || cp == 50229 || cp == 52936 || cp == 54936 )
6000 if ( 57002 <= cp && cp <= 57011 )
6086 OPTIONAL_CSTRING, mappingFlags, OPTIONAL_CSTRING, defaultChar,
RexxStemObject, stem)
6088 const char *source = context->StringData(sourceString);
6089 size_t sourceLength = context->StringLength(sourceString);
6093 if (codePageOpt == NULL)
6095 codePage = GetOEMCP();
6099 if (_stricmp(codePageOpt,
"THREAD_ACP") == 0)
6101 codePage = CP_THREAD_ACP;
6103 else if (_stricmp(codePageOpt,
"ACP") == 0)
6107 else if (_stricmp(codePageOpt,
"MACCP") == 0)
6109 codePage = CP_MACCP;
6111 else if (_stricmp(codePageOpt,
"OEMCP") == 0)
6113 codePage = CP_OEMCP;
6115 else if (_stricmp(codePageOpt,
"SYMBOL") == 0)
6117 codePage = CP_SYMBOL;
6119 else if (_stricmp(codePageOpt,
"UTF7") == 0)
6123 else if (_stricmp(codePageOpt,
"UTF8") == 0)
6129 codePage = atoi(codePageOpt);
6135 if (mappingFlags != NULL && *mappingFlags !=
'\0' )
6143 if ( codePage < 50000 && codePage != CP_SYMBOL )
6145 if ( StrStrI(mappingFlags,
"COMPOSITECHECK") != NULL )
6147 dwFlags |= WC_COMPOSITECHECK;
6149 if ( StrStrI(mappingFlags,
"SEPCHARS") != NULL )
6151 dwFlags |= WC_SEPCHARS | WC_COMPOSITECHECK;
6153 if ( StrStrI(mappingFlags,
"DISCARDNS") != NULL )
6155 dwFlags |= WC_DISCARDNS| WC_COMPOSITECHECK;
6157 if ( StrStrI(mappingFlags,
"DEFAULTCHAR") != NULL )
6159 dwFlags |= WC_DEFAULTCHAR | WC_COMPOSITECHECK;
6163 if ( StrStrI(mappingFlags,
"NO_BEST_FIT") != NULL )
6165 dwFlags |= WC_NO_BEST_FIT_CHARS;
6168 if ( StrStrI(mappingFlags,
"ERR_INVALID") != NULL )
6175 else if ( dwFlags == 0 && ! (codePage < 50000 && codePage != CP_SYMBOL) )
6177 context->InvalidRoutine();
6183 const char *strDefaultChar = NULL;
6184 BOOL bUsedDefaultChar = FALSE;
6185 BOOL *pUsedDefaultChar = &bUsedDefaultChar;
6187 if (defaultChar != NULL && (dwFlags & WC_DEFAULTCHAR) == WC_DEFAULTCHAR)
6189 strDefaultChar = defaultChar;
6194 strDefaultChar =
"?";
6202 strDefaultChar = NULL;
6203 pUsedDefaultChar = NULL;
6208 strDefaultChar = NULL;
6209 pUsedDefaultChar = NULL;
6213 char *strptr = (
char *)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT, sourceLength + 4);
6216 context->InvalidRoutine();
6219 memcpy(strptr, source, sourceLength);
6222 int iBytesNeeded = WideCharToMultiByte( codePage,
6225 (
int)(sourceLength/2),
6231 if (iBytesNeeded == 0)
6234 return GetLastError();
6238 char *str = (
char *)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT, iBytesNeeded + 4);
6241 context->InvalidRoutine();
6246 int iBytesDestination = WideCharToMultiByte(codePage,
6249 (
int)(sourceLength/2),
6255 if (iBytesDestination == 0)
6259 return GetLastError();
6263 if (bUsedDefaultChar)
6265 context->SetStemElement(stem,
"!USEDDEFAULTCHAR", context->True());
6269 context->SetStemElement(stem,
"!USEDDEFAULTCHAR", context->False());
6272 context->SetStemElement(stem,
"!TEXT", context->String(str, iBytesNeeded));
6331 if (codePageOpt == NULL)
6333 codePage = GetOEMCP();
6337 if (_stricmp(codePageOpt,
"THREAD_ACP") == 0)
6339 codePage = CP_THREAD_ACP;
6341 else if (_stricmp(codePageOpt,
"ACP") == 0)
6345 else if (_stricmp(codePageOpt,
"MACCP") == 0)
6347 codePage = CP_MACCP;
6349 else if (_stricmp(codePageOpt,
"OEMCP") == 0)
6351 codePage = CP_OEMCP;
6353 else if (_stricmp(codePageOpt,
"SYMBOL") == 0)
6355 codePage = CP_SYMBOL;
6357 else if (_stricmp(codePageOpt,
"UTF7") == 0)
6361 else if (_stricmp(codePageOpt,
"UTF8") == 0)
6367 codePage = atoi(codePageOpt);
6373 if (mappingFlags != NULL)
6375 if (
mystrstr(mappingFlags,
"PRECOMPOSED"))
6377 dwFlags |= MB_PRECOMPOSED;
6379 if (
mystrstr(mappingFlags,
"COMPOSITE"))
6381 dwFlags |= MB_COMPOSITE;
6383 if (
mystrstr(mappingFlags,
"ERR_INVALID"))
6385 dwFlags |= MB_ERR_INVALID_CHARS;
6387 if (
mystrstr(mappingFlags,
"USEGLYPHCHARS"))
6389 dwFlags |= MB_USEGLYPHCHARS;
6393 context->InvalidRoutine();
6399 ULONG ulWCharsNeeded = MultiByteToWideChar( codePage, dwFlags,
6400 context->StringData(source), (
int)context->StringLength(source), NULL, NULL);
6402 if (ulWCharsNeeded == 0)
6404 return GetLastError();
6407 ULONG ulDataLen = (ulWCharsNeeded)*2;
6409 LPWSTR lpwstr = (LPWSTR)GlobalAlloc(GMEM_FIXED|GMEM_ZEROINIT, ulDataLen+4);
6414 context->InvalidRoutine();
6420 ulWCharsNeeded = MultiByteToWideChar(codePage, dwFlags,
6421 context->StringData(source), (
int)context->StringLength(source),
6422 lpwstr, ulWCharsNeeded);
6424 if (ulWCharsNeeded == 0)
6427 return GetLastError();
6430 context->SetStemElement(stem,
"!TEXT", context->String((
const char *)lpwstr, ulDataLen));
6449 DWORD currentSize = 10*
sizeof(PRINTER_INFO_2)*
sizeof(
char);
6450 char *pArray = (
char*) malloc(
sizeof(
char)*currentSize);
6454 if (EnumPrinters(PRINTER_ENUM_LOCAL|PRINTER_ENUM_CONNECTIONS, NULL, 2, (LPBYTE)pArray,
6455 currentSize, &realSize, &entries) == 0)
6458 DWORD rc = GetLastError();
6459 if ( rc != ERROR_INSUFFICIENT_BUFFER )
6465 if ( currentSize >= realSize )
6469 currentSize = realSize;
6471 pArray = (
char*) realloc(pArray,
sizeof(
char)*currentSize);
6474 PRINTER_INFO_2 *pResult = (PRINTER_INFO_2*) pArray;
6477 context->SetStemArrayElement(stem, 0, context->WholeNumber(entries));
6481 sprintf(szBuffer,
"%s,%s,%s", pResult[entries].pPrinterName, pResult[entries].pDriverName,
6482 pResult[entries].pPortName);
6483 context->SetStemArrayElement(stem, entries + 1, context->String(szBuffer));
6504 GetProfileString(
"Windows",
"DEVICE",
",,,", buffer,
sizeof(buffer));
6505 return context->String(buffer);
6525 for (
size_t i = 0; printer[i] !=
'\0'; i++ )
6527 if (printer[i] ==
',' )
6533 if (count != 0 && count != 2)
6535 context->InvalidRoutine();
6544 if (SetDefaultPrinter(printer) == 0)
6550 return GetLastError();
6559 if (WriteProfileString(
"Windows",
"DEVICE", printer) == 0)
6565 if ( SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0L, 0L, SMTO_NORMAL, 1000, NULL) == 0 )
6575 return GetLastError();
6595 return CopyFile(fromFile, toFile, 0) ? 0 : GetLastError();
6611 return MoveFile(fromFile, toFile) ? 0 : GetLastError();
6626 DWORD dwAttrs = GetFileAttributes(file);
6628 return (dwAttrs != 0xffffffff) && ((dwAttrs & (FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_REPARSE_POINT)) == 0);
6643 DWORD dwAttrs = GetFileAttributes(file);
6644 return (dwAttrs != 0xffffffff) && (dwAttrs & FILE_ATTRIBUTE_DIRECTORY);
6659 DWORD dwAttrs = GetFileAttributes(file);
6660 return (dwAttrs != 0xffffffff) && (dwAttrs & FILE_ATTRIBUTE_REPARSE_POINT);
6675 DWORD dwAttrs = GetFileAttributes(file);
6676 return (dwAttrs != 0xffffffff) && (dwAttrs & FILE_ATTRIBUTE_COMPRESSED);
6691 DWORD dwAttrs = GetFileAttributes(file);
6692 return (dwAttrs != 0xffffffff) && (dwAttrs & FILE_ATTRIBUTE_ENCRYPTED);
6708 DWORD dwAttrs = GetFileAttributes(file);
6709 return (dwAttrs != 0xffffffff) && (dwAttrs & FILE_ATTRIBUTE_NOT_CONTENT_INDEXED);
6724 DWORD dwAttrs = GetFileAttributes(file);
6725 return (dwAttrs != 0xffffffff) && (dwAttrs & FILE_ATTRIBUTE_OFFLINE);
6740 DWORD dwAttrs = GetFileAttributes(file);
6741 return (dwAttrs != 0xffffffff) && (dwAttrs & FILE_ATTRIBUTE_SPARSE_FILE);
6757 DWORD dwAttrs = GetFileAttributes(file);
6758 return (dwAttrs != 0xffffffff) && (dwAttrs & FILE_ATTRIBUTE_TEMPORARY);
6774 DWORD dwAttrs = GetFileAttributes(file);
6775 return (dwAttrs != 0xffffffff);
6794 DWORD code = GetLongPathName(path, longPath,
MAX);
6795 if ((code == 0) || (code >=
MAX))
6797 return context->NullString();
6801 return context->NewStringFromAsciiz(longPath);
6820 CHAR shortPath[
MAX];
6821 DWORD code = GetShortPathName(path, shortPath,
MAX);
6822 if ((code == 0) || (code >=
MAX))
6824 return context->NullString();
6828 return context->NewStringFromAsciiz(shortPath);
RexxReturnCode RexxEntry RexxVariablePool(PSHVBLOCK pshvblock)
#define argumentExists(i)
#define REXX_INTERPRETER_4_0_0
#define REXX_CLASSIC_ROUTINE(n, e)
#define argumentOmitted(i)
#define REXX_LAST_ROUTINE()
#define REXX_TYPED_ROUTINE(n, e)
#define STANDARD_PACKAGE_HEADER
#define Rexx_Error_Invalid_argument_range
#define Rexx_Error_System_resources_user_defined
#define Rexx_Error_Incorrect_call_user_defined
#define Rexx_Error_Invalid_argument_number
#define Rexx_Error_System_service_user_defined
#define Rexx_Error_Incorrect_call_null
RexxReturnCode REXXENTRY RexxLoadMacroSpace(size_t, CONSTANT_STRING *, CONSTANT_STRING)
RexxReturnCode REXXENTRY RexxAddMacro(CONSTANT_STRING, CONSTANT_STRING, size_t)
RexxReturnCode REXXENTRY RexxFreeMemory(void *)
struct _RexxStringObject * RexxStringObject
RexxReturnCode REXXENTRY RexxSaveMacroSpace(size_t, CONSTANT_STRING *, CONSTANT_STRING)
RexxReturnCode REXXENTRY RexxQueryMacro(CONSTANT_STRING, unsigned short *)
struct _RexxObjectPtr * RexxObjectPtr
RexxReturnCode REXXENTRY RexxReorderMacro(CONSTANT_STRING, size_t)
RexxReturnCode REXXENTRY RexxClearMacroSpace(void)
RexxReturnCode REXXENTRY RexxDropMacro(CONSTANT_STRING)
struct _RexxStemObject * RexxStemObject
#define RXMACRO_SEARCH_BEFORE
#define RXMACRO_SEARCH_AFTER
CONSTANT_RXSTRING shvname
struct _SHVBLOCK * shvnext
RexxThreadContext * threadContext
char fileTime[FILETIME_BUF_LEN]
char fNameSpec[FNAMESPEC_BUF_LEN]
char foundFile[FOUNDFILE_BUF_LEN]
char foundFileLine[FOUNDFILELINE_BUF_LEN]
char fileAttr[FILEATTR_BUF_LEN]
size_t RexxEntry SysSetPriority(const char *name, size_t numargs, CONSTRXSTRING args[], const char *queuename, PRXSTRING retstr)
int MoveFile(CSTRING fromFile, CSTRING toFile)
size_t RexxEntry SysGetFileDateTime(const char *name, size_t numargs, CONSTRXSTRING args[], const char *queuename, PRXSTRING retstr)
size_t RexxEntry SysMkDir(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)
size_t RexxEntry SysQueryProcess(const char *name, size_t numargs, CONSTRXSTRING args[], const char *queuename, PRXSTRING retstr)
int SearchPath(int SearchFlag, const char *path, const char *filename, char *buf, size_t buf_size)
size_t RexxEntry SysSetFileDateTime(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)
RexxRoutine2(RexxStringObject, SysCurPos, OPTIONAL_stringsize_t, inrow, OPTIONAL_stringsize_t, incol)
size_t RexxEntry SysSearchPath(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 SysDriveInfo(const char *name, size_t numargs, CONSTRXSTRING args[], const char *queuename, PRXSTRING retstr)
static bool getOptionsFromArg(RexxCallContext *context, char *opts, uint32_t *options, size_t argPos)
size_t RexxEntry SysDriveMap(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)
bool SetFileMode(const char *file, size_t attr)
bool string2size_t(const char *string, size_t *number)
#define BUILDRXSTRING(t, s)
RexxPackageEntry rexxutil_package_entry
OOREXX_GET_PACKAGE(rexxutil)
RexxRoutine6(int, SysStemCopy, RexxStemObject, fromStem, RexxStemObject, toStem, OPTIONAL_stringsize_t, from, OPTIONAL_stringsize_t, to, OPTIONAL_stringsize_t, count, OPTIONAL_CSTRING, option)
bool isAtLeastVista(void)
static bool formatFile(RexxCallContext *c, char *path, RXTREEDATA *treeData, int32_t *newMask, uint32_t options, WIN32_FIND_DATA *wfd)
static bool safeGetCurrentDirectory(RexxCallContext *c, char **pPath, size_t *pPathLen)
struct _GetFileData GetFileData
bool GetLine(char *line, size_t size, GetFileData *filedata)
static bool expandPath2fullPath(RexxCallContext *c, char *fSpec, size_t lastSlashPos, char **pPath, size_t *pPathLen)
static void badMaskException(RexxThreadContext *c, size_t pos, CSTRING actual)
RexxRoutine1(int, SysCurState, CSTRING, option)
size_t RexxEntry SysWinDecryptFile(const char *name, size_t numargs, CONSTRXSTRING args[], const char *queuename, PRXSTRING retstr)
static bool getMaskFromArg(RexxCallContext *context, char *msk, int32_t *mask, size_t argPos)
RexxReturnCode REXXENTRY RexxStemSort(const char *stemname, int order, int type, size_t start, size_t end, size_t firstcol, size_t lastcol)
static bool setAttr(const char *file, uint32_t attr)
VOID GetUniqueFileName(CHAR *Template, CHAR Filler, CHAR *file)
#define FNAMESPEC_BUF_LEN
static char * getFileSpecFromArg(RexxCallContext *context, CSTRING fSpec, size_t *fSpecLen, size_t *fSpecBufLen, size_t argPos)
RexxRoutineEntry rexxutil_routines[]
size_t RexxEntry SysDumpVariables(const char *name, size_t numargs, CONSTRXSTRING args[], const char *queuename, PRXSTRING retstr)
VOID CALLBACK SleepTimerProc(HWND, UINT, UINT, DWORD)
static char * adjustFSpec(char *fSpec)
size_t RexxEntry SysBootDrive(const char *name, size_t numargs, CONSTRXSTRING args[], const char *queuename, PRXSTRING retstr)
RexxRoutine4(int, SysToUniCode, RexxStringObject, source, OPTIONAL_CSTRING, codePageOpt, OPTIONAL_CSTRING, mappingFlags, RexxStemObject, stem)
struct RxTreeData RXTREEDATA
static void badSFTOptsException(RexxThreadContext *c, size_t pos, CSTRING actual)
void safeLocalFree(void *p)
#define FNAMESPEC_BUF_EXTRA
static bool recursiveFindFile(RexxCallContext *c, char *path, RXTREEDATA *treeData, int32_t *targetMask, int32_t *newMask, uint32_t options)
static bool isWindowsVersion(DWORD major, DWORD minor, unsigned int sp, unsigned int type, unsigned int condition)
static bool getPath(RexxCallContext *c, char *fSpec, char **path, char *filename, size_t *pathLen)
size_t RexxEntry SysStemSort(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)
size_t neededSize(size_t need, size_t have)
size_t RexxEntry SysCls(const char *name, size_t numargs, CONSTRXSTRING args[], const char *queuename, PRXSTRING retstr)
#define FOUNDFILE_BUF_LEN
void CloseFile(GetFileData *filedata)
#define MAX_CREATEPROCESS_CMDLINE
static bool expandNonPath2fullPath(RexxCallContext *c, char *fSpec, char **pPath, size_t *pPathLen, int *lastSlashPos)
size_t RexxEntry SysVolumeLabel(const char *name, size_t numargs, CONSTRXSTRING args[], const char *queuename, PRXSTRING retstr)
bool MyOpenFile(const char *file, GetFileData *filedata)
size_t RexxEntry RxWinExec(const char *name, size_t numargs, CONSTRXSTRING args[], const char *queuename, PRXSTRING retstr)
static bool getBiggerBuffer(RexxCallContext *c, char **dBuf, size_t *nBuf, size_t needed, size_t nStaticBuffer)
size_t RexxEntry SysGetErrortext(const char *name, size_t numargs, CONSTRXSTRING args[], const char *queuename, PRXSTRING retstr)
RexxRoutine3(RexxStringObject, SysTextScreenRead, int, row, int, col, OPTIONAL_int, len)
#define WC_ERR_INVALID_CHARS
size_t RexxEntry SysIni(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)
struct RxStemData RXSTEMDATA
RexxRoutine0(int, SysClearRexxMacroSpace)
size_t RexxEntry SysDropFuncs(const char *name, size_t numargs, CONSTRXSTRING args[], const char *queuename, PRXSTRING retstr)
#define FOUNDFILELINE_BUF_LEN
#define SORT_CASESENSITIVE
static uint32_t newAttr(int32_t *mask, uint32_t attr)
void nullStringException(RexxThreadContext *c, CSTRING fName, size_t pos)
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 SysFileSearch(const char *name, size_t numargs, CONSTRXSTRING args[], const char *queuename, PRXSTRING retstr)
char * mystrstr(const char *haystack, const char *needle, size_t hlen, size_t nlen, bool sensitive)
size_t RexxEntry SysFileSystemType(const char *name, size_t numargs, CONSTRXSTRING args[], const char *queuename, PRXSTRING retstr)
BOOL(WINAPI * P_GDFSE)(LPCTSTR, PULARGE_INTEGER, PULARGE_INTEGER, PULARGE_INTEGER)
size_t RexxEntry SysWinVer(const char *name, size_t numargs, CONSTRXSTRING args[], const char *queuename, PRXSTRING retstr)
static char * getPathBuffer(RexxCallContext *context, size_t fSpecLen, size_t *pathLen)
static bool goodOpts(RexxCallContext *c, char *opts, uint32_t *pOpts)
static bool sameAttr(int32_t *mask, uint32_t attr, uint32_t options)
static P_GDFSE pGetDiskFreeSpaceEx
size_t RexxEntry SysTempFileName(const char *name, size_t numargs, CONSTRXSTRING args[], const char *queuename, PRXSTRING retstr)
void memupper(char *location, size_t length)
void outOfMemoryException(RexxThreadContext *c)
static bool canUseWideCharFlags(UINT cp)
static void systemServiceExceptionCode(RexxThreadContext *c, CSTRING api, uint32_t rc)
bool ReadNextBuffer(GetFileData *filedata)
static bool goodMask(RexxCallContext *c, char *msk, int32_t *mask)