Fix buffered input function. Add support for UMB subfunctions to

memory allocation strategy function. Move flock to winedos.
oldstable
Jukka Heinonen 2003-01-30 00:17:03 +00:00 committed by Alexandre Julliard
parent 766ea910b9
commit 8e8518d4ba
2 changed files with 117 additions and 65 deletions

View File

@ -282,6 +282,80 @@ static WORD INT21_GetHeapSelector( CONTEXT86 *context )
}
/***********************************************************************
* INT21_BufferedInput
*
* Handler for function 0x0a.
*
* Reads a string of characters from standard input until
* enter key is pressed.
*/
static void INT21_BufferedInput( CONTEXT86 *context )
{
BYTE *ptr = CTX_SEG_OFF_TO_LIN(context,
context->SegDs,
context->Edx);
BYTE capacity = ptr[0]; /* includes CR */
BYTE length = 0; /* excludes CR */
TRACE( "BUFFERED INPUT (size=%d)\n", capacity );
/*
* Return immediately if capacity is zero.
*
* FIXME: What to return to application?
*/
if (capacity == 0)
return;
/*
* FIXME: Some documents state that
* ptr[1] holds number of chars from last input which
* may be recalled on entry, other documents do not mention
* this at all.
*/
if (ptr[1])
TRACE( "Handle old chars in buffer!\n" );
while(TRUE)
{
BYTE ascii;
BYTE scan;
DOSVM_Int16ReadChar( &ascii, &scan, FALSE );
if (ascii == '\r' || ascii == '\n')
{
/*
* FIXME: What should be echoed here?
*/
DOSVM_PutChar( '\r' );
DOSVM_PutChar( '\n' );
ptr[1] = length;
ptr[2 + length] = '\r';
return;
}
/*
* FIXME: This function is supposed to support
* DOS editing keys...
*/
/*
* If the buffer becomes filled to within one byte of
* capacity, DOS rejects all further characters up to,
* but not including, the terminating carriage return.
*/
if (ascii != 0 && length < capacity-1)
{
DOSVM_PutChar( ascii );
ptr[2 + length] = ascii;
length++;
}
}
}
/***********************************************************************
* INT21_ExtendedCountryInformation
*
@ -792,7 +866,7 @@ void WINAPI DOSVM_Int21Handler( CONTEXT86 *context )
break;
case 0x0a: /* BUFFERED INPUT */
INT_Int21Handler( context );
INT21_BufferedInput( context );
break;
case 0x0b: /* GET STDIN STATUS */
@ -1222,22 +1296,30 @@ void WINAPI DOSVM_Int21Handler( CONTEXT86 *context )
break;
case 0x58: /* GET OR SET MEMORY ALLOCATION STRATEGY */
TRACE( "GET OR SET MEMORY ALLOCATION STRATEGY, subfunction %d\n",
AL_reg(context) );
switch (AL_reg(context))
{
case 0x00: /* GET ALLOCATION STRATEGY */
SET_AX( context, 1 ); /* low memory best fit */
case 0x00: /* GET MEMORY ALLOCATION STRATEGY */
TRACE( "GET MEMORY ALLOCATION STRATEGY\n" );
SET_AX( context, 0 ); /* low memory first fit */
break;
case 0x01: /* SET ALLOCATION STRATEGY */
TRACE( "Set allocation strategy to %d - ignored\n",
TRACE( "SET MEMORY ALLOCATION STRATEGY to %d - ignored\n",
BL_reg(context) );
break;
case 0x02: /* GET UMB LINK STATE */
TRACE( "GET UMB LINK STATE\n" );
SET_AL( context, 0 ); /* UMBs not part of DOS memory chain */
break;
case 0x03: /* SET UMB LINK STATE */
TRACE( "SET UMB LINK STATE to %d - ignored\n",
BX_reg(context) );
break;
default:
INT_BARF( context, 0x21 );
break;
}
break;
@ -1247,10 +1329,37 @@ void WINAPI DOSVM_Int21Handler( CONTEXT86 *context )
case 0x5a: /* CREATE TEMPORARY FILE */
case 0x5b: /* CREATE NEW FILE */
case 0x5c: /* "FLOCK" - RECORD LOCKING */
INT_Int21Handler( context );
break;
case 0x5c: /* "FLOCK" - RECORD LOCKING */
{
DWORD offset = MAKELONG(DX_reg(context), CX_reg(context));
DWORD length = MAKELONG(DI_reg(context), SI_reg(context));
HANDLE handle = DosFileHandleToWin32Handle(BX_reg(context));
switch (AL_reg(context))
{
case 0x00: /* LOCK */
TRACE( "lock handle %d offset %ld length %ld\n",
BX_reg(context), offset, length );
if (!LockFile( handle, offset, 0, length, 0 ))
bSetDOSExtendedError = TRUE;
break;
case 0x01: /* UNLOCK */
TRACE( "unlock handle %d offset %ld length %ld\n",
BX_reg(context), offset, length );
if (!UnlockFile( handle, offset, 0, length, 0 ))
bSetDOSExtendedError = TRUE;
break;
default:
INT_BARF( context, 0x21 );
}
}
break;
case 0x5d: /* NETWORK 5D */
FIXME( "Network function 5D not implemented.\n" );
SetLastError( ER_NoNetwork );

View File

@ -876,43 +876,6 @@ static int INT21_FindNextFCB( CONTEXT86 *context )
}
static void fLock( CONTEXT86 * context )
{
switch ( AX_reg(context) & 0xff )
{
case 0x00: /* LOCK */
TRACE("lock handle %d offset %ld length %ld\n",
BX_reg(context),
MAKELONG(DX_reg(context),CX_reg(context)),
MAKELONG(DI_reg(context),SI_reg(context))) ;
if (!LockFile(DosFileHandleToWin32Handle(BX_reg(context)),
MAKELONG(DX_reg(context),CX_reg(context)), 0,
MAKELONG(DI_reg(context),SI_reg(context)), 0)) {
SET_AX( context, GetLastError() );
SET_CFLAG(context);
}
break;
case 0x01: /* UNLOCK */
TRACE("unlock handle %d offset %ld length %ld\n",
BX_reg(context),
MAKELONG(DX_reg(context),CX_reg(context)),
MAKELONG(DI_reg(context),SI_reg(context))) ;
if (!UnlockFile(DosFileHandleToWin32Handle(BX_reg(context)),
MAKELONG(DX_reg(context),CX_reg(context)), 0,
MAKELONG(DI_reg(context),SI_reg(context)), 0)) {
SET_AX( context, GetLastError() );
SET_CFLAG(context);
}
return;
default:
SET_AX( context, 0x0001 );
SET_CFLAG(context);
return;
}
}
static BOOL
INT21_networkfunc (CONTEXT86 *context)
{
@ -980,26 +943,6 @@ void WINAPI INT_Int21Handler( CONTEXT86 *context )
}
break;
case 0x0a: /* BUFFERED INPUT */
{
char *buffer = ((char *)CTX_SEG_OFF_TO_LIN(context, context->SegDs,
context->Edx ));
int res;
TRACE("BUFFERED INPUT (size=%d)\n",buffer[0]);
if (buffer[1])
TRACE("Handle old chars in buffer!\n");
res=_lread16( 0, buffer+2,buffer[0]);
buffer[1]=res;
if(buffer[res+1] == '\n')
buffer[res+1] = '\r';
break;
}
case 0x5c: /* "FLOCK" - RECORD LOCKING */
fLock(context);
break;
case 0x0e: /* SELECT DEFAULT DRIVE */
TRACE("SELECT DEFAULT DRIVE %d\n", DL_reg(context));
DRIVE_SetCurrentDrive( DL_reg(context) );