mirror of
https://github.com/reactos/reactos.git
synced 2024-12-27 01:24:38 +00:00
made some small changes
svn path=/trunk/; revision=271
This commit is contained in:
parent
b7b31cec92
commit
5a9cee4031
8 changed files with 201 additions and 22 deletions
64
reactos/lib/crtdll/conio/cgets.c
Normal file
64
reactos/lib/crtdll/conio/cgets.c
Normal file
|
@ -0,0 +1,64 @@
|
|||
#include <conio.h>
|
||||
|
||||
|
||||
char *
|
||||
_cgets(char *string)
|
||||
{
|
||||
unsigned len = 0;
|
||||
unsigned int maxlen_wanted;
|
||||
char *sp;
|
||||
int c;
|
||||
/*
|
||||
* Be smart and check for NULL pointer.
|
||||
* Don't know wether TURBOC does this.
|
||||
*/
|
||||
if (!string)
|
||||
return(NULL);
|
||||
maxlen_wanted = (unsigned int)((unsigned char)string[0]);
|
||||
sp = &(string[2]);
|
||||
/*
|
||||
* Should the string be shorter maxlen_wanted including or excluding
|
||||
* the trailing '\0' ? We don't take any risk.
|
||||
*/
|
||||
while(len < maxlen_wanted-1)
|
||||
{
|
||||
c=getch();
|
||||
/*
|
||||
* shold we check for backspace here?
|
||||
* TURBOC does (just checked) but doesn't in cscanf (thats harder
|
||||
* or even impossible). We do the same.
|
||||
*/
|
||||
if (c == '\b')
|
||||
{
|
||||
if (len > 0)
|
||||
{
|
||||
cputs("\b \b"); /* go back, clear char on screen with space
|
||||
and go back again */
|
||||
len--;
|
||||
sp[len] = '\0'; /* clear the character in the string */
|
||||
}
|
||||
}
|
||||
else if (c == '\r')
|
||||
{
|
||||
sp[len] = '\0';
|
||||
break;
|
||||
}
|
||||
else if (c == 0)
|
||||
{
|
||||
/* special character ends input */
|
||||
sp[len] = '\0';
|
||||
ungetch(c); /* keep the char for later processing */
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
sp[len] = putch(c);
|
||||
len++;
|
||||
}
|
||||
}
|
||||
sp[maxlen_wanted-1] = '\0';
|
||||
string[1] = (char)((unsigned char)len);
|
||||
return(sp);
|
||||
}
|
||||
|
||||
|
|
@ -2,10 +2,6 @@
|
|||
#include <io.h>
|
||||
#include <string.h>
|
||||
|
||||
#if 0
|
||||
|
||||
//UnixTimeToFileTime
|
||||
//FileTimeToUnixTime
|
||||
/*
|
||||
* DOS file system functions
|
||||
*
|
||||
|
@ -18,7 +14,7 @@ void UnixTimeToFileTime( time_t unix_time, FILETIME *filetime, DWORD remainder )
|
|||
time_t FileTimeToUnixTime( const FILETIME *filetime, DWORD *remainder );
|
||||
|
||||
|
||||
long _findfirst(char *_name, struct _finddata_t *result)
|
||||
int _findfirst(const char *_name, struct _finddata_t *result)
|
||||
{
|
||||
WIN32_FIND_DATA FindFileData;
|
||||
char dir[MAX_PATH];
|
||||
|
@ -32,7 +28,7 @@ long _findfirst(char *_name, struct _finddata_t *result)
|
|||
}
|
||||
else
|
||||
strcpy(dir,_name);
|
||||
hFindFile = FindFirstFile( dir, &FindFileData );
|
||||
hFindFile = FindFirstFileA( dir, &FindFileData );
|
||||
result->attrib = FindFileData.dwFileAttributes;
|
||||
|
||||
|
||||
|
@ -44,7 +40,7 @@ long _findfirst(char *_name, struct _finddata_t *result)
|
|||
return hFindFile;
|
||||
}
|
||||
|
||||
int _findnext(long handle, struct _finddata_t *result)
|
||||
int _findnext(int handle, struct _finddata_t *result)
|
||||
{
|
||||
WIN32_FIND_DATA FindFileData;
|
||||
if (handle == -1 )
|
||||
|
@ -61,7 +57,7 @@ int _findnext(long handle, struct _finddata_t *result)
|
|||
strncpy(result->name,&FindFileData.cFileName,260);
|
||||
return 0;
|
||||
}
|
||||
int _findclose(long handle)
|
||||
int _findclose(int handle)
|
||||
{
|
||||
return FindClose(handle);
|
||||
}
|
||||
|
@ -252,4 +248,4 @@ time_t FileTimeToUnixTime( const FILETIME *filetime, DWORD *remainder )
|
|||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -50,13 +50,13 @@ int __GetMainArgs(int *argc,char ***argv,char **env,int flag)
|
|||
cmdline = GetCommandLineA();
|
||||
afterlastspace=0;
|
||||
|
||||
dprintf("cmdline '%s'\n",cmdline);
|
||||
//dprintf("cmdline '%s'\n",cmdline);
|
||||
|
||||
while (cmdline[i])
|
||||
{
|
||||
if (cmdline[i]==' ')
|
||||
{
|
||||
dprintf("cmdline '%s'\n",cmdline);
|
||||
// dprintf("cmdline '%s'\n",cmdline);
|
||||
__argc++;
|
||||
cmdline[i]='\0';
|
||||
__argv[__argc-1] = strdup( cmdline+afterlastspace);
|
||||
|
@ -90,7 +90,7 @@ int __GetMainArgs(int *argc,char ***argv,char **env,int flag)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int _chkstk()
|
||||
int _chkstk(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
|
64
reactos/lib/crtdll/stdio/popen.c
Normal file
64
reactos/lib/crtdll/stdio/popen.c
Normal file
|
@ -0,0 +1,64 @@
|
|||
|
||||
#include <io.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
//#include <unistd.h>
|
||||
#include <libc/file.h>
|
||||
|
||||
|
||||
|
||||
int __fileno_alloc(HANDLE hFile, int mode);
|
||||
|
||||
|
||||
|
||||
FILE *
|
||||
_popen (const char *cm, const char *md) /* program name, pipe mode */
|
||||
{
|
||||
FILE *pf;
|
||||
HANDLE hReadPipe, hWritePipe;
|
||||
HANDLE SpawnedProcess;
|
||||
STARTUPINFO StartupInfo;
|
||||
PROCESS_INFORMATION ProcessInformation;
|
||||
if ( !CreatePipe(&hReadPipe,&hWritePipe,NULL,1024,))
|
||||
return NULL;
|
||||
|
||||
StartupInfo.cb = sizeof(STARTUPINFO);
|
||||
if ( md == "r" ) {
|
||||
StartupInfo.hStdOutput = hWritePipe;
|
||||
}
|
||||
else if ( md == "w" ) {
|
||||
StartupInfo.hStdInput = hReadPipe;
|
||||
}
|
||||
|
||||
SpawnedProcess = CreateProcess("cmd.exe",cm,NULL,NULL,TRUE,CREATE_NEW_CONSOLE,NULL,NULL,&StartupInfo,&ProcessInformation );
|
||||
|
||||
|
||||
if ( *md == 'r' ) {
|
||||
pf = _fdopen( __fileno_alloc(hReadPipe, O_RDONLY) , "r" );
|
||||
}
|
||||
else {
|
||||
pf = _fdopen( __fileno_alloc(hWritePipe, _O_WRONLY) , "w" );
|
||||
}
|
||||
|
||||
pf->name_to_remove = SpawnedProcess;
|
||||
|
||||
return pf;
|
||||
|
||||
|
||||
}
|
||||
FILE* _wpopen (const wchar_t* szPipeName, const wchar_t* szMode)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int
|
||||
pclose (FILE *pp)
|
||||
{
|
||||
|
||||
fclose(pp);
|
||||
if (!TerminateProcess(pp->name_to_remove,0))
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
50
reactos/lib/crtdll/stdio/rmtmp.c
Normal file
50
reactos/lib/crtdll/stdio/rmtmp.c
Normal file
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
* FILE: lib/crtdll/stdio/rmtmp.c
|
||||
* PURPOSE: remove temporary files in current directory
|
||||
* PROGRAMMER: Boudewijn ( ariadne@xs4all.nl)
|
||||
* UPDATE HISTORY:
|
||||
* Created 19/01/99
|
||||
* NOTE Not tested.
|
||||
*/
|
||||
extern __file_rec *__file_rec_list;
|
||||
|
||||
int _rmtmp( void )
|
||||
{
|
||||
/*
|
||||
loop files and check for name_to_remove
|
||||
*/
|
||||
__file_rec *fr = __file_rec_list;
|
||||
__file_rec **last_fr = &__file_rec_list;
|
||||
|
||||
int total_closed;
|
||||
int i = 0;
|
||||
char temp_name[260];
|
||||
|
||||
/* Try to find an empty slot */
|
||||
while (fr)
|
||||
{
|
||||
last_fr = &(fr->next);
|
||||
|
||||
/* If one of the existing slots is available, return it */
|
||||
for (i=0; i<fr->count; i++) {
|
||||
if (fr->files[i]->_name_to_remove != NULL) {
|
||||
if ( access(fr->files[i]->_name_to_remove) ) {
|
||||
strcpy(temp_name,fr->files[i]->_name_to_remove);
|
||||
fclose(fr->files[i]);
|
||||
remove(temp_name);
|
||||
total_closed++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* If this one is full, go to the next */
|
||||
if (fr->count == __FILE_REC_MAX)
|
||||
fr = fr->next;
|
||||
else
|
||||
/* it isn't full, we can add to it */
|
||||
break;
|
||||
}
|
||||
return total_closed;
|
||||
}
|
|
@ -1,13 +1,18 @@
|
|||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <windows.h>
|
||||
#include <errno.h>
|
||||
|
||||
#undef errno
|
||||
int errno;
|
||||
int _doserrno;
|
||||
int __crtdll_errno;
|
||||
|
||||
|
||||
int _errno(void)
|
||||
int *_errno(void)
|
||||
{
|
||||
return errno;
|
||||
__crtdll_errno = GetLastError();
|
||||
return &__crtdll_errno;
|
||||
}
|
||||
|
||||
int *__dos_errno(void)
|
||||
{
|
||||
__crtdll_errno = GetLastError();
|
||||
return &__crtdll_errno;
|
||||
}
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ strtol(const char *nptr, char **endptr, int base)
|
|||
if (any < 0)
|
||||
{
|
||||
acc = neg ? LONG_MIN : LONG_MAX;
|
||||
errno = ERANGE;
|
||||
// errno = ERANGE;
|
||||
}
|
||||
else if (neg)
|
||||
acc = -acc;
|
||||
|
@ -168,7 +168,7 @@ wcstol(const wchar_t *nptr, wchar_t **endptr, int base)
|
|||
if (any < 0)
|
||||
{
|
||||
acc = neg ? LONG_MIN : LONG_MAX;
|
||||
errno = ERANGE;
|
||||
// errno = ERANGE;
|
||||
}
|
||||
else if (neg)
|
||||
acc = -acc;
|
||||
|
|
|
@ -65,7 +65,7 @@ strtoul(const char *nptr, char **endptr, int base)
|
|||
if (any < 0)
|
||||
{
|
||||
acc = ULONG_MAX;
|
||||
errno = ERANGE;
|
||||
// errno = ERANGE;
|
||||
}
|
||||
else if (neg)
|
||||
acc = -acc;
|
||||
|
@ -128,7 +128,7 @@ wcstoul(const wchar_t *nptr, wchar_t **endptr, int base)
|
|||
if (any < 0)
|
||||
{
|
||||
acc = ULONG_MAX;
|
||||
errno = ERANGE;
|
||||
// errno = ERANGE;
|
||||
}
|
||||
else if (neg)
|
||||
acc = -acc;
|
||||
|
|
Loading…
Reference in a new issue