Compare commits
61 Commits
4e49ecec1a
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
919ab99ad1 | ||
|
|
4b7d6a1bb9 | ||
|
|
07784e8e9c | ||
|
|
3bd41dd828 | ||
|
|
ed46e3aef9 | ||
|
|
7f4dd3b429 | ||
|
|
64ab3a4fab | ||
|
|
30db93ec8d | ||
|
|
347b9ee67f | ||
|
|
b0652ae5d5 | ||
|
|
c68d73faa6 | ||
|
|
a080dfaa56 | ||
|
|
0d466ce30a | ||
|
|
b5891740cf | ||
|
|
1f5cf85229 | ||
|
|
1b28bcfa99 | ||
|
|
52170c1092 | ||
|
|
f6b017391b | ||
|
|
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;
|
||||||
|
}
|
||||||
26
kern.h
26
kern.h
@@ -13,8 +13,32 @@ 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 C32_LoadNios_Probe(UI axfunc, void *outbuf);
|
||||||
|
extern int KERN_CALL C32_GetFunc_Probe(char *name, void *outbuf);
|
||||||
|
extern int KERN_CALL C32_CallVersion_Nios_Probe(void *outbuf);
|
||||||
|
extern int KERN_CALL C32_MapLock_Probe(void *ptr, UI len, void *outbuf);
|
||||||
|
extern int KERN_CALL C32_NCP87_Raw_Probe(UI connLo, UI connHi,
|
||||||
|
void *hdr, UI hdrLen,
|
||||||
|
void *path, UI pathLen,
|
||||||
|
void *rep0, UI rep0Len,
|
||||||
|
void *rep1, UI rep1Len,
|
||||||
|
void *outbuf);
|
||||||
|
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
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
832
kern_wasm.asm
832
kern_wasm.asm
@@ -20,6 +20,12 @@ public _IPXclose_socket
|
|||||||
public _IPXlisten
|
public _IPXlisten
|
||||||
public _xmemmove
|
public _xmemmove
|
||||||
public _Net_Call
|
public _Net_Call
|
||||||
|
public _C32_LoadNios_Probe
|
||||||
|
public _C32_GetFunc_Probe
|
||||||
|
public _C32_CallVersion_Nios_Probe
|
||||||
|
public _C32_MapLock_Probe
|
||||||
|
public _C32_NCP87_Raw_Probe
|
||||||
|
public _Net_Call_VLM_Raw
|
||||||
|
|
||||||
_IPXinit proc far
|
_IPXinit proc far
|
||||||
push bp
|
push bp
|
||||||
@@ -213,4 +219,830 @@ _Net_Call proc far
|
|||||||
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
|
||||||
|
|
||||||
|
|
||||||
|
; int C32_LoadNios_Probe(UI axfunc, void *outbuf)
|
||||||
|
;
|
||||||
|
; 16-bit object, but captures 32-bit ESI and ECX using manual 386 opcodes.
|
||||||
|
; This keeps the OMF/linker in 16-bit mode while still reading Client32/NIOS
|
||||||
|
; values returned by:
|
||||||
|
; INT 2F AX=D8C1
|
||||||
|
;
|
||||||
|
; outbuf:
|
||||||
|
; +00 word AX after INT 2F
|
||||||
|
; +02 dword ESI after INT 2F
|
||||||
|
; +06 dword ECX after INT 2F
|
||||||
|
; +0A word BX
|
||||||
|
; +0C word CX low
|
||||||
|
; +0E word DX
|
||||||
|
; +10 word SI low
|
||||||
|
; +12 word DS
|
||||||
|
; +14 word ES
|
||||||
|
_C32_LoadNios_Probe proc far
|
||||||
|
push bp
|
||||||
|
mov bp, sp
|
||||||
|
|
||||||
|
push ds
|
||||||
|
push es
|
||||||
|
push si
|
||||||
|
push di
|
||||||
|
|
||||||
|
; xor ecx, ecx
|
||||||
|
db 66h, 33h, 0C9h
|
||||||
|
; xor esi, esi
|
||||||
|
db 66h, 33h, 0F6h
|
||||||
|
|
||||||
|
mov ax, [bp+6]
|
||||||
|
int 2Fh
|
||||||
|
|
||||||
|
push ds
|
||||||
|
push es
|
||||||
|
push si
|
||||||
|
push cx
|
||||||
|
push bx
|
||||||
|
push dx
|
||||||
|
push ax
|
||||||
|
|
||||||
|
les di, dword ptr [bp+8]
|
||||||
|
|
||||||
|
; restore AX result into AX and store word at out+0
|
||||||
|
pop ax
|
||||||
|
mov es:[di+0], ax
|
||||||
|
|
||||||
|
; Store ESI dword at es:[di+2].
|
||||||
|
; Encoding: ES override + operand-size prefix + MOV r/m32,r32
|
||||||
|
; mov es:[di+02], esi = 26 66 89 75 02
|
||||||
|
db 26h, 66h, 89h, 75h, 02h
|
||||||
|
|
||||||
|
; Store ECX dword at es:[di+6].
|
||||||
|
; mov es:[di+06], ecx = 26 66 89 4Dh 06
|
||||||
|
db 26h, 66h, 89h, 4Dh, 06h
|
||||||
|
|
||||||
|
pop dx
|
||||||
|
pop bx
|
||||||
|
pop cx
|
||||||
|
|
||||||
|
mov es:[di+10], bx
|
||||||
|
mov es:[di+12], cx
|
||||||
|
mov es:[di+14], dx
|
||||||
|
|
||||||
|
pop ax ; saved SI
|
||||||
|
mov es:[di+16], ax
|
||||||
|
|
||||||
|
pop ax ; saved ES
|
||||||
|
pop bx ; saved DS
|
||||||
|
mov es:[di+18], bx
|
||||||
|
mov es:[di+20], ax
|
||||||
|
|
||||||
|
pop di
|
||||||
|
pop si
|
||||||
|
pop es
|
||||||
|
pop ds
|
||||||
|
pop bp
|
||||||
|
xor ah, ah
|
||||||
|
ret
|
||||||
|
_C32_LoadNios_Probe endp
|
||||||
|
|
||||||
|
|
||||||
|
; int C32_GetFunc_Probe(char *name, void *outbuf)
|
||||||
|
;
|
||||||
|
; 16-bit OMF Client32 function resolver probe.
|
||||||
|
; This mimics C32BEGINUSE for one function name:
|
||||||
|
; INT 2F AX=D8C1
|
||||||
|
; save ESI as far pointer to __Nios+8 function resolver
|
||||||
|
; push name segment
|
||||||
|
; push name offset
|
||||||
|
; push 0
|
||||||
|
; push 0
|
||||||
|
; call far [ESI]
|
||||||
|
; add sp,8
|
||||||
|
;
|
||||||
|
; outbuf:
|
||||||
|
; +00 word load AX from INT2F
|
||||||
|
; +02 dword ESI from INT2F
|
||||||
|
; +06 dword ECX from INT2F
|
||||||
|
; +0A word resolver return AX
|
||||||
|
; +0C word resolver return DX
|
||||||
|
; +0E word BX
|
||||||
|
; +10 word CX
|
||||||
|
_C32_GetFunc_Probe proc far
|
||||||
|
push bp
|
||||||
|
mov bp, sp
|
||||||
|
sub sp, 4
|
||||||
|
|
||||||
|
push ds
|
||||||
|
push es
|
||||||
|
push si
|
||||||
|
push di
|
||||||
|
|
||||||
|
; clear ECX/ESI
|
||||||
|
db 66h, 33h, 0C9h
|
||||||
|
db 66h, 33h, 0F6h
|
||||||
|
|
||||||
|
mov ax, 0D8C1h
|
||||||
|
int 2Fh
|
||||||
|
|
||||||
|
; save ESI dword to [bp-4]
|
||||||
|
db 66h, 89h, 76h, 0FCh
|
||||||
|
|
||||||
|
push ax ; save load AX
|
||||||
|
|
||||||
|
; call resolver only if AX == 0
|
||||||
|
or ax, ax
|
||||||
|
jne c32get_store_fail
|
||||||
|
|
||||||
|
push word ptr [bp+8] ; name segment
|
||||||
|
push word ptr [bp+6] ; name offset
|
||||||
|
push 0
|
||||||
|
push 0
|
||||||
|
call dword ptr [bp-4]
|
||||||
|
add sp, 8
|
||||||
|
|
||||||
|
jmp short c32get_store
|
||||||
|
|
||||||
|
c32get_store_fail:
|
||||||
|
xor dx, dx
|
||||||
|
xor ax, ax
|
||||||
|
|
||||||
|
c32get_store:
|
||||||
|
push dx
|
||||||
|
push ax
|
||||||
|
|
||||||
|
les di, dword ptr [bp+10]
|
||||||
|
|
||||||
|
pop ax ; resolver AX
|
||||||
|
pop dx ; resolver DX
|
||||||
|
pop bx ; load AX saved in BX temporarily
|
||||||
|
|
||||||
|
mov es:[di+0], bx
|
||||||
|
|
||||||
|
; Store ESI dword at out+2: ES override + operand prefix
|
||||||
|
db 26h, 66h, 89h, 75h, 02h
|
||||||
|
|
||||||
|
; Store ECX dword at out+6
|
||||||
|
db 26h, 66h, 89h, 4Dh, 06h
|
||||||
|
|
||||||
|
mov es:[di+10], ax
|
||||||
|
mov es:[di+12], dx
|
||||||
|
mov es:[di+14], bx
|
||||||
|
mov es:[di+16], cx
|
||||||
|
|
||||||
|
pop di
|
||||||
|
pop si
|
||||||
|
pop es
|
||||||
|
pop ds
|
||||||
|
mov sp, bp
|
||||||
|
pop bp
|
||||||
|
xor ah, ah
|
||||||
|
ret
|
||||||
|
_C32_GetFunc_Probe endp
|
||||||
|
|
||||||
|
|
||||||
|
; int C32_CallVersion_Nios_Probe(void *outbuf)
|
||||||
|
;
|
||||||
|
; Safe Client32 version call using the exact d32wrap convention:
|
||||||
|
; 1) INT 2F AX=D8C1
|
||||||
|
; 2) use ESI resolver to resolve "CLIENT32GetVersion"
|
||||||
|
; 3) call ECX trampoline, not the function pointer directly:
|
||||||
|
; push 0
|
||||||
|
; push 0
|
||||||
|
; push fn_seg
|
||||||
|
; push fn_off
|
||||||
|
; call ECX
|
||||||
|
; add sp,8
|
||||||
|
;
|
||||||
|
; outbuf:
|
||||||
|
; +00 load AX
|
||||||
|
; +02 resolver off
|
||||||
|
; +04 resolver seg
|
||||||
|
; +06 trampoline off
|
||||||
|
; +08 trampoline seg
|
||||||
|
; +0A fn off
|
||||||
|
; +0C fn seg
|
||||||
|
; +0E call AX
|
||||||
|
; +10 call DX
|
||||||
|
; +12 flags
|
||||||
|
_C32_CallVersion_Nios_Probe proc far
|
||||||
|
push bp
|
||||||
|
mov bp, sp
|
||||||
|
sub sp, 12
|
||||||
|
|
||||||
|
push ds
|
||||||
|
push es
|
||||||
|
push si
|
||||||
|
push di
|
||||||
|
pushf
|
||||||
|
|
||||||
|
; clear ECX/ESI
|
||||||
|
db 66h, 33h, 0C9h
|
||||||
|
db 66h, 33h, 0F6h
|
||||||
|
|
||||||
|
mov ax, 0D8C1h
|
||||||
|
int 2Fh
|
||||||
|
|
||||||
|
; save ESI resolver at [bp-4]
|
||||||
|
db 66h, 89h, 76h, 0FCh
|
||||||
|
; save ECX trampoline at [bp-8]
|
||||||
|
db 66h, 89h, 4Eh, 0F8h
|
||||||
|
|
||||||
|
push ax ; load AX for output
|
||||||
|
or ax, ax
|
||||||
|
jne c32ver_fail
|
||||||
|
|
||||||
|
push cs
|
||||||
|
push offset c32ver_name
|
||||||
|
push 0
|
||||||
|
push 0
|
||||||
|
call dword ptr [bp-4]
|
||||||
|
add sp, 8
|
||||||
|
|
||||||
|
; resolver returns DX:AX function pointer
|
||||||
|
mov [bp-12], ax
|
||||||
|
mov [bp-10], dx
|
||||||
|
|
||||||
|
or ax, dx
|
||||||
|
je c32ver_fail
|
||||||
|
|
||||||
|
; d32wrap _CLIENT32GetVersion convention:
|
||||||
|
push 0
|
||||||
|
push 0
|
||||||
|
push word ptr [bp-10]
|
||||||
|
push word ptr [bp-12]
|
||||||
|
call dword ptr [bp-8]
|
||||||
|
add sp, 8
|
||||||
|
|
||||||
|
pushf
|
||||||
|
push dx
|
||||||
|
push ax
|
||||||
|
jmp short c32ver_store
|
||||||
|
|
||||||
|
c32ver_fail:
|
||||||
|
xor dx, dx
|
||||||
|
xor ax, ax
|
||||||
|
pushf
|
||||||
|
push dx
|
||||||
|
push ax
|
||||||
|
|
||||||
|
c32ver_store:
|
||||||
|
les di, dword ptr [bp+6]
|
||||||
|
|
||||||
|
pop ax ; call AX
|
||||||
|
pop dx ; call DX
|
||||||
|
pop bx ; flags
|
||||||
|
pop cx ; load AX
|
||||||
|
|
||||||
|
mov es:[di+0], cx
|
||||||
|
mov cx, word ptr [bp-4]
|
||||||
|
mov es:[di+2], cx
|
||||||
|
mov cx, word ptr [bp-2]
|
||||||
|
mov es:[di+4], cx
|
||||||
|
mov cx, word ptr [bp-8]
|
||||||
|
mov es:[di+6], cx
|
||||||
|
mov cx, word ptr [bp-6]
|
||||||
|
mov es:[di+8], cx
|
||||||
|
mov cx, word ptr [bp-12]
|
||||||
|
mov es:[di+10], cx
|
||||||
|
mov cx, word ptr [bp-10]
|
||||||
|
mov es:[di+12], cx
|
||||||
|
mov es:[di+14], ax
|
||||||
|
mov es:[di+16], dx
|
||||||
|
mov es:[di+18], bx
|
||||||
|
|
||||||
|
popf
|
||||||
|
pop di
|
||||||
|
pop si
|
||||||
|
pop es
|
||||||
|
pop ds
|
||||||
|
mov sp, bp
|
||||||
|
pop bp
|
||||||
|
xor ah, ah
|
||||||
|
ret
|
||||||
|
|
||||||
|
c32ver_name db 'CLIENT32GetVersion',0
|
||||||
|
|
||||||
|
_C32_CallVersion_Nios_Probe endp
|
||||||
|
|
||||||
|
|
||||||
|
; int C32_MapLock_Probe(void *ptr, UI len, void *outbuf)
|
||||||
|
;
|
||||||
|
; Probe d32wrap.o __MapLockFlat / __UnlockFlat:
|
||||||
|
; INT 2F AX=D8C1
|
||||||
|
; ESI resolver returned by D8C1 is used with command 2 and 3:
|
||||||
|
; push len_hi
|
||||||
|
; push len_lo
|
||||||
|
; push seg
|
||||||
|
; push off
|
||||||
|
; push 0
|
||||||
|
; push 2
|
||||||
|
; call ESI ; returns flat DX:AX
|
||||||
|
;
|
||||||
|
; push len_hi
|
||||||
|
; push len_lo
|
||||||
|
; push flat_hi
|
||||||
|
; push flat_lo
|
||||||
|
; push 0
|
||||||
|
; push 3
|
||||||
|
; call ESI ; unlock
|
||||||
|
;
|
||||||
|
; outbuf:
|
||||||
|
; +00 load AX
|
||||||
|
; +02 ESI off
|
||||||
|
; +04 ESI seg
|
||||||
|
; +06 map AX low
|
||||||
|
; +08 map DX high
|
||||||
|
; +0A unlock AX
|
||||||
|
; +0C unlock DX
|
||||||
|
_C32_MapLock_Probe proc far
|
||||||
|
push bp
|
||||||
|
mov bp, sp
|
||||||
|
sub sp, 8
|
||||||
|
|
||||||
|
push ds
|
||||||
|
push es
|
||||||
|
push si
|
||||||
|
push di
|
||||||
|
|
||||||
|
; clear ECX/ESI
|
||||||
|
db 66h, 33h, 0C9h
|
||||||
|
db 66h, 33h, 0F6h
|
||||||
|
|
||||||
|
mov ax, 0D8C1h
|
||||||
|
int 2Fh
|
||||||
|
|
||||||
|
; save ESI resolver at [bp-4]
|
||||||
|
db 66h, 89h, 76h, 0FCh
|
||||||
|
push ax ; load AX
|
||||||
|
|
||||||
|
or ax, ax
|
||||||
|
jne mapflat_fail
|
||||||
|
|
||||||
|
; MapLockFlat(ptr, len)
|
||||||
|
push 0
|
||||||
|
push word ptr [bp+10] ; len
|
||||||
|
push word ptr [bp+8] ; ptr seg
|
||||||
|
push word ptr [bp+6] ; ptr off
|
||||||
|
push 0
|
||||||
|
push 2
|
||||||
|
call dword ptr [bp-4]
|
||||||
|
add sp, 0cH
|
||||||
|
|
||||||
|
; save mapped flat DX:AX at [bp-8]
|
||||||
|
mov word ptr [bp-8], ax
|
||||||
|
mov word ptr [bp-6], dx
|
||||||
|
|
||||||
|
; UnlockFlat(flat, len)
|
||||||
|
push 0
|
||||||
|
push word ptr [bp+10] ; len
|
||||||
|
push dx
|
||||||
|
push ax
|
||||||
|
push 0
|
||||||
|
push 3
|
||||||
|
call dword ptr [bp-4]
|
||||||
|
add sp, 0cH
|
||||||
|
|
||||||
|
jmp short mapflat_store
|
||||||
|
|
||||||
|
mapflat_fail:
|
||||||
|
xor dx, dx
|
||||||
|
xor ax, ax
|
||||||
|
mov word ptr [bp-8], ax
|
||||||
|
mov word ptr [bp-6], dx
|
||||||
|
|
||||||
|
mapflat_store:
|
||||||
|
les di, dword ptr [bp+12]
|
||||||
|
|
||||||
|
mov bx, ax ; unlock AX
|
||||||
|
mov cx, dx ; unlock DX
|
||||||
|
pop ax ; load AX
|
||||||
|
|
||||||
|
mov es:[di+0], ax
|
||||||
|
mov ax, word ptr [bp-4]
|
||||||
|
mov es:[di+2], ax
|
||||||
|
mov ax, word ptr [bp-2]
|
||||||
|
mov es:[di+4], ax
|
||||||
|
mov ax, word ptr [bp-8]
|
||||||
|
mov es:[di+6], ax
|
||||||
|
mov ax, word ptr [bp-6]
|
||||||
|
mov es:[di+8], ax
|
||||||
|
mov es:[di+10], bx
|
||||||
|
mov es:[di+12], cx
|
||||||
|
|
||||||
|
pop di
|
||||||
|
pop si
|
||||||
|
pop es
|
||||||
|
pop ds
|
||||||
|
mov sp, bp
|
||||||
|
pop bp
|
||||||
|
xor ah, ah
|
||||||
|
ret
|
||||||
|
_C32_MapLock_Probe endp
|
||||||
|
|
||||||
|
|
||||||
|
; int C32_NCP87_Raw_Probe(UI connLo, UI connHi,
|
||||||
|
; void *hdr, UI hdrLen,
|
||||||
|
; void *path, UI pathLen,
|
||||||
|
; void *rep0, UI rep0Len,
|
||||||
|
; void *rep1, UI rep1Len,
|
||||||
|
; void *outbuf)
|
||||||
|
;
|
||||||
|
; Specialized raw Client32 NCP87/S6 request probe.
|
||||||
|
; Reproduces d32wrap.o _COMPATNcpRequestReply mechanics:
|
||||||
|
; - INT 2F AX=D8C1
|
||||||
|
; - resolve COMPATNcpRequestReply via ESI resolver
|
||||||
|
; - MapLockFlat each fragment data buffer
|
||||||
|
; - build flat 8-byte frag tables
|
||||||
|
; - MapLockFlat frag tables and actualReplyLen
|
||||||
|
; - call ECX NIOS trampoline with command 8 and COMPATNcpRequestReply pointer
|
||||||
|
; - unlock mappings
|
||||||
|
;
|
||||||
|
; outbuf:
|
||||||
|
; +00 load AX
|
||||||
|
; +02 resolver off
|
||||||
|
; +04 resolver seg
|
||||||
|
; +06 trampoline off
|
||||||
|
; +08 trampoline seg
|
||||||
|
; +0A function off
|
||||||
|
; +0C function seg
|
||||||
|
; +0E ret AX
|
||||||
|
; +10 ret DX
|
||||||
|
; +12 actualReplyLen low
|
||||||
|
; +14 actualReplyLen high
|
||||||
|
_C32_NCP87_Raw_Probe proc far
|
||||||
|
push bp
|
||||||
|
mov bp, sp
|
||||||
|
sub sp, 100
|
||||||
|
|
||||||
|
push ds
|
||||||
|
push es
|
||||||
|
push si
|
||||||
|
push di
|
||||||
|
|
||||||
|
; clear ESI/ECX
|
||||||
|
db 66h, 33h, 0F6h
|
||||||
|
db 66h, 33h, 0C9h
|
||||||
|
|
||||||
|
mov ax, 0D8C1h
|
||||||
|
int 2Fh
|
||||||
|
|
||||||
|
; save resolver ESI at [bp-84]
|
||||||
|
db 66h, 89h, 76h, 0ACh
|
||||||
|
; save trampoline ECX at [bp-88]
|
||||||
|
db 66h, 89h, 4Eh, 0A8h
|
||||||
|
|
||||||
|
mov [bp-2], ax ; load AX
|
||||||
|
or ax, ax
|
||||||
|
jne c32raw_fail
|
||||||
|
|
||||||
|
; resolve "COMPATNcpRequestReply"
|
||||||
|
push cs
|
||||||
|
push offset c32raw_name
|
||||||
|
push 0
|
||||||
|
push 0
|
||||||
|
call dword ptr [bp-84]
|
||||||
|
add sp, 8
|
||||||
|
mov [bp-92], ax
|
||||||
|
mov [bp-90], dx
|
||||||
|
or ax, dx
|
||||||
|
jne c32raw_have_func
|
||||||
|
jmp c32raw_fail
|
||||||
|
|
||||||
|
c32raw_have_func:
|
||||||
|
; actualReplyLen local at [bp-52]
|
||||||
|
mov word ptr [bp-52], 0
|
||||||
|
mov word ptr [bp-50], 0
|
||||||
|
|
||||||
|
; Map hdr data -> [bp-56]
|
||||||
|
push 0
|
||||||
|
push word ptr [bp+0eH]
|
||||||
|
push word ptr [bp+0cH]
|
||||||
|
push word ptr [bp+0aH]
|
||||||
|
push 0
|
||||||
|
push 2
|
||||||
|
call dword ptr [bp-84]
|
||||||
|
add sp, 0cH
|
||||||
|
mov [bp-56], ax
|
||||||
|
mov [bp-54], dx
|
||||||
|
|
||||||
|
; Map path data -> [bp-60]
|
||||||
|
push 0
|
||||||
|
push word ptr [bp+14H]
|
||||||
|
push word ptr [bp+12H]
|
||||||
|
push word ptr [bp+10H]
|
||||||
|
push 0
|
||||||
|
push 2
|
||||||
|
call dword ptr [bp-84]
|
||||||
|
add sp, 0cH
|
||||||
|
mov [bp-60], ax
|
||||||
|
mov [bp-58], dx
|
||||||
|
|
||||||
|
; Map reply0 -> [bp-64]
|
||||||
|
push 0
|
||||||
|
push word ptr [bp+1aH]
|
||||||
|
push word ptr [bp+18H]
|
||||||
|
push word ptr [bp+16H]
|
||||||
|
push 0
|
||||||
|
push 2
|
||||||
|
call dword ptr [bp-84]
|
||||||
|
add sp, 0cH
|
||||||
|
mov [bp-64], ax
|
||||||
|
mov [bp-62], dx
|
||||||
|
|
||||||
|
; Map reply1 -> [bp-68]
|
||||||
|
push 0
|
||||||
|
push word ptr [bp+20H]
|
||||||
|
push word ptr [bp+1eH]
|
||||||
|
push word ptr [bp+1cH]
|
||||||
|
push 0
|
||||||
|
push 2
|
||||||
|
call dword ptr [bp-84]
|
||||||
|
add sp, 0cH
|
||||||
|
mov [bp-68], ax
|
||||||
|
mov [bp-66], dx
|
||||||
|
|
||||||
|
; Build req flat table at [bp-32], two entries:
|
||||||
|
; entry = flatptr dword + len dword
|
||||||
|
mov ax, [bp-56]
|
||||||
|
mov [bp-32], ax
|
||||||
|
mov ax, [bp-54]
|
||||||
|
mov [bp-30], ax
|
||||||
|
mov ax, [bp+0eH]
|
||||||
|
mov [bp-28], ax
|
||||||
|
mov word ptr [bp-26], 0
|
||||||
|
|
||||||
|
mov ax, [bp-60]
|
||||||
|
mov [bp-24], ax
|
||||||
|
mov ax, [bp-58]
|
||||||
|
mov [bp-22], ax
|
||||||
|
mov ax, [bp+14H]
|
||||||
|
mov [bp-20], ax
|
||||||
|
mov word ptr [bp-18], 0
|
||||||
|
|
||||||
|
; Build reply flat table at [bp-48]
|
||||||
|
mov ax, [bp-64]
|
||||||
|
mov [bp-48], ax
|
||||||
|
mov ax, [bp-62]
|
||||||
|
mov [bp-46], ax
|
||||||
|
mov ax, [bp+1aH]
|
||||||
|
mov [bp-44], ax
|
||||||
|
mov word ptr [bp-42], 0
|
||||||
|
|
||||||
|
mov ax, [bp-68]
|
||||||
|
mov [bp-40], ax
|
||||||
|
mov ax, [bp-66]
|
||||||
|
mov [bp-38], ax
|
||||||
|
mov ax, [bp+20H]
|
||||||
|
mov [bp-36], ax
|
||||||
|
mov word ptr [bp-34], 0
|
||||||
|
|
||||||
|
; Map req table [bp-32] len 16 -> [bp-72]
|
||||||
|
push 0
|
||||||
|
push 10H
|
||||||
|
push ss
|
||||||
|
lea ax, -32[bp]
|
||||||
|
push ax
|
||||||
|
push 0
|
||||||
|
push 2
|
||||||
|
call dword ptr [bp-84]
|
||||||
|
add sp, 0cH
|
||||||
|
mov [bp-72], ax
|
||||||
|
mov [bp-70], dx
|
||||||
|
|
||||||
|
; Map reply table [bp-48] len 16 -> [bp-76]
|
||||||
|
push 0
|
||||||
|
push 10H
|
||||||
|
push ss
|
||||||
|
lea ax, -48[bp]
|
||||||
|
push ax
|
||||||
|
push 0
|
||||||
|
push 2
|
||||||
|
call dword ptr [bp-84]
|
||||||
|
add sp, 0cH
|
||||||
|
mov [bp-76], ax
|
||||||
|
mov [bp-74], dx
|
||||||
|
|
||||||
|
; Map actualReplyLen [bp-52] len 4 -> [bp-80]
|
||||||
|
push 0
|
||||||
|
push 4
|
||||||
|
push ss
|
||||||
|
lea ax, -52[bp]
|
||||||
|
push ax
|
||||||
|
push 0
|
||||||
|
push 2
|
||||||
|
call dword ptr [bp-84]
|
||||||
|
add sp, 0cH
|
||||||
|
mov [bp-80], ax
|
||||||
|
mov [bp-78], dx
|
||||||
|
|
||||||
|
; Call NIOS trampoline command 8 with COMPATNcpRequestReply pointer.
|
||||||
|
push word ptr [bp-78] ; actual flat hi
|
||||||
|
push word ptr [bp-80] ; actual flat lo
|
||||||
|
push word ptr [bp-74] ; reply table flat hi
|
||||||
|
push word ptr [bp-76] ; reply table flat lo
|
||||||
|
push 0
|
||||||
|
push 2 ; num reply frags
|
||||||
|
push word ptr [bp-70] ; req table flat hi
|
||||||
|
push word ptr [bp-72] ; req table flat lo
|
||||||
|
push 0
|
||||||
|
push 2 ; num req frags
|
||||||
|
push 0
|
||||||
|
push 57H ; NCP function 87
|
||||||
|
push 0
|
||||||
|
push 0
|
||||||
|
push word ptr [bp+8] ; conn high
|
||||||
|
push word ptr [bp+6] ; conn low
|
||||||
|
push 0
|
||||||
|
push 8
|
||||||
|
push word ptr [bp-90] ; function seg
|
||||||
|
push word ptr [bp-92] ; function off
|
||||||
|
call dword ptr [bp-88]
|
||||||
|
add sp, 28H
|
||||||
|
|
||||||
|
mov [bp-96], ax
|
||||||
|
mov [bp-94], dx
|
||||||
|
|
||||||
|
; unlock mapped actual/table/data. Ignore returns.
|
||||||
|
push 0
|
||||||
|
push 4
|
||||||
|
push word ptr [bp-78]
|
||||||
|
push word ptr [bp-80]
|
||||||
|
push 0
|
||||||
|
push 3
|
||||||
|
call dword ptr [bp-84]
|
||||||
|
add sp, 0cH
|
||||||
|
|
||||||
|
push 0
|
||||||
|
push 10H
|
||||||
|
push word ptr [bp-74]
|
||||||
|
push word ptr [bp-76]
|
||||||
|
push 0
|
||||||
|
push 3
|
||||||
|
call dword ptr [bp-84]
|
||||||
|
add sp, 0cH
|
||||||
|
|
||||||
|
push 0
|
||||||
|
push 10H
|
||||||
|
push word ptr [bp-70]
|
||||||
|
push word ptr [bp-72]
|
||||||
|
push 0
|
||||||
|
push 3
|
||||||
|
call dword ptr [bp-84]
|
||||||
|
add sp, 0cH
|
||||||
|
|
||||||
|
push 0
|
||||||
|
push word ptr [bp+20H]
|
||||||
|
push word ptr [bp-66]
|
||||||
|
push word ptr [bp-68]
|
||||||
|
push 0
|
||||||
|
push 3
|
||||||
|
call dword ptr [bp-84]
|
||||||
|
add sp, 0cH
|
||||||
|
|
||||||
|
push 0
|
||||||
|
push word ptr [bp+1aH]
|
||||||
|
push word ptr [bp-62]
|
||||||
|
push word ptr [bp-64]
|
||||||
|
push 0
|
||||||
|
push 3
|
||||||
|
call dword ptr [bp-84]
|
||||||
|
add sp, 0cH
|
||||||
|
|
||||||
|
push 0
|
||||||
|
push word ptr [bp+14H]
|
||||||
|
push word ptr [bp-58]
|
||||||
|
push word ptr [bp-60]
|
||||||
|
push 0
|
||||||
|
push 3
|
||||||
|
call dword ptr [bp-84]
|
||||||
|
add sp, 0cH
|
||||||
|
|
||||||
|
push 0
|
||||||
|
push word ptr [bp+0eH]
|
||||||
|
push word ptr [bp-54]
|
||||||
|
push word ptr [bp-56]
|
||||||
|
push 0
|
||||||
|
push 3
|
||||||
|
call dword ptr [bp-84]
|
||||||
|
add sp, 0cH
|
||||||
|
|
||||||
|
jmp short c32raw_store
|
||||||
|
|
||||||
|
c32raw_fail:
|
||||||
|
mov word ptr [bp-92], 0
|
||||||
|
mov word ptr [bp-90], 0
|
||||||
|
mov word ptr [bp-96], 0FFFFH
|
||||||
|
mov word ptr [bp-94], 0FFFFH
|
||||||
|
mov word ptr [bp-52], 0
|
||||||
|
mov word ptr [bp-50], 0
|
||||||
|
|
||||||
|
c32raw_store:
|
||||||
|
les di, dword ptr [bp+22H]
|
||||||
|
|
||||||
|
mov ax, [bp-2]
|
||||||
|
mov es:[di+0], ax
|
||||||
|
mov ax, [bp-84]
|
||||||
|
mov es:[di+2], ax
|
||||||
|
mov ax, [bp-82]
|
||||||
|
mov es:[di+4], ax
|
||||||
|
mov ax, [bp-88]
|
||||||
|
mov es:[di+6], ax
|
||||||
|
mov ax, [bp-86]
|
||||||
|
mov es:[di+8], ax
|
||||||
|
mov ax, [bp-92]
|
||||||
|
mov es:[di+10], ax
|
||||||
|
mov ax, [bp-90]
|
||||||
|
mov es:[di+12], ax
|
||||||
|
mov ax, [bp-96]
|
||||||
|
mov es:[di+14], ax
|
||||||
|
mov ax, [bp-94]
|
||||||
|
mov es:[di+16], ax
|
||||||
|
mov ax, [bp-52]
|
||||||
|
mov es:[di+18], ax
|
||||||
|
mov ax, [bp-50]
|
||||||
|
mov es:[di+20], ax
|
||||||
|
|
||||||
|
pop di
|
||||||
|
pop si
|
||||||
|
pop es
|
||||||
|
pop ds
|
||||||
|
mov sp, bp
|
||||||
|
pop bp
|
||||||
|
xor ah, ah
|
||||||
|
ret
|
||||||
|
|
||||||
|
c32raw_name db 'COMPATNcpRequestReply',0
|
||||||
|
|
||||||
|
_C32_NCP87_Raw_Probe 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);
|
||||||
|
|||||||
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