105 lines
2.2 KiB
C
105 lines
2.2 KiB
C
/* nwtests.c - small DOS utility tests */
|
|
|
|
#include "net.h"
|
|
#include "c32ncp.h"
|
|
static int tests_same_arg(char *a, char *b)
|
|
{
|
|
while (*a || *b) {
|
|
int ca = *a++;
|
|
int cb = *b++;
|
|
if (ca >= 'a' && ca <= 'z') ca -= 32;
|
|
if (cb >= 'a' && cb <= 'z') cb -= 32;
|
|
if (ca != cb) return(0);
|
|
}
|
|
return(1);
|
|
}
|
|
|
|
static void tests_usage(void)
|
|
{
|
|
fprintf(stdout, "Usage: TESTS [NCP87C32ATTR|NCP87C32AUTO]\n");
|
|
}
|
|
|
|
static int tests_get_current_drive(void)
|
|
{
|
|
REGS regs;
|
|
|
|
regs.h.ah = 0x19;
|
|
int86(0x21, ®s, ®s);
|
|
return((int)regs.h.al);
|
|
}
|
|
|
|
static int tests_current_dhandle(uint8 *dhandle)
|
|
{
|
|
uint8 connid = 0;
|
|
uint8 flags = 0;
|
|
int drive;
|
|
|
|
drive = tests_get_current_drive();
|
|
if (get_drive_info((uint8)drive, &connid, dhandle, &flags))
|
|
return(-1);
|
|
|
|
if (!connid || (flags & 0x80))
|
|
return(-1);
|
|
|
|
return(0);
|
|
}
|
|
|
|
static int tests_ncp87c32attr(void)
|
|
{
|
|
uint8 dhandle = 0;
|
|
uint32 attr = 0;
|
|
uint16 actual = 0;
|
|
uint16 handle_lo = 0;
|
|
uint16 handle_hi = 0;
|
|
int rc;
|
|
|
|
if (tests_current_dhandle(&dhandle)) {
|
|
fprintf(stdout, "NCP87C32ATTR failed: current drive is not a network drive\n");
|
|
return(1);
|
|
}
|
|
|
|
rc = c32_ncp87_obtain_rim_attributes("LOGIN.EXE",
|
|
(uint16)dhandle,
|
|
&attr,
|
|
&actual,
|
|
&handle_lo,
|
|
&handle_hi);
|
|
if (rc) {
|
|
fprintf(stdout, "NCP87C32ATTR failed rc=%d\n", rc);
|
|
return(rc);
|
|
}
|
|
|
|
fprintf(stdout, "NCP87C32ATTR LOGIN.EXE attr=%02lX handle=%04X:%04X actual=%04X\n",
|
|
attr & 0xffUL, handle_hi, handle_lo, actual);
|
|
|
|
return(0);
|
|
}
|
|
|
|
static int tests_ncp87c32auto(void)
|
|
{
|
|
/*
|
|
* Kept as a compatibility alias for the former verbose test command.
|
|
* The production helper path is exercised by NCP87C32ATTR.
|
|
*/
|
|
return tests_ncp87c32attr();
|
|
}
|
|
|
|
int func_tests(int argc, char *argv[], int mode)
|
|
{
|
|
(void)mode;
|
|
|
|
if (argc < 2) {
|
|
tests_usage();
|
|
return(1);
|
|
}
|
|
|
|
if (tests_same_arg(argv[1], "NCP87C32ATTR"))
|
|
return tests_ncp87c32attr();
|
|
|
|
if (tests_same_arg(argv[1], "NCP87C32AUTO"))
|
|
return tests_ncp87c32auto();
|
|
|
|
tests_usage();
|
|
return(1);
|
|
}
|