diff --git a/reactos/apps/utils/cmd/config.h b/reactos/apps/utils/cmd/config.h index 12edbe5bfc6..a0243cc00e7 100644 --- a/reactos/apps/utils/cmd/config.h +++ b/reactos/apps/utils/cmd/config.h @@ -65,9 +65,7 @@ /*#define INCLUDE_CMD_CTTY*/ #define INCLUDE_CMD_DATE #define INCLUDE_CMD_DEL -#ifndef __REACTOS__ #define INCLUDE_CMD_DIR -#endif #define INCLUDE_CMD_LABEL #define INCLUDE_CMD_MKDIR #define INCLUDE_CMD_MOVE diff --git a/reactos/apps/utils/cmd/dir.c b/reactos/apps/utils/cmd/dir.c index 74ce10c3579..c9d90b071f7 100644 --- a/reactos/apps/utils/cmd/dir.c +++ b/reactos/apps/utils/cmd/dir.c @@ -123,11 +123,13 @@ #include "cmd.h" +#ifdef __REACTOS__ +#include +#endif + + /* flag definitions */ -/* Changed hex to decimal, hex wouldn't work - * if > 8, Rob Lake 06/17/98. - */ enum { DIR_RECURSE = 0x0001, @@ -582,7 +584,11 @@ ConvertULargeInteger (ULARGE_INTEGER num, LPTSTR des, INT len) INT c = 0; INT n = 0; +#ifndef __REACTOS__ if (num.QuadPart == 0) +#else + if (num == 0) +#endif { des[0] = _T('0'); des[1] = _T('\0'); @@ -591,12 +597,21 @@ ConvertULargeInteger (ULARGE_INTEGER num, LPTSTR des, INT len) else { temp[31] = 0; +#ifndef __REACTOS__ while (num.QuadPart > 0) +#else + while (num > 0) +#endif { if (((c + 1) % (nNumberGroups + 1)) == 0) temp[30 - c++] = cThousandSeparator; +#ifndef __REACTOS__ temp[30 - c++] = (TCHAR)(num.QuadPart % 10) + _T('0'); num.QuadPart /= 10; +#else + temp[30 - c++] = (TCHAR)(num % 10) + _T('0'); + num /= 10; +#endif } for (n = 0; n <= c; n++) @@ -667,11 +682,16 @@ PrintSummary (LPTSTR szPath, ULONG ulFiles, ULONG ulDirs, ULARGE_INTEGER bytes, /* print number of files and bytes */ ConvertULong (ulFiles, buffer, sizeof(buffer)); ConOutPrintf (_T(" %6s File%c"), - buffer, ulFiles == 1 ? _T(' ') : _T('s')); + buffer, ulFiles == 1 ? _T(' ') : _T('s')); ConvertULargeInteger (bytes, buffer, sizeof(buffer)); +#ifndef __REACTOS__ ConOutPrintf (_T(" %15s byte%c\n"), - buffer, bytes.QuadPart == 1 ? _T(' ') : _T('s')); + buffer, bytes.QuadPart == 1 ? _T(' ') : _T('s')); +#else + ConOutPrintf (_T(" %15s byte%c\n"), + buffer, bytes == 1 ? _T(' ') : _T('s')); +#endif if (IncLine (pLine, dwFlags)) return 1; @@ -679,7 +699,7 @@ PrintSummary (LPTSTR szPath, ULONG ulFiles, ULONG ulDirs, ULARGE_INTEGER bytes, /* print number of dirs and bytes free */ ConvertULong (ulDirs, buffer, sizeof(buffer)); ConOutPrintf (_T(" %6s Dir%c"), - buffer, ulDirs == 1 ? _T(' ') : _T('s')); + buffer, ulDirs == 1 ? _T(' ') : _T('s')); if (!(dwFlags & DIR_RECURSE)) @@ -693,7 +713,11 @@ PrintSummary (LPTSTR szPath, ULONG ulFiles, ULONG ulDirs, ULARGE_INTEGER bytes, szRoot[0] = szPath[0]; GetDiskFreeSpace (szRoot, &dwSecPerCl, &dwBytPerSec, &dwFreeCl, &dwTotCl); - uliFree.QuadPart = dwSecPerCl * dwBytPerSec * dwFreeCl; +#ifndef __REACTOS__ + uliFree.QuadPart = dwSecPerCl * dwBytPerSec * dwFreeCl; +#else + uliFree = dwSecPerCl * dwBytPerSec * dwFreeCl; +#endif ConvertULargeInteger (uliFree, buffer, sizeof(buffer)); ConOutPrintf (_T(" %15s bytes free\n"), buffer); } @@ -724,7 +748,11 @@ DirList (LPTSTR szPath, LPTSTR szFilespec, LPINT pLine, DWORD dwFlags) ULONG dircount = 0; INT count; +#ifndef __REACTOS__ bytecount.QuadPart = 0; +#else + bytecount = 0; +#endif _tcscpy (szFullPath, szPath); if (szFullPath[_tcslen(szFullPath) - 1] != _T('\\')) @@ -812,9 +840,15 @@ DirList (LPTSTR szPath, LPTSTR szFilespec, LPINT pLine, DWORD dwFlags) count = 0; } +#ifndef __REACTOS__ uliSize.u.LowPart = file.nFileSizeLow; uliSize.u.HighPart = file.nFileSizeHigh; bytecount.QuadPart += uliSize.QuadPart; +#else + SET_LARGE_INTEGER_LOW_PART(uliSize, file.nFileSizeLow); + SET_LARGE_INTEGER_HIGH_PART(uliSize, file.nFileSizeHigh); + bytecount += uliSize; +#endif } else if (dwFlags & DIR_BARE) { @@ -843,9 +877,15 @@ DirList (LPTSTR szPath, LPTSTR szFilespec, LPINT pLine, DWORD dwFlags) if (IncLine (pLine, dwFlags)) return 1; +#ifndef __REACTOS__ uliSize.u.LowPart = file.nFileSizeLow; uliSize.u.HighPart = file.nFileSizeHigh; bytecount.QuadPart += uliSize.QuadPart; +#else + SET_LARGE_INTEGER_LOW_PART(uliSize, file.nFileSizeLow); + SET_LARGE_INTEGER_HIGH_PART(uliSize, file.nFileSizeHigh); + bytecount += uliSize; +#endif } else { @@ -868,14 +908,23 @@ DirList (LPTSTR szPath, LPTSTR szFilespec, LPINT pLine, DWORD dwFlags) { ULARGE_INTEGER uliSize; +#ifndef __REACTOS__ uliSize.u.LowPart = file.nFileSizeLow; uliSize.u.HighPart = file.nFileSizeHigh; +#else + SET_LARGE_INTEGER_LOW_PART(uliSize, file.nFileSizeLow); + SET_LARGE_INTEGER_HIGH_PART(uliSize, file.nFileSizeHigh); +#endif ConvertULargeInteger (uliSize, buffer, sizeof(buffer)); ConOutPrintf (_T(" %20s"), buffer); +#ifndef __REACTOS__ bytecount.QuadPart += uliSize.QuadPart; - filecount++; +#else + bytecount += uliSize; +#endif + filecount++; } /* print long filename */ @@ -920,13 +969,21 @@ DirList (LPTSTR szPath, LPTSTR szFilespec, LPINT pLine, DWORD dwFlags) { ULARGE_INTEGER uliSize; +#ifndef __REACTOS__ uliSize.u.LowPart = file.nFileSizeLow; uliSize.u.HighPart = file.nFileSizeHigh; +#else + SET_LARGE_INTEGER_LOW_PART(uliSize, file.nFileSizeLow); + SET_LARGE_INTEGER_HIGH_PART(uliSize, file.nFileSizeHigh); +#endif ConvertULargeInteger (uliSize, buffer, sizeof(buffer)); ConOutPrintf (_T(" %10s "), buffer); - +#ifndef __REACTOS__ bytecount.QuadPart += uliSize.QuadPart; +#else + bytecount += uliSize; +#endif filecount++; } @@ -961,7 +1018,11 @@ DirList (LPTSTR szPath, LPTSTR szFilespec, LPINT pLine, DWORD dwFlags) { recurse_dir_cnt += dircount; recurse_file_cnt += filecount; +#ifndef __REACTOS__ recurse_bytes.QuadPart += bytecount.QuadPart; +#else + recurse_bytes += bytecount; +#endif /* print_summary */ if (PrintSummary (szPath, filecount, dircount, bytecount, pLine, dwFlags)) @@ -1042,7 +1103,11 @@ DirRecurse (LPTSTR szPath, LPTSTR szSpec, LPINT pLine, DWORD dwFlags) { recurse_dir_cnt = 0L; recurse_file_cnt = 0L; +#ifdef __REACTOS__ + recurse_bytes = 0; +#else recurse_bytes.QuadPart = 0; +#endif if (!PrintDirectoryHeader (szPath, pLine, dwFlags)) return 1; diff --git a/reactos/apps/utils/cmd/ros.c b/reactos/apps/utils/cmd/ros.c index e5000c6347c..53e6ba60025 100644 --- a/reactos/apps/utils/cmd/ros.c +++ b/reactos/apps/utils/cmd/ros.c @@ -72,4 +72,52 @@ void _makepath( char *path, const char *drive, const char *dir, const char *fnam } } + +char *strtok(char *s, const char *delim) +{ + const char *spanp; + int c, sc; + char *tok; + static char *last; + + if (s == NULL && (s = last) == NULL) + return (NULL); + + /* + * Skip (span) leading delimiters (s += strspn(s, delim), sort of). + */ + cont: + c = *s++; + for (spanp = delim; (sc = *spanp++) != 0;) { + if (c == sc) + goto cont; + } + + if (c == 0) { /* no non-delimiter characters */ + last = NULL; + return (NULL); + } + tok = s - 1; + + /* + * Scan token (scan for delimiters: s += strcspn(s, delim), sort of). + * Note that delim must have one NUL; we stop if we see that, too. + */ + for (;;) { + c = *s++; + spanp = delim; + do { + if ((sc = *spanp++) == c) { + if (c == 0) + s = NULL; + else + s[-1] = 0; + last = s; + return (tok); + } + } while (sc != 0); + } + /* NOTREACHED */ +} + #endif diff --git a/reactos/apps/utils/cmd/vol.c b/reactos/apps/utils/cmd/vol.c index 71ee531ad30..e3eae64235e 100644 --- a/reactos/apps/utils/cmd/vol.c +++ b/reactos/apps/utils/cmd/vol.c @@ -31,15 +31,19 @@ #include "cmd.h" -static VOID +static INT PrintVolumeHeader (LPTSTR pszRootPath) { TCHAR szVolName[80]; DWORD dwSerialNr; /* get the volume information of the drive */ - GetVolumeInformation (pszRootPath, szVolName, 80, &dwSerialNr, - NULL, NULL, NULL, 0); + if(!GetVolumeInformation (pszRootPath, szVolName, 80, &dwSerialNr, + NULL, NULL, NULL, 0)) + { + ErrorMessage (GetLastError (), _T("")); + return 1; + } /* print drive info */ ConOutPrintf (_T(" Volume in drive %c:"), pszRootPath[0]); @@ -52,6 +56,7 @@ PrintVolumeHeader (LPTSTR pszRootPath) /* print the volume serial number */ ConOutPrintf (_T(" Volume Serial Number is %04X-%04X\n"), HIWORD(dwSerialNr), LOWORD(dwSerialNr)); + return 0; } @@ -91,7 +96,8 @@ INT cmd_vol (LPTSTR cmd, LPTSTR param) } /* print the header */ - PrintVolumeHeader (szRootPath); + if (!PrintVolumeHeader (szRootPath)) + return 1; return 0; } diff --git a/rosapps/cmd/config.h b/rosapps/cmd/config.h index 12edbe5bfc6..a0243cc00e7 100644 --- a/rosapps/cmd/config.h +++ b/rosapps/cmd/config.h @@ -65,9 +65,7 @@ /*#define INCLUDE_CMD_CTTY*/ #define INCLUDE_CMD_DATE #define INCLUDE_CMD_DEL -#ifndef __REACTOS__ #define INCLUDE_CMD_DIR -#endif #define INCLUDE_CMD_LABEL #define INCLUDE_CMD_MKDIR #define INCLUDE_CMD_MOVE diff --git a/rosapps/cmd/dir.c b/rosapps/cmd/dir.c index 74ce10c3579..c9d90b071f7 100644 --- a/rosapps/cmd/dir.c +++ b/rosapps/cmd/dir.c @@ -123,11 +123,13 @@ #include "cmd.h" +#ifdef __REACTOS__ +#include +#endif + + /* flag definitions */ -/* Changed hex to decimal, hex wouldn't work - * if > 8, Rob Lake 06/17/98. - */ enum { DIR_RECURSE = 0x0001, @@ -582,7 +584,11 @@ ConvertULargeInteger (ULARGE_INTEGER num, LPTSTR des, INT len) INT c = 0; INT n = 0; +#ifndef __REACTOS__ if (num.QuadPart == 0) +#else + if (num == 0) +#endif { des[0] = _T('0'); des[1] = _T('\0'); @@ -591,12 +597,21 @@ ConvertULargeInteger (ULARGE_INTEGER num, LPTSTR des, INT len) else { temp[31] = 0; +#ifndef __REACTOS__ while (num.QuadPart > 0) +#else + while (num > 0) +#endif { if (((c + 1) % (nNumberGroups + 1)) == 0) temp[30 - c++] = cThousandSeparator; +#ifndef __REACTOS__ temp[30 - c++] = (TCHAR)(num.QuadPart % 10) + _T('0'); num.QuadPart /= 10; +#else + temp[30 - c++] = (TCHAR)(num % 10) + _T('0'); + num /= 10; +#endif } for (n = 0; n <= c; n++) @@ -667,11 +682,16 @@ PrintSummary (LPTSTR szPath, ULONG ulFiles, ULONG ulDirs, ULARGE_INTEGER bytes, /* print number of files and bytes */ ConvertULong (ulFiles, buffer, sizeof(buffer)); ConOutPrintf (_T(" %6s File%c"), - buffer, ulFiles == 1 ? _T(' ') : _T('s')); + buffer, ulFiles == 1 ? _T(' ') : _T('s')); ConvertULargeInteger (bytes, buffer, sizeof(buffer)); +#ifndef __REACTOS__ ConOutPrintf (_T(" %15s byte%c\n"), - buffer, bytes.QuadPart == 1 ? _T(' ') : _T('s')); + buffer, bytes.QuadPart == 1 ? _T(' ') : _T('s')); +#else + ConOutPrintf (_T(" %15s byte%c\n"), + buffer, bytes == 1 ? _T(' ') : _T('s')); +#endif if (IncLine (pLine, dwFlags)) return 1; @@ -679,7 +699,7 @@ PrintSummary (LPTSTR szPath, ULONG ulFiles, ULONG ulDirs, ULARGE_INTEGER bytes, /* print number of dirs and bytes free */ ConvertULong (ulDirs, buffer, sizeof(buffer)); ConOutPrintf (_T(" %6s Dir%c"), - buffer, ulDirs == 1 ? _T(' ') : _T('s')); + buffer, ulDirs == 1 ? _T(' ') : _T('s')); if (!(dwFlags & DIR_RECURSE)) @@ -693,7 +713,11 @@ PrintSummary (LPTSTR szPath, ULONG ulFiles, ULONG ulDirs, ULARGE_INTEGER bytes, szRoot[0] = szPath[0]; GetDiskFreeSpace (szRoot, &dwSecPerCl, &dwBytPerSec, &dwFreeCl, &dwTotCl); - uliFree.QuadPart = dwSecPerCl * dwBytPerSec * dwFreeCl; +#ifndef __REACTOS__ + uliFree.QuadPart = dwSecPerCl * dwBytPerSec * dwFreeCl; +#else + uliFree = dwSecPerCl * dwBytPerSec * dwFreeCl; +#endif ConvertULargeInteger (uliFree, buffer, sizeof(buffer)); ConOutPrintf (_T(" %15s bytes free\n"), buffer); } @@ -724,7 +748,11 @@ DirList (LPTSTR szPath, LPTSTR szFilespec, LPINT pLine, DWORD dwFlags) ULONG dircount = 0; INT count; +#ifndef __REACTOS__ bytecount.QuadPart = 0; +#else + bytecount = 0; +#endif _tcscpy (szFullPath, szPath); if (szFullPath[_tcslen(szFullPath) - 1] != _T('\\')) @@ -812,9 +840,15 @@ DirList (LPTSTR szPath, LPTSTR szFilespec, LPINT pLine, DWORD dwFlags) count = 0; } +#ifndef __REACTOS__ uliSize.u.LowPart = file.nFileSizeLow; uliSize.u.HighPart = file.nFileSizeHigh; bytecount.QuadPart += uliSize.QuadPart; +#else + SET_LARGE_INTEGER_LOW_PART(uliSize, file.nFileSizeLow); + SET_LARGE_INTEGER_HIGH_PART(uliSize, file.nFileSizeHigh); + bytecount += uliSize; +#endif } else if (dwFlags & DIR_BARE) { @@ -843,9 +877,15 @@ DirList (LPTSTR szPath, LPTSTR szFilespec, LPINT pLine, DWORD dwFlags) if (IncLine (pLine, dwFlags)) return 1; +#ifndef __REACTOS__ uliSize.u.LowPart = file.nFileSizeLow; uliSize.u.HighPart = file.nFileSizeHigh; bytecount.QuadPart += uliSize.QuadPart; +#else + SET_LARGE_INTEGER_LOW_PART(uliSize, file.nFileSizeLow); + SET_LARGE_INTEGER_HIGH_PART(uliSize, file.nFileSizeHigh); + bytecount += uliSize; +#endif } else { @@ -868,14 +908,23 @@ DirList (LPTSTR szPath, LPTSTR szFilespec, LPINT pLine, DWORD dwFlags) { ULARGE_INTEGER uliSize; +#ifndef __REACTOS__ uliSize.u.LowPart = file.nFileSizeLow; uliSize.u.HighPart = file.nFileSizeHigh; +#else + SET_LARGE_INTEGER_LOW_PART(uliSize, file.nFileSizeLow); + SET_LARGE_INTEGER_HIGH_PART(uliSize, file.nFileSizeHigh); +#endif ConvertULargeInteger (uliSize, buffer, sizeof(buffer)); ConOutPrintf (_T(" %20s"), buffer); +#ifndef __REACTOS__ bytecount.QuadPart += uliSize.QuadPart; - filecount++; +#else + bytecount += uliSize; +#endif + filecount++; } /* print long filename */ @@ -920,13 +969,21 @@ DirList (LPTSTR szPath, LPTSTR szFilespec, LPINT pLine, DWORD dwFlags) { ULARGE_INTEGER uliSize; +#ifndef __REACTOS__ uliSize.u.LowPart = file.nFileSizeLow; uliSize.u.HighPart = file.nFileSizeHigh; +#else + SET_LARGE_INTEGER_LOW_PART(uliSize, file.nFileSizeLow); + SET_LARGE_INTEGER_HIGH_PART(uliSize, file.nFileSizeHigh); +#endif ConvertULargeInteger (uliSize, buffer, sizeof(buffer)); ConOutPrintf (_T(" %10s "), buffer); - +#ifndef __REACTOS__ bytecount.QuadPart += uliSize.QuadPart; +#else + bytecount += uliSize; +#endif filecount++; } @@ -961,7 +1018,11 @@ DirList (LPTSTR szPath, LPTSTR szFilespec, LPINT pLine, DWORD dwFlags) { recurse_dir_cnt += dircount; recurse_file_cnt += filecount; +#ifndef __REACTOS__ recurse_bytes.QuadPart += bytecount.QuadPart; +#else + recurse_bytes += bytecount; +#endif /* print_summary */ if (PrintSummary (szPath, filecount, dircount, bytecount, pLine, dwFlags)) @@ -1042,7 +1103,11 @@ DirRecurse (LPTSTR szPath, LPTSTR szSpec, LPINT pLine, DWORD dwFlags) { recurse_dir_cnt = 0L; recurse_file_cnt = 0L; +#ifdef __REACTOS__ + recurse_bytes = 0; +#else recurse_bytes.QuadPart = 0; +#endif if (!PrintDirectoryHeader (szPath, pLine, dwFlags)) return 1; diff --git a/rosapps/cmd/ros.c b/rosapps/cmd/ros.c index e5000c6347c..53e6ba60025 100644 --- a/rosapps/cmd/ros.c +++ b/rosapps/cmd/ros.c @@ -72,4 +72,52 @@ void _makepath( char *path, const char *drive, const char *dir, const char *fnam } } + +char *strtok(char *s, const char *delim) +{ + const char *spanp; + int c, sc; + char *tok; + static char *last; + + if (s == NULL && (s = last) == NULL) + return (NULL); + + /* + * Skip (span) leading delimiters (s += strspn(s, delim), sort of). + */ + cont: + c = *s++; + for (spanp = delim; (sc = *spanp++) != 0;) { + if (c == sc) + goto cont; + } + + if (c == 0) { /* no non-delimiter characters */ + last = NULL; + return (NULL); + } + tok = s - 1; + + /* + * Scan token (scan for delimiters: s += strcspn(s, delim), sort of). + * Note that delim must have one NUL; we stop if we see that, too. + */ + for (;;) { + c = *s++; + spanp = delim; + do { + if ((sc = *spanp++) == c) { + if (c == 0) + s = NULL; + else + s[-1] = 0; + last = s; + return (tok); + } + } while (sc != 0); + } + /* NOTREACHED */ +} + #endif diff --git a/rosapps/cmd/vol.c b/rosapps/cmd/vol.c index 71ee531ad30..e3eae64235e 100644 --- a/rosapps/cmd/vol.c +++ b/rosapps/cmd/vol.c @@ -31,15 +31,19 @@ #include "cmd.h" -static VOID +static INT PrintVolumeHeader (LPTSTR pszRootPath) { TCHAR szVolName[80]; DWORD dwSerialNr; /* get the volume information of the drive */ - GetVolumeInformation (pszRootPath, szVolName, 80, &dwSerialNr, - NULL, NULL, NULL, 0); + if(!GetVolumeInformation (pszRootPath, szVolName, 80, &dwSerialNr, + NULL, NULL, NULL, 0)) + { + ErrorMessage (GetLastError (), _T("")); + return 1; + } /* print drive info */ ConOutPrintf (_T(" Volume in drive %c:"), pszRootPath[0]); @@ -52,6 +56,7 @@ PrintVolumeHeader (LPTSTR pszRootPath) /* print the volume serial number */ ConOutPrintf (_T(" Volume Serial Number is %04X-%04X\n"), HIWORD(dwSerialNr), LOWORD(dwSerialNr)); + return 0; } @@ -91,7 +96,8 @@ INT cmd_vol (LPTSTR cmd, LPTSTR param) } /* print the header */ - PrintVolumeHeader (szRootPath); + if (!PrintVolumeHeader (szRootPath)) + return 1; return 0; }