Compare commits
43 Commits
4e49ecec1a
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1d4789de1b | ||
|
|
a5ce0d2f63 | ||
|
|
3562cd1301 | ||
|
|
99c3eed1bf | ||
|
|
ed5da6c063 | ||
|
|
19ded9333b | ||
|
|
847559631a | ||
|
|
1f74c940d8 | ||
|
|
24ccc1257d | ||
|
|
e6495fb949 | ||
|
|
e5aa3a8b90 | ||
|
|
56a76d3b43 | ||
|
|
0c14d040aa | ||
|
|
7ceddb8a82 | ||
|
|
cc96eb72c4 | ||
|
|
fe91b08d5d | ||
|
|
ae2e1c3062 | ||
|
|
f48f62dd91 | ||
|
|
fa999bd0c9 | ||
|
|
e4dc502dcb | ||
|
|
02566b661f | ||
|
|
c412f2ebbd | ||
|
|
b8b323e3c3 | ||
|
|
30fc1f7069 | ||
|
|
b42b0e2a58 | ||
|
|
4d01fbd118 | ||
|
|
a2d4025452 | ||
|
|
f0bb61b0d7 | ||
|
|
6db4fc17fa | ||
|
|
1601a80513 | ||
|
|
d1840da361 | ||
|
|
f263335ef9 | ||
|
|
bb6c34dce4 | ||
|
|
f0c1cfcd84 | ||
|
|
7e5b75b4cc | ||
|
|
4809bd7e30 | ||
|
|
0ca6a3baaf | ||
|
|
3d2e7913ad | ||
|
|
04c737d310 | ||
|
|
7dad85c13e | ||
|
|
00654ad161 | ||
|
|
7b3778ceb4 | ||
|
|
f08aa986a8 |
@@ -24,6 +24,7 @@ set(MARS_DOSUTILS_PUBLIC_TOOLS
|
|||||||
mapdel
|
mapdel
|
||||||
logout
|
logout
|
||||||
slist
|
slist
|
||||||
|
flag
|
||||||
capture
|
capture
|
||||||
endcap
|
endcap
|
||||||
)
|
)
|
||||||
@@ -35,6 +36,7 @@ if(MARS_NWE_BUILD_DOSUTILS)
|
|||||||
find_package(OpenWatcom REQUIRED)
|
find_package(OpenWatcom REQUIRED)
|
||||||
|
|
||||||
set(DOSUTILS_C_SOURCES
|
set(DOSUTILS_C_SOURCES
|
||||||
|
kern.c
|
||||||
net.c
|
net.c
|
||||||
tools.c
|
tools.c
|
||||||
netcall.c
|
netcall.c
|
||||||
@@ -42,6 +44,7 @@ if(MARS_NWE_BUILD_DOSUTILS)
|
|||||||
login.c
|
login.c
|
||||||
map.c
|
map.c
|
||||||
slist.c
|
slist.c
|
||||||
|
flag.c
|
||||||
nwcrypt.c
|
nwcrypt.c
|
||||||
nwdebug.c
|
nwdebug.c
|
||||||
nwtests.c
|
nwtests.c
|
||||||
@@ -117,3 +120,8 @@ install(FILES "${MARS_DOSUTILS_NET_EXE}"
|
|||||||
install(FILES "${MARS_DOSUTILS_NET_EXE}"
|
install(FILES "${MARS_DOSUTILS_NET_EXE}"
|
||||||
DESTINATION "${MARS_NWE_INSTALL_FULL_FILEDIR}/SYS/login"
|
DESTINATION "${MARS_NWE_INSTALL_FULL_FILEDIR}/SYS/login"
|
||||||
RENAME map.exe)
|
RENAME map.exe)
|
||||||
|
|
||||||
|
install(FILES "${MARS_DOSUTILS_NET_EXE}"
|
||||||
|
DESTINATION "${MARS_NWE_INSTALL_FULL_FILEDIR}/SYS/login"
|
||||||
|
RENAME slist.exe)
|
||||||
|
|
||||||
|
|||||||
486
flag.c
Normal file
486
flag.c
Normal file
@@ -0,0 +1,486 @@
|
|||||||
|
/* flag.c - Novell FLAG-like DOS utility, stage 1 */
|
||||||
|
|
||||||
|
#include "net.h"
|
||||||
|
#include <dos.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* FLAG v4b: NCP 87 namespace DOS info.
|
||||||
|
*
|
||||||
|
* ncpfs reference:
|
||||||
|
* ncp_ns_modify_entry_dos_info():
|
||||||
|
* subfunction 7, namespace DOS, search attrs SA_ALL,
|
||||||
|
* ModifyInformationMask, struct ncp_dos_info, handle/path.
|
||||||
|
*
|
||||||
|
* We use dirstyle=0 (short directory handle) against the current DOS
|
||||||
|
* directory handle and a one-component DOS filename.
|
||||||
|
*/
|
||||||
|
#define FLAG_NW_NS_DOS 0x00
|
||||||
|
#define FLAG_SA_ALL 0x0006
|
||||||
|
#define FLAG_RIM_ATTRIBUTES 0x00000004UL
|
||||||
|
|
||||||
|
#define NWFA_RO 0x00000001UL
|
||||||
|
#define NWFA_H 0x00000002UL
|
||||||
|
#define NWFA_SY 0x00000004UL
|
||||||
|
#define NWFA_A 0x00000020UL
|
||||||
|
#define NWFA_S 0x00000080UL
|
||||||
|
#define NWFA_T 0x00001000UL
|
||||||
|
#define NWFA_RA 0x00004000UL
|
||||||
|
#define NWFA_WA 0x00008000UL
|
||||||
|
#define NWFA_P 0x00010000UL
|
||||||
|
#define NWFA_RI 0x00020000UL
|
||||||
|
#define NWFA_DI 0x00040000UL
|
||||||
|
#define NWFA_CI 0x00080000UL
|
||||||
|
|
||||||
|
static void flag_put_word_lh(uint8 *p, uint16 v)
|
||||||
|
{
|
||||||
|
p[0] = (uint8)(v & 0xff);
|
||||||
|
p[1] = (uint8)((v >> 8) & 0xff);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void flag_put_dword_lh(uint8 *p, uint32 v)
|
||||||
|
{
|
||||||
|
p[0] = (uint8)(v & 0xff);
|
||||||
|
p[1] = (uint8)((v >> 8) & 0xff);
|
||||||
|
p[2] = (uint8)((v >> 16) & 0xff);
|
||||||
|
p[3] = (uint8)((v >> 24) & 0xff);
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint32 flag_get_dword_lh(uint8 *p)
|
||||||
|
{
|
||||||
|
return((uint32)p[0] |
|
||||||
|
((uint32)p[1] << 8) |
|
||||||
|
((uint32)p[2] << 16) |
|
||||||
|
((uint32)p[3] << 24));
|
||||||
|
}
|
||||||
|
|
||||||
|
static int flag_get_current_drive(void)
|
||||||
|
{
|
||||||
|
REGS regs;
|
||||||
|
|
||||||
|
regs.h.ah = 0x19; /* DOS get current default drive */
|
||||||
|
int86(0x21, ®s, ®s); /* AL = 0 for A:, 1 for B:, ... */
|
||||||
|
|
||||||
|
return((int)regs.h.al);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int flag_current_dhandle(uint8 *dhandle)
|
||||||
|
{
|
||||||
|
uint8 connid = 0;
|
||||||
|
uint8 flags = 0;
|
||||||
|
int drive;
|
||||||
|
|
||||||
|
drive = flag_get_current_drive();
|
||||||
|
if (get_drive_info((uint8)drive, &connid, dhandle, &flags))
|
||||||
|
return(-1);
|
||||||
|
|
||||||
|
if (!connid || (flags & 0x80))
|
||||||
|
return(-1);
|
||||||
|
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int flag_add_handle_path(uint8 *p, uint8 dhandle, char *name)
|
||||||
|
{
|
||||||
|
int nlen;
|
||||||
|
|
||||||
|
nlen = strlen(name);
|
||||||
|
if (nlen > 255) nlen = 255;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* handle/path:
|
||||||
|
* volume/handle byte
|
||||||
|
* dir base dword
|
||||||
|
* dirstyle byte (0 = short dir handle)
|
||||||
|
* path components: 1 component, length, bytes
|
||||||
|
*/
|
||||||
|
*p++ = dhandle;
|
||||||
|
flag_put_dword_lh(p, 0L); p += 4;
|
||||||
|
*p++ = 0; /* dirstyle = handle */
|
||||||
|
*p++ = 1; /* one path component */
|
||||||
|
*p++ = (uint8)nlen;
|
||||||
|
memcpy(p, name, nlen);
|
||||||
|
p += nlen;
|
||||||
|
|
||||||
|
return(1 + 4 + 1 + 1 + 1 + nlen);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int flag_ncp87_obtain_attrs(char *name, uint32 *attrs)
|
||||||
|
{
|
||||||
|
struct {
|
||||||
|
uint16 len;
|
||||||
|
uint8 data[320];
|
||||||
|
} req;
|
||||||
|
struct {
|
||||||
|
uint16 len;
|
||||||
|
uint8 data[128];
|
||||||
|
} repl;
|
||||||
|
uint8 dhandle = 0;
|
||||||
|
uint8 *p;
|
||||||
|
int hlen;
|
||||||
|
|
||||||
|
if (flag_current_dhandle(&dhandle))
|
||||||
|
return(-1);
|
||||||
|
|
||||||
|
memset(&req, 0, sizeof(req));
|
||||||
|
memset(&repl, 0, sizeof(repl));
|
||||||
|
|
||||||
|
p = req.data;
|
||||||
|
*p++ = 6; /* subfunction: obtain file/subdir info */
|
||||||
|
*p++ = FLAG_NW_NS_DOS; /* source namespace */
|
||||||
|
*p++ = FLAG_NW_NS_DOS; /* target namespace */
|
||||||
|
flag_put_word_lh(p, FLAG_SA_ALL); p += 2;
|
||||||
|
flag_put_dword_lh(p, FLAG_RIM_ATTRIBUTES); p += 4;
|
||||||
|
hlen = flag_add_handle_path(p, dhandle, name);
|
||||||
|
p += hlen;
|
||||||
|
|
||||||
|
req.len = (uint16)(p - req.data);
|
||||||
|
repl.len = sizeof(repl.data);
|
||||||
|
|
||||||
|
neterrno = Net_Call(0xF257, &req, &repl);
|
||||||
|
if (neterrno)
|
||||||
|
return(-1);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* With RIM_ATTRIBUTES only, ncpfs expects NSI_Attributes first.
|
||||||
|
* First dword is the 32-bit Attributes field.
|
||||||
|
*/
|
||||||
|
if (attrs)
|
||||||
|
*attrs = flag_get_dword_lh(repl.data);
|
||||||
|
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int flag_ncp87_modify_attrs(char *name, uint32 attrs)
|
||||||
|
{
|
||||||
|
struct {
|
||||||
|
uint16 len;
|
||||||
|
uint8 data[384];
|
||||||
|
} req;
|
||||||
|
struct {
|
||||||
|
uint16 len;
|
||||||
|
uint8 data[8];
|
||||||
|
} repl;
|
||||||
|
uint8 dhandle = 0;
|
||||||
|
uint8 *p;
|
||||||
|
int hlen;
|
||||||
|
|
||||||
|
if (flag_current_dhandle(&dhandle))
|
||||||
|
return(-1);
|
||||||
|
|
||||||
|
memset(&req, 0, sizeof(req));
|
||||||
|
memset(&repl, 0, sizeof(repl));
|
||||||
|
|
||||||
|
p = req.data;
|
||||||
|
*p++ = 7; /* subfunction: modify DOS info */
|
||||||
|
*p++ = FLAG_NW_NS_DOS;
|
||||||
|
*p++ = 0; /* reserved */
|
||||||
|
flag_put_word_lh(p, FLAG_SA_ALL); p += 2;
|
||||||
|
|
||||||
|
flag_put_dword_lh(p, FLAG_RIM_ATTRIBUTES); p += 4; /* modify mask */
|
||||||
|
flag_put_dword_lh(p, attrs); p += 4; /* Attributes */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Remaining ncp_dos_info fields. Mask says only Attributes is valid,
|
||||||
|
* so these should be ignored, but ncpfs still sends the full structure.
|
||||||
|
*/
|
||||||
|
memset(p, 0, 34);
|
||||||
|
p += 34;
|
||||||
|
|
||||||
|
hlen = flag_add_handle_path(p, dhandle, name);
|
||||||
|
p += hlen;
|
||||||
|
|
||||||
|
req.len = (uint16)(p - req.data);
|
||||||
|
repl.len = sizeof(repl.data);
|
||||||
|
|
||||||
|
neterrno = Net_Call(0xF257, &req, &repl);
|
||||||
|
if (neterrno)
|
||||||
|
return(-1);
|
||||||
|
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef _A_NORMAL
|
||||||
|
#define _A_NORMAL 0x00
|
||||||
|
#endif
|
||||||
|
#ifndef _A_RDONLY
|
||||||
|
#define _A_RDONLY 0x01
|
||||||
|
#endif
|
||||||
|
#ifndef _A_HIDDEN
|
||||||
|
#define _A_HIDDEN 0x02
|
||||||
|
#endif
|
||||||
|
#ifndef _A_SYSTEM
|
||||||
|
#define _A_SYSTEM 0x04
|
||||||
|
#endif
|
||||||
|
#ifndef _A_SUBDIR
|
||||||
|
#define _A_SUBDIR 0x10
|
||||||
|
#endif
|
||||||
|
#ifndef _A_ARCH
|
||||||
|
#define _A_ARCH 0x20
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static int flag_same(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 flag_help(void)
|
||||||
|
{
|
||||||
|
fprintf(stdout, "USAGE: FLAG [path [ option | [+|-] attribute(s) ] [SUB]]\n");
|
||||||
|
fprintf(stdout, "\n");
|
||||||
|
fprintf(stdout, "386 Attributes:\n");
|
||||||
|
fprintf(stdout, "--------------\n");
|
||||||
|
fprintf(stdout, "\n");
|
||||||
|
fprintf(stdout, "RO Read Only\n");
|
||||||
|
fprintf(stdout, "RW Read Write\n");
|
||||||
|
fprintf(stdout, "S Sharable\n");
|
||||||
|
fprintf(stdout, "H Hidden\n");
|
||||||
|
fprintf(stdout, "Sy System\n");
|
||||||
|
fprintf(stdout, "T Transactional\n");
|
||||||
|
fprintf(stdout, "P Purge\n");
|
||||||
|
fprintf(stdout, "A Archive Needed\n");
|
||||||
|
fprintf(stdout, "RA Read Audit\n");
|
||||||
|
fprintf(stdout, "WA Write Audit\n");
|
||||||
|
fprintf(stdout, "CI Copy Inhibit\n");
|
||||||
|
fprintf(stdout, "DI Delete Inhibit\n");
|
||||||
|
fprintf(stdout, "RI Rename Inhibit\n");
|
||||||
|
fprintf(stdout, "\n");
|
||||||
|
fprintf(stdout, "All All\n");
|
||||||
|
fprintf(stdout, "N Normal\n");
|
||||||
|
fprintf(stdout, "SUB\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
static int flag_attr_mask(char *s, unsigned *setbits, unsigned *clearbits)
|
||||||
|
{
|
||||||
|
int set = 1;
|
||||||
|
char *p = s;
|
||||||
|
|
||||||
|
if (*p == '+') {
|
||||||
|
set = 1;
|
||||||
|
p++;
|
||||||
|
} else if (*p == '-') {
|
||||||
|
set = 0;
|
||||||
|
p++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!*p) return(-1);
|
||||||
|
|
||||||
|
if (flag_same(p, "RO")) {
|
||||||
|
if (set) {
|
||||||
|
*setbits |= (unsigned)(NWFA_RO | NWFA_DI | NWFA_RI);
|
||||||
|
} else {
|
||||||
|
*clearbits |= (unsigned)(NWFA_RO | NWFA_DI | NWFA_RI);
|
||||||
|
}
|
||||||
|
} else if (flag_same(p, "RW")) {
|
||||||
|
*clearbits |= (unsigned)(NWFA_RO | NWFA_DI | NWFA_RI);
|
||||||
|
} else if (flag_same(p, "S")) {
|
||||||
|
if (set) *setbits |= (unsigned)NWFA_S;
|
||||||
|
else *clearbits |= (unsigned)NWFA_S;
|
||||||
|
} else if (flag_same(p, "H")) {
|
||||||
|
if (set) *setbits |= (unsigned)NWFA_H;
|
||||||
|
else *clearbits |= (unsigned)NWFA_H;
|
||||||
|
} else if (flag_same(p, "SY") || flag_same(p, "SYS") || flag_same(p, "SYSTEM")) {
|
||||||
|
if (set) *setbits |= (unsigned)NWFA_SY;
|
||||||
|
else *clearbits |= (unsigned)NWFA_SY;
|
||||||
|
} else if (flag_same(p, "T")) {
|
||||||
|
if (set) *setbits |= (unsigned)NWFA_T;
|
||||||
|
else *clearbits |= (unsigned)NWFA_T;
|
||||||
|
} else if (flag_same(p, "P")) {
|
||||||
|
if (set) *setbits |= (unsigned)NWFA_P;
|
||||||
|
else *clearbits |= (unsigned)NWFA_P;
|
||||||
|
} else if (flag_same(p, "A")) {
|
||||||
|
if (set) *setbits |= (unsigned)NWFA_A;
|
||||||
|
else *clearbits |= (unsigned)NWFA_A;
|
||||||
|
} else if (flag_same(p, "RA")) {
|
||||||
|
if (set) *setbits |= (unsigned)NWFA_RA;
|
||||||
|
else *clearbits |= (unsigned)NWFA_RA;
|
||||||
|
} else if (flag_same(p, "WA")) {
|
||||||
|
if (set) *setbits |= (unsigned)NWFA_WA;
|
||||||
|
else *clearbits |= (unsigned)NWFA_WA;
|
||||||
|
} else if (flag_same(p, "CI")) {
|
||||||
|
if (set) *setbits |= (unsigned)NWFA_CI;
|
||||||
|
else *clearbits |= (unsigned)NWFA_CI;
|
||||||
|
} else if (flag_same(p, "DI")) {
|
||||||
|
if (set) *setbits |= (unsigned)NWFA_DI;
|
||||||
|
else *clearbits |= (unsigned)NWFA_DI;
|
||||||
|
} else if (flag_same(p, "RI")) {
|
||||||
|
if (set) *setbits |= (unsigned)NWFA_RI;
|
||||||
|
else *clearbits |= (unsigned)NWFA_RI;
|
||||||
|
} else if (flag_same(p, "N") || flag_same(p, "NORMAL")) {
|
||||||
|
*clearbits |= (unsigned)(NWFA_RO | NWFA_H | NWFA_SY | NWFA_A |
|
||||||
|
NWFA_S | NWFA_T | NWFA_P |
|
||||||
|
NWFA_RA | NWFA_WA | NWFA_CI | NWFA_DI | NWFA_RI);
|
||||||
|
} else if (flag_same(p, "ALL")) {
|
||||||
|
*setbits |= (unsigned)(NWFA_RO | NWFA_H | NWFA_SY | NWFA_A |
|
||||||
|
NWFA_S | NWFA_T | NWFA_P |
|
||||||
|
NWFA_RA | NWFA_WA | NWFA_CI | NWFA_DI | NWFA_RI);
|
||||||
|
} else {
|
||||||
|
fprintf(stderr, "Unknown attribute encountered in command line.\n");
|
||||||
|
return(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void flag_print_attrs(unsigned attr)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Novell order:
|
||||||
|
* RO/RW S A H Sy T P RA WA CI DI RI
|
||||||
|
*/
|
||||||
|
fprintf(stdout, "[ ");
|
||||||
|
fprintf(stdout, "%s ", (attr & NWFA_RO) ? "RO" : "Rw");
|
||||||
|
fprintf(stdout, "%c ", (attr & NWFA_S) ? 'S' : '-');
|
||||||
|
fprintf(stdout, "%c ", (attr & NWFA_A) ? 'A' : '-');
|
||||||
|
fprintf(stdout, "%c ", (attr & NWFA_H) ? 'H' : '-');
|
||||||
|
fprintf(stdout, "%s ", (attr & NWFA_SY) ? "Sy" : "-");
|
||||||
|
fprintf(stdout, "%c ", (attr & NWFA_T) ? 'T' : '-');
|
||||||
|
fprintf(stdout, "%c ", (attr & NWFA_P) ? 'P' : '-');
|
||||||
|
fprintf(stdout, "%s ", (attr & NWFA_RA) ? "Ra" : "--");
|
||||||
|
fprintf(stdout, "%s ", (attr & NWFA_WA) ? "Wa" : "--");
|
||||||
|
fprintf(stdout, "%s ", (attr & NWFA_CI) ? "CI" : "--");
|
||||||
|
fprintf(stdout, "%s ", (attr & NWFA_DI) ? "DI" : "--");
|
||||||
|
fprintf(stdout, "%s ", (attr & NWFA_RI) ? "RI" : "--");
|
||||||
|
fprintf(stdout, "]");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void flag_display_one(char *name, unsigned attr)
|
||||||
|
{
|
||||||
|
fprintf(stdout, " %-23s ", name);
|
||||||
|
flag_print_attrs(attr);
|
||||||
|
fprintf(stdout, "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
static int flag_has_wildcards(char *s)
|
||||||
|
{
|
||||||
|
while (*s) {
|
||||||
|
if (*s == '*' || *s == '?') return(1);
|
||||||
|
s++;
|
||||||
|
}
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int flag_list(char *pattern)
|
||||||
|
{
|
||||||
|
struct find_t ff;
|
||||||
|
unsigned findattr = _A_RDONLY | _A_HIDDEN | _A_SYSTEM | _A_ARCH;
|
||||||
|
int found = 0;
|
||||||
|
|
||||||
|
if (_dos_findfirst(pattern, findattr, &ff))
|
||||||
|
return(-1);
|
||||||
|
|
||||||
|
do {
|
||||||
|
if (!(ff.attrib & _A_SUBDIR)) {
|
||||||
|
uint32 nwattrs;
|
||||||
|
|
||||||
|
if (flag_ncp87_obtain_attrs(ff.name, &nwattrs))
|
||||||
|
nwattrs = (uint32)ff.attrib;
|
||||||
|
|
||||||
|
flag_display_one(ff.name, (unsigned)nwattrs);
|
||||||
|
found++;
|
||||||
|
}
|
||||||
|
} while (!_dos_findnext(&ff));
|
||||||
|
|
||||||
|
return(found);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int flag_apply(char *pattern, unsigned setbits, unsigned clearbits)
|
||||||
|
{
|
||||||
|
struct find_t ff;
|
||||||
|
unsigned findattr = _A_RDONLY | _A_HIDDEN | _A_SYSTEM | _A_ARCH;
|
||||||
|
int shown = 0;
|
||||||
|
|
||||||
|
if (_dos_findfirst(pattern, findattr, &ff))
|
||||||
|
return(-1);
|
||||||
|
|
||||||
|
do {
|
||||||
|
uint32 attrs;
|
||||||
|
uint32 newattrs;
|
||||||
|
char fname[260];
|
||||||
|
|
||||||
|
if (ff.attrib & _A_SUBDIR) continue;
|
||||||
|
|
||||||
|
strmaxcpy(fname, ff.name, sizeof(fname) - 1);
|
||||||
|
|
||||||
|
if (flag_ncp87_obtain_attrs(fname, &attrs))
|
||||||
|
attrs = (uint32)ff.attrib;
|
||||||
|
|
||||||
|
newattrs = (attrs | (uint32)setbits) & ~((uint32)clearbits);
|
||||||
|
|
||||||
|
if (newattrs != attrs) {
|
||||||
|
if (flag_ncp87_modify_attrs(fname, newattrs)) {
|
||||||
|
unsigned dosattr = (unsigned)(newattrs & (_A_RDONLY|_A_HIDDEN|_A_SYSTEM|_A_ARCH));
|
||||||
|
if (_dos_setfileattr(fname, dosattr)) {
|
||||||
|
fprintf(stderr, "You don't have rights to change : %s\n", fname);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flag_ncp87_obtain_attrs(fname, &attrs))
|
||||||
|
attrs = newattrs;
|
||||||
|
|
||||||
|
flag_display_one(fname, (unsigned)attrs);
|
||||||
|
shown++;
|
||||||
|
|
||||||
|
} while (!_dos_findnext(&ff));
|
||||||
|
|
||||||
|
return(shown);
|
||||||
|
}
|
||||||
|
|
||||||
|
int func_flag(int argc, char *argv[], int mode)
|
||||||
|
{
|
||||||
|
char *path = "*.*";
|
||||||
|
int i;
|
||||||
|
unsigned setbits = 0;
|
||||||
|
unsigned clearbits = 0;
|
||||||
|
int have_change = 0;
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
(void)mode;
|
||||||
|
|
||||||
|
if (argc > 1 && (flag_same(argv[1], "/?") || flag_same(argv[1], "-?") ||
|
||||||
|
flag_same(argv[1], "?"))) {
|
||||||
|
flag_help();
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (argc > 1) {
|
||||||
|
path = argv[1];
|
||||||
|
if (flag_same(path, "SUB")) path = "*.*";
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 2; i < argc; i++) {
|
||||||
|
if (flag_same(argv[i], "SUB")) continue;
|
||||||
|
|
||||||
|
rc = flag_attr_mask(argv[i], &setbits, &clearbits);
|
||||||
|
if (rc < 0) return(1);
|
||||||
|
if (rc > 0) continue;
|
||||||
|
have_change = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (have_change) {
|
||||||
|
rc = flag_apply(path, setbits, clearbits);
|
||||||
|
if (rc < 0) {
|
||||||
|
fprintf(stderr, "Files could not be found with pattern \"%s\"\n", path);
|
||||||
|
return(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
rc = flag_list(path);
|
||||||
|
if (rc < 0) {
|
||||||
|
fprintf(stderr, "Files could not be found with pattern \"%s\"\n", path);
|
||||||
|
return(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
271
kern.c
Normal file
271
kern.c
Normal file
@@ -0,0 +1,271 @@
|
|||||||
|
/*
|
||||||
|
* kern.c - C-side experimental NetWare/DOS request wrappers
|
||||||
|
*
|
||||||
|
* kern_wasm.asm remains the production/reference implementation.
|
||||||
|
* These C functions are test wrappers so we can inspect register setup and
|
||||||
|
* slowly port proven pieces from ASM to C.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <dos.h>
|
||||||
|
|
||||||
|
#include "net.h"
|
||||||
|
|
||||||
|
#if defined(__WATCOMC__)
|
||||||
|
#define KERN_C_CALL _Cdecl
|
||||||
|
#else
|
||||||
|
#define KERN_C_CALL
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
unsigned int in_ax;
|
||||||
|
unsigned int in_bx;
|
||||||
|
unsigned int in_cx;
|
||||||
|
unsigned int in_dx;
|
||||||
|
unsigned int in_si;
|
||||||
|
unsigned int in_di;
|
||||||
|
unsigned int in_ds;
|
||||||
|
unsigned int in_es;
|
||||||
|
|
||||||
|
unsigned int out_ax;
|
||||||
|
unsigned int out_bx;
|
||||||
|
unsigned int out_cx;
|
||||||
|
unsigned int out_dx;
|
||||||
|
unsigned int out_si;
|
||||||
|
unsigned int out_di;
|
||||||
|
unsigned int out_flags;
|
||||||
|
|
||||||
|
void far *req_ptr;
|
||||||
|
void far *repl_ptr;
|
||||||
|
|
||||||
|
int rc;
|
||||||
|
} NET_CALL_C_DEBUG;
|
||||||
|
|
||||||
|
NET_CALL_C_DEBUG Net_Call_C_Last;
|
||||||
|
|
||||||
|
static void net_call_c_clear(void)
|
||||||
|
{
|
||||||
|
memset(&Net_Call_C_Last, 0, sizeof(Net_Call_C_Last));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void net_call_c_save_in(union REGS *r, struct SREGS *s,
|
||||||
|
void *req, void *repl)
|
||||||
|
{
|
||||||
|
Net_Call_C_Last.in_ax = r->x.ax;
|
||||||
|
Net_Call_C_Last.in_bx = r->x.bx;
|
||||||
|
Net_Call_C_Last.in_cx = r->x.cx;
|
||||||
|
Net_Call_C_Last.in_dx = r->x.dx;
|
||||||
|
Net_Call_C_Last.in_si = r->x.si;
|
||||||
|
Net_Call_C_Last.in_di = r->x.di;
|
||||||
|
Net_Call_C_Last.in_ds = s->ds;
|
||||||
|
Net_Call_C_Last.in_es = s->es;
|
||||||
|
Net_Call_C_Last.req_ptr = req;
|
||||||
|
Net_Call_C_Last.repl_ptr = repl;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void net_call_c_save_out(union REGS *r, unsigned int returned_ax)
|
||||||
|
{
|
||||||
|
Net_Call_C_Last.out_ax = returned_ax;
|
||||||
|
Net_Call_C_Last.out_bx = r->x.bx;
|
||||||
|
Net_Call_C_Last.out_cx = r->x.cx;
|
||||||
|
Net_Call_C_Last.out_dx = r->x.dx;
|
||||||
|
Net_Call_C_Last.out_si = r->x.si;
|
||||||
|
Net_Call_C_Last.out_di = r->x.di;
|
||||||
|
Net_Call_C_Last.out_flags = r->x.cflag;
|
||||||
|
Net_Call_C_Last.rc = returned_ax & 0x00ff;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* C equivalent of kern_wasm.asm Net_Call:
|
||||||
|
* AX = func
|
||||||
|
* DS:SI = request
|
||||||
|
* ES:DI = reply
|
||||||
|
* int 21h
|
||||||
|
* return AL only, because kern_wasm.asm clears AH before return.
|
||||||
|
*/
|
||||||
|
int KERN_C_CALL Net_Call_C(unsigned int ax, void *req, void *repl)
|
||||||
|
{
|
||||||
|
return Net_Call_CX(ax, 0, 0, 0, req, repl);
|
||||||
|
}
|
||||||
|
|
||||||
|
int KERN_C_CALL Net_Call_CX(unsigned int ax, unsigned int bx,
|
||||||
|
unsigned int cx, unsigned int dx,
|
||||||
|
void *req, void *repl)
|
||||||
|
{
|
||||||
|
union REGS inregs;
|
||||||
|
union REGS outregs;
|
||||||
|
struct SREGS segregs;
|
||||||
|
unsigned int ret_ax;
|
||||||
|
|
||||||
|
memset(&inregs, 0, sizeof(inregs));
|
||||||
|
memset(&outregs, 0, sizeof(outregs));
|
||||||
|
memset(&segregs, 0, sizeof(segregs));
|
||||||
|
net_call_c_clear();
|
||||||
|
|
||||||
|
inregs.x.ax = ax;
|
||||||
|
inregs.x.bx = bx;
|
||||||
|
inregs.x.cx = cx;
|
||||||
|
inregs.x.dx = dx;
|
||||||
|
|
||||||
|
inregs.x.si = FP_OFF(req);
|
||||||
|
inregs.x.di = FP_OFF(repl);
|
||||||
|
segregs.ds = FP_SEG(req);
|
||||||
|
segregs.es = FP_SEG(repl);
|
||||||
|
|
||||||
|
net_call_c_save_in(&inregs, &segregs, req, repl);
|
||||||
|
|
||||||
|
int86x(0x21, &inregs, &outregs, &segregs);
|
||||||
|
|
||||||
|
ret_ax = outregs.x.ax & 0x00ff; /* match ASM Net_Call return */
|
||||||
|
|
||||||
|
net_call_c_save_out(&outregs, ret_ax);
|
||||||
|
|
||||||
|
return (int)ret_ax;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Experimental Novell Client/VLM AH=F2 wrapper derived from official FLAG.EXE
|
||||||
|
* disassembly:
|
||||||
|
* AH = F2h
|
||||||
|
* AL = NCP function, e.g. 57h for NCP 87
|
||||||
|
* CX = request length
|
||||||
|
* DX = reply buffer length
|
||||||
|
* DS:SI = request buffer
|
||||||
|
* ES:DI = reply buffer
|
||||||
|
*/
|
||||||
|
int KERN_C_CALL Net_Call_F2_C(unsigned int function,
|
||||||
|
unsigned int req_len,
|
||||||
|
unsigned int repl_len,
|
||||||
|
void *req,
|
||||||
|
void *repl)
|
||||||
|
{
|
||||||
|
union REGS inregs;
|
||||||
|
union REGS outregs;
|
||||||
|
struct SREGS segregs;
|
||||||
|
unsigned int ret_ax;
|
||||||
|
|
||||||
|
memset(&inregs, 0, sizeof(inregs));
|
||||||
|
memset(&outregs, 0, sizeof(outregs));
|
||||||
|
memset(&segregs, 0, sizeof(segregs));
|
||||||
|
net_call_c_clear();
|
||||||
|
|
||||||
|
inregs.h.ah = 0xF2;
|
||||||
|
inregs.h.al = (unsigned char)(function & 0xff);
|
||||||
|
inregs.x.cx = req_len;
|
||||||
|
inregs.x.dx = repl_len;
|
||||||
|
inregs.x.si = FP_OFF(req);
|
||||||
|
inregs.x.di = FP_OFF(repl);
|
||||||
|
segregs.ds = FP_SEG(req);
|
||||||
|
segregs.es = FP_SEG(repl);
|
||||||
|
|
||||||
|
net_call_c_save_in(&inregs, &segregs, req, repl);
|
||||||
|
|
||||||
|
int86x(0x21, &inregs, &outregs, &segregs);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Novell wrapper behavior:
|
||||||
|
* xor ah,ah
|
||||||
|
* or al,al
|
||||||
|
* if al != 0: ah=89h
|
||||||
|
* Return AL only for C caller, but keep 89xx in debug out_ax.
|
||||||
|
*/
|
||||||
|
ret_ax = outregs.x.ax & 0x00ff;
|
||||||
|
if (ret_ax)
|
||||||
|
ret_ax |= 0x8900;
|
||||||
|
|
||||||
|
net_call_c_save_out(&outregs, ret_ax);
|
||||||
|
|
||||||
|
return (int)(ret_ax & 0x00ff);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Fully generic INT 21h register test wrapper.
|
||||||
|
* Used for reproducing the NWCREQUEST/NWCSHELLREQ register calls seen in
|
||||||
|
* DeveloperNet 1997 clndos16.lib.
|
||||||
|
*/
|
||||||
|
int KERN_C_CALL Net_Call_F2X_C(unsigned int ax,
|
||||||
|
unsigned int bx,
|
||||||
|
unsigned int cx,
|
||||||
|
unsigned int dx,
|
||||||
|
void *req,
|
||||||
|
void *repl)
|
||||||
|
{
|
||||||
|
union REGS inregs;
|
||||||
|
union REGS outregs;
|
||||||
|
struct SREGS segregs;
|
||||||
|
unsigned int ret_ax;
|
||||||
|
|
||||||
|
memset(&inregs, 0, sizeof(inregs));
|
||||||
|
memset(&outregs, 0, sizeof(outregs));
|
||||||
|
memset(&segregs, 0, sizeof(segregs));
|
||||||
|
net_call_c_clear();
|
||||||
|
|
||||||
|
inregs.x.ax = ax;
|
||||||
|
inregs.x.bx = bx;
|
||||||
|
inregs.x.cx = cx;
|
||||||
|
inregs.x.dx = dx;
|
||||||
|
inregs.x.si = FP_OFF(req);
|
||||||
|
inregs.x.di = FP_OFF(repl);
|
||||||
|
segregs.ds = FP_SEG(req);
|
||||||
|
segregs.es = FP_SEG(repl);
|
||||||
|
|
||||||
|
net_call_c_save_in(&inregs, &segregs, req, repl);
|
||||||
|
|
||||||
|
int86x(0x21, &inregs, &outregs, &segregs);
|
||||||
|
|
||||||
|
ret_ax = outregs.x.ax & 0x00ff;
|
||||||
|
if (ret_ax)
|
||||||
|
ret_ax |= 0x8900;
|
||||||
|
|
||||||
|
net_call_c_save_out(&outregs, ret_ax);
|
||||||
|
|
||||||
|
return (int)(ret_ax & 0x00ff);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void KERN_C_CALL Net_Call_C_Dump(void)
|
||||||
|
{
|
||||||
|
fprintf(stdout, "NETCALLC in : AX=%04X BX=%04X CX=%04X DX=%04X DS:SI=%04X:%04X ES:DI=%04X:%04X\n",
|
||||||
|
Net_Call_C_Last.in_ax,
|
||||||
|
Net_Call_C_Last.in_bx,
|
||||||
|
Net_Call_C_Last.in_cx,
|
||||||
|
Net_Call_C_Last.in_dx,
|
||||||
|
Net_Call_C_Last.in_ds,
|
||||||
|
Net_Call_C_Last.in_si,
|
||||||
|
Net_Call_C_Last.in_es,
|
||||||
|
Net_Call_C_Last.in_di);
|
||||||
|
|
||||||
|
fprintf(stdout, "NETCALLC out: AX=%04X BX=%04X CX=%04X DX=%04X SI=%04X DI=%04X CF=%04X RC=%d\n",
|
||||||
|
Net_Call_C_Last.out_ax,
|
||||||
|
Net_Call_C_Last.out_bx,
|
||||||
|
Net_Call_C_Last.out_cx,
|
||||||
|
Net_Call_C_Last.out_dx,
|
||||||
|
Net_Call_C_Last.out_si,
|
||||||
|
Net_Call_C_Last.out_di,
|
||||||
|
Net_Call_C_Last.out_flags,
|
||||||
|
Net_Call_C_Last.rc);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int KERN_C_CALL Net_Call_C_GetDebug(unsigned int idx)
|
||||||
|
{
|
||||||
|
switch (idx) {
|
||||||
|
case 0: return Net_Call_C_Last.in_ax;
|
||||||
|
case 1: return Net_Call_C_Last.in_bx;
|
||||||
|
case 2: return Net_Call_C_Last.in_cx;
|
||||||
|
case 3: return Net_Call_C_Last.in_dx;
|
||||||
|
case 4: return Net_Call_C_Last.in_ds;
|
||||||
|
case 5: return Net_Call_C_Last.in_si;
|
||||||
|
case 6: return Net_Call_C_Last.in_es;
|
||||||
|
case 7: return Net_Call_C_Last.in_di;
|
||||||
|
case 8: return Net_Call_C_Last.out_ax;
|
||||||
|
case 9: return Net_Call_C_Last.out_bx;
|
||||||
|
case 10: return Net_Call_C_Last.out_cx;
|
||||||
|
case 11: return Net_Call_C_Last.out_dx;
|
||||||
|
case 12: return Net_Call_C_Last.out_si;
|
||||||
|
case 13: return Net_Call_C_Last.out_di;
|
||||||
|
case 14: return Net_Call_C_Last.out_flags;
|
||||||
|
case 15: return (unsigned int)Net_Call_C_Last.rc;
|
||||||
|
}
|
||||||
|
return 0xffff;
|
||||||
|
}
|
||||||
16
kern.h
16
kern.h
@@ -13,8 +13,22 @@ extern void asm_esr_routine(void);
|
|||||||
extern void esr_routine(ECB *ecb);
|
extern void esr_routine(ECB *ecb);
|
||||||
extern void KERN_CALL xmemmove(void *ziel, void *quelle, UI anz);
|
extern void KERN_CALL xmemmove(void *ziel, void *quelle, UI anz);
|
||||||
extern int KERN_CALL Net_Call(UI func, void *req, void *repl);
|
extern int KERN_CALL Net_Call(UI func, void *req, void *repl);
|
||||||
|
extern int KERN_CALL Net_Call_VLM_Raw(UI ax, UI bx, UI cx, UI dx,
|
||||||
|
void *req, void *repl,
|
||||||
|
UI p1, UI p2, UI p3);
|
||||||
|
extern int KERN_CALL Net_Call_C(UI func, void *req, void *repl);
|
||||||
|
extern int KERN_CALL Net_Call_CX(UI func, UI bx, UI cx, UI dx,
|
||||||
|
void *req, void *repl);
|
||||||
|
extern int KERN_CALL Net_Call_F2_C(UI function, UI req_len, UI repl_len,
|
||||||
|
void *req, void *repl);
|
||||||
|
extern int KERN_CALL Net_Call_F2X_C(UI ax, UI bx, UI cx, UI dx,
|
||||||
|
void *req, void *repl);
|
||||||
|
extern void KERN_CALL Net_Call_C_Dump(void);
|
||||||
|
extern UI KERN_CALL Net_Call_C_GetDebug(UI idx);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#undef KERN_CALL
|
#undef KERN_CALL
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
110
kern_wasm.asm
110
kern_wasm.asm
@@ -14,14 +14,15 @@ enterIPX dd 0
|
|||||||
|
|
||||||
.code
|
.code
|
||||||
|
|
||||||
public _IPXinit
|
public IPXinit_
|
||||||
public _IPXopen_socket
|
public IPXopen_socket_
|
||||||
public _IPXclose_socket
|
public IPXclose_socket_
|
||||||
public _IPXlisten
|
public IPXlisten_
|
||||||
public _xmemmove
|
public xmemmove_
|
||||||
public _Net_Call
|
public Net_Call_
|
||||||
|
public Net_Call_VLM_Raw_
|
||||||
|
|
||||||
_IPXinit proc far
|
IPXinit_ proc far
|
||||||
push bp
|
push bp
|
||||||
mov bp, sp
|
mov bp, sp
|
||||||
push ds
|
push ds
|
||||||
@@ -48,9 +49,9 @@ ipxinit_done:
|
|||||||
pop ds
|
pop ds
|
||||||
pop bp
|
pop bp
|
||||||
ret
|
ret
|
||||||
_IPXinit endp
|
IPXinit_ endp
|
||||||
|
|
||||||
_xmemmove proc far
|
xmemmove_ proc far
|
||||||
push bp
|
push bp
|
||||||
mov bp, sp
|
mov bp, sp
|
||||||
|
|
||||||
@@ -101,9 +102,9 @@ xmem_done:
|
|||||||
pop bp
|
pop bp
|
||||||
sti
|
sti
|
||||||
ret
|
ret
|
||||||
_xmemmove endp
|
xmemmove_ endp
|
||||||
|
|
||||||
_IPXopen_socket proc far
|
IPXopen_socket_ proc far
|
||||||
push bp
|
push bp
|
||||||
mov bp, sp
|
mov bp, sp
|
||||||
push ds
|
push ds
|
||||||
@@ -138,9 +139,9 @@ ipxopen_done:
|
|||||||
pop ds
|
pop ds
|
||||||
pop bp
|
pop bp
|
||||||
ret
|
ret
|
||||||
_IPXopen_socket endp
|
IPXopen_socket_ endp
|
||||||
|
|
||||||
_IPXclose_socket proc far
|
IPXclose_socket_ proc far
|
||||||
push bp
|
push bp
|
||||||
mov bp, sp
|
mov bp, sp
|
||||||
push ds
|
push ds
|
||||||
@@ -159,9 +160,9 @@ _IPXclose_socket proc far
|
|||||||
pop ds
|
pop ds
|
||||||
pop bp
|
pop bp
|
||||||
ret
|
ret
|
||||||
_IPXclose_socket endp
|
IPXclose_socket_ endp
|
||||||
|
|
||||||
_IPXlisten proc far
|
IPXlisten_ proc far
|
||||||
push bp
|
push bp
|
||||||
mov bp, sp
|
mov bp, sp
|
||||||
push ds
|
push ds
|
||||||
@@ -181,9 +182,9 @@ _IPXlisten proc far
|
|||||||
pop bp
|
pop bp
|
||||||
mov ah, 0
|
mov ah, 0
|
||||||
ret
|
ret
|
||||||
_IPXlisten endp
|
IPXlisten_ endp
|
||||||
|
|
||||||
_Net_Call proc far
|
Net_Call_ proc far
|
||||||
push bp
|
push bp
|
||||||
mov bp, sp
|
mov bp, sp
|
||||||
|
|
||||||
@@ -211,6 +212,79 @@ _Net_Call proc far
|
|||||||
pop bp
|
pop bp
|
||||||
mov ah, 0
|
mov ah, 0
|
||||||
ret
|
ret
|
||||||
_Net_Call endp
|
Net_Call_ endp
|
||||||
|
|
||||||
|
; int Net_Call_VLM_Raw(UI ax, UI bx, UI cx, UI dx,
|
||||||
|
; void *req, void *repl,
|
||||||
|
; UI p1, UI p2, UI p3)
|
||||||
|
;
|
||||||
|
; Experimental VLM entry caller.
|
||||||
|
; INT 2F AX=7A20 returns ES:BX = VLM entry if AX == 0000.
|
||||||
|
;
|
||||||
|
; Register setup for VLM entry:
|
||||||
|
; AX, BX, CX, DX from function args
|
||||||
|
; DS:SI = req
|
||||||
|
; ES:DI = repl
|
||||||
|
;
|
||||||
|
; Extra stack args pushed before calling VLM entry:
|
||||||
|
; p3, p2, p1
|
||||||
|
;
|
||||||
|
; For NWCREQUEST/VLM test:
|
||||||
|
; AX=function
|
||||||
|
; BX=numReqFrags
|
||||||
|
; CX=connid
|
||||||
|
; DX=numReplyFrags
|
||||||
|
; DS:SI=reqFragList
|
||||||
|
; ES:DI=replyFragList
|
||||||
|
; p1=6, p2=20h, p3=0
|
||||||
|
Net_Call_VLM_Raw_ proc far
|
||||||
|
push bp
|
||||||
|
mov bp, sp
|
||||||
|
sub sp, 4
|
||||||
|
|
||||||
|
push ds
|
||||||
|
push si
|
||||||
|
push di
|
||||||
|
push es
|
||||||
|
|
||||||
|
mov ax, 7A20h
|
||||||
|
xor bx, bx
|
||||||
|
int 2Fh
|
||||||
|
or ax, ax
|
||||||
|
jz vlm_raw_found
|
||||||
|
|
||||||
|
mov ax, 88FFh
|
||||||
|
jmp short vlm_raw_done
|
||||||
|
|
||||||
|
vlm_raw_found:
|
||||||
|
; save VLM entry ES:BX in stack locals
|
||||||
|
mov [bp-4], bx
|
||||||
|
mov ax, es
|
||||||
|
mov [bp-2], ax
|
||||||
|
|
||||||
|
; load caller-requested registers
|
||||||
|
mov ax, [bp+6]
|
||||||
|
mov bx, [bp+8]
|
||||||
|
mov cx, [bp+10]
|
||||||
|
mov dx, [bp+12]
|
||||||
|
lds si, dword ptr [bp+14]
|
||||||
|
les di, dword ptr [bp+18]
|
||||||
|
|
||||||
|
push word ptr [bp+26]
|
||||||
|
push word ptr [bp+24]
|
||||||
|
push word ptr [bp+22]
|
||||||
|
call dword ptr [bp-4]
|
||||||
|
|
||||||
|
vlm_raw_done:
|
||||||
|
pop es
|
||||||
|
pop di
|
||||||
|
pop si
|
||||||
|
pop ds
|
||||||
|
|
||||||
|
mov sp, bp
|
||||||
|
pop bp
|
||||||
|
ret
|
||||||
|
Net_Call_VLM_Raw_ endp
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
338
login.c
338
login.c
@@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
#include "net.h"
|
#include "net.h"
|
||||||
#include "nwcrypt.h"
|
#include "nwcrypt.h"
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
#ifndef BLACK
|
#ifndef BLACK
|
||||||
#define BLACK 0
|
#define BLACK 0
|
||||||
@@ -23,18 +24,75 @@
|
|||||||
static uint8 script_login_name[64];
|
static uint8 script_login_name[64];
|
||||||
static uint8 script_file_server[52];
|
static uint8 script_file_server[52];
|
||||||
|
|
||||||
#if defined(__WATCOMC__)
|
static char **build_argv(char *buf, int bufsize, char *str);
|
||||||
extern void textbackground(int color);
|
|
||||||
extern void textcolor(int color);
|
|
||||||
extern void clrscr(void);
|
|
||||||
extern void gotoxy(int x, int y);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
extern char **build_argv(char *buf, int bufsize, char *str);
|
|
||||||
extern int read_command_file(char *fstr);
|
extern int read_command_file(char *fstr);
|
||||||
extern int get_fs_name(int connid, char *name);
|
extern int get_fs_name(int connid, char *name);
|
||||||
|
|
||||||
|
|
||||||
|
static uint8 login_video_attr = 0x07;
|
||||||
|
|
||||||
|
static void login_gotoxy(int x, int y)
|
||||||
|
{
|
||||||
|
REGS regs;
|
||||||
|
|
||||||
|
regs.h.ah = 0x02;
|
||||||
|
regs.h.bh = 0x00;
|
||||||
|
regs.h.dh = (uint8)(y - 1);
|
||||||
|
regs.h.dl = (uint8)(x - 1);
|
||||||
|
int86(0x10, ®s, ®s);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void login_cls_attr(uint8 attr)
|
||||||
|
{
|
||||||
|
REGS regs;
|
||||||
|
|
||||||
|
regs.h.ah = 0x06;
|
||||||
|
regs.h.al = 0x00;
|
||||||
|
regs.h.bh = attr;
|
||||||
|
regs.h.ch = 0;
|
||||||
|
regs.h.cl = 0;
|
||||||
|
regs.h.dh = 24;
|
||||||
|
regs.h.dl = 79;
|
||||||
|
int86(0x10, ®s, ®s);
|
||||||
|
login_gotoxy(1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void login_write_attr(int x, int y, const char *s, uint8 attr)
|
||||||
|
{
|
||||||
|
REGS regs;
|
||||||
|
int col = x;
|
||||||
|
|
||||||
|
while (*s) {
|
||||||
|
login_gotoxy(col++, y);
|
||||||
|
regs.h.ah = 0x09;
|
||||||
|
regs.h.al = (uint8)*s++;
|
||||||
|
regs.h.bh = 0;
|
||||||
|
regs.h.bl = attr;
|
||||||
|
regs.x.cx = 1;
|
||||||
|
int86(0x10, ®s, ®s);
|
||||||
|
}
|
||||||
|
login_gotoxy(col, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void login_fill_line(int y, uint8 attr)
|
||||||
|
{
|
||||||
|
REGS regs;
|
||||||
|
|
||||||
|
login_gotoxy(1, y);
|
||||||
|
regs.h.ah = 0x09;
|
||||||
|
regs.h.al = ' ';
|
||||||
|
regs.h.bh = 0;
|
||||||
|
regs.h.bl = attr;
|
||||||
|
regs.x.cx = 80;
|
||||||
|
int86(0x10, ®s, ®s);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void login_screen_normal(void)
|
||||||
|
{
|
||||||
|
login_video_attr = 0x07;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int login_help(void)
|
static int login_help(void)
|
||||||
{
|
{
|
||||||
fprintf(stdout, "\n");
|
fprintf(stdout, "\n");
|
||||||
@@ -58,20 +116,22 @@ static int login_help(void)
|
|||||||
|
|
||||||
static void login_banner(void)
|
static void login_banner(void)
|
||||||
{
|
{
|
||||||
int i;
|
login_cls_attr(0x07); /* normal black background */
|
||||||
|
|
||||||
textbackground(BLUE);
|
/*
|
||||||
textcolor(WHITE);
|
* NetWare-like header, but blue for Mars NWE:
|
||||||
clrscr();
|
* blue separator
|
||||||
|
* blue title line
|
||||||
|
* blue separator
|
||||||
|
* then normal black prompt area.
|
||||||
|
*/
|
||||||
|
login_fill_line(1, 0x1f); /* white on blue */
|
||||||
|
login_fill_line(2, 0x1f); /* white on blue */
|
||||||
|
login_write_attr(36, 2, "Mars NWE", 0x1f);
|
||||||
|
login_fill_line(3, 0x1f); /* white on blue */
|
||||||
|
|
||||||
gotoxy(1, 1);
|
login_screen_normal();
|
||||||
for (i = 0; i < 80; i++) putch(' ');
|
login_gotoxy(1, 4);
|
||||||
gotoxy(36, 1);
|
|
||||||
cputs("Mars NWE");
|
|
||||||
|
|
||||||
textbackground(BLACK);
|
|
||||||
textcolor(LIGHTGRAY);
|
|
||||||
gotoxy(1, 3);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *skip_spaces(char *p)
|
static char *skip_spaces(char *p)
|
||||||
@@ -100,18 +160,100 @@ static void strip_quotes(char *s)
|
|||||||
*d = '\0';
|
*d = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void script_get_timevar(char *name, char *out, int outlen)
|
||||||
|
{
|
||||||
|
time_t now;
|
||||||
|
struct tm *tmv;
|
||||||
|
int hour;
|
||||||
|
static char *months[] = {
|
||||||
|
"JANUARY", "FEBRUARY", "MARCH", "APRIL", "MAY", "JUNE",
|
||||||
|
"JULY", "AUGUST", "SEPTEMBER", "OCTOBER", "NOVEMBER", "DECEMBER"
|
||||||
|
};
|
||||||
|
static char *days[] = {
|
||||||
|
"SUNDAY", "MONDAY", "TUESDAY", "WEDNESDAY",
|
||||||
|
"THURSDAY", "FRIDAY", "SATURDAY"
|
||||||
|
};
|
||||||
|
|
||||||
|
*out = '\0';
|
||||||
|
|
||||||
|
time(&now);
|
||||||
|
tmv = localtime(&now);
|
||||||
|
if (!tmv) return;
|
||||||
|
|
||||||
|
upstr(name);
|
||||||
|
|
||||||
|
if (!strcmp(name, "GREETING_TIME")) {
|
||||||
|
if (tmv->tm_hour < 12) strcpy(out, "MORNING");
|
||||||
|
else if (tmv->tm_hour < 18) strcpy(out, "AFTERNOON");
|
||||||
|
else strcpy(out, "EVENING");
|
||||||
|
} else if (!strcmp(name, "MONTH_NAME")) {
|
||||||
|
strmaxcpy(out, months[tmv->tm_mon], outlen - 1);
|
||||||
|
} else if (!strcmp(name, "MONTH")) {
|
||||||
|
sprintf(out, "%02d", tmv->tm_mon + 1);
|
||||||
|
} else if (!strcmp(name, "DAY")) {
|
||||||
|
sprintf(out, "%02d", tmv->tm_mday);
|
||||||
|
} else if (!strcmp(name, "YEAR")) {
|
||||||
|
sprintf(out, "%04d", tmv->tm_year + 1900);
|
||||||
|
} else if (!strcmp(name, "DAY_OF_WEEK")) {
|
||||||
|
strmaxcpy(out, days[tmv->tm_wday], outlen - 1);
|
||||||
|
} else if (!strcmp(name, "HOUR")) {
|
||||||
|
hour = tmv->tm_hour % 12;
|
||||||
|
if (!hour) hour = 12;
|
||||||
|
sprintf(out, "%d", hour);
|
||||||
|
} else if (!strcmp(name, "MINUTE")) {
|
||||||
|
sprintf(out, "%02d", tmv->tm_min);
|
||||||
|
} else if (!strcmp(name, "SECOND")) {
|
||||||
|
sprintf(out, "%02d", tmv->tm_sec);
|
||||||
|
} else if (!strcmp(name, "AM_PM")) {
|
||||||
|
strcpy(out, tmv->tm_hour >= 12 ? "PM" : "AM");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void script_expand_var(char *name, char *out, int outlen)
|
||||||
|
{
|
||||||
|
upstr(name);
|
||||||
|
*out = '\0';
|
||||||
|
|
||||||
|
if (!strcmp(name, "LOGIN_NAME")) {
|
||||||
|
strmaxcpy(out, script_login_name, outlen - 1);
|
||||||
|
} else if (!strcmp(name, "FILE_SERVER")) {
|
||||||
|
strmaxcpy(out, script_file_server, outlen - 1);
|
||||||
|
} else if (!strcmp(name, "P_STATION") || !strcmp(name, "STATION")) {
|
||||||
|
strcpy(out, "000000000000");
|
||||||
|
} else {
|
||||||
|
script_get_timevar(name, out, outlen);
|
||||||
|
if (!*out) {
|
||||||
|
strcpy(out, "%");
|
||||||
|
strncat(out, name, outlen - strlen(out) - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void script_put_expanded(char *s)
|
static void script_put_expanded(char *s)
|
||||||
{
|
{
|
||||||
while (s && *s) {
|
while (s && *s) {
|
||||||
if (!strncmp(s, "%LOGIN_NAME", 11) || !strncmp(s, "%login_name", 11)) {
|
if (*s == '%') {
|
||||||
fprintf(stdout, "%s", script_login_name);
|
char name[64];
|
||||||
s += 11;
|
char value[128];
|
||||||
} else if (!strncmp(s, "%FILE_SERVER", 12) || !strncmp(s, "%file_server", 12)) {
|
int i = 0;
|
||||||
fprintf(stdout, "%s", script_file_server);
|
|
||||||
s += 12;
|
s++;
|
||||||
} else if (!strncmp(s, "%P_STATION", 10) || !strncmp(s, "%p_station", 10)) {
|
while ((*s == '_' ||
|
||||||
fprintf(stdout, "000000000000");
|
(*s >= 'A' && *s <= 'Z') ||
|
||||||
s += 10;
|
(*s >= 'a' && *s <= 'z') ||
|
||||||
|
(*s >= '0' && *s <= '9')) &&
|
||||||
|
i < (int)sizeof(name) - 1) {
|
||||||
|
name[i++] = *s++;
|
||||||
|
}
|
||||||
|
name[i] = '\0';
|
||||||
|
|
||||||
|
if (i) {
|
||||||
|
script_expand_var(name, value, sizeof(value));
|
||||||
|
fprintf(stdout, "%s", value);
|
||||||
|
} else {
|
||||||
|
fputc('%', stdout);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
fputc(*s++, stdout);
|
fputc(*s++, stdout);
|
||||||
}
|
}
|
||||||
@@ -182,30 +324,52 @@ static int script_eval_if(char *line)
|
|||||||
|
|
||||||
if (q != NULL) {
|
if (q != NULL) {
|
||||||
char want[64];
|
char want[64];
|
||||||
char *v;
|
char have[64];
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
q += neg ? 2 : 1;
|
q += neg ? 2 : 1;
|
||||||
q = skip_spaces(q);
|
q = skip_spaces(q);
|
||||||
if (*q == '"' || *q == '\'') q++;
|
if (*q == '"' || *q == '\'') q++;
|
||||||
|
|
||||||
while (*q && *q != '"' && *q != '\'' && *q != 32 && *q != '\t' && i < 63) {
|
while (*q && *q != '"' && *q != '\'' && *q != 32 && *q != '\t' && i < 63)
|
||||||
want[i++] = *q++;
|
want[i++] = *q++;
|
||||||
}
|
|
||||||
want[i] = '\0';
|
want[i] = '\0';
|
||||||
|
|
||||||
strmaxcpy(tmp, script_login_name, sizeof(tmp) - 1);
|
strmaxcpy(have, script_login_name, sizeof(have) - 1);
|
||||||
upstr(tmp);
|
upstr(have);
|
||||||
|
|
||||||
if (neg) return(strcmp(tmp, want) != 0);
|
if (neg) return(strcmp(have, want) != 0);
|
||||||
else return(strcmp(tmp, want) == 0);
|
return(strcmp(have, want) == 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
p = strstr(tmp, "DAY_OF_WEEK");
|
||||||
|
if (p != NULL) {
|
||||||
|
q = strchr(p, '=');
|
||||||
|
if (q != NULL) {
|
||||||
|
char want[64];
|
||||||
|
char have[64];
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
q++;
|
||||||
|
q = skip_spaces(q);
|
||||||
|
if (*q == '"' || *q == '\'') q++;
|
||||||
|
|
||||||
|
while (*q && *q != '"' && *q != '\'' && *q != 32 && *q != '\t' && i < 63)
|
||||||
|
want[i++] = *q++;
|
||||||
|
want[i] = '\0';
|
||||||
|
|
||||||
|
strcpy(have, "DAY_OF_WEEK");
|
||||||
|
script_get_timevar(have, have, sizeof(have));
|
||||||
|
upstr(have);
|
||||||
|
|
||||||
|
return(strcmp(have, want) == 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int login_strnicmp(char *a, char *b, int n)
|
static int login_strnicmp(char *a, char *b, int n)
|
||||||
{
|
{
|
||||||
while (n-- > 0) {
|
while (n-- > 0) {
|
||||||
@@ -230,7 +394,7 @@ static int script_execute_line(char *line)
|
|||||||
strmaxcpy(work, line, sizeof(work) - 1);
|
strmaxcpy(work, line, sizeof(work) - 1);
|
||||||
p = skip_spaces(work);
|
p = skip_spaces(work);
|
||||||
|
|
||||||
if (!*p) return(0);
|
if (!*p || *p == ';') return(0);
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
while (p[i] && p[i] != 32 && p[i] != '\t' && i < 31) {
|
while (p[i] && p[i] != 32 && p[i] != '\t' && i < 31) {
|
||||||
@@ -256,7 +420,7 @@ static int script_execute_line(char *line)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!strcmp(cmd, "CLS")) {
|
if (!strcmp(cmd, "CLS")) {
|
||||||
clrscr();
|
login_cls_attr(0x07);
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -288,6 +452,13 @@ static int script_execute_line(char *line)
|
|||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!strncmp(up, "ROOT ", 5)) {
|
||||||
|
char callbuf[512];
|
||||||
|
sprintf(callbuf, "MAP %s", skip_spaces(arg + 5));
|
||||||
|
script_call_line(callbuf);
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
if (!strncmp(up, "INS ", 4) || !strncmp(up, "INSERT ", 7)) {
|
if (!strncmp(up, "INS ", 4) || !strncmp(up, "INSERT ", 7)) {
|
||||||
char callbuf[512];
|
char callbuf[512];
|
||||||
char *a = arg;
|
char *a = arg;
|
||||||
@@ -309,6 +480,10 @@ static int script_execute_line(char *line)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!strcmp(cmd, "ATTACH")) {
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
if (!strcmp(cmd, "EXIT")) {
|
if (!strcmp(cmd, "EXIT")) {
|
||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
@@ -317,20 +492,87 @@ static int script_execute_line(char *line)
|
|||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int try_login_script_file(char *name)
|
||||||
|
{
|
||||||
|
return(read_command_file(name));
|
||||||
|
}
|
||||||
|
|
||||||
static int run_login_script(void)
|
static int run_login_script(void)
|
||||||
{
|
{
|
||||||
char profile[200];
|
char profile[200];
|
||||||
|
char drive;
|
||||||
|
|
||||||
sprintf(profile, "%snet$log.dat", prgpath);
|
/*
|
||||||
if (read_command_file(profile) != -2) return(0);
|
* Novell LOGIN looks for the system login script using server based paths,
|
||||||
|
* for example \\SERVER\SYS\PUBLIC\NET$LOG.DAT. Try that first.
|
||||||
|
*/
|
||||||
|
if (*script_file_server) {
|
||||||
|
sprintf(profile, "\\\\%s\\SYS\\PUBLIC\\NET$LOG.DAT", script_file_server);
|
||||||
|
if (try_login_script_file(profile) != -2) return(0);
|
||||||
|
|
||||||
sprintf(profile, "%slogin", prgpath);
|
sprintf(profile, "\\\\%s\\SYS\\PUBLIC\\net$log.dat", script_file_server);
|
||||||
if (read_command_file(profile) != -2) return(0);
|
if (try_login_script_file(profile) != -2) return(0);
|
||||||
|
|
||||||
if (read_command_file("net$log.dat") != -2) return(0);
|
sprintf(profile, "\\\\%s\\SYS\\LOGIN\\LOGIN", script_file_server);
|
||||||
if (read_command_file("login") != -2) return(0);
|
if (try_login_script_file(profile) != -2) return(0);
|
||||||
if (read_command_file("\\login\\login") != -2) return(0);
|
|
||||||
if (read_command_file("\\login\\net$log.dat") != -2) return(0);
|
sprintf(profile, "\\\\%s\\SYS\\LOGIN\\NET$LOG.DAT", script_file_server);
|
||||||
|
if (try_login_script_file(profile) != -2) return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Then try current directory and the executable path. LOGIN.EXE is often
|
||||||
|
* executed from PUBLIC, so this covers SYS:PUBLIC\NET$LOG.DAT without
|
||||||
|
* relying on an absolute drive path.
|
||||||
|
*/
|
||||||
|
if (try_login_script_file("NET$LOG.DAT") != -2) return(0);
|
||||||
|
if (try_login_script_file("net$log.dat") != -2) return(0);
|
||||||
|
if (try_login_script_file("LOGIN") != -2) return(0);
|
||||||
|
if (try_login_script_file("login") != -2) return(0);
|
||||||
|
|
||||||
|
if (*prgpath) {
|
||||||
|
sprintf(profile, "%sNET$LOG.DAT", prgpath);
|
||||||
|
if (try_login_script_file(profile) != -2) return(0);
|
||||||
|
|
||||||
|
sprintf(profile, "%snet$log.dat", prgpath);
|
||||||
|
if (try_login_script_file(profile) != -2) return(0);
|
||||||
|
|
||||||
|
sprintf(profile, "%sLOGIN", prgpath);
|
||||||
|
if (try_login_script_file(profile) != -2) return(0);
|
||||||
|
|
||||||
|
sprintf(profile, "%slogin", prgpath);
|
||||||
|
if (try_login_script_file(profile) != -2) return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Fallbacks for requesters/runtimes that cannot open UNC from C fopen().
|
||||||
|
*/
|
||||||
|
if (try_login_script_file("\\PUBLIC\\NET$LOG.DAT") != -2) return(0);
|
||||||
|
if (try_login_script_file("\\public\\net$log.dat") != -2) return(0);
|
||||||
|
if (try_login_script_file("\\PUBLIC\\LOGIN") != -2) return(0);
|
||||||
|
if (try_login_script_file("\\public\\login") != -2) return(0);
|
||||||
|
|
||||||
|
if (try_login_script_file("\\LOGIN\\LOGIN") != -2) return(0);
|
||||||
|
if (try_login_script_file("\\login\\login") != -2) return(0);
|
||||||
|
if (try_login_script_file("\\LOGIN\\NET$LOG.DAT") != -2) return(0);
|
||||||
|
if (try_login_script_file("\\login\\net$log.dat") != -2) return(0);
|
||||||
|
|
||||||
|
for (drive = 'C'; drive <= 'Z'; drive++) {
|
||||||
|
sprintf(profile, "%c:\\PUBLIC\\NET$LOG.DAT", drive);
|
||||||
|
if (try_login_script_file(profile) != -2) return(0);
|
||||||
|
|
||||||
|
sprintf(profile, "%c:\\public\\net$log.dat", drive);
|
||||||
|
if (try_login_script_file(profile) != -2) return(0);
|
||||||
|
|
||||||
|
sprintf(profile, "%c:\\PUBLIC\\LOGIN", drive);
|
||||||
|
if (try_login_script_file(profile) != -2) return(0);
|
||||||
|
|
||||||
|
sprintf(profile, "%c:\\LOGIN\\LOGIN", drive);
|
||||||
|
if (try_login_script_file(profile) != -2) return(0);
|
||||||
|
|
||||||
|
sprintf(profile, "%c:\\LOGIN\\NET$LOG.DAT", drive);
|
||||||
|
if (try_login_script_file(profile) != -2) return(0);
|
||||||
|
}
|
||||||
|
|
||||||
return(-2);
|
return(-2);
|
||||||
}
|
}
|
||||||
@@ -495,7 +737,7 @@ int func_login(int argc, char *argv[], int mode)
|
|||||||
if (argv[1][0] == '-' || argv[1][0] == '/') {
|
if (argv[1][0] == '-' || argv[1][0] == '/') {
|
||||||
if (argv[1][1] == 'u' || argv[1][1] == 'U') option |= 1;
|
if (argv[1][1] == 'u' || argv[1][1] == 'U') option |= 1;
|
||||||
else if (!strcmp(argv[1], "/NS") || !strcmp(argv[1], "-NS")) no_script = 1;
|
else if (!strcmp(argv[1], "/NS") || !strcmp(argv[1], "-NS")) no_script = 1;
|
||||||
else if (!strcmp(argv[1], "/CLS") || !strcmp(argv[1], "-CLS")) clrscr();
|
else if (!strcmp(argv[1], "/CLS") || !strcmp(argv[1], "-CLS")) login_cls_attr(0x07);
|
||||||
else return(login_usage());
|
else return(login_usage());
|
||||||
argc--;
|
argc--;
|
||||||
argv++;
|
argv++;
|
||||||
|
|||||||
306
map.c
306
map.c
@@ -28,9 +28,9 @@ static void show_map(uint8 *drvstr)
|
|||||||
if (flags & 0x80) { /* lokal DRIVE */
|
if (flags & 0x80) { /* lokal DRIVE */
|
||||||
path[0]= '\\';
|
path[0]= '\\';
|
||||||
if (j < 2){
|
if (j < 2){
|
||||||
strcpy(path, "DISK LW");
|
strcpy(path, "maps to a local disk.");
|
||||||
} else if (getcurdir(j+1, path+1)) {
|
} else if (getcurdir(j+1, path+1)) {
|
||||||
strcpy(path, "LW !OK");
|
strcpy(path, "maps to a local disk.");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (get_dir_path(dhandle, path)) {
|
if (get_dir_path(dhandle, path)) {
|
||||||
@@ -41,7 +41,7 @@ static void show_map(uint8 *drvstr)
|
|||||||
strcat(servern, "\\");
|
strcat(servern, "\\");
|
||||||
} else servern[0]='\0';
|
} else servern[0]='\0';
|
||||||
}
|
}
|
||||||
printf("MAP %c: = %s%s\n", (char)j+'A', servern, path);
|
if (flags & 0x80) printf("Drive %c: %s\n", (char)j+'A', path); else printf("Drive %c: = %s%s\n", (char)j+'A', servern, path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -58,9 +58,9 @@ static void do_map(int drive, NWPATH *nwp)
|
|||||||
if (flags & 0x80) { /* lokal DRIVE */
|
if (flags & 0x80) { /* lokal DRIVE */
|
||||||
path[0]= '\\';
|
path[0]= '\\';
|
||||||
if (drive < 2){
|
if (drive < 2){
|
||||||
strcpy(path, "DISK LW");
|
strcpy(path, "maps to a local disk.");
|
||||||
} else if (getcurdir(drive+1, path+1)) {
|
} else if (getcurdir(drive+1, path+1)) {
|
||||||
strcpy(path, "LW !OK");
|
strcpy(path, "maps to a local disk.");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (get_dir_path(dhandle, path)) {
|
if (get_dir_path(dhandle, path)) {
|
||||||
@@ -188,11 +188,129 @@ static int parse_argv(uint8 *drvstr, NWPATH *nwpath,
|
|||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int parse_pathins_arg(uint8 *drvstr, NWPATH *nwp,
|
||||||
|
int argc, char *argv[], int mode);
|
||||||
|
static int set_search_native(uint8 *drvstr, NWPATH *nwp, int pathmode);
|
||||||
|
static int show_search(uint8 *drvstr);
|
||||||
|
|
||||||
|
static int map_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 int map_is_drive_arg(char *s)
|
||||||
|
{
|
||||||
|
if (!s || !s[0] || s[1] != ':' || s[2]) return(0);
|
||||||
|
if (s[0] >= 'A' && s[0] <= 'Z') return(1);
|
||||||
|
if (s[0] >= 'a' && s[0] <= 'z') return(1);
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int map_drive_index(char *s)
|
||||||
|
{
|
||||||
|
if (s[0] >= 'a' && s[0] <= 'z') return(s[0] - 'a');
|
||||||
|
return(s[0] - 'A');
|
||||||
|
}
|
||||||
|
|
||||||
|
static void map_drive_name(char *dst, char *src)
|
||||||
|
{
|
||||||
|
dst[0] = src[0];
|
||||||
|
if (dst[0] >= 'a' && dst[0] <= 'z') dst[0] -= 32;
|
||||||
|
dst[1] = ':';
|
||||||
|
dst[2] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
static int map_handle_path_command(int argc, char *argv[], int pathmode)
|
||||||
|
{
|
||||||
|
uint8 drvstr[22];
|
||||||
|
NWPATH nwpath;
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
rc = parse_pathins_arg(drvstr, &nwpath, argc, argv, pathmode);
|
||||||
|
if (!rc) {
|
||||||
|
int result = 0;
|
||||||
|
|
||||||
|
if (*(nwpath.path) || pathmode == 1)
|
||||||
|
result = set_search_native(drvstr, &nwpath, pathmode);
|
||||||
|
|
||||||
|
if (result < 0)
|
||||||
|
fprintf(stderr, "Cannot interpret line. errcode=-1\n");
|
||||||
|
else if (pathmode != 1)
|
||||||
|
show_search(drvstr);
|
||||||
|
else
|
||||||
|
fprintf(stdout, "The search mapping for drive S%d: was deleted\n",
|
||||||
|
(int)drvstr[1]);
|
||||||
|
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(stderr, "Cannot interpret line. errcode=-1\n");
|
||||||
|
return(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int func_map(int argc, char *argv[], int mode)
|
int func_map(int argc, char *argv[], int mode)
|
||||||
{
|
{
|
||||||
uint8 drvstr[22];
|
uint8 drvstr[22];
|
||||||
NWPATH nwpath;
|
NWPATH nwpath;
|
||||||
|
|
||||||
if (!ipx_init()) argc = 1;
|
if (!ipx_init()) argc = 1;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Novell MAP accepts subcommands through MAP itself:
|
||||||
|
* MAP DEL H:
|
||||||
|
* MAP INS S1:=SYS:PUBLIC
|
||||||
|
* MAP DEL S1:
|
||||||
|
* The original mars-dosutils exposed those mainly as MAPDEL/PATHINS/PATHDEL,
|
||||||
|
* so handle the Novell syntax here and then reuse the existing primitives.
|
||||||
|
*/
|
||||||
|
if (argc > 1) {
|
||||||
|
if (map_same_arg(argv[1], "/?") || map_same_arg(argv[1], "-?") ||
|
||||||
|
map_same_arg(argv[1], "?")) {
|
||||||
|
fprintf(stderr, "Directory \"/?\" is not locatable.\n");
|
||||||
|
return(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (map_same_arg(argv[1], "INS") || map_same_arg(argv[1], "INSERT")) {
|
||||||
|
if (argc < 3) {
|
||||||
|
fprintf(stderr, "Cannot interpret line. errcode=-1\n");
|
||||||
|
return(1);
|
||||||
|
}
|
||||||
|
return(map_handle_path_command(argc - 1, argv + 1, 2));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (map_same_arg(argv[1], "DEL") || map_same_arg(argv[1], "DELETE")) {
|
||||||
|
if (argc < 3) {
|
||||||
|
fprintf(stderr, "Cannot interpret line. errcode=-1\n");
|
||||||
|
return(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (map_is_drive_arg(argv[2])) {
|
||||||
|
char dname[3];
|
||||||
|
int drive = map_drive_index(argv[2]);
|
||||||
|
|
||||||
|
if (do_map(drive, &nwpath, 1) < 0) {
|
||||||
|
fprintf(stderr, "Cannot interpret line. errcode=-1\n");
|
||||||
|
return(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
map_drive_name(dname, argv[2]);
|
||||||
|
fprintf(stdout, "The mapping for drive %s has been deleted.\n", dname);
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return(map_handle_path_command(argc - 1, argv + 1, 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!parse_argv(drvstr, &nwpath, argc, argv, 0, mode)) {
|
if (!parse_argv(drvstr, &nwpath, argc, argv, 0, mode)) {
|
||||||
if (*(nwpath.path) || mode==1) {
|
if (*(nwpath.path) || mode==1) {
|
||||||
if (do_map(*drvstr - 'A', &nwpath, mode)< 0)
|
if (do_map(*drvstr - 'A', &nwpath, mode)< 0)
|
||||||
@@ -297,18 +415,192 @@ static int set_search(uint8 *drvstr, NWPATH *nwp, int pathmode)
|
|||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int path_is_drive_path(uint8 *path)
|
||||||
|
{
|
||||||
|
if (!path || !path[0] || path[1] != ':') return(0);
|
||||||
|
if (path[0] >= 'A' && path[0] <= 'Z') return(1);
|
||||||
|
if (path[0] >= 'a' && path[0] <= 'z') return(1);
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void upstr_local(uint8 *s)
|
||||||
|
{
|
||||||
|
while (*s) {
|
||||||
|
if (*s >= 'a' && *s <= 'z') *s -= 0x20;
|
||||||
|
s++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static int parse_pathins_arg(uint8 *drvstr, NWPATH *nwp, int argc, char *argv[], int mode)
|
||||||
|
{
|
||||||
|
char joined[512];
|
||||||
|
char *p;
|
||||||
|
char *q;
|
||||||
|
int slot = 0;
|
||||||
|
int k;
|
||||||
|
|
||||||
|
*drvstr = '\0';
|
||||||
|
memset(nwp, 0, sizeof(NWPATH));
|
||||||
|
nwp->path = nwp->buff;
|
||||||
|
*(nwp->buff) = '\0';
|
||||||
|
|
||||||
|
if (argc < 2) return(1);
|
||||||
|
|
||||||
|
joined[0] = '\0';
|
||||||
|
for (k = 1; k < argc; k++) {
|
||||||
|
if (k > 1) strcat(joined, " ");
|
||||||
|
strncat(joined, argv[k], sizeof(joined) - strlen(joined) - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
p = joined;
|
||||||
|
while (*p == ' ' || *p == '\t') p++;
|
||||||
|
|
||||||
|
if (*p != 'S' && *p != 's') return(-1);
|
||||||
|
p++;
|
||||||
|
|
||||||
|
while (*p >= '0' && *p <= '9') {
|
||||||
|
slot = slot * 10 + (*p - '0');
|
||||||
|
p++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (slot < 1 || slot > 16) return(-1);
|
||||||
|
if (*p != ':') return(-1);
|
||||||
|
p++;
|
||||||
|
|
||||||
|
drvstr[0] = 's';
|
||||||
|
drvstr[1] = (uint8)slot;
|
||||||
|
drvstr[2] = '\0';
|
||||||
|
|
||||||
|
while (*p == ' ' || *p == '\t') p++;
|
||||||
|
|
||||||
|
if (mode == 1) {
|
||||||
|
/* PATHDEL S1: */
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*p == '=') p++;
|
||||||
|
while (*p == ' ' || *p == '\t') p++;
|
||||||
|
|
||||||
|
if (!*p) return(-1);
|
||||||
|
|
||||||
|
q = nwp->buff;
|
||||||
|
while (*p && (q - nwp->buff) < (int)sizeof(nwp->buff) - 1) {
|
||||||
|
*q++ = *p++;
|
||||||
|
}
|
||||||
|
*q = '\0';
|
||||||
|
|
||||||
|
upstr_local(nwp->buff);
|
||||||
|
nwp->path = nwp->buff;
|
||||||
|
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int set_search_native(uint8 *drvstr, NWPATH *nwp, int pathmode)
|
||||||
|
{
|
||||||
|
int result=-1;
|
||||||
|
SEARCH_VECTOR drives;
|
||||||
|
SEARCH_VECTOR_ENTRY *p=drives;
|
||||||
|
int j=0;
|
||||||
|
int entry = (*drvstr=='s') ? *(drvstr+1) : 0;
|
||||||
|
|
||||||
|
get_search_drive_vektor(drives);
|
||||||
|
|
||||||
|
while (p->drivenummer != 0xff && j++ < 16) {
|
||||||
|
if (!entry && path_is_drive_path(nwp->path)
|
||||||
|
&& (p->drivenummer + 'A' == nwp->path[0])) entry=j;
|
||||||
|
|
||||||
|
if (path_is_drive_path(nwp->path)
|
||||||
|
&& p->drivenummer + 'A' == nwp->path[0]
|
||||||
|
&& !strcmp(nwp->path+2, p->dospath)) {
|
||||||
|
p->drivenummer=0xfe;
|
||||||
|
*(p->dospath) = '\0';
|
||||||
|
p->flags = 0;
|
||||||
|
}
|
||||||
|
p++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entry > 0) {
|
||||||
|
if (entry > 16) entry = 16;
|
||||||
|
|
||||||
|
if (pathmode == 2 && entry <= j && entry < 16) { /* insert modus */
|
||||||
|
int k=j+1-entry;
|
||||||
|
if (j < 16) {
|
||||||
|
p++;
|
||||||
|
k++;
|
||||||
|
j++;
|
||||||
|
}
|
||||||
|
while (k--) {
|
||||||
|
memcpy(p, p-1, sizeof(SEARCH_VECTOR_ENTRY));
|
||||||
|
--p;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (--entry < j)
|
||||||
|
p = drives+entry;
|
||||||
|
else
|
||||||
|
(p+1)->drivenummer = 0xff;
|
||||||
|
|
||||||
|
memset(p, 0, sizeof(SEARCH_VECTOR_ENTRY));
|
||||||
|
|
||||||
|
if (pathmode==1) {
|
||||||
|
p->drivenummer = 0xfe;
|
||||||
|
*(p->dospath) = '\0';
|
||||||
|
result = set_search_drive_vektor(drives);
|
||||||
|
} else if (path_is_drive_path(nwp->path)) {
|
||||||
|
p->flags = 0;
|
||||||
|
p->drivenummer = (uint8)(nwp->path[0] - 'A');
|
||||||
|
if (nwp->path[0] >= 'a' && nwp->path[0] <= 'z')
|
||||||
|
p->drivenummer = (uint8)(nwp->path[0] - 'a');
|
||||||
|
strmaxcpy(p->dospath, nwp->path+2, sizeof(p->dospath)-1);
|
||||||
|
result = set_search_drive_vektor(drives);
|
||||||
|
} else {
|
||||||
|
/*
|
||||||
|
* Search path entries are not drive mappings. The original code stores
|
||||||
|
* the NetWare path text directly in dospath with drivenummer=0xfe.
|
||||||
|
* Client32 keeps/prints these entries correctly; allocating a permanent
|
||||||
|
* directory handle here made set_search_drive_vektor() return success,
|
||||||
|
* but the entry did not actually replace SEARCH1.
|
||||||
|
*/
|
||||||
|
p->flags = 0;
|
||||||
|
p->drivenummer = 0xfe;
|
||||||
|
strmaxcpy(p->dospath, nwp->path, sizeof(p->dospath)-1);
|
||||||
|
result = set_search_drive_vektor(drives);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int func_path(int argc, char *argv[], int mode)
|
int func_path(int argc, char *argv[], int mode)
|
||||||
{
|
{
|
||||||
uint8 drvstr[22];
|
uint8 drvstr[22];
|
||||||
NWPATH nwpath;
|
NWPATH nwpath;
|
||||||
if (!parse_argv(drvstr, &nwpath, argc, argv, 1, mode)) {
|
int rc;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* PATH/PATHINS/PATHDEL need their own parser. The old parse_argv()
|
||||||
|
* rejects common login-script syntax such as:
|
||||||
|
* PATHINS S1:=SYS:PUBLIC
|
||||||
|
* MAP INS S1:=SYS:PUBLIC
|
||||||
|
*/
|
||||||
|
if (argc < 2) {
|
||||||
|
show_search("");
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
rc = parse_pathins_arg(drvstr, &nwpath, argc, argv, mode);
|
||||||
|
if (!rc) {
|
||||||
int result=0;
|
int result=0;
|
||||||
if (*(nwpath.path) || mode==1)
|
if (*(nwpath.path) || mode==1)
|
||||||
result=set_search(drvstr, &nwpath, mode);
|
result=set_search_native(drvstr, &nwpath, mode);
|
||||||
if (mode != 1)
|
if (mode != 1)
|
||||||
show_search(drvstr);
|
show_search(drvstr);
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fprintf(stderr, "Cannot interpret line. errcode=-1\n");
|
||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
1
net.c
1
net.c
@@ -34,6 +34,7 @@ static struct s_net_functions {
|
|||||||
{"PATHDEL","removes search path" , func_path , 1},
|
{"PATHDEL","removes search path" , func_path , 1},
|
||||||
{"PATHINS","insert search path" , func_path , 2},
|
{"PATHINS","insert search path" , func_path , 2},
|
||||||
{"LOGOUT", "logout from server", func_logout , 0},
|
{"LOGOUT", "logout from server", func_logout , 0},
|
||||||
|
{"FLAG", "display or modify file attributes", func_flag , 0},
|
||||||
{"SLIST", "list servers", func_slist , 0},
|
{"SLIST", "list servers", func_slist , 0},
|
||||||
{"PASSWD", "change password", func_passwd , 0},
|
{"PASSWD", "change password", func_passwd , 0},
|
||||||
#if 1
|
#if 1
|
||||||
|
|||||||
3
net.h
3
net.h
@@ -252,6 +252,9 @@ extern int func_tests (int argc, char *argv[], int mode);
|
|||||||
/* capture.c */
|
/* capture.c */
|
||||||
extern int func_capture(int argc, char *argv[], int mode);
|
extern int func_capture(int argc, char *argv[], int mode);
|
||||||
|
|
||||||
|
/* flag.c */
|
||||||
|
extern int func_flag (int argc, char *argv[], int mode);
|
||||||
|
|
||||||
|
|
||||||
extern int ncp_17_37(uint32 last_id, uint16 objtyp, uint8 *pattern,
|
extern int ncp_17_37(uint32 last_id, uint16 objtyp, uint8 *pattern,
|
||||||
BINDERY_OBJECT *target);
|
BINDERY_OBJECT *target);
|
||||||
|
|||||||
508
nwtests.c
508
nwtests.c
@@ -6,13 +6,59 @@
|
|||||||
|
|
||||||
#include "net.h"
|
#include "net.h"
|
||||||
|
|
||||||
static int usage(void)
|
|
||||||
|
static int tests_same_arg(char *a, char *b)
|
||||||
{
|
{
|
||||||
return(-1);
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
int func_tests(int argc, char *argv[], int mode)
|
static void tests_usage(void)
|
||||||
{
|
{
|
||||||
|
fprintf(stdout, "Usage: TESTS [OLD|NETCALL|E300|NCPF2 [file]|NWREQ87 [file]]\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
static int tests_netcall(void)
|
||||||
|
{
|
||||||
|
unsigned char req[4];
|
||||||
|
unsigned char repl[4];
|
||||||
|
int asm_rc;
|
||||||
|
int c_rc;
|
||||||
|
|
||||||
|
memset(req, 0, sizeof(req));
|
||||||
|
memset(repl, 0, sizeof(repl));
|
||||||
|
|
||||||
|
fprintf(stdout, "TEST Net_Call ASM vs C\n");
|
||||||
|
fprintf(stdout, "Call: INT 21h AH=19h get current drive\n");
|
||||||
|
fprintf(stdout, "Expected: AL=0 for A:, 1 for B:, 2 for C:, ...\n\n");
|
||||||
|
|
||||||
|
asm_rc = Net_Call(0x1900, req, repl);
|
||||||
|
fprintf(stdout, "ASM Net_Call(1900h) rc=%04X drive=%c:\n",
|
||||||
|
asm_rc, 'A' + (asm_rc & 0xff));
|
||||||
|
|
||||||
|
c_rc = Net_Call_C(0x1900, req, repl);
|
||||||
|
fprintf(stdout, "C Net_Call_C(1900h) rc=%04X drive=%c:\n",
|
||||||
|
c_rc, 'A' + (c_rc & 0xff));
|
||||||
|
|
||||||
|
Net_Call_C_Dump();
|
||||||
|
|
||||||
|
if ((asm_rc & 0xff) == (c_rc & 0xff))
|
||||||
|
fprintf(stdout, "\nNETCALL C basic register test OK\n");
|
||||||
|
else
|
||||||
|
fprintf(stdout, "\nNETCALL C basic register test FAILED\n");
|
||||||
|
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int tests_old(int argc, char *argv[], int mode)
|
||||||
|
{
|
||||||
|
|
||||||
int level = ncp_17_02(NWCONN, 6);
|
int level = ncp_17_02(NWCONN, 6);
|
||||||
int dirhandle = alloc_temp_dir_handle(0, "SYS:", 'd', NULL);
|
int dirhandle = alloc_temp_dir_handle(0, "SYS:", 'd', NULL);
|
||||||
int result = -1;
|
int result = -1;
|
||||||
@@ -42,3 +88,459 @@ int func_tests(int argc, char *argv[], int mode)
|
|||||||
if (level > -1) (void) ncp_17_02(NWCONN, level);
|
if (level > -1) (void) ncp_17_02(NWCONN, level);
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void tests_dump_bytes(char *title, unsigned char *p, int len)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
fprintf(stdout, "%s", title);
|
||||||
|
for (i = 0; i < len; i++)
|
||||||
|
fprintf(stdout, " %02X", p[i]);
|
||||||
|
fprintf(stdout, "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
static int tests_netcall_e300(void)
|
||||||
|
{
|
||||||
|
struct {
|
||||||
|
uint16 len;
|
||||||
|
uint8 func;
|
||||||
|
} req_asm, req_c;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
uint16 len;
|
||||||
|
uint8 data[16];
|
||||||
|
} repl_asm, repl_c;
|
||||||
|
|
||||||
|
int asm_rc;
|
||||||
|
int c_rc;
|
||||||
|
|
||||||
|
memset(&req_asm, 0, sizeof(req_asm));
|
||||||
|
memset(&req_c, 0, sizeof(req_c));
|
||||||
|
memset(&repl_asm, 0, sizeof(repl_asm));
|
||||||
|
memset(&repl_c, 0, sizeof(repl_c));
|
||||||
|
|
||||||
|
/*
|
||||||
|
* NCP 17/17 Get Login Encryption Key.
|
||||||
|
* This is a known safe bindery/login helper call used by LOGIN/PASSWD code.
|
||||||
|
* Request via old DOS NetWare API AX=E300.
|
||||||
|
*/
|
||||||
|
req_asm.len = 1;
|
||||||
|
req_asm.func = 0x17;
|
||||||
|
repl_asm.len = 8;
|
||||||
|
|
||||||
|
req_c.len = 1;
|
||||||
|
req_c.func = 0x17;
|
||||||
|
repl_c.len = 8;
|
||||||
|
|
||||||
|
fprintf(stdout, "TEST Net_Call ASM vs C E300/NCP17/17\n");
|
||||||
|
fprintf(stdout, "Call: Get Login Encryption Key\n\n");
|
||||||
|
|
||||||
|
asm_rc = Net_Call(0xE300, &req_asm, &repl_asm);
|
||||||
|
fprintf(stdout, "ASM Net_Call(E300h) rc=%04X\n", asm_rc);
|
||||||
|
tests_dump_bytes("ASM key:", repl_asm.data, 8);
|
||||||
|
|
||||||
|
c_rc = Net_Call_C(0xE300, &req_c, &repl_c);
|
||||||
|
fprintf(stdout, "C Net_Call_C(E300h) rc=%04X\n", c_rc);
|
||||||
|
tests_dump_bytes("C key:", repl_c.data, 8);
|
||||||
|
|
||||||
|
Net_Call_C_Dump();
|
||||||
|
|
||||||
|
if ((asm_rc & 0xff) == (c_rc & 0xff))
|
||||||
|
fprintf(stdout, "\nNETCALL C E300 return test OK\n");
|
||||||
|
else
|
||||||
|
fprintf(stdout, "\nNETCALL C E300 return test FAILED\n");
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Keys can differ per request, so do not require byte-identical keys.
|
||||||
|
* We only compare return status and check that both calls returned 8 bytes.
|
||||||
|
*/
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void tests_put_word_lh(uint8 *p, uint16 v)
|
||||||
|
{
|
||||||
|
p[0] = (uint8)(v & 0xff);
|
||||||
|
p[1] = (uint8)((v >> 8) & 0xff);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void tests_put_dword_lh(uint8 *p, uint32 v)
|
||||||
|
{
|
||||||
|
p[0] = (uint8)(v & 0xff);
|
||||||
|
p[1] = (uint8)((v >> 8) & 0xff);
|
||||||
|
p[2] = (uint8)((v >> 16) & 0xff);
|
||||||
|
p[3] = (uint8)((v >> 24) & 0xff);
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint32 tests_get_dword_lh(uint8 *p)
|
||||||
|
{
|
||||||
|
return((uint32)p[0] |
|
||||||
|
((uint32)p[1] << 8) |
|
||||||
|
((uint32)p[2] << 16) |
|
||||||
|
((uint32)p[3] << 24));
|
||||||
|
}
|
||||||
|
|
||||||
|
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_conn_dhandle(uint8 *connid, uint8 *dhandle)
|
||||||
|
{
|
||||||
|
uint8 flags = 0;
|
||||||
|
int drive;
|
||||||
|
|
||||||
|
drive = tests_get_current_drive();
|
||||||
|
|
||||||
|
if (get_drive_info((uint8)drive, connid, dhandle, &flags)) {
|
||||||
|
fprintf(stdout, "NCPF2DBG get_drive_info failed drive=%c:\n", 'A' + drive);
|
||||||
|
return(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(stdout, "NCPF2DBG drive=%c: connid=%u dhandle=%u flags=%02X\n",
|
||||||
|
'A' + drive, *connid, *dhandle, flags);
|
||||||
|
|
||||||
|
if (!*connid || (flags & 0x80)) {
|
||||||
|
fprintf(stdout, "NCPF2DBG current drive is not a network drive\n");
|
||||||
|
return(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int tests_add_handle_path(uint8 *p, uint8 dhandle, char *name)
|
||||||
|
{
|
||||||
|
int nlen;
|
||||||
|
|
||||||
|
nlen = strlen(name);
|
||||||
|
if (nlen > 255) nlen = 255;
|
||||||
|
|
||||||
|
*p++ = dhandle;
|
||||||
|
tests_put_dword_lh(p, 0L); p += 4;
|
||||||
|
*p++ = 0; /* dirstyle = short dir handle */
|
||||||
|
*p++ = 1; /* one component */
|
||||||
|
*p++ = (uint8)nlen;
|
||||||
|
memcpy(p, name, nlen);
|
||||||
|
p += nlen;
|
||||||
|
|
||||||
|
return(1 + 4 + 1 + 1 + 1 + nlen);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int tests_ncpf2_read_one(char *name, UI cx_mode)
|
||||||
|
{
|
||||||
|
struct {
|
||||||
|
uint8 data[320];
|
||||||
|
} req;
|
||||||
|
struct {
|
||||||
|
uint8 data[256];
|
||||||
|
} repl;
|
||||||
|
|
||||||
|
uint8 *p;
|
||||||
|
uint8 connid = 0;
|
||||||
|
uint8 dhandle = 0;
|
||||||
|
UI cx;
|
||||||
|
int hlen;
|
||||||
|
int rc;
|
||||||
|
uint32 attr;
|
||||||
|
|
||||||
|
if (tests_current_conn_dhandle(&connid, &dhandle))
|
||||||
|
return(1);
|
||||||
|
|
||||||
|
memset(&req, 0, sizeof(req));
|
||||||
|
memset(&repl, 0, sizeof(repl));
|
||||||
|
|
||||||
|
p = req.data;
|
||||||
|
*p++ = 6; /* NCP87 subfunction 6: obtain file/subdir info */
|
||||||
|
*p++ = 0; /* source namespace DOS */
|
||||||
|
*p++ = 0; /* target namespace DOS */
|
||||||
|
tests_put_word_lh(p, 0x0006); p += 2; /* SA_ALL */
|
||||||
|
tests_put_dword_lh(p, 0x00000004UL); p += 4; /* RIM_ATTRIBUTES */
|
||||||
|
hlen = tests_add_handle_path(p, dhandle, name);
|
||||||
|
p += hlen;
|
||||||
|
|
||||||
|
if (cx_mode == 0)
|
||||||
|
cx = (UI)(p - req.data); /* most likely: request length */
|
||||||
|
else
|
||||||
|
cx = sizeof(repl.data); /* alternate: reply buffer size */
|
||||||
|
|
||||||
|
fprintf(stdout, "NCPF2DBG name=%s func=57 conn=%u cx=%u dx=%u mode=%u req.len=%u repl.max=%u\n",
|
||||||
|
name, connid, cx, (UI)sizeof(repl.data), cx_mode, (UI)(p - req.data), (UI)sizeof(repl.data));
|
||||||
|
tests_dump_bytes("NCPF2DBG req:", req.data, (p - req.data) > 64 ? 64 : (int)(p - req.data));
|
||||||
|
|
||||||
|
rc = Net_Call_F2_C(0x57, cx, (UI)sizeof(repl.data), req.data, repl.data);
|
||||||
|
|
||||||
|
fprintf(stdout, "NCPF2DBG rc=%04X\n", rc);
|
||||||
|
tests_dump_bytes("NCPF2DBG repl:", repl.data, 64);
|
||||||
|
Net_Call_C_Dump();
|
||||||
|
|
||||||
|
attr = tests_get_dword_lh(repl.data);
|
||||||
|
fprintf(stdout, "NCPF2DBG attr[0]=%08lX\n", attr);
|
||||||
|
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int tests_ncpf2(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
char *name = "LOGIN.EXE";
|
||||||
|
UI mode = 0;
|
||||||
|
|
||||||
|
if (argc > 2)
|
||||||
|
name = argv[2];
|
||||||
|
if (argc > 3 && tests_same_arg(argv[3], "REPLY"))
|
||||||
|
mode = 1;
|
||||||
|
|
||||||
|
fprintf(stdout, "TEST NCPF2 AH=F2/AL=57 NCP87 obtain RIM_ATTRIBUTES\n");
|
||||||
|
fprintf(stdout, "Default CX is request length. Add REPLY to use reply size.\n");
|
||||||
|
fprintf(stdout, "This is read-only, but still experimental.\n\n");
|
||||||
|
|
||||||
|
return tests_ncpf2_read_one(name, mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void tests_build_nwreq87_path(uint8 *buf, uint8 dhandle,
|
||||||
|
char *name, UI *out_len)
|
||||||
|
{
|
||||||
|
uint8 *p;
|
||||||
|
int nlen;
|
||||||
|
|
||||||
|
memset(buf, 0, 300);
|
||||||
|
|
||||||
|
p = buf;
|
||||||
|
nlen = strlen(name);
|
||||||
|
if (nlen > 255) nlen = 255;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Same compact handle/path payload we used before:
|
||||||
|
* handle, dirbase, dirstyle, component-count, len, name
|
||||||
|
* The new part in this test is not the path itself; it is that we now
|
||||||
|
* reproduce NWCREQUEST's fragmented request and full reply size.
|
||||||
|
*/
|
||||||
|
*p++ = dhandle;
|
||||||
|
tests_put_dword_lh(p, 0L); p += 4;
|
||||||
|
*p++ = 0; /* dirstyle = short directory handle */
|
||||||
|
*p++ = 1; /* one path component */
|
||||||
|
*p++ = (uint8)nlen;
|
||||||
|
memcpy(p, name, nlen);
|
||||||
|
p += nlen;
|
||||||
|
|
||||||
|
*out_len = (UI)(p - buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
static UI tests_build_nwreq87s6_flat(uint8 *req,
|
||||||
|
uint8 *path,
|
||||||
|
UI path_len)
|
||||||
|
{
|
||||||
|
uint8 *p;
|
||||||
|
|
||||||
|
memset(req, 0, 400);
|
||||||
|
p = req;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* DeveloperNet ncpdos16 87s6.c builds two request fragments:
|
||||||
|
* frag 1 length 9:
|
||||||
|
* subfn=6, srcNS, dstNS, searchAttrs, returnInfoMask
|
||||||
|
* frag 2:
|
||||||
|
* packed handle/path structure
|
||||||
|
*
|
||||||
|
* NWCREQUEST for NETX/Shell concatenates those request fragments before
|
||||||
|
* calling NWCSHELLREQ.
|
||||||
|
*/
|
||||||
|
*p++ = 6; /* NCP87 subfunction 6 */
|
||||||
|
*p++ = 0; /* source namespace DOS */
|
||||||
|
*p++ = 0; /* target namespace DOS */
|
||||||
|
tests_put_word_lh(p, 0x0006); p += 2; /* SA_ALL */
|
||||||
|
tests_put_dword_lh(p, 0x00000004UL); p += 4;/* RIM_ATTRIBUTES */
|
||||||
|
|
||||||
|
memcpy(p, path, path_len);
|
||||||
|
p += path_len;
|
||||||
|
|
||||||
|
return (UI)(p - req);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int tests_nwreq87(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
char *name = "LOGIN.EXE";
|
||||||
|
uint8 connid = 0;
|
||||||
|
uint8 dhandle = 0;
|
||||||
|
uint8 path[300];
|
||||||
|
uint8 req[400];
|
||||||
|
uint8 repl[0x180];
|
||||||
|
uint8 dummy[8];
|
||||||
|
UI path_len;
|
||||||
|
UI req_len;
|
||||||
|
int rc;
|
||||||
|
uint32 a0;
|
||||||
|
uint32 a4;
|
||||||
|
uint32 a4d;
|
||||||
|
|
||||||
|
if (argc > 2)
|
||||||
|
name = argv[2];
|
||||||
|
|
||||||
|
if (tests_current_conn_dhandle(&connid, &dhandle))
|
||||||
|
return(1);
|
||||||
|
|
||||||
|
tests_build_nwreq87_path(path, dhandle, name, &path_len);
|
||||||
|
req_len = tests_build_nwreq87s6_flat(req, path, path_len);
|
||||||
|
|
||||||
|
memset(repl, 0, sizeof(repl));
|
||||||
|
memset(dummy, 0, sizeof(dummy));
|
||||||
|
|
||||||
|
fprintf(stdout, "TEST NWREQ87 shell-style NCP87/S6 for %s\n", name);
|
||||||
|
fprintf(stdout, "connid=%u dhandle=%u path.len=%u req.len=%u repl.len=%u\n",
|
||||||
|
connid, dhandle, path_len, req_len, (UI)0x014d);
|
||||||
|
tests_dump_bytes("NWREQ87 path:", path, path_len > 48 ? 48 : path_len);
|
||||||
|
tests_dump_bytes("NWREQ87 req :", req, req_len > 64 ? 64 : req_len);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Reproduce the NETX/Shell path in clndos16 dreq.c:
|
||||||
|
* first AH=F0/DX=conn via NWCSHELLREQ
|
||||||
|
* then AH=F2/AL=function with DS:SI=request, CX=requestLen,
|
||||||
|
* ES:DI=reply, DX=sum(replyFragLengths).
|
||||||
|
*
|
||||||
|
* For 87s6.c reply fragments are 0x4d + 0x100 = 0x014d.
|
||||||
|
*/
|
||||||
|
fprintf(stdout, "NWREQ87 init F000 DX=conn\n");
|
||||||
|
rc = Net_Call_F2X_C(0xF000, 0, 0, (UI)connid, dummy, repl);
|
||||||
|
fprintf(stdout, "NWREQ87 init rc=%04X\n", rc);
|
||||||
|
Net_Call_C_Dump();
|
||||||
|
|
||||||
|
fprintf(stdout, "NWREQ87 call F257 CX=req.len DX=014D\n");
|
||||||
|
rc = Net_Call_F2X_C(0xF257, 0, req_len, 0x014d, req, repl);
|
||||||
|
fprintf(stdout, "NWREQ87 rc=%04X\n", rc);
|
||||||
|
Net_Call_C_Dump();
|
||||||
|
|
||||||
|
tests_dump_bytes("NWREQ87 repl[0..63]:", repl, 64);
|
||||||
|
tests_dump_bytes("NWREQ87 repl[4d..8c]:", repl + 0x4d, 64);
|
||||||
|
|
||||||
|
a0 = tests_get_dword_lh(repl);
|
||||||
|
a4 = tests_get_dword_lh(repl + 4);
|
||||||
|
a4d = tests_get_dword_lh(repl + 0x4d);
|
||||||
|
|
||||||
|
fprintf(stdout, "NWREQ87 dword[0]=%08lX dword[4]=%08lX dword[4d]=%08lX\n",
|
||||||
|
a0, a4, a4d);
|
||||||
|
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint16 off;
|
||||||
|
uint16 seg;
|
||||||
|
uint16 len;
|
||||||
|
} TEST_NWFRAG16;
|
||||||
|
|
||||||
|
static void tests_set_frag(TEST_NWFRAG16 *f, void *ptr, UI len)
|
||||||
|
{
|
||||||
|
f->off = FP_OFF(ptr);
|
||||||
|
f->seg = FP_SEG(ptr);
|
||||||
|
f->len = (uint16)len;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int tests_nwreq87vlm(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
char *name = "LOGIN.EXE";
|
||||||
|
uint8 connid = 0;
|
||||||
|
uint8 dhandle = 0;
|
||||||
|
uint8 path[300];
|
||||||
|
uint8 hdr[16];
|
||||||
|
uint8 repl[0x180];
|
||||||
|
TEST_NWFRAG16 reqfrags[2];
|
||||||
|
TEST_NWFRAG16 replfrags[2];
|
||||||
|
UI path_len;
|
||||||
|
int rc;
|
||||||
|
uint32 a0;
|
||||||
|
uint32 a4d;
|
||||||
|
|
||||||
|
if (argc > 2)
|
||||||
|
name = argv[2];
|
||||||
|
|
||||||
|
if (tests_current_conn_dhandle(&connid, &dhandle))
|
||||||
|
return(1);
|
||||||
|
|
||||||
|
tests_build_nwreq87_path(path, dhandle, name, &path_len);
|
||||||
|
|
||||||
|
memset(hdr, 0, sizeof(hdr));
|
||||||
|
memset(repl, 0, sizeof(repl));
|
||||||
|
memset(reqfrags, 0, sizeof(reqfrags));
|
||||||
|
memset(replfrags, 0, sizeof(replfrags));
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ncpdos16 87s6.c request frag #1, length 9.
|
||||||
|
*/
|
||||||
|
hdr[0] = 6; /* subfunction */
|
||||||
|
hdr[1] = 0; /* src namespace DOS */
|
||||||
|
hdr[2] = 0; /* dst namespace DOS */
|
||||||
|
tests_put_word_lh(hdr + 3, 0x0006); /* SA_ALL */
|
||||||
|
tests_put_dword_lh(hdr + 5, 0x00000004UL); /* RIM_ATTRIBUTES */
|
||||||
|
|
||||||
|
tests_set_frag(&reqfrags[0], hdr, 9);
|
||||||
|
tests_set_frag(&reqfrags[1], path, path_len);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ncpdos16 87s6.c reply frags:
|
||||||
|
* local entry-info block 0x4d
|
||||||
|
* caller output extension 0x100
|
||||||
|
*/
|
||||||
|
tests_set_frag(&replfrags[0], repl, 0x4d);
|
||||||
|
tests_set_frag(&replfrags[1], repl + 0x4d, 0x100);
|
||||||
|
|
||||||
|
fprintf(stdout, "TEST NWREQ87VLM NCP87/S6 for %s\n", name);
|
||||||
|
fprintf(stdout, "connid=%u dhandle=%u path.len=%u\n", connid, dhandle, path_len);
|
||||||
|
tests_dump_bytes("VLM hdr :", hdr, 9);
|
||||||
|
tests_dump_bytes("VLM path:", path, path_len > 48 ? 48 : path_len);
|
||||||
|
|
||||||
|
fprintf(stdout, "VLM call: AX=0057 BX=0002 CX=conn DX=0002 p1=6 p2=20 p3=0\n");
|
||||||
|
|
||||||
|
rc = Net_Call_VLM_Raw(0x0057, 2, (UI)connid, 2,
|
||||||
|
reqfrags, replfrags,
|
||||||
|
6, 0x20, 0);
|
||||||
|
|
||||||
|
fprintf(stdout, "NWREQ87VLM rc=%04X\n", rc);
|
||||||
|
tests_dump_bytes("VLM repl[0..63]:", repl, 64);
|
||||||
|
tests_dump_bytes("VLM repl[4d..8c]:", repl + 0x4d, 64);
|
||||||
|
|
||||||
|
a0 = tests_get_dword_lh(repl);
|
||||||
|
a4d = tests_get_dword_lh(repl + 0x4d);
|
||||||
|
fprintf(stdout, "NWREQ87VLM dword[0]=%08lX dword[4d]=%08lX\n", a0, a4d);
|
||||||
|
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int func_tests(int argc, char *argv[], int mode)
|
||||||
|
{
|
||||||
|
if (argc >= 2) {
|
||||||
|
if (tests_same_arg(argv[1], "NETCALL"))
|
||||||
|
return tests_netcall();
|
||||||
|
|
||||||
|
if (tests_same_arg(argv[1], "E300") || tests_same_arg(argv[1], "NETCALLE300"))
|
||||||
|
return tests_netcall_e300();
|
||||||
|
|
||||||
|
if (tests_same_arg(argv[1], "NWREQ87"))
|
||||||
|
return tests_nwreq87(argc, argv);
|
||||||
|
|
||||||
|
if (tests_same_arg(argv[1], "NWREQ87VLM"))
|
||||||
|
return tests_nwreq87vlm(argc, argv);
|
||||||
|
|
||||||
|
if (tests_same_arg(argv[1], "NCPF2"))
|
||||||
|
return tests_ncpf2(argc, argv);
|
||||||
|
|
||||||
|
if (tests_same_arg(argv[1], "OLD"))
|
||||||
|
return tests_old(argc - 1, argv + 1, mode);
|
||||||
|
|
||||||
|
if (tests_same_arg(argv[1], "/?") || tests_same_arg(argv[1], "-?") ||
|
||||||
|
tests_same_arg(argv[1], "?")) {
|
||||||
|
tests_usage();
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Default and unknown arguments keep the historical nwtests.c behavior.
|
||||||
|
*/
|
||||||
|
return tests_old(argc, argv, mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
84
slist.c
84
slist.c
@@ -2,17 +2,49 @@
|
|||||||
|
|
||||||
#include "net.h"
|
#include "net.h"
|
||||||
|
|
||||||
|
#define NCP_BINDERY_FSERVER 0x0004
|
||||||
|
|
||||||
static int usage(void)
|
static int usage(void)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "usage:\t%s [pattern]\n", funcname);
|
fprintf(stdout, "Usage: SLIST [Server] [/Continue]\n");
|
||||||
return(-1);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void print_net_node(uint8 *addr)
|
static int same_arg(char *a, char *b)
|
||||||
{
|
{
|
||||||
fprintf(stdout, "%08lX %02X%02X%02X%02X%02X%02X",
|
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 int is_help_arg(char *s)
|
||||||
|
{
|
||||||
|
if (!s) return(0);
|
||||||
|
return(same_arg(s, "/?") || same_arg(s, "-?") || same_arg(s, "?"));
|
||||||
|
}
|
||||||
|
|
||||||
|
static unsigned long node_to_number(uint8 *addr)
|
||||||
|
{
|
||||||
|
unsigned long n = 0;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 4; i < 10; i++)
|
||||||
|
n = (n << 8) + addr[i];
|
||||||
|
|
||||||
|
return(n);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void print_net_node_status(uint8 *addr, int is_default)
|
||||||
|
{
|
||||||
|
fprintf(stdout, "[%08lX][%12lu]%s",
|
||||||
(unsigned long)GET_BE32(addr),
|
(unsigned long)GET_BE32(addr),
|
||||||
addr[4], addr[5], addr[6], addr[7], addr[8], addr[9]);
|
node_to_number(addr),
|
||||||
|
is_default ? "Default" : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
int func_slist(int argc, char *argv[], int mode)
|
int func_slist(int argc, char *argv[], int mode)
|
||||||
@@ -22,33 +54,50 @@ int func_slist(int argc, char *argv[], int mode)
|
|||||||
uint8 pattern[50];
|
uint8 pattern[50];
|
||||||
int found = 0;
|
int found = 0;
|
||||||
int result;
|
int result;
|
||||||
|
int i;
|
||||||
|
|
||||||
(void)mode;
|
(void)mode;
|
||||||
|
|
||||||
if (argc > 2) return(usage());
|
strcpy(pattern, "*");
|
||||||
|
|
||||||
|
for (i = 1; i < argc; i++) {
|
||||||
|
if (is_help_arg(argv[i])) return(usage());
|
||||||
|
|
||||||
|
if (argv[i][0] == '/' || argv[i][0] == '-') {
|
||||||
|
if (same_arg(argv[i], "/C") || same_arg(argv[i], "/CONTINUE") ||
|
||||||
|
same_arg(argv[i], "-C") || same_arg(argv[i], "-CONTINUE")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
return(usage());
|
||||||
|
}
|
||||||
|
|
||||||
|
strmaxcpy(pattern, argv[i], sizeof(pattern) - 1);
|
||||||
|
}
|
||||||
|
|
||||||
if (argc == 2) strmaxcpy(pattern, argv[1], sizeof(pattern) - 1);
|
|
||||||
else strcpy(pattern, "*");
|
|
||||||
upstr(pattern);
|
upstr(pattern);
|
||||||
|
|
||||||
fprintf(stdout, "\n%-52s%-10s%-12s\n",
|
/*
|
||||||
"Known NetWare File Servers", "Network", "Node Address");
|
* Novell-like layout from the DOS client:
|
||||||
fprintf(stdout,
|
* Known NetWare File Servers Network Node Address Status
|
||||||
"-----------------------------------------------"
|
* ------------------------- -------- -------------------
|
||||||
"---------------------------\n");
|
*/
|
||||||
|
fprintf(stdout, "%-44sNetwork Node Address Status\n",
|
||||||
|
"Known NetWare File Servers");
|
||||||
|
fprintf(stdout, "%-44s------- ----------- ------\n",
|
||||||
|
"--------------------------");
|
||||||
|
|
||||||
while ((result = ncp_17_37(last_id, NCP_BINDERY_FSERVER,
|
while ((result = ncp_17_37(last_id, NCP_BINDERY_FSERVER,
|
||||||
pattern, &obj)) == 0) {
|
pattern, &obj)) == 0) {
|
||||||
NW_PROPERTY prop;
|
NW_PROPERTY prop;
|
||||||
|
|
||||||
found = 1;
|
found++;
|
||||||
last_id = obj.object_id;
|
last_id = obj.object_id;
|
||||||
|
|
||||||
fprintf(stdout, "%-52s", obj.object_name);
|
fprintf(stdout, "%-44s", obj.object_name);
|
||||||
|
|
||||||
if (!ncp_17_3d(NCP_BINDERY_FSERVER, obj.object_name,
|
if (!ncp_17_3d(NCP_BINDERY_FSERVER, obj.object_name,
|
||||||
1, "NET_ADDRESS", &prop)) {
|
1, "NET_ADDRESS", &prop)) {
|
||||||
print_net_node(prop.value);
|
print_net_node_status(prop.value, found == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stdout, "\n");
|
fprintf(stdout, "\n");
|
||||||
@@ -56,8 +105,7 @@ int func_slist(int argc, char *argv[], int mode)
|
|||||||
if (last_id == MAX_U32) break;
|
if (last_id == MAX_U32) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!found)
|
fprintf(stdout, "\nTotal of %d file servers found\n", found);
|
||||||
fprintf(stdout, "No servers found\n");
|
|
||||||
|
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user