inthndler cleanups, mostly from Arkady

Bart: made dosmktmp to return a long: consistent with DosOpen et al and
avoids the cast.


git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@948 6ac86273-5f31-0410-b378-82cca8765d1b
This commit is contained in:
Bart Oldeman 2004-05-23 19:45:48 +00:00
parent e0133fe31b
commit b723ff9a46
3 changed files with 58 additions and 74 deletions

View File

@ -382,7 +382,7 @@ int int21_fat32(lregs *r)
VOID ASMCFUNC int21_service(iregs FAR * r) VOID ASMCFUNC int21_service(iregs FAR * r)
{ {
COUNT rc = 0; COUNT rc;
long lrc; long lrc;
lregs lr; /* 8 local registers (ax, bx, cx, dx, si, di, ds, es) */ lregs lr; /* 8 local registers (ax, bx, cx, dx, si, di, ds, es) */
@ -671,10 +671,9 @@ dispatch:
/* Parse File Name */ /* Parse File Name */
case 0x29: case 0x29:
{ rc = 0;
lr.SI = FcbParseFname(&rc, MK_FP(lr.DS, lr.SI), FP_ES_DI); lr.SI = FcbParseFname(&rc, MK_FP(lr.DS, lr.SI), FP_ES_DI);
lr.AL = rc; lr.AL = rc;
}
break; break;
/* Get Date */ /* Get Date */
@ -765,8 +764,8 @@ dispatch:
if (dpb == NULL) if (dpb == NULL)
{ {
CritErrCode = -DE_INVLDDRV;
lr.AL = 0xFF; lr.AL = 0xFF;
CritErrCode = 0x0f;
break; break;
} }
/* hazard: no error checking! */ /* hazard: no error checking! */
@ -780,7 +779,7 @@ dispatch:
#endif #endif
{ {
lr.AL = 0xff; lr.AL = 0xff;
CritErrCode = 0x0f; CritErrCode = -DE_INVLDDRV;
break; break;
} }
lr.DS = FP_SEG(dpb); lr.DS = FP_SEG(dpb);
@ -839,21 +838,24 @@ dispatch:
if (0xffff == lr.DX) if (0xffff == lr.DX)
{ {
/* Set Country Code */ /* Set Country Code */
if ((rc = DosSetCountry(cntry)) < 0) rc = DosSetCountry(cntry);
goto error_invalid; goto short_check;
} }
else else
{ {
if (cntry == 0) if (cntry == 0)
cntry--; cntry--;
/* Get Country Information */ /* Get Country Information */
if ((rc = DosGetCountryInformation(cntry, FP_DS_DX)) < 0) rc = DosGetCountryInformation(cntry, FP_DS_DX);
goto error_invalid; if (rc >= SUCCESS)
/* HACK FIXME */ {
if (cntry == (UWORD) - 1) /* HACK FIXME */
cntry = 1; if (cntry == (UWORD) - 1)
/* END OF HACK */ cntry = 1;
lr.AX = lr.BX = cntry; /* END OF HACK */
lr.AX = lr.BX = cntry;
}
goto short_check;
} }
} }
break; break;
@ -928,8 +930,7 @@ dispatch:
case 0x01: case 0x01:
rc = DosSetFattr((BYTE FAR *) FP_DS_DX, lr.CX); rc = DosSetFattr((BYTE FAR *) FP_DS_DX, lr.CX);
if (rc >= SUCCESS) lr.AX = lr.CX;
lr.AX = lr.CX;
break; break;
default: default:
@ -941,11 +942,11 @@ dispatch:
case 0x44: case 0x44:
rc = DosDevIOctl(&lr); /* can set critical error code! */ rc = DosDevIOctl(&lr); /* can set critical error code! */
if (rc != SUCCESS) if (rc < SUCCESS)
{ {
lr.AX = -rc; lr.AX = -rc;
if (rc != DE_DEVICE && rc != DE_ACCESS) if (rc != DE_DEVICE && rc != DE_ACCESS)
CritErrCode = -rc; CritErrCode = lr.AX;
goto error_carry; goto error_carry;
} }
break; break;
@ -963,34 +964,29 @@ dispatch:
/* Get Current Directory */ /* Get Current Directory */
case 0x47: case 0x47:
rc = DosGetCuDir(lr.DL, MK_FP(lr.DS, lr.SI)); rc = DosGetCuDir(lr.DL, MK_FP(lr.DS, lr.SI));
if (rc >= SUCCESS) lr.AX = 0x0100; /*jpp: from interrupt list */
lr.AX = 0x0100; /*jpp: from interrupt list */
goto short_check; goto short_check;
/* Allocate memory */ /* Allocate memory */
case 0x48: case 0x48:
if ((rc = if ((rc = DosMemAlloc(lr.BX, mem_access_mode, &lr.AX, &lr.BX)) < 0)
DosMemAlloc(lr.BX, mem_access_mode, &(lr.AX), &(lr.BX))) < 0)
{ {
DosMemLargest(&(lr.BX)); DosMemLargest(&lr.BX);
{ if (DosMemCheck() != SUCCESS)
if (DosMemCheck() != SUCCESS) panic("MCB chain corrupted");
panic("MCB chain corrupted");
}
goto error_exit; goto error_exit;
} }
else lr.AX++; /* DosMemAlloc() returns seg of MCB rather than data */
++(lr.AX); /* DosMemAlloc() returns seg of MCB rather than data */
break; break;
/* Free memory */ /* Free memory */
case 0x49: case 0x49:
if ((rc = DosMemFree((lr.ES) - 1)) < 0) if ((rc = DosMemFree(lr.ES - 1)) < SUCCESS)
{ {
if (DosMemCheck() != SUCCESS) if (DosMemCheck() != SUCCESS)
panic("MCB chain corrupted"); panic("MCB chain corrupted");
goto error_exit; goto error_exit;
} }
break; break;
/* Set memory block size */ /* Set memory block size */
@ -1003,10 +999,7 @@ dispatch:
#if 0 #if 0
if (cu_psp == lr.ES) if (cu_psp == lr.ES)
{ {
psp FAR *p = MK_FP(cu_psp, 0);
psp FAR *p;
p = MK_FP(cu_psp, 0);
p->ps_size = lr.BX + cu_psp; p->ps_size = lr.BX + cu_psp;
} }
#endif #endif
@ -1032,21 +1025,18 @@ dispatch:
if (((psp FAR *)MK_FP(cu_psp, 0))->ps_parent == cu_psp) if (((psp FAR *)MK_FP(cu_psp, 0))->ps_parent == cu_psp)
break; break;
tsr = FALSE; tsr = FALSE;
rc = 0;
if (ErrorMode) if (ErrorMode)
{ {
ErrorMode = FALSE; ErrorMode = FALSE;
rc = 2; rc = 0x200;
} }
else if (break_flg) else if (break_flg)
{ {
break_flg = FALSE; break_flg = FALSE;
rc = 1; rc = 0x100;
} }
else return_code = lr.AL | rc;
{
rc = 0;
}
return_code = lr.AL | (rc << 8);
if (DosMemCheck() != SUCCESS) if (DosMemCheck() != SUCCESS)
panic("MCB chain corrupted"); panic("MCB chain corrupted");
#ifdef TSC #ifdef TSC
@ -1067,8 +1057,7 @@ dispatch:
/* dta for this call is set on entry. This */ /* dta for this call is set on entry. This */
/* needs to be changed for new versions. */ /* needs to be changed for new versions. */
rc = DosFindFirst(lr.CX, FP_DS_DX); rc = DosFindFirst(lr.CX, FP_DS_DX);
if (rc >= SUCCESS) lr.AX = 0;
lr.AX = 0;
goto short_check; goto short_check;
/* Dos Find Next */ /* Dos Find Next */
@ -1076,8 +1065,7 @@ dispatch:
/* dta for this call is set on entry. This */ /* dta for this call is set on entry. This */
/* needs to be changed for new versions. */ /* needs to be changed for new versions. */
rc = DosFindNext(); rc = DosFindNext();
if (rc >= SUCCESS) lr.AX = 0;
lr.AX = 0;
goto short_check; goto short_check;
/* /*
case 0x50: case 0x50:
@ -1189,10 +1177,8 @@ dispatch:
/* Create Temporary File */ /* Create Temporary File */
case 0x5a: case 0x5a:
if ((rc = DosMkTmp(FP_DS_DX, lr.CX)) < 0) lrc = DosMkTmp(FP_DS_DX, lr.CX);
goto error_exit; goto long_check;
lr.AX = rc;
break;
/* Create New File */ /* Create New File */
case 0x5b: case 0x5b:
@ -1202,11 +1188,10 @@ dispatch:
/* /// Added for SHARE. - Ron Cemer */ /* /// Added for SHARE. - Ron Cemer */
/* Lock/unlock file access */ /* Lock/unlock file access */
case 0x5c: case 0x5c:
if ((rc = DosLockUnlock rc = DosLockUnlock
(lr.BX, (lr.BX, ((unsigned long)lr.CX << 16) | lr.DX,
(((unsigned long)lr.CX) << 16) | (((unsigned long)lr.DX) ), ((unsigned long)lr.SI << 16) | lr.DI, lr.AL != 0);
(((unsigned long)lr.SI) << 16) | (((unsigned long)lr.DI) ), if (rc != SUCCESS)
((lr.AX & 0xff) != 0))) != 0)
goto error_exit; goto error_exit;
break; break;
/* /// End of additions for SHARE. - Ron Cemer */ /* /// End of additions for SHARE. - Ron Cemer */
@ -1232,10 +1217,11 @@ dispatch:
case 0x08: case 0x08:
case 0x09: case 0x09:
rc = remote_printredir(lr.DX, Int21AX); rc = remote_printredir(lr.DX, Int21AX);
CLEAR_CARRY_FLAG();
if (rc != SUCCESS) if (rc != SUCCESS)
goto error_exit; goto error_exit;
CLEAR_CARRY_FLAG();
break; break;
default: default:
CritErrCode = SUCCESS; CritErrCode = SUCCESS;
goto error_invalid; goto error_invalid;
@ -1499,21 +1485,19 @@ dispatch:
goto error_invalid; goto error_invalid;
} }
lr.AX = rc; lr.AX = rc;
if (rc < 0) goto error_exit; CLEAR_CARRY_FLAG();
else CLEAR_CARRY_FLAG(); goto short_check;
break;
} }
#endif #endif
} }
goto exit_dispatch; goto exit_dispatch;
long_check: long_check:
if (lrc < SUCCESS) if (lrc >= SUCCESS)
{ {
rc = (int)lrc; lr.AX = (UWORD)lrc;
goto error_exit; goto exit_dispatch;
} }
lr.AX = (UWORD)lrc; rc = (int)lrc;
goto exit_dispatch;
short_check: short_check:
if (rc < SUCCESS) if (rc < SUCCESS)
goto error_exit; goto error_exit;

