Compare commits
59 Commits
4e49ecec1a
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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
|
||||
logout
|
||||
slist
|
||||
flag
|
||||
capture
|
||||
endcap
|
||||
)
|
||||
@@ -35,6 +36,7 @@ if(MARS_NWE_BUILD_DOSUTILS)
|
||||
find_package(OpenWatcom REQUIRED)
|
||||
|
||||
set(DOSUTILS_C_SOURCES
|
||||
kern.c
|
||||
net.c
|
||||
tools.c
|
||||
netcall.c
|
||||
@@ -42,6 +44,7 @@ if(MARS_NWE_BUILD_DOSUTILS)
|
||||
login.c
|
||||
map.c
|
||||
slist.c
|
||||
flag.c
|
||||
nwcrypt.c
|
||||
nwdebug.c
|
||||
nwtests.c
|
||||
@@ -117,3 +120,8 @@ install(FILES "${MARS_DOSUTILS_NET_EXE}"
|
||||
install(FILES "${MARS_DOSUTILS_NET_EXE}"
|
||||
DESTINATION "${MARS_NWE_INSTALL_FULL_FILEDIR}/SYS/login"
|
||||
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;
|
||||
}
|
||||
21
kern.h
21
kern.h
@@ -13,8 +13,27 @@ extern void asm_esr_routine(void);
|
||||
extern void esr_routine(ECB *ecb);
|
||||
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 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 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_NWCVLMREQ(UI flags, void *regblk,
|
||||
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
|
||||
|
||||
|
||||
|
||||
|
||||
491
kern_wasm.asm
491
kern_wasm.asm
@@ -20,6 +20,11 @@ public _IPXclose_socket
|
||||
public _IPXlisten
|
||||
public _xmemmove
|
||||
public _Net_Call
|
||||
public _C32_LoadNios_Probe
|
||||
public _C32_GetFunc_Probe
|
||||
public _C32_CallVersion_Nios_Probe
|
||||
public _Net_Call_VLM_Raw
|
||||
public _Net_Call_NWCVLMREQ
|
||||
|
||||
_IPXinit proc far
|
||||
push bp
|
||||
@@ -213,4 +218,490 @@ _Net_Call proc far
|
||||
ret
|
||||
_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 Net_Call_NWCVLMREQ(UI flags, void *regblk, UI p1, UI p2, UI p3)
|
||||
;
|
||||
; 16-bit wrapper that reproduces the DeveloperNet NWCVLMREQ register-block
|
||||
; calling convention, but without using Novell globals.
|
||||
;
|
||||
; regblk layout, same as dvlmreq.o:
|
||||
; +00 SI
|
||||
; +02 DS
|
||||
; +04 DI
|
||||
; +06 ES
|
||||
; +08 AX
|
||||
; +0A BX
|
||||
; +0C CX
|
||||
; +0E DX
|
||||
;
|
||||
; It calls the VLM entry returned by INT 2F AX=7A20.
|
||||
; Stack args are pushed as p3,p2,p1, exactly like NWCVLMREQ.
|
||||
_Net_Call_NWCVLMREQ 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 nwcvlm_found
|
||||
|
||||
mov ax, 88FFh
|
||||
jmp short nwcvlm_done
|
||||
|
||||
nwcvlm_found:
|
||||
; save VLM entry ES:BX in [bp-4]
|
||||
mov [bp-4], bx
|
||||
mov ax, es
|
||||
mov [bp-2], ax
|
||||
|
||||
les bx, dword ptr [bp+8] ; regblk
|
||||
|
||||
; Match NWCVLMREQ defaulting:
|
||||
; if !(flags & 2), set regblk.ES to current ES.
|
||||
; We normally pass flags=2, so this is skipped.
|
||||
test word ptr [bp+6], 2
|
||||
jne nwcvlm_skip_es
|
||||
mov ax, es
|
||||
mov word ptr es:[bx+6], ax
|
||||
nwcvlm_skip_es:
|
||||
|
||||
; if !(flags & 1), set regblk.DS to current DS.
|
||||
test word ptr [bp+6], 1
|
||||
jne nwcvlm_skip_ds
|
||||
mov ax, ds
|
||||
mov word ptr es:[bx+2], ax
|
||||
nwcvlm_skip_ds:
|
||||
|
||||
; Load target registers from regblk.
|
||||
mov ax, word ptr es:[bx+0Ah]
|
||||
push ax ; target BX
|
||||
mov ax, word ptr es:[bx+6]
|
||||
push ax ; target ES
|
||||
|
||||
mov ax, word ptr es:[bx+8]
|
||||
mov cx, word ptr es:[bx+0Ch]
|
||||
mov dx, word ptr es:[bx+0Eh]
|
||||
mov si, word ptr es:[bx+0]
|
||||
mov di, word ptr es:[bx+4]
|
||||
mov ds, word ptr es:[bx+2]
|
||||
|
||||
pop es
|
||||
pop bx
|
||||
|
||||
push word ptr [bp+10h] ; p3
|
||||
push word ptr [bp+0eh] ; p2
|
||||
push word ptr [bp+0ch] ; p1
|
||||
call dword ptr [bp-4]
|
||||
|
||||
; Store registers back into regblk.
|
||||
push bx
|
||||
push es
|
||||
|
||||
les bx, dword ptr [bp+8]
|
||||
mov word ptr es:[bx+8], ax
|
||||
pop ax
|
||||
mov word ptr es:[bx+6], ax
|
||||
pop ax
|
||||
mov word ptr es:[bx+0Ah], ax
|
||||
mov word ptr es:[bx+0Ch], cx
|
||||
mov word ptr es:[bx+0Eh], dx
|
||||
mov word ptr es:[bx+0], si
|
||||
mov word ptr es:[bx+4], di
|
||||
mov word ptr es:[bx+2], ds
|
||||
|
||||
mov ax, word ptr es:[bx+8]
|
||||
|
||||
nwcvlm_done:
|
||||
pop es
|
||||
pop di
|
||||
pop si
|
||||
pop ds
|
||||
|
||||
mov sp, bp
|
||||
pop bp
|
||||
ret
|
||||
_Net_Call_NWCVLMREQ endp
|
||||
|
||||
|
||||
end
|
||||
|
||||
338
login.c
338
login.c
@@ -6,6 +6,7 @@
|
||||
|
||||
#include "net.h"
|
||||
#include "nwcrypt.h"
|
||||
#include <time.h>
|
||||
|
||||
#ifndef BLACK
|
||||
#define BLACK 0
|
||||
@@ -23,18 +24,75 @@
|
||||
static uint8 script_login_name[64];
|
||||
static uint8 script_file_server[52];
|
||||
|
||||
#if defined(__WATCOMC__)
|
||||
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);
|
||||
static char **build_argv(char *buf, int bufsize, char *str);
|
||||
extern int read_command_file(char *fstr);
|
||||
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)
|
||||
{
|
||||
fprintf(stdout, "\n");
|
||||
@@ -58,20 +116,22 @@ static int login_help(void)
|
||||
|
||||
static void login_banner(void)
|
||||
{
|
||||
int i;
|
||||
login_cls_attr(0x07); /* normal black background */
|
||||
|
||||
textbackground(BLUE);
|
||||
textcolor(WHITE);
|
||||
clrscr();
|
||||
/*
|
||||
* NetWare-like header, but blue for Mars NWE:
|
||||
* 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);
|
||||
for (i = 0; i < 80; i++) putch(' ');
|
||||
gotoxy(36, 1);
|
||||
cputs("Mars NWE");
|
||||
|
||||
textbackground(BLACK);
|
||||
textcolor(LIGHTGRAY);
|
||||
gotoxy(1, 3);
|
||||
login_screen_normal();
|
||||
login_gotoxy(1, 4);
|
||||
}
|
||||
|
||||
static char *skip_spaces(char *p)
|
||||
@@ -100,18 +160,100 @@ static void strip_quotes(char *s)
|
||||
*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)
|
||||
{
|
||||
while (s && *s) {
|
||||
if (!strncmp(s, "%LOGIN_NAME", 11) || !strncmp(s, "%login_name", 11)) {
|
||||
fprintf(stdout, "%s", script_login_name);
|
||||
s += 11;
|
||||
} else if (!strncmp(s, "%FILE_SERVER", 12) || !strncmp(s, "%file_server", 12)) {
|
||||
fprintf(stdout, "%s", script_file_server);
|
||||
s += 12;
|
||||
} else if (!strncmp(s, "%P_STATION", 10) || !strncmp(s, "%p_station", 10)) {
|
||||
fprintf(stdout, "000000000000");
|
||||
s += 10;
|
||||
if (*s == '%') {
|
||||
char name[64];
|
||||
char value[128];
|
||||
int i = 0;
|
||||
|
||||
s++;
|
||||
while ((*s == '_' ||
|
||||
(*s >= 'A' && *s <= 'Z') ||
|
||||
(*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 {
|
||||
fputc(*s++, stdout);
|
||||
}
|
||||
@@ -182,30 +324,52 @@ static int script_eval_if(char *line)
|
||||
|
||||
if (q != NULL) {
|
||||
char want[64];
|
||||
char *v;
|
||||
char have[64];
|
||||
int i = 0;
|
||||
|
||||
q += neg ? 2 : 1;
|
||||
q = skip_spaces(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] = '\0';
|
||||
|
||||
strmaxcpy(tmp, script_login_name, sizeof(tmp) - 1);
|
||||
upstr(tmp);
|
||||
strmaxcpy(have, script_login_name, sizeof(have) - 1);
|
||||
upstr(have);
|
||||
|
||||
if (neg) return(strcmp(tmp, want) != 0);
|
||||
else return(strcmp(tmp, want) == 0);
|
||||
if (neg) return(strcmp(have, 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);
|
||||
}
|
||||
|
||||
|
||||
static int login_strnicmp(char *a, char *b, int n)
|
||||
{
|
||||
while (n-- > 0) {
|
||||
@@ -230,7 +394,7 @@ static int script_execute_line(char *line)
|
||||
strmaxcpy(work, line, sizeof(work) - 1);
|
||||
p = skip_spaces(work);
|
||||
|
||||
if (!*p) return(0);
|
||||
if (!*p || *p == ';') return(0);
|
||||
|
||||
i = 0;
|
||||
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")) {
|
||||
clrscr();
|
||||
login_cls_attr(0x07);
|
||||
return(0);
|
||||
}
|
||||
|
||||
@@ -288,6 +452,13 @@ static int script_execute_line(char *line)
|
||||
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)) {
|
||||
char callbuf[512];
|
||||
char *a = arg;
|
||||
@@ -309,6 +480,10 @@ static int script_execute_line(char *line)
|
||||
}
|
||||
}
|
||||
|
||||
if (!strcmp(cmd, "ATTACH")) {
|
||||
return(0);
|
||||
}
|
||||
|
||||
if (!strcmp(cmd, "EXIT")) {
|
||||
return(1);
|
||||
}
|
||||
@@ -317,20 +492,87 @@ static int script_execute_line(char *line)
|
||||
return(0);
|
||||
}
|
||||
|
||||
static int try_login_script_file(char *name)
|
||||
{
|
||||
return(read_command_file(name));
|
||||
}
|
||||
|
||||
static int run_login_script(void)
|
||||
{
|
||||
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);
|
||||
if (read_command_file(profile) != -2) return(0);
|
||||
sprintf(profile, "\\\\%s\\SYS\\PUBLIC\\net$log.dat", script_file_server);
|
||||
if (try_login_script_file(profile) != -2) return(0);
|
||||
|
||||
if (read_command_file("net$log.dat") != -2) return(0);
|
||||
if (read_command_file("login") != -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\\LOGIN", script_file_server);
|
||||
if (try_login_script_file(profile) != -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);
|
||||
}
|
||||
@@ -495,7 +737,7 @@ int func_login(int argc, char *argv[], int mode)
|
||||
if (argv[1][0] == '-' || argv[1][0] == '/') {
|
||||
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], "/CLS") || !strcmp(argv[1], "-CLS")) clrscr();
|
||||
else if (!strcmp(argv[1], "/CLS") || !strcmp(argv[1], "-CLS")) login_cls_attr(0x07);
|
||||
else return(login_usage());
|
||||
argc--;
|
||||
argv++;
|
||||
|
||||
306
map.c
306
map.c
@@ -28,9 +28,9 @@ static void show_map(uint8 *drvstr)
|
||||
if (flags & 0x80) { /* lokal DRIVE */
|
||||
path[0]= '\\';
|
||||
if (j < 2){
|
||||
strcpy(path, "DISK LW");
|
||||
strcpy(path, "maps to a local disk.");
|
||||
} else if (getcurdir(j+1, path+1)) {
|
||||
strcpy(path, "LW !OK");
|
||||
strcpy(path, "maps to a local disk.");
|
||||
}
|
||||
} else {
|
||||
if (get_dir_path(dhandle, path)) {
|
||||
@@ -41,7 +41,7 @@ static void show_map(uint8 *drvstr)
|
||||
strcat(servern, "\\");
|
||||
} 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 */
|
||||
path[0]= '\\';
|
||||
if (drive < 2){
|
||||
strcpy(path, "DISK LW");
|
||||
strcpy(path, "maps to a local disk.");
|
||||
} else if (getcurdir(drive+1, path+1)) {
|
||||
strcpy(path, "LW !OK");
|
||||
strcpy(path, "maps to a local disk.");
|
||||
}
|
||||
} else {
|
||||
if (get_dir_path(dhandle, path)) {
|
||||
@@ -188,11 +188,129 @@ static int parse_argv(uint8 *drvstr, NWPATH *nwpath,
|
||||
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)
|
||||
{
|
||||
uint8 drvstr[22];
|
||||
NWPATH nwpath;
|
||||
|
||||
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 (*(nwpath.path) || mode==1) {
|
||||
if (do_map(*drvstr - 'A', &nwpath, mode)< 0)
|
||||
@@ -297,18 +415,192 @@ static int set_search(uint8 *drvstr, NWPATH *nwp, int pathmode)
|
||||
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)
|
||||
{
|
||||
uint8 drvstr[22];
|
||||
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;
|
||||
if (*(nwpath.path) || mode==1)
|
||||
result=set_search(drvstr, &nwpath, mode);
|
||||
result=set_search_native(drvstr, &nwpath, mode);
|
||||
if (mode != 1)
|
||||
show_search(drvstr);
|
||||
return(result);
|
||||
}
|
||||
|
||||
fprintf(stderr, "Cannot interpret line. errcode=-1\n");
|
||||
return(1);
|
||||
}
|
||||
|
||||
|
||||
1
net.c
1
net.c
@@ -34,6 +34,7 @@ static struct s_net_functions {
|
||||
{"PATHDEL","removes search path" , func_path , 1},
|
||||
{"PATHINS","insert search path" , func_path , 2},
|
||||
{"LOGOUT", "logout from server", func_logout , 0},
|
||||
{"FLAG", "display or modify file attributes", func_flag , 0},
|
||||
{"SLIST", "list servers", func_slist , 0},
|
||||
{"PASSWD", "change password", func_passwd , 0},
|
||||
#if 1
|
||||
|
||||
3
net.h
3
net.h
@@ -252,6 +252,9 @@ extern int func_tests (int argc, char *argv[], int mode);
|
||||
/* capture.c */
|
||||
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,
|
||||
BINDERY_OBJECT *target);
|
||||
|
||||
84
slist.c
84
slist.c
@@ -2,17 +2,49 @@
|
||||
|
||||
#include "net.h"
|
||||
|
||||
#define NCP_BINDERY_FSERVER 0x0004
|
||||
|
||||
static int usage(void)
|
||||
{
|
||||
fprintf(stderr, "usage:\t%s [pattern]\n", funcname);
|
||||
return(-1);
|
||||
fprintf(stdout, "Usage: SLIST [Server] [/Continue]\n");
|
||||
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),
|
||||
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)
|
||||
@@ -22,33 +54,50 @@ int func_slist(int argc, char *argv[], int mode)
|
||||
uint8 pattern[50];
|
||||
int found = 0;
|
||||
int result;
|
||||
int i;
|
||||
|
||||
(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);
|
||||
|
||||
fprintf(stdout, "\n%-52s%-10s%-12s\n",
|
||||
"Known NetWare File Servers", "Network", "Node Address");
|
||||
fprintf(stdout,
|
||||
"-----------------------------------------------"
|
||||
"---------------------------\n");
|
||||
/*
|
||||
* Novell-like layout from the DOS client:
|
||||
* Known NetWare File Servers Network Node Address Status
|
||||
* ------------------------- -------- -------------------
|
||||
*/
|
||||
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,
|
||||
pattern, &obj)) == 0) {
|
||||
NW_PROPERTY prop;
|
||||
|
||||
found = 1;
|
||||
found++;
|
||||
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,
|
||||
1, "NET_ADDRESS", &prop)) {
|
||||
print_net_node(prop.value);
|
||||
print_net_node_status(prop.value, found == 1);
|
||||
}
|
||||
|
||||
fprintf(stdout, "\n");
|
||||
@@ -56,8 +105,7 @@ int func_slist(int argc, char *argv[], int mode)
|
||||
if (last_id == MAX_U32) break;
|
||||
}
|
||||
|
||||
if (!found)
|
||||
fprintf(stdout, "No servers found\n");
|
||||
fprintf(stdout, "\nTotal of %d file servers found\n", found);
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user