diff options
author | Adam <you@example.com> | 2020-05-17 05:51:50 +0200 |
---|---|---|
committer | Adam <you@example.com> | 2020-05-17 05:51:50 +0200 |
commit | e611b132f9b8abe35b362e5870b74bce94a1e58e (patch) | |
tree | a5781d2ec0e085eeca33cf350cf878f2efea6fe5 /private/crt32/direct | |
download | NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.gz NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.bz2 NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.lz NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.xz NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.zst NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.zip |
Diffstat (limited to '')
-rw-r--r-- | private/crt32/direct/drivemap.c | 39 | ||||
-rw-r--r-- | private/crt32/direct/drivfree.c | 69 | ||||
-rw-r--r-- | private/crt32/direct/findfile.c | 224 | ||||
-rw-r--r-- | private/crt32/direct/makefile | 6 | ||||
-rw-r--r-- | private/crt32/direct/peekpoke.c | 95 | ||||
-rw-r--r-- | private/crt32/direct/seterrm.c | 63 | ||||
-rw-r--r-- | private/crt32/direct/slbeep.c | 105 | ||||
-rw-r--r-- | private/crt32/direct/sources | 40 |
8 files changed, 641 insertions, 0 deletions
diff --git a/private/crt32/direct/drivemap.c b/private/crt32/direct/drivemap.c new file mode 100644 index 000000000..160eab54c --- /dev/null +++ b/private/crt32/direct/drivemap.c @@ -0,0 +1,39 @@ +/*** +*drivemap.c - _getdrives +* +* Copyright (c) 1991, Microsoft Corporation. All rights reserved. +* +*Purpose: +* defines _getdrives() +* +*Revision History: +* 08-22-91 BWM Wrote module. +* +*******************************************************************************/ + +#include <cruntime.h> +#include <oscalls.h> +#include <direct.h> + +#if !defined(_WIN32_) +#error ERROR - ONLY WIN32 TARGET SUPPORTED! +#endif + +/*** +*void _getdrivemap(void) - Get bit map of all available drives +* +*Purpose: +* +*Entry: +* +*Exit: +* drive map with drive A in bit 0, B in 1, etc. +* +*Exceptions: +* +*******************************************************************************/ + +unsigned long _CALLTYPE1 _getdrives() +{ + return (GetLogicalDrives()); +} diff --git a/private/crt32/direct/drivfree.c b/private/crt32/direct/drivfree.c new file mode 100644 index 000000000..3ff8b77a5 --- /dev/null +++ b/private/crt32/direct/drivfree.c @@ -0,0 +1,69 @@ +/*** +*drivfree.c - Get the size of a disk +* +* Copyright (c) 1991, Microsoft Corporation. All rights reserved. +* +*Purpose: +* This file has _getdiskfree() +* +*Revision History: +* 08-21-91 PHG Module created for Win32 +* 10-24-91 GJF Added LPDWORD casts to make MIPS compiler happy. +* ASSUMES THAT sizeof(unsigned) == sizeof(DWORD). +* +*******************************************************************************/ + +#include <cruntime.h> +#include <direct.h> +#include <oscalls.h> + +/*** +*int _getdiskfree(drivenum, diskfree) - get size of a specified disk +* +*Purpose: +* Gets the size of the current or specified disk drive +* +*Entry: +* int drivenum - 0 for current drive, or drive 1-26 +* +*Exit: +* returns 0 if succeeds +* returns system error code on error. +* +*Exceptions: +* +*******************************************************************************/ + +#if !defined(_WIN32_) +#error ERROR - ONLY WIN32 TARGET SUPPORTED! +#endif + +unsigned _CALLTYPE1 _getdiskfree(unsigned uDrive, struct _diskfree_t * pdf) +{ + char szRoot[] = "?:\\"; + char szCur[MAX_PATH]; + + if (uDrive == 0) { + GetCurrentDirectory(MAX_PATH, szCur); + if ((szCur[0] == '\\') && (szCur[1] == '\\')) { + return (ERROR_INVALID_PARAMETER); + } + szRoot[0] = szCur[0]; + } + else if (uDrive > 26) { + return (ERROR_INVALID_PARAMETER); + } + else { + szRoot[0] = (char)uDrive + (char)('A' - 1); + } + + + if (!GetDiskFreeSpace(szRoot, + (LPDWORD)&(pdf->sectors_per_cluster), + (LPDWORD)&(pdf->bytes_per_sector), + (LPDWORD)&(pdf->avail_clusters), + (LPDWORD)&(pdf->total_clusters))) { + return ((int)GetLastError()); + } + return (0); +} diff --git a/private/crt32/direct/findfile.c b/private/crt32/direct/findfile.c new file mode 100644 index 000000000..346c63f78 --- /dev/null +++ b/private/crt32/direct/findfile.c @@ -0,0 +1,224 @@ +/*** +*findfile.c - C find file functions +* +* Copyright (c) 1991-1993, Microsoft Corporation. All rights reserved. +* +*Purpose: +* Defines findfirst(), findnext(), and findclose(). +* +*Revision History: +* 08-21-91 BWM Wrote Win32 versions. +* 09-13-91 BWM Changed handle type to long. +* 08-18-92 SKS Add a call to FileTimeToLocalFileTime +* as a temporary fix until _dtoxtime takes UTC +* 08-26-92 SKS creation and last access time should be same as the +* last write time if ctime/atime are not available. +* 01-08-93 SKS Remove change I made 8-26-92. Previous behavior +* was deemed "by design" and preferable. +* 03-30-93 GJF Replaced reference to _dtoxtime with __gmtotime_t. Also +* made _timet_from_ft a static function. +* +*******************************************************************************/ + +#include <cruntime.h> +#include <oscalls.h> +#include <errno.h> +#include <io.h> +#include <time.h> +#include <ctime.h> +#include <string.h> +#include <internal.h> + +#if !defined(_WIN32_) +#error ERROR - ONLY WIN32 TARGET SUPPORTED! +#endif + +static time_t _CRTAPI3 _timet_from_ft(FILETIME * pft); + +/*** +*long findfirst(wildspec, finddata) - Find first matching file +* +*Purpose: +* Finds the first file matching a given wild card filespec and +* returns data about the file. +* +*Entry: +* char * wild - file spec optionally containing wild cards +* +* struct _finddata_t * finddata - structure to receive file data +* +*Exit: +* Good return: +* Unique handle identifying the group of files matching the spec +* +* Error return: +* Returns -1 and errno is set to error value +* +*Exceptions: +* None. +* +*******************************************************************************/ + +long _CRTAPI1 _findfirst(char * szWild, struct _finddata_t * pfd) +{ + WIN32_FIND_DATA wfd; + HANDLE hFile; + DWORD err; + + if ((hFile = FindFirstFile(szWild, &wfd)) == INVALID_HANDLE_VALUE) { + err = GetLastError(); + switch (err) { + case ERROR_NO_MORE_FILES: + case ERROR_FILE_NOT_FOUND: + case ERROR_PATH_NOT_FOUND: + errno = ENOENT; + break; + + case ERROR_NOT_ENOUGH_MEMORY: + errno = ENOMEM; + break; + + default: + errno = EINVAL; + break; + } + return (-1); + } + + pfd->attrib = (wfd.dwFileAttributes == FILE_ATTRIBUTE_NORMAL) + ? 0 : wfd.dwFileAttributes; + pfd->time_create = _timet_from_ft(&wfd.ftCreationTime); + pfd->time_access = _timet_from_ft(&wfd.ftLastAccessTime); + pfd->time_write = _timet_from_ft(&wfd.ftLastWriteTime); + pfd->size = wfd.nFileSizeLow; + strcpy(pfd->name, wfd.cFileName); + + return ((long)hFile); +} + +/*** +*int _findnext(hfind, finddata) - Find next matching file +* +*Purpose: +* Finds the next file matching a given wild card filespec and +* returns data about the file. +* +*Entry: +* hfind - handle from _findfirst +* +* struct _finddata_t * finddata - structure to receive file data +* +*Exit: +* Good return: +* 0 if file found +* -1 if error or file not found +* errno set +* +*Exceptions: +* None. +* +*******************************************************************************/ + +int _CRTAPI1 _findnext(long hFile, struct _finddata_t * pfd) +{ + WIN32_FIND_DATA wfd; + DWORD err; + + if (!FindNextFile((HANDLE)hFile, &wfd)) { + err = GetLastError(); + switch (err) { + case ERROR_NO_MORE_FILES: + case ERROR_FILE_NOT_FOUND: + case ERROR_PATH_NOT_FOUND: + errno = ENOENT; + break; + + case ERROR_NOT_ENOUGH_MEMORY: + errno = ENOMEM; + break; + + default: + errno = EINVAL; + break; + } + return (-1); + } + + pfd->attrib = (wfd.dwFileAttributes == FILE_ATTRIBUTE_NORMAL) + ? 0 : wfd.dwFileAttributes; + pfd->time_create = _timet_from_ft(&wfd.ftCreationTime); + pfd->time_access = _timet_from_ft(&wfd.ftLastAccessTime); + pfd->time_write = _timet_from_ft(&wfd.ftLastWriteTime); + pfd->size = wfd.nFileSizeLow; + strcpy(pfd->name, wfd.cFileName); + + return (0); +} + +/*** +*int _findclose(hfind) - Release resources of find +* +*Purpose: +* Releases resources of a group of files found by _findfirst and +* _findnext +* +*Entry: +* hfind - handle from _findfirst +* +*Exit: +* Good return: +* 0 if success +* -1 if fail, errno set +* +*Exceptions: +* None. +* +*******************************************************************************/ + +int _CRTAPI1 _findclose(long hFile) +{ + if (!FindClose((HANDLE)hFile)) { + errno = EINVAL; + return (-1); + } + return (0); +} + +/*** +*time_t _fttotimet(ft) - convert Win32 file time to Xenix time +* +*Purpose: +* converts a Win32 file time value to Xenix time_t +* +*Entry: +* int yr, mo, dy - date +* int hr, mn, sc - time +* +*Exit: +* returns Xenix time value +* +*Exceptions: +* +*******************************************************************************/ + +static time_t _CRTAPI3 _timet_from_ft(FILETIME * pft) +{ + SYSTEMTIME st; + + // 0 FILETIME returns a -1 time_t + + if (!pft->dwLowDateTime && !pft->dwHighDateTime) { + return (-1L); + } + + if (!FileTimeToSystemTime(pft, &st)) { + return (-1L); + } + + return ( __gmtotime_t(st.wYear, + st.wMonth, + st.wDay, + st.wHour, + st.wMinute, + st.wSecond) ); +} diff --git a/private/crt32/direct/makefile b/private/crt32/direct/makefile new file mode 100644 index 000000000..6ee4f43fa --- /dev/null +++ b/private/crt32/direct/makefile @@ -0,0 +1,6 @@ +# +# DO NOT EDIT THIS FILE!!! Edit .\sources. if you want to add a new source +# file to this component. This file merely indirects to the real make file +# that is shared by all the components of NT OS/2 +# +!INCLUDE $(NTMAKEENV)\makefile.def diff --git a/private/crt32/direct/peekpoke.c b/private/crt32/direct/peekpoke.c new file mode 100644 index 000000000..f00ffb6c2 --- /dev/null +++ b/private/crt32/direct/peekpoke.c @@ -0,0 +1,95 @@ +/*** +*peekpoke.c - Peek or poke absolute memory. +* +* Copyright (c) 1991, Microsoft Corporation. All rights reserved. +* +*Purpose: +* defines _peek(), _poke(), and _getvideoaddress(). +* +*Revision History: +* 08-21-91 BWM Wrote module. +* +*******************************************************************************/ + +#include <cruntime.h> +#include <oscalls.h> +#include <stdlib.h> +#include <dos.h> + +#if !defined(_DOSX32_) +#error ERROR - ONLY DOSX32 TARGET SUPPORTED! +#endif + +/*** +*void _peek(src, dst, size) - Peek at memory +* +*Purpose: +* +*Entry: +* _absaddr_t src - address to be peeked +* void * dst - pointer to location to receive copy +* unsigned short size - number of bytes to peek +* +*Exit: +* None +* +*Exceptions: +* +*******************************************************************************/ + +void _CALLTYPE1 _peek(_absaddr_t aaSrc, void * pvDst, unsigned short cb) +{ + PeekAddress((WORD)((aaSrc & 0xffff0000) >> 16), + (WORD) (aaSrc & 0x0000ffff), + pvDst, cb); +} + +/*** +*void _poke(src, dst, size) - Poke into memory +* +*Purpose: +* +*Entry: +* void * src - pointer to data to be poked +* _absaddr_t dst - address where data will be poked +* unsigned short size - number of bytes to poke +* +*Exit: +* None +* +*Exceptions: +* +*******************************************************************************/ + +void _CALLTYPE1 _poke(void * pvSrc, _absaddr_t aaDst, unsigned short cb) +{ + PokeAddress(pvSrc, + (WORD)((aaDst & 0xffff0000) >> 16), + (WORD) (aaDst & 0x0000ffff), cb); +} + + +/*** +*void _getvideoaddr(region) - Get flat address of video memory +* +*Purpose: +* +*Entry: +* unsigned region - screen memory region: +* +* _ADDR_NO_PALETTE_GRAPHICS - Absolute B800:0000 +* _ADDR_PALETTE_GRAPHICS - Absolute A000:0000 +* _ADDR_COLOR_TEXT - Absolute B800:0000 +* _ADDR_MONO_TEXT - Absolute B000:0000 +* +*Exit: +* None +* +*Exceptions: +* +*******************************************************************************/ + +void * _CALLTYPE1 _getvideoaddr(unsigned dwRegion) +{ + return (GetVideoAddress(dwRegion)); +} diff --git a/private/crt32/direct/seterrm.c b/private/crt32/direct/seterrm.c new file mode 100644 index 000000000..838854db0 --- /dev/null +++ b/private/crt32/direct/seterrm.c @@ -0,0 +1,63 @@ +/*** +*seterrm.c - Set mode for handling critical errors +* +* Copyright (c) 1991, Microsoft Corporation. All rights reserved +* +*Purpose: +* Defines signal() and raise(). +* +*Revision History: +* 08-21-92 BWM Wrote for Win32. +* +*******************************************************************************/ + +#include <cruntime.h> +#include <oscalls.h> + +/*** +*void _seterrormode(mode) - set the critical error mode +* +*Purpose: +* +*Entry: +* int mode - error mode: +* +* 0 means system displays a prompt asking user how to +* respond to the error. Choices differ depending on the +* error but may include Abort, Retry, Ignore, and Fail. +* +* 1 means the call system call causing the error will fail +* and return an error indicating the cause. +* +*Exit: +* none +* +*Exceptions: +* +*******************************************************************************/ + +void _CALLTYPE1 _seterrormode(int mode) +{ +#ifdef _CRUISER_ + + if (mode == 1) { + DOSERROR(1); + else if (mode == 0) { + DOSERROR(0); + } + +#else /* ndef _CRUISER_ */ + +#ifdef _WIN32_ + + SetErrorMode(mode); + +#else /* ndef _WIN32_ */ + +#error ERROR - ONLY CRUISER OR WIN32 TARGET SUPPORTED! + +#endif /* _WIN32_ */ + +#endif /* _CRUISER_ */ + +} diff --git a/private/crt32/direct/slbeep.c b/private/crt32/direct/slbeep.c new file mode 100644 index 000000000..a549e4a5e --- /dev/null +++ b/private/crt32/direct/slbeep.c @@ -0,0 +1,105 @@ +/*** +*slbeep.c - Sleep and beep +* +* Copyright (c) 1991, Microsoft Corporation. All rights reserved. +* +*Purpose: +* defines _sleep() and _beep() +* +*Revision History: +* 08-22-91 BWM Wrote module. +* +*******************************************************************************/ + +#include <cruntime.h> +#include <oscalls.h> +#include <stdlib.h> + +/*** +*void _sleep(duration) - Length of sleep +* +*Purpose: +* +*Entry: +* unsigned long duration - length of sleep in milliseconds or +* one of the following special values: +* +* _SLEEP_MINIMUM - Sends a yield message without any delay +* _SLEEP_FOREVER - Never return +* +*Exit: +* None +* +*Exceptions: +* +*******************************************************************************/ + +void _CALLTYPE1 _sleep(unsigned long dwDuration) +{ +#ifdef _CRUISER_ + + if (dwDuration == _SLEEP_FOREVER) { + while(1) { + DOSSLEEP(dwDuration); + } + } + else { + DOSSLEEP(dwDuration); + } + +#else /* ndef _CRUISER_ */ + +#ifdef _WIN32_ + + if (dwDuration == 0) { + dwDuration++; + } + Sleep(dwDuration); + +#else /* ndef _WIN32_ */ + +#error ERROR - ONLY CRUISER OR WIN32 TARGET SUPPORTED! + +#endif /* _WIN32_ */ + +#endif /* _CRUISER_ */ + +} + +/*** +*void _beep(frequency, duration) - Length of sleep +* +*Purpose: +* +*Entry: +* unsigned frequency - frequency in hertz +* unsigned duration - length of beep in milliseconds +* +*Exit: +* None +* +*Exceptions: +* +*******************************************************************************/ + +void _CALLTYPE1 _beep(unsigned dwFrequency, unsigned dwDuration) +{ +#ifdef _CRUISER_ + + DOSBEEP(dwFrequency, dwDuration); + +#else /* ndef _CRUISER_ */ + +#ifdef _WIN32_ + + Beep(dwFrequency, dwDuration); + +#else /* ndef _WIN32_ */ + +#error ERROR - ONLY CRUISER OR WIN32 TARGET SUPPORTED! + +#endif /* _WIN32_ */ + +#endif /* _CRUISER_ */ + +} diff --git a/private/crt32/direct/sources b/private/crt32/direct/sources new file mode 100644 index 000000000..2fe65d1d1 --- /dev/null +++ b/private/crt32/direct/sources @@ -0,0 +1,40 @@ +!IF 0 + +Copyright (c) 1989 Microsoft Corporation + +Module Name: + + sources. + +Abstract: + + This file specifies the target component being built and the list of + sources files needed to build that component. Also specifies optional + compiler switches and libraries that are unique for the component being + built. + + +Author: + + Steve Wood (stevewo) 12-Apr-1990 + jeffrob 29-sep-1990, use crt32.def + +NOTE: Commented description of this file is in \nt\bak\bin\sources.tpl + +!ENDIF + +MAJORCOMP=crt +MINORCOMP=direct + +TARGETNAME=direct +TARGETPATH=..\obj +TARGETTYPE=LIBRARY +386_STDCALL=0 + +!INCLUDE ..\crt32.def + +SOURCES=drivemap.c \ + drivfree.c \ + findfile.c \ + seterrm.c \ + slbeep.c |