View File

@ -65,12 +65,12 @@ int SetJFTSize(UWORD nHandles)
return SUCCESS; return SUCCESS;
} }
int DosMkTmp(BYTE FAR * pathname, UWORD attr) long DosMkTmp(BYTE FAR * pathname, UWORD attr)
{ {
/* create filename from current date and time */ /* create filename from current date and time */
char FAR *ptmp; char FAR *ptmp;
unsigned long randvar; unsigned long randvar;
int rc; long rc;
int loop; int loop;
ptmp = pathname + fstrlen(pathname); ptmp = pathname + fstrlen(pathname);
@ -94,7 +94,7 @@ int DosMkTmp(BYTE FAR * pathname, UWORD attr)
ptmp[i] -= (ptmp[i] < 'A' + 10) ? '0' - 'A' : 10; ptmp[i] -= (ptmp[i] < 'A' + 10) ? '0' - 'A' : 10;
/* only create new file -- 2001/09/22 ska*/ /* only create new file -- 2001/09/22 ska*/
rc = (short)DosOpen(pathname, O_LEGACY | O_CREAT | O_RDWR, attr); rc = DosOpen(pathname, O_LEGACY | O_CREAT | O_RDWR, attr);
} while (rc == DE_FILEEXISTS && loop++ < 0xfff); } while (rc == DE_FILEEXISTS && loop++ < 0xfff);
return rc; return rc;

View File

@ -373,7 +373,7 @@ VOID InitPSP(VOID);
/* newstuff.c */ /* newstuff.c */
int SetJFTSize(UWORD nHandles); int SetJFTSize(UWORD nHandles);
int DosMkTmp(BYTE FAR * pathname, UWORD attr); long DosMkTmp(BYTE FAR * pathname, UWORD attr);
COUNT truename(const char FAR * src, char * dest, COUNT t); COUNT truename(const char FAR * src, char * dest, COUNT t);
/* network.c */ /* network.c */