Compare commits
30 Commits
master
...
f08aa986a8
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f08aa986a8 | ||
|
|
4e49ecec1a | ||
|
|
c53abba212 | ||
|
|
ff344fcf4c | ||
|
|
36d566939c | ||
|
|
09a3f9f551 | ||
|
|
7f66df5a6e | ||
|
|
d4b29aea5d | ||
|
|
c12c93b958 | ||
|
|
82202fd6fb | ||
|
|
534f70844a | ||
|
|
b40ec03e7d | ||
|
|
0ea11f7f5d | ||
|
|
22d862cd12 | ||
|
|
417716a36f | ||
|
|
b2da728f4b | ||
|
|
3b8664cb77 | ||
|
|
acac4892a0 | ||
|
|
c64a20acac | ||
|
|
36b1458eb7 | ||
|
|
fa27fe4213 | ||
|
|
6d005a1713 | ||
|
|
af2f16add4 | ||
|
|
932d08cac8 | ||
|
|
0e42d3a85b | ||
|
|
093af0687a | ||
|
|
dcb74331e7 | ||
|
|
ad2bc6b02e | ||
|
|
5e75a9e8a7 | ||
|
|
975f34431a |
119
CMakeLists.txt
Normal file
119
CMakeLists.txt
Normal file
@@ -0,0 +1,119 @@
|
||||
# DOS utilities for mars-nwe.
|
||||
#
|
||||
# Default mode: install a prebuilt net.exe from this source tree. This keeps the
|
||||
# normal mars-nwe build independent from Open Watcom.
|
||||
#
|
||||
# Maintainer mode: configure with -DMARS_NWE_BUILD_DOSUTILS=ON to rebuild
|
||||
# net.exe with Open Watcom v2 on Linux.
|
||||
|
||||
set(MARS_DOSUTILS_NET_EXE
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/net.exe"
|
||||
CACHE FILEPATH "Prebuilt DOS net.exe used for installation when MARS_NWE_BUILD_DOSUTILS is OFF"
|
||||
)
|
||||
|
||||
set(MARS_DOSUTILS_PUBLIC_TOOLS
|
||||
net
|
||||
login
|
||||
profile
|
||||
spawn
|
||||
passwd
|
||||
path
|
||||
pathins
|
||||
pathdel
|
||||
map
|
||||
mapdel
|
||||
logout
|
||||
slist
|
||||
capture
|
||||
endcap
|
||||
)
|
||||
|
||||
# Do not install slist.exe yet: func_slist() is empty and SLIST is disabled in net.c.
|
||||
# Do not install tests/debug by default either; they are developer-only helpers.
|
||||
|
||||
if(MARS_NWE_BUILD_DOSUTILS)
|
||||
find_package(OpenWatcom REQUIRED)
|
||||
|
||||
set(DOSUTILS_C_SOURCES
|
||||
net.c
|
||||
tools.c
|
||||
netcall.c
|
||||
ncpcall.c
|
||||
login.c
|
||||
map.c
|
||||
slist.c
|
||||
nwcrypt.c
|
||||
nwdebug.c
|
||||
nwtests.c
|
||||
capture.c
|
||||
)
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/kern.obj"
|
||||
COMMAND "${CMAKE_COMMAND}" -E env ${OPENWATCOM_ENV}
|
||||
"${OPENWATCOM_WASM}"
|
||||
-q
|
||||
-zq
|
||||
-fo="${CMAKE_CURRENT_BINARY_DIR}/kern.obj"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/kern_wasm.asm"
|
||||
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/kern_wasm.asm"
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
VERBATIM
|
||||
)
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/net.exe"
|
||||
COMMAND "${CMAKE_COMMAND}" -E env ${OPENWATCOM_ENV}
|
||||
"${OPENWATCOM_WCL}"
|
||||
-q
|
||||
-zq
|
||||
-bt=dos
|
||||
-ml
|
||||
-0
|
||||
-k32768
|
||||
-fe="${CMAKE_CURRENT_BINARY_DIR}/net.exe"
|
||||
${DOSUTILS_C_SOURCES}
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/kern.obj"
|
||||
DEPENDS
|
||||
${DOSUTILS_C_SOURCES}
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/kern.obj"
|
||||
net.h
|
||||
kern.h
|
||||
nwcrypt.h
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
VERBATIM
|
||||
)
|
||||
|
||||
add_custom_target(dosutils_net ALL
|
||||
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/net.exe"
|
||||
)
|
||||
|
||||
set(MARS_DOSUTILS_NET_EXE "${CMAKE_CURRENT_BINARY_DIR}/net.exe")
|
||||
else()
|
||||
if(NOT EXISTS "${MARS_DOSUTILS_NET_EXE}")
|
||||
message(FATAL_ERROR
|
||||
"Prebuilt DOS utility missing: ${MARS_DOSUTILS_NET_EXE}. "
|
||||
"Either commit net.exe into dosutils or configure with "
|
||||
"-DMARS_NWE_BUILD_DOSUTILS=ON and Open Watcom installed."
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
foreach(tool IN LISTS MARS_DOSUTILS_PUBLIC_TOOLS)
|
||||
if(tool STREQUAL "net")
|
||||
install(FILES "${MARS_DOSUTILS_NET_EXE}"
|
||||
DESTINATION "${MARS_NWE_INSTALL_FULL_FILEDIR}/SYS/public")
|
||||
else()
|
||||
install(FILES "${MARS_DOSUTILS_NET_EXE}"
|
||||
DESTINATION "${MARS_NWE_INSTALL_FULL_FILEDIR}/SYS/public"
|
||||
RENAME "${tool}.exe")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
install(FILES "${MARS_DOSUTILS_NET_EXE}"
|
||||
DESTINATION "${MARS_NWE_INSTALL_FULL_FILEDIR}/SYS/login"
|
||||
RENAME login.exe)
|
||||
|
||||
install(FILES "${MARS_DOSUTILS_NET_EXE}"
|
||||
DESTINATION "${MARS_NWE_INSTALL_FULL_FILEDIR}/SYS/login"
|
||||
RENAME map.exe)
|
||||
331
README.md
Normal file
331
README.md
Normal file
@@ -0,0 +1,331 @@
|
||||
# mars_dosutils
|
||||
|
||||
DOS client-side utilities for **mars_nwe** and compatible NetWare-style NCP environments.
|
||||
|
||||
This repository contains the source for a small DOS utility suite built around a **single multi-call executable**, `net.exe`. The program can be used either as:
|
||||
|
||||
- `net <command> [args...]`, or
|
||||
- a renamed executable such as `login.exe`, `map.exe`, `capture.exe`, or `logout.exe`
|
||||
|
||||
That design is explicit in the command table in `net.c`, and the install rules also deploy the same binary under multiple command names. The original project documentation describes it as a “simple DOS-client program to allow standard NCP network actions, mainly for mars_nwe,” and also notes that it was still incomplete at the time of writing.
|
||||
|
||||
## Features
|
||||
|
||||
- Login and logout against an NCP server
|
||||
- Password change support
|
||||
- DOS drive mapping and unmapping
|
||||
- Search-path management (`PATH`, `PATHINS`, `PATHDEL`)
|
||||
- Printer capture and release (`CAPTURE`, `ENDCAP`)
|
||||
- Scripted session setup through command files
|
||||
- External program execution via `SPAWN` and `EXEC`
|
||||
- Optional mars_nwe debug control hooks
|
||||
|
||||
## Available commands
|
||||
|
||||
The current command dispatcher includes these built-ins:
|
||||
|
||||
- `LOGIN`
|
||||
- `LOGOUT`
|
||||
- `PASSWD`
|
||||
- `PROFILE`
|
||||
- `SPAWN`
|
||||
- `EXEC`
|
||||
- `MAP`
|
||||
- `MAPDEL`
|
||||
- `PATH`
|
||||
- `PATHINS`
|
||||
- `PATHDEL`
|
||||
- `CAPTURE`
|
||||
- `ENDCAP`
|
||||
- `DEBUG`
|
||||
- `ECHO`
|
||||
- `CD`
|
||||
- `TESTS` (developer/testing only)
|
||||
|
||||
`SLIST` is present in the historical build/install metadata, but the command is disabled in the dispatcher and the provided `slist.c` is only a stub in this source snapshot.
|
||||
|
||||
## How it works
|
||||
|
||||
The program resolves the command from either:
|
||||
|
||||
1. the executable name itself, or
|
||||
2. the first command-line argument
|
||||
|
||||
That means all of the following styles are valid:
|
||||
|
||||
```text
|
||||
NET LOGIN alice secret
|
||||
NET MAP F:=SYS:
|
||||
LOGIN.EXE alice secret
|
||||
MAP.EXE F:=SYS:
|
||||
CAPTURE.EXE LPT1 Q1
|
||||
```
|
||||
|
||||
This is one of the key design ideas of the project, and the original README specifically recommends copying or linking `net.exe` to `login.exe` for convenience.
|
||||
|
||||
## Command reference
|
||||
|
||||
### `LOGIN`
|
||||
|
||||
Authenticate to an NCP server as a user.
|
||||
|
||||
```text
|
||||
LOGIN [-u] [user | user password]
|
||||
```
|
||||
|
||||
- `-u` forces the older unencrypted login path.
|
||||
- If no username is provided, the tool prompts interactively.
|
||||
- If no password is provided, it prompts for one after the username.
|
||||
- Successful login clears and rebuilds NetWare search-path state before running a local post-login script named `login` from the executable directory.
|
||||
|
||||
### `LOGOUT`
|
||||
|
||||
Log out from the current NCP session.
|
||||
|
||||
The implementation also removes configured network search paths before performing logout.
|
||||
|
||||
### `PASSWD`
|
||||
|
||||
Change a user password.
|
||||
|
||||
```text
|
||||
PASSWD [user]
|
||||
```
|
||||
|
||||
Notes:
|
||||
|
||||
- If no username is supplied, the tool attempts to resolve the currently logged-in user. fileciteturn1file2L162-L190
|
||||
- The source comments note that password changes currently use the older unencrypted password-change call.
|
||||
|
||||
### `PROFILE`
|
||||
|
||||
Execute a command script.
|
||||
|
||||
```text
|
||||
PROFILE <filename>
|
||||
```
|
||||
|
||||
This is a central part of the workflow. The command reader parses non-empty lines, ignores `#` comments, uppercases the command token, and dispatches it through the same internal command table used for direct invocation. `ECHO` is treated specially so the rest of the line is preserved as a single string.
|
||||
|
||||
### `SPAWN`
|
||||
|
||||
Run an external program and wait for it to finish.
|
||||
|
||||
### `EXEC`
|
||||
|
||||
Execute an external program using overlay-style execution.
|
||||
|
||||
Both commands share the same implementation and differ only in whether they use `spawnvp(..., P_WAIT, ...)` or `execvp(...)`.
|
||||
|
||||
### `MAP`
|
||||
|
||||
List current drive mappings or map a DOS drive letter to a network path.
|
||||
|
||||
```text
|
||||
MAP [d:[=[path]]]
|
||||
```
|
||||
|
||||
Examples:
|
||||
|
||||
```text
|
||||
MAP
|
||||
MAP F:=SYS:
|
||||
MAP H:=HOME:
|
||||
```
|
||||
|
||||
The implementation lists active mappings, distinguishes local vs. redirected drives, and uses DOS-style drive letters.
|
||||
|
||||
### `MAPDEL`
|
||||
|
||||
Remove an existing drive mapping.
|
||||
|
||||
```text
|
||||
MAPDEL d:
|
||||
```
|
||||
|
||||
Example:
|
||||
|
||||
```text
|
||||
MAPDEL F:
|
||||
```
|
||||
|
||||
### `PATH`
|
||||
|
||||
List or set a search-path entry.
|
||||
|
||||
```text
|
||||
PATH sn:[=[path]]
|
||||
```
|
||||
|
||||
Where `sn` is `s1` through `s16`. The original documentation notes that this updates the path environment rather than directly creating a drive mapping.
|
||||
|
||||
### `PATHINS`
|
||||
|
||||
Insert a search-path entry instead of overwriting one.
|
||||
|
||||
```text
|
||||
PATHINS sn:[=[path]]
|
||||
```
|
||||
|
||||
### `PATHDEL`
|
||||
|
||||
Delete a search-path entry.
|
||||
|
||||
```text
|
||||
PATHDEL sn:
|
||||
```
|
||||
|
||||
### `CAPTURE`
|
||||
|
||||
List printer captures or redirect a local printer device to a queue.
|
||||
|
||||
Typical usage:
|
||||
|
||||
```text
|
||||
CAPTURE [device [queue]]
|
||||
```
|
||||
|
||||
Examples:
|
||||
|
||||
```text
|
||||
CAPTURE
|
||||
CAPTURE LPT1 Q1
|
||||
CAPTURE PRN Q1
|
||||
```
|
||||
|
||||
`PRN` is normalized to `LPT1` internally. The command can also display existing captures.
|
||||
|
||||
### `ENDCAP`
|
||||
|
||||
Cancel a printer redirection.
|
||||
|
||||
Typical usage:
|
||||
|
||||
```text
|
||||
ENDCAP device
|
||||
```
|
||||
|
||||
Example:
|
||||
|
||||
```text
|
||||
ENDCAP LPT1
|
||||
```
|
||||
|
||||
### `DEBUG`
|
||||
|
||||
Set mars_nwe debug levels for selected server-side modules.
|
||||
|
||||
```text
|
||||
DEBUG NCPSERV|NWCONN|NWBIND level
|
||||
```
|
||||
|
||||
- `level` must be between `0` and `99`.
|
||||
- The original docs say this requires `FUNC_17_02_IS_DEBUG` to be enabled in `mars_nwe/config.h`.
|
||||
|
||||
### `ECHO`
|
||||
|
||||
Print a string, mainly for use inside profile/login scripts.
|
||||
|
||||
### `CD`
|
||||
|
||||
Change the current DOS directory. It also adjusts the active drive if a drive-qualified path is supplied.
|
||||
|
||||
### `TESTS`
|
||||
|
||||
Internal developer test routines. Not intended as a regular end-user command.
|
||||
|
||||
## Login script workflow
|
||||
|
||||
A particularly important feature is the automatic execution of a file named `login` located beside the executable after a successful login. The historical README gives this example:
|
||||
|
||||
```text
|
||||
map f:=SYS:
|
||||
map h:=home:
|
||||
map z:=SYS:PUBLIC
|
||||
path s16:=z:.
|
||||
capture lpt1 q1
|
||||
profile h:\profile
|
||||
```
|
||||
|
||||
This makes the tool suite useful not just for authentication, but for setting up a full DOS network session: drive mappings, search paths, printer capture, and then a user-specific profile script.
|
||||
|
||||
## Building
|
||||
|
||||
### Historical DOS build
|
||||
|
||||
The included `makefile.bcc` is the primary historical build file and targets **Borland C / Borland tools** on DOS.
|
||||
|
||||
Key settings from the makefile:
|
||||
|
||||
- compiler: `bcc`
|
||||
- linker: `bcc`
|
||||
- assembler: `tasm`
|
||||
- memory model: `-ml`
|
||||
- define: `-Dmsdos`
|
||||
- output: `net.exe`
|
||||
|
||||
The object list includes:
|
||||
|
||||
- `net.c`
|
||||
- `tools.c`
|
||||
- `netcall.c`
|
||||
- `ncpcall.c`
|
||||
- `login.c`
|
||||
- `map.c`
|
||||
- `slist.c`
|
||||
- `nwcrypt.c`
|
||||
- `nwdebug.c`
|
||||
- `nwtests.c`
|
||||
- `capture.c`
|
||||
- `kern.asm`
|
||||
|
||||
|
||||
### CMake status
|
||||
|
||||
A `CMakeLists.txt` is present, but in this snapshot it is only a **partial modern build description**. It defines include paths, version-related macros, and install rules, while the actual `add_executable(...)` line is still commented out. That means it is better understood as packaging metadata than a ready-to-use complete build system.
|
||||
|
||||
## Installation layout
|
||||
|
||||
The CMake install rules deploy the same binary multiple times into `SYS/public`:
|
||||
|
||||
- `net.exe`
|
||||
- `login.exe`
|
||||
- `profile.exe`
|
||||
- `spawn.exe`
|
||||
- `passwd.exe`
|
||||
- `path.exe`
|
||||
- `pathins.exe`
|
||||
- `pathdel.exe`
|
||||
- `map.exe`
|
||||
- `mapdel.exe`
|
||||
- `logout.exe`
|
||||
- `slist.exe`
|
||||
- `capture.exe`
|
||||
- `endcap.exe`
|
||||
|
||||
They also install minimal `login.exe` and `map.exe` copies into `SYS/login`.
|
||||
|
||||
## Project status and limitations
|
||||
|
||||
This is legacy DOS networking code from the mid-1990s, and a few caveats are worth keeping in mind:
|
||||
|
||||
- The original README explicitly says the program was still incomplete.
|
||||
- `SLIST` is not implemented in the provided source snapshot.
|
||||
- Parts of the authentication and password-change path still rely on older unencrypted operations when the newer keyed flow is unavailable or disabled.
|
||||
- The code is tightly coupled to DOS, IPX/NCP behavior, and mars_nwe-specific expectations.
|
||||
|
||||
## Historical metadata
|
||||
|
||||
From the included project metadata:
|
||||
|
||||
- project: `mars_dosutils`
|
||||
- version: `0.10`
|
||||
- entered: `21-May-96`
|
||||
- keywords: `mars_nwe`, `dos`, `dosemu`
|
||||
- platforms: `DOS`, `DOSEMU`
|
||||
- author/maintainer: Martin Stover
|
||||
|
||||
|
||||
## License
|
||||
|
||||
No standalone license file is included in the provided snapshot. The source files do contain copyright notices naming **Martin Stover**. Anyone planning to redistribute or modernize the project should verify licensing status before publishing derivative releases.
|
||||
80
capture.c
Normal file
80
capture.c
Normal file
@@ -0,0 +1,80 @@
|
||||
/* capture.c 05-Apr-96 */
|
||||
|
||||
/****************************************************************
|
||||
* (C)opyright (C) 1993,1996 Martin Stover, Marburg, Germany *
|
||||
****************************************************************/
|
||||
|
||||
#include "net.h"
|
||||
|
||||
static int usage(void)
|
||||
{
|
||||
fprintf(stderr, "usage:\t%s level\n", funcname);
|
||||
fprintf(stderr, "\tlevel=0 .. 99\n" );
|
||||
return(-1);
|
||||
}
|
||||
|
||||
static int parse_argv(uint8 *devname, uint8 *queuename,
|
||||
int argc, char *argv[], int parsemode)
|
||||
{
|
||||
int k = 0;
|
||||
*devname = '\0';
|
||||
*queuename = '\0';
|
||||
while (++k < argc) {
|
||||
uint8 *p = argv[k];
|
||||
if (k == 1) {
|
||||
strmaxcpy(devname, p, 20);
|
||||
upstr(devname);
|
||||
if (!strcmp(devname, "PRN"))
|
||||
strcpy(devname, "LPT1");
|
||||
} else if (k == 2) {
|
||||
strmaxcpy(queuename, p, 20);
|
||||
upstr(queuename);
|
||||
}
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
static int do_capture(uint8 *drvstr, uint8 *queuestr, int delete)
|
||||
{
|
||||
int result = redir_device_drive(delete ? -1 : 0x3, drvstr, queuestr);
|
||||
return(result);
|
||||
}
|
||||
|
||||
static int show_capture(uint8 *drvstr)
|
||||
{
|
||||
int result;
|
||||
int k =-1;
|
||||
uint8 devname[20];
|
||||
uint8 remotename[130];
|
||||
int devicetyp;
|
||||
while ((result = list_redir(++k, &devicetyp, devname, remotename)) > -1){
|
||||
if (result > -1 && devicetyp == 0x3) {
|
||||
upstr(devname);
|
||||
upstr(remotename);
|
||||
if (!drvstr || !*drvstr || !strcmp(devname, drvstr))
|
||||
fprintf(stdout, "%-10s captured to %s\n", devname, remotename);
|
||||
}
|
||||
}
|
||||
return(result);
|
||||
}
|
||||
|
||||
int func_capture(int argc, char *argv[], int mode)
|
||||
{
|
||||
uint8 devname [22];
|
||||
uint8 queuestr[22];
|
||||
if (!parse_argv(devname, queuestr, argc, argv, mode)) {
|
||||
int result=0;
|
||||
if (*queuestr || mode == 1) {
|
||||
result=do_capture(devname, queuestr, mode);
|
||||
if (result< 0)
|
||||
fprintf(stderr, "capture error:%d, device:%s \n", result, devname);
|
||||
}
|
||||
if (mode != 1)
|
||||
show_capture(devname);
|
||||
else if (result > -1)
|
||||
fprintf(stdout, "Capture of %s removed\n", devname);
|
||||
return(result);
|
||||
}
|
||||
return(1);
|
||||
}
|
||||
|
||||
46
doc
46
doc
@@ -1,46 +0,0 @@
|
||||
/* DOC for NET.EXE */
|
||||
This is a short description of net.exe which is a simple DOS-client
|
||||
programm to allow standard NCP network actions, mainly for mars_nwe.
|
||||
All functions are called as a second parameter.
|
||||
This programm is very incomplete till now, but some functions
|
||||
works well with mars_nwe.
|
||||
|
||||
LOGOUT:
|
||||
Logout from a NCP Server.
|
||||
|
||||
LOGIN:
|
||||
usage: LOGIN [-u] [user | user password]
|
||||
-u = use unencrypted password.
|
||||
With this function you can log into a NCP Server.
|
||||
Its only make a login, no mappings or something else.
|
||||
|
||||
If you want a login similar to NOVELL's login.exe you should
|
||||
do it with a batch job.
|
||||
|
||||
example:
|
||||
[\LOGIN\LOGIN.BAT]
|
||||
@echo OFF
|
||||
net logout
|
||||
net login %1 %2 %3
|
||||
if errorlevel 1 goto :end
|
||||
map h:=HOME:
|
||||
if not exist h:\profile.bat goto :end
|
||||
h:
|
||||
profile.bat
|
||||
:end
|
||||
|
||||
PASSWD:
|
||||
usage: PASSWD [user]
|
||||
With this function you are able to change a users password.
|
||||
This call uses the old unencryted change password call !!
|
||||
|
||||
|
||||
PATH:
|
||||
usage: PATH sn:[=[path]]
|
||||
sn = 's1' .. 's16'
|
||||
|
||||
With this function a new path element can be created.
|
||||
Its only sets the path environment.
|
||||
|
||||
|
||||
|
||||
93
doc/README
Executable file
93
doc/README
Executable file
@@ -0,0 +1,93 @@
|
||||
/* DOC for NET.EXE */
|
||||
/* last updated: 21-May-96 */
|
||||
This is a short description of net.exe which is a simple DOS-client
|
||||
program to allow standard NCP network actions, mainly for mars_nwe.
|
||||
All functions are called as a second parameter, or if the program
|
||||
is renamed to a guilty function like login.exe then the function
|
||||
will be the progname. This is very usefull for login.exe.
|
||||
|
||||
This program is very incomplete till now, but some functions
|
||||
works well with mars_nwe.
|
||||
|
||||
|
||||
LOGIN:
|
||||
usage: LOGIN [-u] [user | user password]
|
||||
-u = use unencrypted password.
|
||||
With this function you can log into a NCP Server.
|
||||
If there exists a 'login' file in the same directory as
|
||||
net.exe resides then this file will be interpreted as a
|
||||
command file. You also can use command files with
|
||||
the PROFILE command.
|
||||
It is usefull to copy (or do a Linux link) net.exe to login.exe.
|
||||
|
||||
example for a 'login' script (resides in same directory as net.exe)
|
||||
|
||||
map f:=SYS:
|
||||
map h:=home:
|
||||
map z:=SYS:PUBLIC
|
||||
path s16:=z:.
|
||||
capture lpt1 q1
|
||||
profile h:\profile # will call users home 'profile'
|
||||
|
||||
if not exist h:\profile.bat goto :end
|
||||
|
||||
|
||||
PROFILE:
|
||||
usage: PROFILE filename
|
||||
With this function you are able to run a command script.
|
||||
In this command script you can use every net.exe command.
|
||||
|
||||
SPAWN:
|
||||
With SPAWN you can start external programs.
|
||||
|
||||
PASSWD:
|
||||
usage: PASSWD [user]
|
||||
With this function you are able to change a users password.
|
||||
This call uses the old unencryted change password call !!
|
||||
|
||||
PATH:
|
||||
usage: PATH sn:[=[path]]
|
||||
sn = 's1' .. 's16'
|
||||
|
||||
With this function a new path element can be created.
|
||||
Its only sets the path environment !
|
||||
|
||||
PATHINS:
|
||||
usage: PATHINS sn:[=[path]]
|
||||
sn = 's1' .. 's16'
|
||||
like PATH, but inserts PATH, not overwrites.
|
||||
|
||||
PATHDEL:
|
||||
usage: PATHDEL sn:
|
||||
sn = 's1' .. 's16'
|
||||
deletes PATH element
|
||||
|
||||
MAP:
|
||||
usage: MAP [d:[=[path]]]
|
||||
d = 'A' .. 'Z'
|
||||
Maps a drive to a volume or volume/path.
|
||||
|
||||
|
||||
MAPDEL:
|
||||
usage: MAPDEL d:
|
||||
d = 'A' .. 'Z'
|
||||
Removes a map.
|
||||
|
||||
|
||||
LOGOUT:
|
||||
Logout from a NCP Server.
|
||||
|
||||
DEBUG:
|
||||
For setting debug flag in mars_nwe processes.
|
||||
If you want to use this, you must set
|
||||
mars_nwe/config.h: FUNC_17_02_IS_DEBUG to '1'
|
||||
|
||||
|
||||
SPAWN:
|
||||
EXEC:
|
||||
external program execution spawning or overlayed.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
16
doc/mars_dosutils.lsm
Normal file
16
doc/mars_dosutils.lsm
Normal file
@@ -0,0 +1,16 @@
|
||||
Begin3
|
||||
Title: mars_dosutils
|
||||
Version: 0.10
|
||||
Entered-date: 21-May-96
|
||||
|
||||
Description: Simple DOS client program specially
|
||||
for mars_nwe.
|
||||
Supports login, map, capture, passwd
|
||||
Binary + sourcen
|
||||
Keywords: novell, netware, client, ipx, ncp, mars_nwe
|
||||
Author: mstover@freeway.de (Martin Stover)
|
||||
Maintained-by: mstover@freeway.de (Martin Stover)
|
||||
Primary-site: ftp.gwdg.de:/pub/linux/misc/ncpfs
|
||||
60kB mars_dosutils-0.10.tgz
|
||||
Platforms: DOS, DOSEMU
|
||||
End
|
||||
32
kern.h
Executable file → Normal file
32
kern.h
Executable file → Normal file
@@ -1,12 +1,20 @@
|
||||
/* kern.h Assembler Routinen 20-Nov-93 */
|
||||
extern int IPXinit(void);
|
||||
extern int IPXopen_socket(UI sock, int live);
|
||||
extern void IPXclose_socket(UI sock);
|
||||
extern int IPXlisten(ECB *ecb);
|
||||
extern void asm_esr_routine(void);
|
||||
extern void esr_routine(ECB *ecb);
|
||||
extern void xmemmove(void *ziel, void *quelle, UI anz);
|
||||
extern int Net_Call(UI func, void *req, void *repl);
|
||||
|
||||
|
||||
|
||||
/* kern.h Assembler Routinen 20-Nov-93 */
|
||||
#if defined(__WATCOMC__)
|
||||
#define KERN_CALL _Cdecl
|
||||
#else
|
||||
#define KERN_CALL
|
||||
#endif
|
||||
|
||||
extern int KERN_CALL IPXinit(void);
|
||||
extern int KERN_CALL IPXopen_socket(UI sock, int live);
|
||||
extern void KERN_CALL IPXclose_socket(UI sock);
|
||||
extern int KERN_CALL IPXlisten(ECB *ecb);
|
||||
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);
|
||||
|
||||
#undef KERN_CALL
|
||||
|
||||
|
||||
|
||||
|
||||
317
kern.lst
317
kern.lst
@@ -1,317 +0,0 @@
|
||||
Turbo Assembler Version 3.1 28/04/96 13:28:50 Page 1
|
||||
kern.asm
|
||||
|
||||
|
||||
|
||||
1 ; kern.asm: 20-Nov-93, 21:52
|
||||
2 IDEAL
|
||||
3 P286
|
||||
4 0000 MODEL LARGE
|
||||
5 ; Fuer Turboc gerettet werden muessen folgende Register:
|
||||
6 ; BP, SS, SP, DS, CS u. SI, DI
|
||||
7
|
||||
8 MACRO P_START
|
||||
9 push bp
|
||||
10 mov bp, sp
|
||||
11 ENDM
|
||||
12
|
||||
13 MACRO P_END
|
||||
14 pop bp
|
||||
15 ENDM
|
||||
16
|
||||
17 MACRO PUSH_REGS
|
||||
18 push ds
|
||||
19 push si
|
||||
20 push di
|
||||
21 ENDM
|
||||
22
|
||||
23 MACRO POP_REGS
|
||||
24 pop di
|
||||
25 pop si
|
||||
26 pop ds
|
||||
27 ENDM
|
||||
28
|
||||
29 ;; EXTRN _esr_routine:FAR
|
||||
30
|
||||
31 PUBLIC _IPXinit;
|
||||
32 PUBLIC _IPXopen_socket;
|
||||
33 PUBLIC _IPXclose_socket;
|
||||
34 PUBLIC _IPXlisten;
|
||||
35 ;; PUBLIC _asm_esr_routine;
|
||||
36 PUBLIC _xmemmove;
|
||||
37 PUBLIC _Net_Call;
|
||||
38
|
||||
39 0000 DATASEG
|
||||
40 0000 0000FFFE enterIPX DD FAR
|
||||
41
|
||||
42 0004 CODESEG
|
||||
43 0000 PROC _IPXinit;
|
||||
44 P_START
|
||||
1 45 0000 55 push bp
|
||||
1 46 0001 8B EC mov bp, sp
|
||||
47 PUSH_REGS
|
||||
1 48 0003 1E push ds
|
||||
1 49 0004 56 push si
|
||||
1 50 0005 57 push di
|
||||
51 0006 B8 7A00 mov ax, 7A00h
|
||||
52 0009 CD 2F int 2Fh
|
||||
53 000B 3C FF cmp al, 0FFh
|
||||
54 000D 75 10 jne @@fertig
|
||||
55 000F B9 0000s mov cx, @data
|
||||
56 0012 8E D9 mov ds, cx
|
||||
57 0014 89 3E 0000r mov [WORD PTR enterIPX], di
|
||||
Turbo Assembler Version 3.1 28/04/96 13:28:50 Page 2
|
||||
kern.asm
|
||||
|
||||
|
||||
|
||||
58 0018 8C C0 mov ax, es
|
||||
59 001A A3 0002r mov [WORD PTR enterIPX+2], ax
|
||||
60 001D B0 01 mov al, 1 ; OK
|
||||
61 001F @@fertig:
|
||||
62 001F B4 00 mov ah, 0
|
||||
63 POP_REGS
|
||||
1 64 0021 5F pop di
|
||||
1 65 0022 5E pop si
|
||||
1 66 0023 1F pop ds
|
||||
67 P_END
|
||||
1 68 0024 5D pop bp
|
||||
69 0025 CB ret ; OK = 1 ; nicht ok = 0
|
||||
70 0026 ENDP
|
||||
71
|
||||
72 0026 PROC _xmemmove;
|
||||
73 ARG z:DATAPTR, q:DATAPTR, nmbr:WORD; Argumente
|
||||
74 0026 FA cli ; Disable Interrupts
|
||||
75 0027 55 push bp
|
||||
76 0028 8B EC mov bp,sp
|
||||
77 002A 8B 4E 0E mov cx, [nmbr];
|
||||
78 002D 0B C9 or cx, cx;
|
||||
79 002F 74 1F jz @@fertig; Anzahl ist 0;
|
||||
80 0031 1E push ds;
|
||||
81 0032 56 push si;
|
||||
82 0033 57 push di;
|
||||
83 0034 9C pushf
|
||||
84 0035 C5 76 0A lds si, [q] ; Quelle
|
||||
85 0038 C4 7E 06 les di, [z] ; Ziel
|
||||
86 003B 3B FE cmp di, si ;
|
||||
87 003D 7C 0A jl @@L1 ; Ziel ist kleiner
|
||||
88 003F FD std ; Richtungsflag setzen
|
||||
89 0040 49 dec cx
|
||||
90 0041 03 F9 add di, cx ; Von oben nach unten kopieren
|
||||
91 0043 03 F1 add si, cx ;
|
||||
92 0045 41 inc cx ; alten Wert wiederherstellen
|
||||
93 0046 EB 02 90 jmp @@L2;
|
||||
94 0049 @@L1:
|
||||
95 0049 FC cld ; Richtungsflag loeschen
|
||||
96 004A @@L2: ; und nun das eigentliche kopieren
|
||||
97 004A F3> A4 REP movsb ;
|
||||
98 004C 9D popf
|
||||
99 004D 5F pop di;
|
||||
100 004E 5E pop si;
|
||||
101 004F 1F pop ds;
|
||||
102 0050 @@fertig:
|
||||
103 0050 5D pop bp;
|
||||
104 0051 FB sti ; enable Interrupts
|
||||
105 0052 CB ret
|
||||
106 0053 ENDP
|
||||
107
|
||||
108 0053 PROC _IPXopen_socket;
|
||||
109 ARG sock:WORD, live:WORD
|
||||
110 P_START
|
||||
1 111 0053 55 push bp
|
||||
1 112 0054 8B EC mov bp, sp
|
||||
113 PUSH_REGS
|
||||
1 114 0056 1E push ds
|
||||
Turbo Assembler Version 3.1 28/04/96 13:28:50 Page 3
|
||||
kern.asm
|
||||
|
||||
|
||||
|
||||
1 115 0057 56 push si
|
||||
1 116 0058 57 push di
|
||||
117 0059 8B 46 08 mov ax, [live]
|
||||
118 005C 8B 56 06 mov dx, [sock]
|
||||
119 005F BB 0000s mov bx, @data
|
||||
120 0062 8E DB mov ds, bx
|
||||
121 0064 BB 0000 mov bx, 0
|
||||
122 0067 FF 1E 0000r call [enterIPX]
|
||||
123 006B 3C FF cmp al, 0FFh
|
||||
124 006D 75 06 jne @@L1
|
||||
125 006F B8 FFFF mov ax, -1 ; Socket already open
|
||||
126 0072 EB 0D 90 jmp @@L3
|
||||
127 0075 @@L1:
|
||||
128 0075 3C FE cmp al, 0FEh
|
||||
129 0077 75 06 jne @@L2
|
||||
130 0079 B8 FFFE mov ax, -2 ; Socket Table full
|
||||
131 007C EB 03 90 jmp @@L3
|
||||
132 007F @@L2:
|
||||
133 007F 8B C2 mov ax, dx
|
||||
134 0081 @@L3:
|
||||
135 POP_REGS
|
||||
1 136 0081 5F pop di
|
||||
1 137 0082 5E pop si
|
||||
1 138 0083 1F pop ds
|
||||
139 P_END
|
||||
1 140 0084 5D pop bp
|
||||
141 0085 CB ret
|
||||
142 0086 ENDP
|
||||
143
|
||||
144 0086 PROC _IPXclose_socket;
|
||||
145 ARG sock:WORD
|
||||
146 P_START
|
||||
1 147 0086 55 push bp
|
||||
1 148 0087 8B EC mov bp, sp
|
||||
149 PUSH_REGS
|
||||
1 150 0089 1E push ds
|
||||
1 151 008A 56 push si
|
||||
1 152 008B 57 push di
|
||||
153 008C 8B 56 06 mov dx, [sock]
|
||||
154 008F BB 0000s mov bx, @data
|
||||
155 0092 8E DB mov ds, bx
|
||||
156 0094 BB 0001 mov bx, 1
|
||||
157 0097 FF 1E 0000r call [enterIPX]
|
||||
158 POP_REGS
|
||||
1 159 009B 5F pop di
|
||||
1 160 009C 5E pop si
|
||||
1 161 009D 1F pop ds
|
||||
162 P_END
|
||||
1 163 009E 5D pop bp
|
||||
164 009F CB ret
|
||||
165 00A0 ENDP
|
||||
166
|
||||
167 00A0 PROC _IPXlisten;
|
||||
168 ARG ecb:DATAPTR
|
||||
169 P_START
|
||||
1 170 00A0 55 push bp
|
||||
1 171 00A1 8B EC mov bp, sp
|
||||
Turbo Assembler Version 3.1 28/04/96 13:28:50 Page 4
|
||||
kern.asm
|
||||
|
||||
|
||||
|
||||
172 PUSH_REGS
|
||||
1 173 00A3 1E push ds
|
||||
1 174 00A4 56 push si
|
||||
1 175 00A5 57 push di
|
||||
176 00A6 C4 76 06 les si, [ecb] ; Adresse ecb
|
||||
177 00A9 BB 0000s mov bx, @data
|
||||
178 00AC 8E DB mov ds, bx
|
||||
179 00AE BB 0004 mov bx, 4
|
||||
180 00B1 FF 1E 0000r call [enterIPX]
|
||||
181 POP_REGS
|
||||
1 182 00B5 5F pop di
|
||||
1 183 00B6 5E pop si
|
||||
1 184 00B7 1F pop ds
|
||||
185 P_END
|
||||
1 186 00B8 5D pop bp
|
||||
187 00B9 B4 00 mov ah, 0
|
||||
188 00BB CB ret
|
||||
189 00BC ENDP
|
||||
190
|
||||
191 ;; PROC _asm_esr_routine;
|
||||
192 ;; push bp;
|
||||
193 ;; PUSH_REGS;
|
||||
194 ;; mov ax, @data
|
||||
195 ;; mov ds, ax ; F<>r C PROGRAMM
|
||||
196 ;; push es; Adressegment vom EBC
|
||||
197 ;; push si; Adressoffset vom ECB
|
||||
198 ;; call _esr_routine; C ROUTINE
|
||||
199 ;; pop si;
|
||||
200 ;; pop es;
|
||||
201 ;; POP_REGS;
|
||||
202 ;; pop bp;
|
||||
203 ;; cli ; no Interrupt says NOVELL
|
||||
204 ;; ret
|
||||
205 ;; ENDP
|
||||
206
|
||||
207
|
||||
208 00BC PROC _Net_Call;
|
||||
209 ARG func:WORD, req:DATAPTR, repl:DATAPTR; Argumente
|
||||
210 00BC 55 push bp
|
||||
211 00BD 8B EC mov bp, sp
|
||||
212 00BF 8B 46 06 mov ax, [func];
|
||||
213 00C2 1E push ds;
|
||||
214 00C3 56 push si;
|
||||
215 00C4 57 push di;
|
||||
216 00C5 9C pushf
|
||||
217 00C6 C5 76 08 lds si, [req] ; Request
|
||||
218 00C9 C4 7E 0C les di, [repl] ; Reply
|
||||
219 00CC CD 21 int 21h
|
||||
220 00CE 9D popf
|
||||
221 00CF 5F pop di;
|
||||
222 00D0 5E pop si;
|
||||
223 00D1 1F pop ds;
|
||||
224 00D2 5D pop bp;
|
||||
225 00D3 B4 00 mov ah, 0
|
||||
226 00D5 CB ret
|
||||
227 00D6 ENDP
|
||||
228
|
||||
Turbo Assembler Version 3.1 28/04/96 13:28:50 Page 5
|
||||
kern.asm
|
||||
|
||||
|
||||
|
||||
229 END
|
||||
Turbo Assembler Version 3.1 28/04/96 13:28:50 Page 6
|
||||
Symbol Table
|
||||
|
||||
|
||||
|
||||
|
||||
Symbol Name Type Value
|
||||
|
||||
??DATE Text "28/04/96"
|
||||
??FILENAME Text "kern "
|
||||
??TIME Text "13:28:50"
|
||||
??VERSION Number 030A
|
||||
@32BIT Text 0
|
||||
@@FERTIG Near KERN_TEXT:001F
|
||||
@@FERTIG Near KERN_TEXT:0050
|
||||
@@L1 Near KERN_TEXT:0049
|
||||
@@L1 Near KERN_TEXT:0075
|
||||
@@L2 Near KERN_TEXT:004A
|
||||
@@L2 Near KERN_TEXT:007F
|
||||
@@L3 Near KERN_TEXT:0081
|
||||
@CODE Text KERN_TEXT
|
||||
@CODESIZE Text 1
|
||||
@CPU Text 0787H
|
||||
@CURSEG Text KERN_TEXT
|
||||
@DATA Text DGROUP
|
||||
@DATASIZE Text 1
|
||||
@FILENAME Text KERN
|
||||
@INTERFACE Text 00H
|
||||
@MODEL Text 5
|
||||
@STACK Text DGROUP
|
||||
@WORDSIZE Text 2
|
||||
ECB Number [DGROUP:BP+0006]
|
||||
ENTERIPX Dword DGROUP:0000
|
||||
FUNC Number [DGROUP:BP+0006]
|
||||
LIVE Number [DGROUP:BP+0008]
|
||||
NMBR Number [DGROUP:BP+000E]
|
||||
Q Number [DGROUP:BP+000A]
|
||||
REPL Number [DGROUP:BP+000C]
|
||||
REQ Number [DGROUP:BP+0008]
|
||||
SOCK Number [DGROUP:BP+0006]
|
||||
Z Number [DGROUP:BP+0006]
|
||||
_IPXCLOSE_SOCKET + Far KERN_TEXT:0086
|
||||
(_IPXclose_socket)
|
||||
_IPXINIT (_IPXinit) Far KERN_TEXT:0000
|
||||
_IPXLISTEN (_IPXlisten) Far KERN_TEXT:00A0
|
||||
_IPXOPEN_SOCKET + Far KERN_TEXT:0053
|
||||
(_IPXopen_socket)
|
||||
_NET_CALL (_Net_Call) Far KERN_TEXT:00BC
|
||||
_XMEMMOVE (_xmemmove) Far KERN_TEXT:0026
|
||||
|
||||
Macro Name
|
||||
|
||||
POP_REGS
|
||||
PUSH_REGS
|
||||
P_END
|
||||
P_START
|
||||
|
||||
Groups & Segments Bit Size Align Combine Class
|
||||
|
||||
DGROUP Group
|
||||
_DATA 16 0004 Word Public DATA
|
||||
KERN_TEXT 16 00D6 Word Public CODE
|
||||
|
||||
216
kern_wasm.asm
Normal file
216
kern_wasm.asm
Normal file
@@ -0,0 +1,216 @@
|
||||
; kern_wasm.asm
|
||||
;
|
||||
; Open Watcom WASM/MASM-syntax port of the old TASM IDEAL kern.asm.
|
||||
; Intended for 16-bit DOS large memory model builds on Linux with Open Watcom v2.
|
||||
;
|
||||
; Keep kern.asm as the historical TASM source and use this file for the
|
||||
; reproducible Open Watcom build.
|
||||
|
||||
.286
|
||||
.model large
|
||||
|
||||
.data
|
||||
enterIPX dd 0
|
||||
|
||||
.code
|
||||
|
||||
public _IPXinit
|
||||
public _IPXopen_socket
|
||||
public _IPXclose_socket
|
||||
public _IPXlisten
|
||||
public _xmemmove
|
||||
public _Net_Call
|
||||
|
||||
_IPXinit proc far
|
||||
push bp
|
||||
mov bp, sp
|
||||
push ds
|
||||
push si
|
||||
push di
|
||||
|
||||
mov ax, 7A00h
|
||||
int 2Fh
|
||||
cmp al, 0FFh
|
||||
jne ipxinit_done
|
||||
|
||||
mov cx, @data
|
||||
mov ds, cx
|
||||
mov word ptr enterIPX, di
|
||||
mov ax, es
|
||||
mov word ptr enterIPX+2, ax
|
||||
mov al, 1
|
||||
|
||||
ipxinit_done:
|
||||
mov ah, 0
|
||||
|
||||
pop di
|
||||
pop si
|
||||
pop ds
|
||||
pop bp
|
||||
ret
|
||||
_IPXinit endp
|
||||
|
||||
_xmemmove proc far
|
||||
push bp
|
||||
mov bp, sp
|
||||
|
||||
; far procedure stack layout, large model:
|
||||
; [bp+0] old bp
|
||||
; [bp+2] return offset
|
||||
; [bp+4] return segment
|
||||
; [bp+6] z offset
|
||||
; [bp+8] z segment
|
||||
; [bp+10] q offset
|
||||
; [bp+12] q segment
|
||||
; [bp+14] nmbr
|
||||
|
||||
cli
|
||||
mov cx, [bp+14]
|
||||
or cx, cx
|
||||
jz xmem_done
|
||||
|
||||
push ds
|
||||
push si
|
||||
push di
|
||||
pushf
|
||||
|
||||
lds si, dword ptr [bp+10]
|
||||
les di, dword ptr [bp+6]
|
||||
cmp di, si
|
||||
jl xmem_forward
|
||||
|
||||
std
|
||||
dec cx
|
||||
add di, cx
|
||||
add si, cx
|
||||
inc cx
|
||||
jmp xmem_copy
|
||||
|
||||
xmem_forward:
|
||||
cld
|
||||
|
||||
xmem_copy:
|
||||
rep movsb
|
||||
|
||||
popf
|
||||
pop di
|
||||
pop si
|
||||
pop ds
|
||||
|
||||
xmem_done:
|
||||
pop bp
|
||||
sti
|
||||
ret
|
||||
_xmemmove endp
|
||||
|
||||
_IPXopen_socket proc far
|
||||
push bp
|
||||
mov bp, sp
|
||||
push ds
|
||||
push si
|
||||
push di
|
||||
|
||||
; int IPXopen_socket(UI sock, int live)
|
||||
mov ax, [bp+8] ; live
|
||||
mov dx, [bp+6] ; sock
|
||||
mov bx, @data
|
||||
mov ds, bx
|
||||
mov bx, 0
|
||||
call dword ptr enterIPX
|
||||
|
||||
cmp al, 0FFh
|
||||
jne ipxopen_not_already
|
||||
mov ax, -1 ; socket already open
|
||||
jmp ipxopen_done
|
||||
|
||||
ipxopen_not_already:
|
||||
cmp al, 0FEh
|
||||
jne ipxopen_ok
|
||||
mov ax, -2 ; socket table full
|
||||
jmp ipxopen_done
|
||||
|
||||
ipxopen_ok:
|
||||
mov ax, dx
|
||||
|
||||
ipxopen_done:
|
||||
pop di
|
||||
pop si
|
||||
pop ds
|
||||
pop bp
|
||||
ret
|
||||
_IPXopen_socket endp
|
||||
|
||||
_IPXclose_socket proc far
|
||||
push bp
|
||||
mov bp, sp
|
||||
push ds
|
||||
push si
|
||||
push di
|
||||
|
||||
; void IPXclose_socket(UI sock)
|
||||
mov dx, [bp+6]
|
||||
mov bx, @data
|
||||
mov ds, bx
|
||||
mov bx, 1
|
||||
call dword ptr enterIPX
|
||||
|
||||
pop di
|
||||
pop si
|
||||
pop ds
|
||||
pop bp
|
||||
ret
|
||||
_IPXclose_socket endp
|
||||
|
||||
_IPXlisten proc far
|
||||
push bp
|
||||
mov bp, sp
|
||||
push ds
|
||||
push si
|
||||
push di
|
||||
|
||||
; int IPXlisten(ECB *ecb)
|
||||
les si, dword ptr [bp+6]
|
||||
mov bx, @data
|
||||
mov ds, bx
|
||||
mov bx, 4
|
||||
call dword ptr enterIPX
|
||||
|
||||
pop di
|
||||
pop si
|
||||
pop ds
|
||||
pop bp
|
||||
mov ah, 0
|
||||
ret
|
||||
_IPXlisten endp
|
||||
|
||||
_Net_Call proc far
|
||||
push bp
|
||||
mov bp, sp
|
||||
|
||||
; int Net_Call(UI func, void *req, void *repl)
|
||||
; [bp+6] func
|
||||
; [bp+8] req offset
|
||||
; [bp+10] req segment
|
||||
; [bp+12] repl offset
|
||||
; [bp+14] repl segment
|
||||
mov ax, [bp+6]
|
||||
|
||||
push ds
|
||||
push si
|
||||
push di
|
||||
pushf
|
||||
|
||||
lds si, dword ptr [bp+8]
|
||||
les di, dword ptr [bp+12]
|
||||
int 21h
|
||||
|
||||
popf
|
||||
pop di
|
||||
pop si
|
||||
pop ds
|
||||
pop bp
|
||||
mov ah, 0
|
||||
ret
|
||||
_Net_Call endp
|
||||
|
||||
end
|
||||
707
login.c
Executable file → Normal file
707
login.c
Executable file → Normal file
@@ -1,4 +1,4 @@
|
||||
/* login.c 05-Apr-96 */
|
||||
/* login.c 21-May-96 */
|
||||
|
||||
/****************************************************************
|
||||
* (C)opyright (C) 1993,1996 Martin Stover, Marburg, Germany *
|
||||
@@ -7,6 +7,383 @@
|
||||
#include "net.h"
|
||||
#include "nwcrypt.h"
|
||||
|
||||
#ifndef BLACK
|
||||
#define BLACK 0
|
||||
#endif
|
||||
#ifndef BLUE
|
||||
#define BLUE 1
|
||||
#endif
|
||||
#ifndef LIGHTGRAY
|
||||
#define LIGHTGRAY 7
|
||||
#endif
|
||||
#ifndef WHITE
|
||||
#define WHITE 15
|
||||
#endif
|
||||
|
||||
static uint8 script_login_name[64];
|
||||
static uint8 script_file_server[52];
|
||||
|
||||
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");
|
||||
fprintf(stdout, " LOGIN General Help Mars NWE\n");
|
||||
fprintf(stdout, " ------------------------------------------------------------------------\n");
|
||||
fprintf(stdout, " Purpose: To gain access to the network.\n");
|
||||
fprintf(stdout, " Syntax: LOGIN [/VER] [[Server | Tree/][Username] [/options]\n");
|
||||
fprintf(stdout, "\n");
|
||||
fprintf(stdout, " To: Use:\n");
|
||||
fprintf(stdout, " Login without running login scripts /NS\n");
|
||||
fprintf(stdout, " Clear the screen before executing /CLS\n");
|
||||
fprintf(stdout, " Specify a script file /S filename\n");
|
||||
fprintf(stdout, " Display version information /VER\n");
|
||||
fprintf(stdout, "\n");
|
||||
fprintf(stdout, " Examples:\n");
|
||||
fprintf(stdout, " LOGIN SUPERVISOR\n");
|
||||
fprintf(stdout, " LOGIN MARS/SUPERVISOR\n");
|
||||
fprintf(stdout, "\n");
|
||||
return(0);
|
||||
}
|
||||
|
||||
static void login_banner(void)
|
||||
{
|
||||
login_video_attr = 0x1f; /* white on blue */
|
||||
login_cls_attr(login_video_attr);
|
||||
login_fill_line(1, login_video_attr);
|
||||
login_write_attr(36, 1, "Mars NWE", login_video_attr);
|
||||
login_screen_normal();
|
||||
login_gotoxy(1, 3);
|
||||
}
|
||||
|
||||
static char *skip_spaces(char *p)
|
||||
{
|
||||
while (*p == 32 || *p == '\t') p++;
|
||||
return(p);
|
||||
}
|
||||
|
||||
static void strip_quotes(char *s)
|
||||
{
|
||||
char *d = s;
|
||||
char quote = 0;
|
||||
|
||||
while (*s) {
|
||||
if (!quote && (*s == '"' || *s == '\'')) {
|
||||
quote = *s++;
|
||||
continue;
|
||||
}
|
||||
if (quote && *s == quote) {
|
||||
quote = 0;
|
||||
s++;
|
||||
continue;
|
||||
}
|
||||
*d++ = *s++;
|
||||
}
|
||||
*d = '\0';
|
||||
}
|
||||
|
||||
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;
|
||||
} else {
|
||||
fputc(*s++, stdout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void script_write(char *p)
|
||||
{
|
||||
p = skip_spaces(p);
|
||||
strip_quotes(p);
|
||||
script_put_expanded(p);
|
||||
fputc('\n', stdout);
|
||||
}
|
||||
|
||||
static void script_join_args(char **argv, int argc)
|
||||
{
|
||||
if (argc > 2) {
|
||||
char *p = argv[argc-1];
|
||||
while (p-- > argv[1]) {
|
||||
if (*p == '\0') *p = 32;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void script_call_line(char *line)
|
||||
{
|
||||
char *buf;
|
||||
char **argv;
|
||||
int argc = 0;
|
||||
char **pp;
|
||||
|
||||
buf = xmalloc(512);
|
||||
argv = build_argv(buf, 512, line);
|
||||
if (argv != NULL) {
|
||||
pp = argv;
|
||||
while (*pp) {
|
||||
argc++;
|
||||
pp++;
|
||||
}
|
||||
if (argc > 0) {
|
||||
upstr(argv[0]);
|
||||
call_func_entry(argc, argv);
|
||||
}
|
||||
}
|
||||
xfree(buf);
|
||||
}
|
||||
|
||||
static int script_eval_if(char *line)
|
||||
{
|
||||
char tmp[512];
|
||||
char *p;
|
||||
char *q;
|
||||
int neg = 0;
|
||||
|
||||
strmaxcpy(tmp, line, sizeof(tmp) - 1);
|
||||
upstr(tmp);
|
||||
|
||||
if (strstr(tmp, "MEMBER OF") != NULL) {
|
||||
if (strstr(tmp, "EVERYONE") != NULL) return(1);
|
||||
return(0);
|
||||
}
|
||||
|
||||
p = strstr(tmp, "LOGIN_NAME");
|
||||
if (p != NULL) {
|
||||
q = strstr(p, "<>");
|
||||
if (q != NULL) neg = 1;
|
||||
else q = strchr(p, '=');
|
||||
|
||||
if (q != NULL) {
|
||||
char want[64];
|
||||
char *v;
|
||||
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) {
|
||||
want[i++] = *q++;
|
||||
}
|
||||
want[i] = '\0';
|
||||
|
||||
strmaxcpy(tmp, script_login_name, sizeof(tmp) - 1);
|
||||
upstr(tmp);
|
||||
|
||||
if (neg) return(strcmp(tmp, want) != 0);
|
||||
else return(strcmp(tmp, want) == 0);
|
||||
}
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
static int login_strnicmp(char *a, char *b, int n)
|
||||
{
|
||||
while (n-- > 0) {
|
||||
int ca = *a++;
|
||||
int cb = *b++;
|
||||
if (ca >= 'a' && ca <= 'z') ca -= 32;
|
||||
if (cb >= 'a' && cb <= 'z') cb -= 32;
|
||||
if (ca != cb) return(ca - cb);
|
||||
if (!ca) return(0);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
static int script_execute_line(char *line)
|
||||
{
|
||||
char work[512];
|
||||
char cmd[32];
|
||||
char *p;
|
||||
char *arg;
|
||||
int i;
|
||||
|
||||
strmaxcpy(work, line, sizeof(work) - 1);
|
||||
p = skip_spaces(work);
|
||||
|
||||
if (!*p) return(0);
|
||||
|
||||
i = 0;
|
||||
while (p[i] && p[i] != 32 && p[i] != '\t' && i < 31) {
|
||||
cmd[i] = p[i];
|
||||
i++;
|
||||
}
|
||||
cmd[i] = '\0';
|
||||
upstr(cmd);
|
||||
|
||||
arg = skip_spaces(p + i);
|
||||
|
||||
if (!strcmp(cmd, "WRITE") || !strcmp(cmd, "ECHO")) {
|
||||
script_write(arg);
|
||||
return(0);
|
||||
}
|
||||
|
||||
if (!strcmp(cmd, "PAUSE")) {
|
||||
fprintf(stdout, "Strike any key when ready . . .");
|
||||
fflush(stdout);
|
||||
getch();
|
||||
fprintf(stdout, "\n");
|
||||
return(0);
|
||||
}
|
||||
|
||||
if (!strcmp(cmd, "CLS")) {
|
||||
login_cls_attr(0x07);
|
||||
return(0);
|
||||
}
|
||||
|
||||
if (!strcmp(cmd, "BREAK")) {
|
||||
return(0);
|
||||
}
|
||||
|
||||
if (!strcmp(cmd, "SET")) {
|
||||
if (*arg) putglobenv(arg);
|
||||
return(0);
|
||||
}
|
||||
|
||||
if (!strcmp(cmd, "DRIVE")) {
|
||||
arg = skip_spaces(arg);
|
||||
if ((*arg >= 'A' && *arg <= 'Z') || (*arg >= 'a' && *arg <= 'z')) {
|
||||
if (*arg >= 'a') setdisk(*arg - 'a');
|
||||
else setdisk(*arg - 'A');
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
if (!strcmp(cmd, "MAP")) {
|
||||
char up[512];
|
||||
|
||||
strmaxcpy(up, arg, sizeof(up) - 1);
|
||||
upstr(up);
|
||||
|
||||
if (!strncmp(up, "DISPLAY", 7)) {
|
||||
return(0);
|
||||
}
|
||||
|
||||
if (!strncmp(up, "INS ", 4) || !strncmp(up, "INSERT ", 7)) {
|
||||
char callbuf[512];
|
||||
char *a = arg;
|
||||
if (!login_strnicmp(up, "INS ", 4)) a += 4;
|
||||
else a += 7;
|
||||
sprintf(callbuf, "PATHINS %s", skip_spaces(a));
|
||||
script_call_line(callbuf);
|
||||
return(0);
|
||||
}
|
||||
|
||||
if (!strncmp(up, "DEL ", 4) || !strncmp(up, "DELETE ", 7)) {
|
||||
char callbuf[512];
|
||||
char *a = arg;
|
||||
if (!login_strnicmp(up, "DEL ", 4)) a += 4;
|
||||
else a += 7;
|
||||
sprintf(callbuf, "PATHDEL %s", skip_spaces(a));
|
||||
script_call_line(callbuf);
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
|
||||
if (!strcmp(cmd, "EXIT")) {
|
||||
return(1);
|
||||
}
|
||||
|
||||
script_call_line(p);
|
||||
return(0);
|
||||
}
|
||||
|
||||
static int run_login_script(void)
|
||||
{
|
||||
char profile[200];
|
||||
|
||||
sprintf(profile, "%snet$log.dat", prgpath);
|
||||
if (read_command_file(profile) != -2) return(0);
|
||||
|
||||
sprintf(profile, "%slogin", prgpath);
|
||||
if (read_command_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);
|
||||
|
||||
return(-2);
|
||||
}
|
||||
|
||||
|
||||
static int do_change_object_passwd(char *name,
|
||||
uint16 objtyp,
|
||||
@@ -15,31 +392,55 @@ static int do_change_object_passwd(char *name,
|
||||
|
||||
{
|
||||
uint8 key[8];
|
||||
if (0 && !ncp_17_17(key)) {
|
||||
|
||||
if (!ncp_17_17(key)) {
|
||||
uint32 objid = ncp_17_35(name, objtyp);
|
||||
if (objid) {
|
||||
uint8 buff[128];
|
||||
uint8 encrypted[8];
|
||||
uint8 newcryptpasswd[16];
|
||||
int passwdx=0;
|
||||
uint8 oldpwd[16]; /* old passwd as stored by server */
|
||||
uint8 newpwd[16]; /* new passwd as stored by server */
|
||||
uint8 cryptkey[8];
|
||||
uint8 tmpid[4];
|
||||
uint8 passwdx;
|
||||
int newlen;
|
||||
|
||||
memcpy(cryptkey, key, 8);
|
||||
U32_TO_BE32(objid, tmpid);
|
||||
shuffle(tmpid, oldpassword, strlen(oldpassword), buff);
|
||||
nw_encrypt(key, buff, encrypted);
|
||||
|
||||
shuffle(tmpid, newpassword, strlen(newpassword), buff);
|
||||
shuffle(tmpid, oldpassword, strlen(oldpassword), oldpwd);
|
||||
shuffle(tmpid, newpassword, strlen(newpassword), newpwd);
|
||||
|
||||
if (!ncp_17_4b(encrypted, name, objtyp, passwdx, newcryptpasswd)) {
|
||||
nw_encrypt(cryptkey, oldpwd, cryptkey);
|
||||
|
||||
/*
|
||||
* Same keyed change password transformation as ncpfs
|
||||
* ncp_change_login_passwd(): encrypt both 8-byte halves of the
|
||||
* stored new password using the stored old password as key material.
|
||||
* newpassencrypt() intentionally mutates oldpwd; the passwd length
|
||||
* byte must be calculated afterwards, just like ncpfs does it.
|
||||
*/
|
||||
newpassencrypt(oldpwd, newpwd);
|
||||
newpassencrypt(oldpwd + 8, newpwd + 8);
|
||||
|
||||
newlen = strlen(newpassword);
|
||||
if (newlen > 63) newlen = 63;
|
||||
passwdx = (uint8)(((newlen ^ oldpwd[0] ^ oldpwd[1]) & 0x7f) | 0x40);
|
||||
|
||||
if (!ncp_17_4b(cryptkey, name, objtyp, passwdx, newpwd)) {
|
||||
;;
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
} else { /* now we use old unencrypted algorithmus */
|
||||
if (!ncp_17_40(name, objtyp, oldpassword, newpassword)) {
|
||||
;;
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Fallback for old servers/requesters where Get Encryption Key is not
|
||||
* available. Keep the original unencrypted behavior as fallback only.
|
||||
*/
|
||||
if (!ncp_17_40(name, objtyp, oldpassword, newpassword)) {
|
||||
;;
|
||||
return(0);
|
||||
}
|
||||
|
||||
return(-1);
|
||||
}
|
||||
|
||||
@@ -84,7 +485,10 @@ static int get_raw_str(uint8 *s, int maxlen, int doecho)
|
||||
case 8 : if (len) {
|
||||
--len;
|
||||
--s;
|
||||
if (doecho) fprintf(stdout, "\010 \010");
|
||||
if (doecho) {
|
||||
fprintf(stdout, "\010 \010");
|
||||
fflush(stdout);
|
||||
}
|
||||
} else beep();
|
||||
continue;
|
||||
|
||||
@@ -95,7 +499,10 @@ static int get_raw_str(uint8 *s, int maxlen, int doecho)
|
||||
len++;
|
||||
break;
|
||||
} /* switch */
|
||||
if (doecho) fprintf(stdout, "%c", (uint8)key);
|
||||
if (doecho) {
|
||||
fprintf(stdout, "%c", (uint8)key);
|
||||
fflush(stdout);
|
||||
}
|
||||
}
|
||||
*s='\0';
|
||||
return(len);
|
||||
@@ -104,44 +511,64 @@ static int get_raw_str(uint8 *s, int maxlen, int doecho)
|
||||
static void getstr(char *what, char *str, int rsize, int doecho)
|
||||
{
|
||||
fprintf(stdout, "%s: ", what);
|
||||
fflush(stdout);
|
||||
get_raw_str(str, rsize, doecho);
|
||||
fprintf(stdout, "\n");
|
||||
}
|
||||
|
||||
static int login_usage(void)
|
||||
{
|
||||
fprintf(stderr, "usage:\t%s [-u] [user | user password]\n", funcname);
|
||||
fprintf(stderr, "\t-u : use unecrypted password\n" );
|
||||
return(-1);
|
||||
return(login_help());
|
||||
}
|
||||
|
||||
int func_login(int argc, char *argv[])
|
||||
int func_login(int argc, char *argv[], int mode)
|
||||
{
|
||||
int result=-1;
|
||||
int option=0;
|
||||
uint8 uname[200];
|
||||
uint8 upasswd[200];
|
||||
SEARCH_VECTOR save_drives;
|
||||
int interactive_login = 0;
|
||||
int no_script = 0;
|
||||
|
||||
if (argc > 1) {
|
||||
if (argv[1][0] == '-') {
|
||||
if (argv[1][1] == 'u') option |= 1;
|
||||
if (!strcmp(argv[1], "/?") || !strcmp(argv[1], "-?") || !strcmp(argv[1], "?"))
|
||||
return(login_help());
|
||||
if (!strcmp(argv[1], "/VER") || !strcmp(argv[1], "-VER")) {
|
||||
fprintf(stdout, "Mars NWE LOGIN 0.99\n");
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
|
||||
if (argc > 1) {
|
||||
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")) login_cls_attr(0x07);
|
||||
else return(login_usage());
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
}
|
||||
|
||||
get_search_drive_vektor(save_drives);
|
||||
remove_nwpathes();
|
||||
if (argc > 1) strmaxcpy(uname, argv[1], sizeof(uname) -1);
|
||||
else uname[0]='\0';
|
||||
if (argc > 2) strmaxcpy(upasswd, argv[2], sizeof(upasswd) -1);
|
||||
else upasswd[0]='\0';
|
||||
|
||||
if (!uname[0]) {
|
||||
interactive_login = 1;
|
||||
login_banner();
|
||||
}
|
||||
|
||||
while (result) {
|
||||
if (!uname[0]) getstr("login", uname, sizeof(uname)-1, 1);
|
||||
if (!uname[0]) getstr("Enter your login name", uname, sizeof(uname)-1, 1);
|
||||
if (uname[0]) {
|
||||
upstr(uname);
|
||||
upstr(upasswd);
|
||||
if ((result = do_object_login(uname, 0x1, upasswd, option)) < 0 && !*upasswd) {
|
||||
getstr("Password", upasswd, sizeof(upasswd)-1, 0);
|
||||
getstr("Enter your password", upasswd, sizeof(upasswd)-1, 0);
|
||||
upstr(upasswd);
|
||||
result = do_object_login(uname, 0x1, upasswd, option);
|
||||
}
|
||||
@@ -152,16 +579,37 @@ int func_login(int argc, char *argv[])
|
||||
}
|
||||
} else break;
|
||||
}
|
||||
if (result > -1) {
|
||||
strmaxcpy(script_login_name, uname, sizeof(script_login_name) - 1);
|
||||
|
||||
if (get_fs_name(1, script_file_server))
|
||||
strcpy(script_file_server, "MARS");
|
||||
|
||||
if (interactive_login)
|
||||
fprintf(stdout, "You are attached to server %s.\n", script_file_server);
|
||||
|
||||
remove_nwpathes();
|
||||
|
||||
if (!no_script)
|
||||
run_login_script();
|
||||
} else {
|
||||
(void)set_search_drive_vektor(save_drives);
|
||||
}
|
||||
return(result);
|
||||
}
|
||||
|
||||
int func_logout(int argc, char *argv[])
|
||||
int func_logout(int argc, char *argv[], int mode)
|
||||
{
|
||||
if (logout()) fprintf(stderr, "logout=%d", neterrno);
|
||||
remove_nwpathes();
|
||||
if (logout()) {
|
||||
fprintf(stderr, "logout=%d\n", neterrno);
|
||||
return(1);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
int func_passwd(int argc, char *argv[])
|
||||
int func_passwd(int argc, char *argv[], int mode)
|
||||
{
|
||||
int result=0;
|
||||
uint8 uname[100];
|
||||
@@ -169,7 +617,7 @@ int func_passwd(int argc, char *argv[])
|
||||
uint32 my_obj_id;
|
||||
|
||||
if (ncp_14_46(&my_obj_id) < 0 || my_obj_id == MAX_U32 || !my_obj_id) {
|
||||
fprintf(stderr, "Cannot get actual User ID\n");
|
||||
fprintf(stderr, "Cannot get actual user id\n");
|
||||
result = -1;
|
||||
}
|
||||
|
||||
@@ -179,13 +627,13 @@ int func_passwd(int argc, char *argv[])
|
||||
upstr(uname);
|
||||
obj_id = ncp_17_35(uname, 1);
|
||||
if (!obj_id) {
|
||||
fprintf(stderr, "Unkwown User: %s\n", uname);
|
||||
fprintf(stderr, "Unkwown user: %s\n", uname);
|
||||
return(-1);
|
||||
}
|
||||
} else if (!result) {
|
||||
uint16 obj_typ;
|
||||
if (ncp_17_36(my_obj_id, uname, &obj_typ) || obj_typ != 1) {
|
||||
fprintf(stderr, "Cannot get actual Username\n");
|
||||
fprintf(stderr, "Cannot get actual username\n");
|
||||
result=-1;
|
||||
}
|
||||
}
|
||||
@@ -194,11 +642,11 @@ int func_passwd(int argc, char *argv[])
|
||||
uint8 newpasswd2[130];
|
||||
if (my_obj_id == 1L) *upasswd='\0';
|
||||
else {
|
||||
getstr("Old Password", upasswd, sizeof(upasswd)-1, 0);
|
||||
getstr("Old password", upasswd, sizeof(upasswd)-1, 0);
|
||||
upstr(upasswd);
|
||||
}
|
||||
getstr("New Password", newpasswd, sizeof(newpasswd)-1, 0);
|
||||
getstr("New Password again", newpasswd2, sizeof(newpasswd2)-1, 0);
|
||||
getstr("New password", newpasswd, sizeof(newpasswd)-1, 0);
|
||||
getstr("New password again", newpasswd2, sizeof(newpasswd2)-1, 0);
|
||||
if (!strcmp(newpasswd, newpasswd2)) {
|
||||
upstr(uname);
|
||||
upstr(newpasswd);
|
||||
@@ -213,3 +661,192 @@ int func_passwd(int argc, char *argv[])
|
||||
return(result);
|
||||
}
|
||||
|
||||
static int get_line(FILE *f, char *buff, int bufsize, uint8 *str, int strsize)
|
||||
/* returns command line or -1 if ends */
|
||||
{
|
||||
if ((FILE*) NULL != f) {
|
||||
while (fgets(buff, bufsize, f) != NULL){
|
||||
char *p = buff;
|
||||
char *beg = NULL;
|
||||
char c;
|
||||
int len=0;
|
||||
while (0 != (c = *p++) && c != '\n' && c != '\r' && c != '#') {
|
||||
if (!beg){
|
||||
if (c != '\t' && c != 32) {
|
||||
beg = p - 1;
|
||||
len = 1;
|
||||
}
|
||||
} else ++len;
|
||||
}
|
||||
if (len) {
|
||||
strmaxcpy((uint8*)str, (uint8*)beg, min(len, strsize-1));
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
return(-1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static char **build_argv(char *buf, int bufsize, char *command)
|
||||
/* routine returns **argv for use with execv routines */
|
||||
/* buf will contain the path component */
|
||||
{
|
||||
int len = strlen(command);
|
||||
int offset = ((len+4) / 4) * 4; /* aligned offset for **argv */
|
||||
int components = (bufsize - offset) / 4;
|
||||
if (components > 1) { /* minimal argv[0] + NULL */
|
||||
char **argv = (char **)(buf+offset);
|
||||
char **pp = argv;
|
||||
char *p = buf;
|
||||
char c;
|
||||
int i=0;
|
||||
--components;
|
||||
memcpy(buf, command, len);
|
||||
memset(buf+len, 0, bufsize - len);
|
||||
*pp = p;
|
||||
while ((0 != (c = *p++)) && i < components) {
|
||||
if (c == 32 || c == '\t') {
|
||||
*(p-1) = '\0';
|
||||
if (*p != 32 && *p != '\t') {
|
||||
*(++pp)=p;
|
||||
i++;
|
||||
}
|
||||
} else if (!i && c == '/') { /* here i must get argv[0] */
|
||||
*pp=p;
|
||||
}
|
||||
}
|
||||
return(argv);
|
||||
}
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
int read_command_file(char *fstr)
|
||||
{
|
||||
FILE *f=fopen(fstr, "r");
|
||||
int result=-1;
|
||||
|
||||
if (f != NULL) {
|
||||
char *linebuf = xmalloc(512);
|
||||
char *buf = xmalloc(512);
|
||||
int stack[16];
|
||||
int level = 0;
|
||||
int active = 1;
|
||||
|
||||
while (get_line(f, buf, 512, linebuf, 512) > -1) {
|
||||
char tmp[512];
|
||||
char *p;
|
||||
|
||||
strmaxcpy(tmp, linebuf, sizeof(tmp) - 1);
|
||||
p = skip_spaces(tmp);
|
||||
upstr(p);
|
||||
|
||||
if (!strncmp(p, "IF ", 3)) {
|
||||
if (level < 16) {
|
||||
stack[level++] = active;
|
||||
active = active && script_eval_if(linebuf);
|
||||
}
|
||||
result = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!strcmp(p, "END") || !strncmp(p, "END ", 4)) {
|
||||
if (level > 0) active = stack[--level];
|
||||
result = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!active) {
|
||||
result = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (script_execute_line(linebuf))
|
||||
break;
|
||||
|
||||
result = 0;
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
xfree(linebuf);
|
||||
xfree(buf);
|
||||
} else result=-2;
|
||||
|
||||
return(result);
|
||||
}
|
||||
|
||||
int func_profile(int argc, char *argv[], int mode)
|
||||
{
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "usage:\t%s fn\n", funcname);
|
||||
return(-1);
|
||||
}
|
||||
if (read_command_file(argv[1]) == -2) {
|
||||
fprintf(stderr, "command file %s not found\n", argv[1]);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
int func_cwd(int argc, char *argv[], int mode)
|
||||
{
|
||||
char pathname[65];
|
||||
int len;
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "usage:\t%s path\n", funcname);
|
||||
return(-1);
|
||||
}
|
||||
strmaxcpy(pathname, argv[1], sizeof(pathname) -1);
|
||||
korrpath(pathname);
|
||||
if (0 != (len = strlen(pathname))) {
|
||||
char *p=pathname+len-1;
|
||||
if (*p == '/' || *p == ':') {
|
||||
*(++p) = '.';
|
||||
*(++p) = '\0';
|
||||
len++;
|
||||
}
|
||||
if (!chdir(pathname)) {
|
||||
if (len > 2 && *(pathname+1) == ':') /* device changed */
|
||||
setdisk(*pathname - 'a' );
|
||||
} else {
|
||||
fprintf(stderr, "cannot chdir to %s\n", pathname);
|
||||
return(1);
|
||||
}
|
||||
return(0);
|
||||
} else return(-1);
|
||||
}
|
||||
|
||||
int func_echo(int argc, char *argv[], int mode)
|
||||
{
|
||||
if (argc > 1)
|
||||
fprintf(stdout, "%s\n", argv[1]);
|
||||
return(0);
|
||||
}
|
||||
|
||||
int func_exec(int argc, char *argv[], int mode)
|
||||
{
|
||||
if (argc > 1) {
|
||||
char *buf = xmalloc(512);
|
||||
char *buff = xmalloc(512);
|
||||
char *p = buff;
|
||||
int k = 0;
|
||||
char **nargv;
|
||||
while (++k < argc) {
|
||||
strcpy(p, argv[k]);
|
||||
p += strlen(argv[k]);
|
||||
*p++ = 32;
|
||||
*p = '\0';
|
||||
}
|
||||
nargv=build_argv(buf, 512, buff);
|
||||
xfree(buff);
|
||||
if (nargv != NULL) {
|
||||
if (!mode)
|
||||
spawnvp(P_WAIT, buf, (const char *const *)nargv);
|
||||
else
|
||||
execvp(buf, (const char *const *)nargv);
|
||||
}
|
||||
xfree(buf);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
2
makefile → makefile.bcc
Executable file → Normal file
2
makefile → makefile.bcc
Executable file → Normal file
@@ -21,7 +21,7 @@ RM = del
|
||||
ASMODS= kern$(O)
|
||||
CCMODS= tools$(O) netcall$(O) ncpcall$(O) \
|
||||
login$(O) map$(O) slist$(O) nwcrypt$(O) \
|
||||
nwdebug$(O) nwtests$(O)
|
||||
nwdebug$(O) nwtests$(O) capture$(O)
|
||||
|
||||
all: net$(E)
|
||||
|
||||
177
map.c
Executable file → Normal file
177
map.c
Executable file → Normal file
@@ -24,6 +24,7 @@ static void show_map(uint8 *drvstr)
|
||||
if ((!get_drive_info(j, &connid, &dhandle, &flags)) && flags){
|
||||
char servern[52];
|
||||
char path[256];
|
||||
servern[0]='\0';
|
||||
if (flags & 0x80) { /* lokal DRIVE */
|
||||
path[0]= '\\';
|
||||
if (j < 2){
|
||||
@@ -35,11 +36,11 @@ static void show_map(uint8 *drvstr)
|
||||
if (get_dir_path(dhandle, path)) {
|
||||
strcpy(path, "DHANDLE !OK");
|
||||
}
|
||||
if (connid) {
|
||||
get_fs_name(connid, servern);
|
||||
strcat(servern, "\\");
|
||||
} else servern[0]='\0';
|
||||
}
|
||||
if (connid) {
|
||||
get_fs_name(connid, servern);
|
||||
strcat(servern, "\\");
|
||||
} else servern[0]='\0';
|
||||
printf("MAP %c: = %s%s\n", (char)j+'A', servern, path);
|
||||
}
|
||||
}
|
||||
@@ -76,22 +77,49 @@ static void do_map(int drive, NWPATH *nwp)
|
||||
}
|
||||
#endif
|
||||
|
||||
static int do_map(int drive, NWPATH *nwp)
|
||||
static int do_map(int drive, NWPATH *nwp, int delete)
|
||||
{
|
||||
int result = -1;
|
||||
|
||||
if (drive > -1 && drive < 32) {
|
||||
uint8 nmdrive[3];
|
||||
nmdrive[0] = drive+'A';
|
||||
nmdrive[1] = ':';
|
||||
nmdrive[2] = '\0';
|
||||
result = redir_device_drive(0x4, nmdrive, nwp->path);
|
||||
uint8 connid = 0;
|
||||
uint8 dhandle = 0;
|
||||
uint8 flags = 0;
|
||||
|
||||
if (delete) {
|
||||
if (!get_drive_info(drive, &connid, &dhandle, &flags)
|
||||
&& flags && !(flags & 0x80) && connid) {
|
||||
result = dealloc_dir_handle(dhandle);
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* The old mars-dosutils MAP used DOS redirector INT 21h AX=5F03h.
|
||||
* NetWare Client32 returns AX=0001 for that call, while Novell MAP
|
||||
* works. Use the NetWare shell/NCP "Allocate Permanent Directory
|
||||
* Handle" path instead; this is what the surrounding code already
|
||||
* provides via alloc_permanent_dir_handle().
|
||||
*/
|
||||
if (!get_drive_info(drive, &connid, &dhandle, &flags)
|
||||
&& flags && !(flags & 0x80) && connid) {
|
||||
(void)dealloc_dir_handle(dhandle);
|
||||
}
|
||||
|
||||
result = alloc_permanent_dir_handle(0, nwp->path, drive + 'A', NULL);
|
||||
|
||||
/*
|
||||
* Some requesters historically accepted lowercase drive letters in
|
||||
* this call. Keep this only as compatibility fallback.
|
||||
*/
|
||||
if (result < 0)
|
||||
result = alloc_permanent_dir_handle(0, nwp->path, drive + 'a', NULL);
|
||||
}
|
||||
}
|
||||
|
||||
return(result);
|
||||
}
|
||||
|
||||
|
||||
static int parse_argv(uint8 *drvstr, NWPATH *nwpath,
|
||||
int argc, char *argv[], int smode)
|
||||
int argc, char *argv[], int smode, int argvmode)
|
||||
{
|
||||
int k = 0;
|
||||
int mode = 0;
|
||||
@@ -149,7 +177,8 @@ static int parse_argv(uint8 *drvstr, NWPATH *nwpath,
|
||||
} /* while *p */
|
||||
} /* while k */
|
||||
if (mode == 30) {
|
||||
getcwd((char *)nwpath->buff, sizeof(nwpath->buff));
|
||||
if (argvmode != 1)
|
||||
getcwd((char *)nwpath->buff, sizeof(nwpath->buff));
|
||||
mode = 40;
|
||||
}
|
||||
if (mode && mode != 20 && mode != 40) {
|
||||
@@ -159,21 +188,24 @@ static int parse_argv(uint8 *drvstr, NWPATH *nwpath,
|
||||
return(0);
|
||||
}
|
||||
|
||||
int func_map(int argc, char *argv[])
|
||||
int func_map(int argc, char *argv[], int mode)
|
||||
{
|
||||
uint8 drvstr[22];
|
||||
NWPATH nwpath;
|
||||
if (!ipx_init()) argc = 1;
|
||||
if (!parse_argv(drvstr, &nwpath, argc, argv, 0)) {
|
||||
if (*(nwpath.path)) {
|
||||
if (do_map(*drvstr - 'A', &nwpath)< 0)
|
||||
if (!parse_argv(drvstr, &nwpath, argc, argv, 0, mode)) {
|
||||
if (*(nwpath.path) || mode==1) {
|
||||
if (do_map(*drvstr - 'A', &nwpath, mode)< 0)
|
||||
fprintf(stderr, "MAP Error\n");
|
||||
}
|
||||
show_map(drvstr);
|
||||
if (mode != 1)
|
||||
show_map(drvstr);
|
||||
return(0);
|
||||
}
|
||||
return(1);
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------- */
|
||||
static int show_search(uint8 *drvstr)
|
||||
{
|
||||
@@ -183,38 +215,42 @@ static int show_search(uint8 *drvstr)
|
||||
get_search_drive_vektor(drives);
|
||||
while (p->drivenummer != 0xff && j++ < 16) {
|
||||
char path[256];
|
||||
char nwname[256];
|
||||
char nwname_path[300];
|
||||
|
||||
|
||||
if ( !*drvstr || j == *(drvstr+1)) {
|
||||
if (p->flags && !(p->flags & 0x80)){
|
||||
get_fs_name(p->u.fs.connid, nwname);
|
||||
if (get_dir_path(p->u.fs.dhandle, path)) {
|
||||
strcpy(path, "ERROR NW");
|
||||
}
|
||||
(void)xadd_char(nwname, '\\', 20);
|
||||
|
||||
if (p->drivenummer == 0xfe){
|
||||
strcpy(path, p->dospath);
|
||||
} else {
|
||||
nwname[0] = '\0';
|
||||
/*
|
||||
nwname[0] = '<';
|
||||
strcpy(nwname+1, "LOCAL");
|
||||
*/
|
||||
if (p->drivenummer == 0xfe){
|
||||
strcpy(path, p->u.d.dospath);
|
||||
} else if (getcurdir((int)(p->drivenummer)+1, path)) {
|
||||
strcpy(path, "ERROR DOS");
|
||||
}
|
||||
/*
|
||||
(void)xadd_char(nwname, '>', 20);
|
||||
*/
|
||||
*path = p->drivenummer+'A';
|
||||
*(path+1) = ':';
|
||||
strcpy(path+2, p->dospath);
|
||||
}
|
||||
strcat(nwname, path);
|
||||
printf("SEARCH%2d = %c: %s\n", j, (char)(p->drivenummer)+'A', nwname);
|
||||
|
||||
if (p->flags && !(p->flags & 0x80)){
|
||||
char *pp=nwname_path;
|
||||
*pp++ = '[';
|
||||
get_fs_name(p->connid, pp);
|
||||
pp +=strlen(pp);
|
||||
*pp++='\\';
|
||||
if (get_dir_path(p->dhandle, pp)) {
|
||||
strcpy(pp, "ERROR NW");
|
||||
}
|
||||
pp += strlen(pp);
|
||||
*pp ++= ']';
|
||||
*pp = '\0';
|
||||
} else {
|
||||
*nwname_path = '\0';
|
||||
}
|
||||
printf("SEARCH%2d = %s %s\n", j, path, nwname_path);
|
||||
}
|
||||
p++;
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
static int set_search(uint8 *drvstr, NWPATH *nwp)
|
||||
static int set_search(uint8 *drvstr, NWPATH *nwp, int pathmode)
|
||||
{
|
||||
int result=-1;
|
||||
SEARCH_VECTOR drives;
|
||||
@@ -222,31 +258,78 @@ static int set_search(uint8 *drvstr, NWPATH *nwp)
|
||||
int j=0;
|
||||
int entry = (*drvstr=='s') ? *(drvstr+1) : 0;
|
||||
get_search_drive_vektor(drives);
|
||||
|
||||
while (p->drivenummer != 0xff && j++ < 16) {
|
||||
if (!entry && (p->drivenummer + 'A' == *drvstr)) entry=j;
|
||||
if (p->drivenummer + 'A' == nwp->path[0] && nwp->path[1] == ':'
|
||||
&& !strcmp(nwp->path+2, p->dospath)) {
|
||||
p->drivenummer=0xfe;
|
||||
*(p->dospath) = '\0';
|
||||
}
|
||||
p++;
|
||||
}
|
||||
|
||||
if (entry > 0) {
|
||||
if (entry > 16) entry = 16;
|
||||
if (--entry < j) p = drives+entry;
|
||||
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;
|
||||
p->flags = 0;
|
||||
p->drivenummer = 0xfe;
|
||||
strcpy(p->u.d.dospath, nwp->path);
|
||||
if (pathmode==1)
|
||||
*(p->dospath) = '\0';
|
||||
else
|
||||
strcpy(p->dospath, nwp->path);
|
||||
result = set_search_drive_vektor(drives);
|
||||
}
|
||||
return(result);
|
||||
}
|
||||
|
||||
int func_path(int argc, char *argv[])
|
||||
int func_path(int argc, char *argv[], int mode)
|
||||
{
|
||||
uint8 drvstr[22];
|
||||
NWPATH nwpath;
|
||||
if (!parse_argv(drvstr, &nwpath, argc, argv, 1)) {
|
||||
if (!parse_argv(drvstr, &nwpath, argc, argv, 1, mode)) {
|
||||
int result=0;
|
||||
if (*(nwpath.path)) result=set_search(drvstr, &nwpath);
|
||||
show_search(drvstr);
|
||||
if (*(nwpath.path) || mode==1)
|
||||
result=set_search(drvstr, &nwpath, mode);
|
||||
if (mode != 1)
|
||||
show_search(drvstr);
|
||||
return(result);
|
||||
}
|
||||
return(1);
|
||||
}
|
||||
|
||||
void remove_nwpathes(void)
|
||||
{
|
||||
SEARCH_VECTOR drives;
|
||||
SEARCH_VECTOR_ENTRY *p=drives;
|
||||
int j=0;
|
||||
get_search_drive_vektor(drives);
|
||||
while (p->drivenummer != 0xff && j++ < 16) {
|
||||
if (p->flags && !(p->flags & 0x80)){
|
||||
p->flags=0;
|
||||
p->drivenummer=0xfe;
|
||||
*(p->dospath) ='\0';
|
||||
}
|
||||
++p;
|
||||
}
|
||||
set_search_drive_vektor(drives);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
103
ncpcall.c
Executable file → Normal file
103
ncpcall.c
Executable file → Normal file
@@ -283,3 +283,106 @@ int ncp_17_4b(uint8 *cryptkey, uint8 *objname, uint16 objtyp,
|
||||
if (neterrno) return(-1);
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
int ncp_17_37(uint32 last_id, uint16 objtyp, uint8 *pattern,
|
||||
BINDERY_OBJECT *target)
|
||||
/* scan bindery object */
|
||||
{
|
||||
struct {
|
||||
uint16 len;
|
||||
uint8 func;
|
||||
uint8 last_id[4];
|
||||
uint8 typ[2];
|
||||
uint8 patlen;
|
||||
uint8 pattern[48];
|
||||
} req;
|
||||
struct {
|
||||
uint16 len;
|
||||
uint8 object_id[4];
|
||||
uint8 object_type[2];
|
||||
uint8 object_name[48];
|
||||
uint8 object_flags;
|
||||
uint8 object_security;
|
||||
uint8 object_has_prop;
|
||||
} repl;
|
||||
int patlen = (pattern) ? min(48, strlen(pattern)) : 1;
|
||||
|
||||
memset(&req, 0, sizeof(req));
|
||||
memset(&repl, 0, sizeof(repl));
|
||||
|
||||
req.func = 0x37;
|
||||
U32_TO_BE32(last_id, req.last_id);
|
||||
U16_TO_BE16(objtyp, req.typ);
|
||||
req.patlen = (uint8)patlen;
|
||||
if (pattern) memcpy(req.pattern, pattern, patlen);
|
||||
else req.pattern[0] = '*';
|
||||
req.len = 8 + patlen;
|
||||
|
||||
repl.len = sizeof(repl) - sizeof(uint16);
|
||||
|
||||
neterrno = Net_Call(0xE300, &req, &repl);
|
||||
if (neterrno) return(-1);
|
||||
|
||||
if (target) {
|
||||
target->object_id = GET_BE32(repl.object_id);
|
||||
target->object_type = GET_BE16(repl.object_type);
|
||||
memcpy(target->object_name, repl.object_name, 48);
|
||||
target->object_name[48] = '\0';
|
||||
deb(target->object_name);
|
||||
target->object_flags = repl.object_flags;
|
||||
target->object_security = repl.object_security;
|
||||
target->object_has_prop = repl.object_has_prop;
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
int ncp_17_3d(uint16 objtyp, uint8 *objname, int segment,
|
||||
uint8 *propname, NW_PROPERTY *target)
|
||||
/* read bindery property value */
|
||||
{
|
||||
struct {
|
||||
uint16 len;
|
||||
uint8 func;
|
||||
uint8 typ[2];
|
||||
uint8 buff[1+48+1+1+16];
|
||||
} req;
|
||||
struct {
|
||||
uint16 len;
|
||||
uint8 value[128];
|
||||
uint8 more_flag;
|
||||
uint8 property_flag;
|
||||
} repl;
|
||||
uint8 *p = req.buff;
|
||||
int objlen = min(48, strlen(objname));
|
||||
int proplen = min(16, strlen(propname));
|
||||
|
||||
memset(&req, 0, sizeof(req));
|
||||
memset(&repl, 0, sizeof(repl));
|
||||
|
||||
req.func = 0x3d;
|
||||
U16_TO_BE16(objtyp, req.typ);
|
||||
|
||||
*p++ = (uint8)objlen;
|
||||
memcpy(p, objname, objlen);
|
||||
p += objlen;
|
||||
|
||||
*p++ = (uint8)segment;
|
||||
|
||||
*p++ = (uint8)proplen;
|
||||
memcpy(p, propname, proplen);
|
||||
|
||||
req.len = 6 + objlen + proplen;
|
||||
repl.len = sizeof(repl) - sizeof(uint16);
|
||||
|
||||
neterrno = Net_Call(0xE300, &req, &repl);
|
||||
if (neterrno) return(-1);
|
||||
|
||||
if (target) {
|
||||
memcpy(target->value, repl.value, 128);
|
||||
target->more_flag = repl.more_flag;
|
||||
target->property_flag = repl.property_flag;
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
195
net.c
Executable file → Normal file
195
net.c
Executable file → Normal file
@@ -1,74 +1,121 @@
|
||||
/* net.c 14-Mar-96 */
|
||||
/* simple client programm to act with mars_nwe */
|
||||
|
||||
/****************************************************************
|
||||
* (C)opyright (C) 1993,1996 Martin Stover, Marburg, Germany *
|
||||
****************************************************************/
|
||||
|
||||
#include "net.h"
|
||||
char *funcname=NULL;
|
||||
typedef int (*NET_FUNC)(int argc, char *argv[]);
|
||||
|
||||
static struct s_net_functions {
|
||||
char *name;
|
||||
char *description;
|
||||
NET_FUNC func;
|
||||
} net_functions[] = {
|
||||
{"LOGIN", "login to Server as User" , func_login },
|
||||
{"MAP", "list maps and map drives" , func_map },
|
||||
{"PATH", "list and set search path" , func_path },
|
||||
{"LOGOUT", "logout from Server", func_logout },
|
||||
#if 0
|
||||
{"SLIST", "list Servers", func_slist },
|
||||
#endif
|
||||
{"PASSWD", "change password", func_passwd },
|
||||
#if 1
|
||||
{"TESTS", "only testroutines!", func_tests },
|
||||
#endif
|
||||
{"DEBUG", "set debug level, for mars_nwe only !", func_debug }
|
||||
};
|
||||
|
||||
#define MAX_FUNCS (sizeof(net_functions) / sizeof(struct s_net_functions))
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
NET_FUNC func = NULL;
|
||||
int result = -1;
|
||||
if (argc > 1) {
|
||||
char funcn[200];
|
||||
int k= MAX_FUNCS;
|
||||
strmaxcpy(funcn, argv[1], sizeof(funcn)-1);
|
||||
upstr(funcn);
|
||||
while (k--) {
|
||||
if (!strcmp(funcn, net_functions[k].name)) {
|
||||
func=net_functions[k].func;
|
||||
funcname=net_functions[k].name;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (func != NULL) {
|
||||
if (ipx_init() || func == func_map) {
|
||||
result = (*func) (argc-1, &(argv[1]));
|
||||
}
|
||||
} else {
|
||||
int k= MAX_FUNCS;
|
||||
char progname[256];
|
||||
strmaxcpy(progname, argv[0], sizeof(progname)-1);
|
||||
upstr(progname);
|
||||
fprintf(stderr, "\n"
|
||||
"****************************************************************\n"
|
||||
"* (C)opyright (C) 1993,1996 Martin Stover, Marburg, Germany *\n"
|
||||
"****************************************************************\n\n" );
|
||||
fprintf(stderr, "Usage:\t%s func ... \nfuncs:", progname);
|
||||
while (k--) {
|
||||
if (net_functions[k].func) {
|
||||
fprintf(stderr, "\t%s\t: %s\n",
|
||||
net_functions[k].name, net_functions[k].description);
|
||||
}
|
||||
}
|
||||
}
|
||||
return(result);
|
||||
}
|
||||
|
||||
|
||||
/* net.c */
|
||||
#define VERS_DATE "21-May-96"
|
||||
/* simple client program to act with mars_nwe */
|
||||
|
||||
/****************************************************************
|
||||
* (C)opyright (C) 1993,1996 Martin Stover, Marburg, Germany *
|
||||
****************************************************************/
|
||||
|
||||
#include "net.h"
|
||||
|
||||
char *funcname=NULL;
|
||||
char prgpath[65];
|
||||
|
||||
typedef int (*NET_FUNC)(int argc, char *argv[], int mode);
|
||||
|
||||
static struct s_net_functions {
|
||||
char *name;
|
||||
char *description;
|
||||
NET_FUNC func;
|
||||
int mode;
|
||||
} net_functions[] = {
|
||||
|
||||
{"SPAWN", "spawn program(command file)" , func_exec , 0},
|
||||
{"EXEC", "execute program(command file)", func_exec , 1},
|
||||
{"ECHO", "echoes string (command file)" , func_echo , 0},
|
||||
{"CD", "change directory (command file)" , func_cwd , 0},
|
||||
{"LOGIN", "login to server as user" , func_login , 0},
|
||||
{"PROFILE","read command file" , func_profile, 0},
|
||||
{"CAPTURE","list and redirect printers" , func_capture, 0},
|
||||
{"ENDCAP", "cancel redirect printers" , func_capture, 1},
|
||||
{"MAP", "list maps and map drives" , func_map , 0},
|
||||
{"MAPDEL", "removes maps" , func_map , 1},
|
||||
{"PATH", "list and set search path" , func_path , 0},
|
||||
{"PATHDEL","removes search path" , func_path , 1},
|
||||
{"PATHINS","insert search path" , func_path , 2},
|
||||
{"LOGOUT", "logout from server", func_logout , 0},
|
||||
{"SLIST", "list servers", func_slist , 0},
|
||||
{"PASSWD", "change password", func_passwd , 0},
|
||||
#if 1
|
||||
{"TESTS", "only testroutines!", func_tests , 0},
|
||||
#endif
|
||||
{"DEBUG", "set debug level, for mars_nwe only !", func_debug , 0}
|
||||
};
|
||||
|
||||
#define MAX_FUNCS (sizeof(net_functions) / sizeof(struct s_net_functions))
|
||||
|
||||
static int get_entry_nr(char *fstr)
|
||||
{
|
||||
int entry = MAX_FUNCS;
|
||||
char buff[200];
|
||||
char funcn[100];
|
||||
char *pp;
|
||||
strmaxcpy(buff, fstr, sizeof(buff)-1);
|
||||
korrpath(buff);
|
||||
get_path_fn(buff, NULL, funcn);
|
||||
pp=strrchr(funcn, '.');
|
||||
if (NULL != pp) *pp = '\0';
|
||||
upstr(funcn);
|
||||
while (entry--) {
|
||||
if (!strcmp(funcn, net_functions[entry].name)) return(entry);
|
||||
}
|
||||
return(-1);
|
||||
}
|
||||
|
||||
int call_func_entry(int argc, char *argv[])
|
||||
{
|
||||
int funcmode;
|
||||
int result = -1;
|
||||
NET_FUNC func = NULL;
|
||||
int entry = get_entry_nr(argv[0]);
|
||||
if (entry > -1) {
|
||||
func = net_functions[entry].func;
|
||||
funcmode = net_functions[entry].mode;
|
||||
funcname = net_functions[entry].name;
|
||||
}
|
||||
if (NULL != func) {
|
||||
if (ipx_init() || func == func_map) {
|
||||
result = (*func)(argc, argv, funcmode);
|
||||
} else {
|
||||
fprintf(stderr, "Cannot init IPX\n");
|
||||
}
|
||||
} else result = -0xff;
|
||||
return(result);
|
||||
}
|
||||
|
||||
static void get_path(char *path)
|
||||
{
|
||||
char buf[100];
|
||||
strmaxcpy(buf, path, sizeof(buf)-1);
|
||||
korrpath(buf);
|
||||
get_path_fn(buf, prgpath, NULL);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int result = -0xff;
|
||||
get_path(argv[0]);
|
||||
result = call_func_entry(argc, argv);
|
||||
if (result == -0xff)
|
||||
result = call_func_entry(argc-1, argv+1);
|
||||
if (result == -0xff) {
|
||||
int k= MAX_FUNCS;
|
||||
char progname[256];
|
||||
strmaxcpy(progname, argv[0], sizeof(progname)-1);
|
||||
upstr(progname);
|
||||
fprintf(stderr, "\n"
|
||||
"* (C)opyright (C) 1993,1996 Martin Stover, Marburg, Germany *\n"
|
||||
" Version: %s\n\n", VERS_DATE);
|
||||
|
||||
fprintf(stderr, "Usage:\t%s func ... \nfuncs:", progname);
|
||||
while (k--) {
|
||||
if (net_functions[k].func) {
|
||||
fprintf(stderr, "\t%s\t: %s\n",
|
||||
net_functions[k].name, net_functions[k].description);
|
||||
}
|
||||
}
|
||||
}
|
||||
return(result);
|
||||
}
|
||||
|
||||
|
||||
|
||||
104
net.h
Executable file → Normal file
104
net.h
Executable file → Normal file
@@ -1,4 +1,4 @@
|
||||
/* net.h: 01-Feb-96 */
|
||||
/* net.h: 20-May-96 */
|
||||
|
||||
/****************************************************************
|
||||
* (C)opyright (C) 1993,1996 Martin Stover, Marburg, Germany *
|
||||
@@ -15,8 +15,12 @@
|
||||
#include <dos.h>
|
||||
#include <process.h>
|
||||
#include <stdarg.h>
|
||||
#ifdef __WATCOMC__
|
||||
#include <direct.h>
|
||||
#endif
|
||||
|
||||
typedef unsigned int UI;
|
||||
typedef unsigned int uint;
|
||||
typedef unsigned char UC;
|
||||
typedef unsigned char uint8;
|
||||
typedef unsigned short int uint16;
|
||||
@@ -54,7 +58,7 @@ typedef struct {
|
||||
uint16 fragment_count; /* Anzahl Fragment Buffers */
|
||||
uint8 *fragment_1;
|
||||
uint16 fragment_1_size;
|
||||
/* K”nnen auch mehr sein */
|
||||
/* K<EFBFBD>nnen auch mehr sein */
|
||||
} ECB;
|
||||
|
||||
#include "kern.h"
|
||||
@@ -102,39 +106,73 @@ typedef struct {
|
||||
#define NWCLIENT 4
|
||||
#define NWBIND 5
|
||||
|
||||
#define NCP_BINDERY_FSERVER 0x0004
|
||||
|
||||
typedef struct {
|
||||
uint32 object_id;
|
||||
uint16 object_type;
|
||||
uint8 object_name[49];
|
||||
uint8 object_flags;
|
||||
uint8 object_security;
|
||||
uint8 object_has_prop;
|
||||
} BINDERY_OBJECT;
|
||||
|
||||
typedef struct {
|
||||
uint8 value[128];
|
||||
uint8 more_flag;
|
||||
uint8 property_flag;
|
||||
} NW_PROPERTY;
|
||||
|
||||
|
||||
/* net.c */
|
||||
extern char *funcname;
|
||||
extern char *funcname;
|
||||
extern char prgpath[];
|
||||
|
||||
extern int call_func_entry(int argc, char *argv[]);
|
||||
|
||||
/* tools.c */
|
||||
extern void clear_kb(void);
|
||||
extern int key_pressed(void);
|
||||
extern int ask_user(char *p, ...);
|
||||
#define xfree(p) x_x_xfree((char **)&(p))
|
||||
extern void x_x_xfree(char **p);
|
||||
extern char *xmalloc(uint size);
|
||||
extern char *xcmalloc(uint size);
|
||||
|
||||
extern int strmaxcpy(char *dest, char *source, int len);
|
||||
extern char *xadd_char(char *s, int c, int maxlen);
|
||||
extern uint8 *upstr(uint8 *s);
|
||||
extern void korrpath(char *s);
|
||||
extern void get_path_fn(char *s, char *p, char *fn);
|
||||
|
||||
#define reb(s) deb((s)),leb((s))
|
||||
|
||||
extern void deb(uint8 *s);
|
||||
extern void leb(uint8 *s);
|
||||
|
||||
|
||||
#define add_char(s, c) xadd_char((s), (c), -1)
|
||||
|
||||
extern char *getglobenv(char *option);
|
||||
extern int putglobenv(char *option);
|
||||
|
||||
#ifdef __WATCOMC__
|
||||
/* Borland C compatibility wrappers implemented in tools.c. */
|
||||
extern int getcurdir(int drive, char *directory);
|
||||
extern void setdisk(int drive);
|
||||
#endif
|
||||
|
||||
/* NETCALLS */
|
||||
#define DRIVE_ADD 1
|
||||
#define DRIVE_INSERT 2
|
||||
#define DRIVE_DELETE 3
|
||||
|
||||
typedef struct {
|
||||
uint8 drivenummer; /* 0xff, 0xfe f<EFBFBD>r DOSPATH mit Pfad */
|
||||
uint8 flags;
|
||||
union {
|
||||
struct {
|
||||
char dospath[65];
|
||||
} d;
|
||||
struct fs {
|
||||
uint8 connid;
|
||||
uint8 dhandle;
|
||||
} fs;
|
||||
} u;
|
||||
uint8 drivenummer; /* 0xff=last of list, 0xfe only DOSPATH */
|
||||
uint8 flags; /* 0x80 = local drive */
|
||||
char dospath[65];
|
||||
uint8 connid;
|
||||
uint8 dhandle;
|
||||
} SEARCH_VECTOR_ENTRY;
|
||||
|
||||
typedef SEARCH_VECTOR_ENTRY SEARCH_VECTOR[17];
|
||||
@@ -148,6 +186,12 @@ extern int neterrno;
|
||||
alloc_dir_handle(0x13, (dhandle), (path), (drive), (rights))
|
||||
|
||||
extern int ipx_init(void);
|
||||
extern int logout(void);
|
||||
extern int redir_device_drive(int devicetyp, uint8 *devname, uint8 *remotename);
|
||||
extern int list_redir(int index, int *devicetyp, uint8 *devname, uint8 *remotename);
|
||||
extern int get_drive_info(uint8 drivenumber, uint8 *connid,
|
||||
uint8 *dhandle, uint8 *statusflags);
|
||||
extern int get_fs_name(int connid, char *name);
|
||||
|
||||
extern int alloc_dir_handle(int func, int dhandle, char *path,
|
||||
int driveletter, uint8 *effrights);
|
||||
@@ -168,11 +212,13 @@ extern int ncp_16_02(int dirhandle,
|
||||
uint32 *creattime,
|
||||
uint32 *owner_id);
|
||||
|
||||
extern int ncp_14_46(uint32 *obj_id);
|
||||
extern int ncp_17_02(int module, int debuglevel);
|
||||
extern int ncp_17_14(uint8 *objname, uint16 objtyp, uint8 *password);
|
||||
extern int ncp_17_17(uint8 *key);
|
||||
extern int ncp_17_18(uint8 *cryptkey, uint8 *objname, uint16 objtyp);
|
||||
extern uint32 ncp_17_35(uint8 *objname, uint16 objtyp);
|
||||
extern int ncp_17_36(uint32 obj_id, uint8 *objname, uint16 *objtyp);
|
||||
extern int ncp_17_40(uint8 *objname, uint16 objtyp, uint8 *password,
|
||||
uint8 *newpassword);
|
||||
|
||||
@@ -180,23 +226,35 @@ extern int ncp_17_4b(uint8 *cryptkey, uint8 *objname, uint16 objtyp,
|
||||
int passwx, uint8 *newpassword);
|
||||
|
||||
/* map.c */
|
||||
extern int func_map(int argc, char *argv[]);
|
||||
extern int func_path(int argc, char *argv[]);
|
||||
extern int func_map (int argc, char *argv[], int mode);
|
||||
extern int func_path (int argc, char *argv[], int mode);
|
||||
extern void remove_nwpathes(void);
|
||||
|
||||
/* login.c */
|
||||
extern int func_login(int argc, char *argv[]);
|
||||
extern int func_logout(int argc, char *argv[]);
|
||||
extern int func_passwd(int argc, char *argv[]);
|
||||
extern int func_login (int argc, char *argv[], int mode);
|
||||
extern int func_logout (int argc, char *argv[], int mode);
|
||||
extern int func_passwd (int argc, char *argv[], int mode);
|
||||
extern int func_profile(int argc, char *argv[], int mode);
|
||||
extern int func_cwd (int argc, char *argv[], int mode);
|
||||
extern int func_echo (int argc, char *argv[], int mode);
|
||||
extern int func_exec (int argc, char *argv[], int mode);
|
||||
extern int read_command_file(char *fstr);
|
||||
|
||||
/* slist.c */
|
||||
extern int func_slist(int argc, char *argv[]);
|
||||
extern int func_slist (int argc, char *argv[], int mode);
|
||||
|
||||
/* nwdebug.c */
|
||||
extern int func_debug(int argc, char *argv[]);
|
||||
extern int func_debug (int argc, char *argv[], int mode);
|
||||
|
||||
/* nwtests.c */
|
||||
extern int func_tests(int argc, char *argv[]);
|
||||
|
||||
extern int func_tests (int argc, char *argv[], int mode);
|
||||
|
||||
/* capture.c */
|
||||
extern int func_capture(int argc, char *argv[], int mode);
|
||||
|
||||
|
||||
extern int ncp_17_37(uint32 last_id, uint16 objtyp, uint8 *pattern,
|
||||
BINDERY_OBJECT *target);
|
||||
extern int ncp_17_3d(uint16 objtyp, uint8 *objname, int segment,
|
||||
uint8 *propname, NW_PROPERTY *target);
|
||||
|
||||
|
||||
45
netcall.c
Executable file → Normal file
45
netcall.c
Executable file → Normal file
@@ -49,6 +49,8 @@ int logout(void)
|
||||
|
||||
int redir_device_drive(int devicetyp, uint8 *devname, uint8 *remotename)
|
||||
/* if devicetyp == -1, the redir is canceled */
|
||||
/* devicetyp 3 = printer */
|
||||
/* devicetyp 4 = disk drive */
|
||||
{
|
||||
REGS regs;
|
||||
SREGS sregs;
|
||||
@@ -157,16 +159,15 @@ int get_search_drive_vektor(SEARCH_VECTOR_ENTRY *vec)
|
||||
char *p1 = path;
|
||||
int len = 0;
|
||||
while (*path && *path++ !=';') len++;
|
||||
if (*(p1+1) == ':'
|
||||
&& *p1 >= 'A' && *p1 <= 'Z' &&
|
||||
(len==2 || (len == 3 && *(p1+2) == '.'))) {
|
||||
if (*(p1+1) == ':' && *p1 >= 'A' && *p1 <= 'Z') {
|
||||
v->drivenummer = *p1 - 'A';
|
||||
get_drive_info(v->drivenummer, &(v->u.fs.connid),
|
||||
&(v->u.fs.dhandle), &(v->flags));
|
||||
get_drive_info(v->drivenummer, &(v->connid),
|
||||
&(v->dhandle), &(v->flags));
|
||||
strmaxcpy(v->dospath, p1+2, min(len-2, sizeof(v->dospath)-1));
|
||||
} else {
|
||||
v->flags = 0;
|
||||
v->drivenummer = 0xfe; /* ergibt ? */
|
||||
strmaxcpy(v->u.d.dospath, p1, len);
|
||||
strmaxcpy(v->dospath, p1, min(len, sizeof(v->dospath)-1));
|
||||
}
|
||||
(++v)->drivenummer = 0xff;
|
||||
if (*path == ';') path++;
|
||||
@@ -181,20 +182,29 @@ int set_search_drive_vektor(SEARCH_VECTOR_ENTRY *vec)
|
||||
char *p=path;
|
||||
SEARCH_VECTOR_ENTRY *v;
|
||||
int plen=strlen(path_env_name);
|
||||
int maxcount=16;
|
||||
strcpy(path, path_env_name);
|
||||
path[plen] = '=';
|
||||
path[++plen] = '\0';
|
||||
while ((NULL != (v = vec++)) && v->drivenummer != 0xff){
|
||||
if (p > path) *p++=';';
|
||||
else p+=plen;
|
||||
if (v->drivenummer < 26) {
|
||||
*p++ = (char) v->drivenummer + 'A';
|
||||
*p++ = ':';
|
||||
*p++ = '.';
|
||||
*p = '\0';
|
||||
} else {
|
||||
strcpy(p, v->u.d.dospath);
|
||||
p+= strlen(v->u.d.dospath);
|
||||
|
||||
while (maxcount-- && (NULL != (v = vec++)) && v->drivenummer != 0xff){
|
||||
if (v->drivenummer < 26 || *(v->dospath)) {
|
||||
if (p > path) *p++=';';
|
||||
else p+=plen;
|
||||
if (v->drivenummer < 26) {
|
||||
*p++ = (char) v->drivenummer + 'A';
|
||||
*p++ = ':';
|
||||
if (*v->dospath) {
|
||||
strcpy(p, v->dospath);
|
||||
p+= strlen(v->dospath);
|
||||
} else {
|
||||
*p++='.';
|
||||
*p ='\0';
|
||||
}
|
||||
} else {
|
||||
strcpy(p, v->dospath);
|
||||
p+= strlen(v->dospath);
|
||||
}
|
||||
}
|
||||
}
|
||||
return(putglobenv(path));
|
||||
@@ -231,7 +241,6 @@ int alloc_dir_handle(int func,
|
||||
printf("alloc_dir_handle, path=%s, len=%d, disk=%c\n", path, pathlen, driveletter);
|
||||
*/
|
||||
neterrno = Net_Call(0xE200, &req, &repl);
|
||||
fprintf(stderr, "neterrno=%d\n", neterrno);
|
||||
if (neterrno && neterrno != 0xff) return(-1);
|
||||
|
||||
if (effrights) *effrights = repl.effrights;
|
||||
|
||||
113
nwcrypt.c
Executable file → Normal file
113
nwcrypt.c
Executable file → Normal file
@@ -118,6 +118,7 @@ static buf32 encryptkeys =
|
||||
0x6B,0x0F,0xD5,0x70,0xAE,0xFB,0xAD,0x11,
|
||||
0xF4,0x47,0xDC,0xA7,0xEC,0xCF,0x50,0xC0};
|
||||
|
||||
#include <string.h>
|
||||
#include "nwcrypt.h"
|
||||
static void
|
||||
shuffle1(buf32 temp, unsigned char *target)
|
||||
@@ -210,4 +211,116 @@ nw_encrypt(unsigned char *fra,unsigned char *buf,unsigned char *til)
|
||||
til[s] = k[s] ^ k[15 - s];
|
||||
}
|
||||
|
||||
static unsigned char
|
||||
newshuffle[256] =
|
||||
{
|
||||
0x0f, 0x08, 0x05, 0x07, 0x0c, 0x02, 0x0e, 0x09,
|
||||
0x00, 0x01, 0x06, 0x0d, 0x03, 0x04, 0x0b, 0x0a,
|
||||
0x02, 0x0c, 0x0e, 0x06, 0x0f, 0x00, 0x01, 0x08,
|
||||
0x0d, 0x03, 0x0a, 0x04, 0x09, 0x0b, 0x05, 0x07,
|
||||
|
||||
0x05, 0x02, 0x09, 0x0f, 0x0c, 0x04, 0x0d, 0x00,
|
||||
0x0e, 0x0a, 0x06, 0x08, 0x0b, 0x01, 0x03, 0x07,
|
||||
0x0f, 0x0d, 0x02, 0x06, 0x07, 0x08, 0x05, 0x09,
|
||||
0x00, 0x04, 0x0c, 0x03, 0x01, 0x0a, 0x0b, 0x0e,
|
||||
|
||||
0x05, 0x0e, 0x02, 0x0b, 0x0d, 0x0a, 0x07, 0x00,
|
||||
0x08, 0x06, 0x04, 0x01, 0x0f, 0x0c, 0x03, 0x09,
|
||||
0x08, 0x02, 0x0f, 0x0a, 0x05, 0x09, 0x06, 0x0c,
|
||||
0x00, 0x0b, 0x01, 0x0d, 0x07, 0x03, 0x04, 0x0e,
|
||||
|
||||
0x0e, 0x08, 0x00, 0x09, 0x04, 0x0b, 0x02, 0x07,
|
||||
0x0c, 0x03, 0x0a, 0x05, 0x0d, 0x01, 0x06, 0x0f,
|
||||
0x01, 0x04, 0x08, 0x0a, 0x0d, 0x0b, 0x07, 0x0e,
|
||||
0x05, 0x0f, 0x03, 0x09, 0x00, 0x02, 0x06, 0x0c,
|
||||
|
||||
0x05, 0x03, 0x0c, 0x08, 0x0b, 0x02, 0x0e, 0x0a,
|
||||
0x04, 0x01, 0x0d, 0x00, 0x06, 0x07, 0x0f, 0x09,
|
||||
0x06, 0x00, 0x0b, 0x0e, 0x0d, 0x04, 0x0c, 0x0f,
|
||||
0x07, 0x02, 0x08, 0x0a, 0x01, 0x05, 0x03, 0x09,
|
||||
|
||||
0x0b, 0x05, 0x0a, 0x0e, 0x0f, 0x01, 0x0c, 0x00,
|
||||
0x06, 0x04, 0x02, 0x09, 0x03, 0x0d, 0x07, 0x08,
|
||||
0x07, 0x02, 0x0a, 0x00, 0x0e, 0x08, 0x0f, 0x04,
|
||||
0x0c, 0x0b, 0x09, 0x01, 0x05, 0x0d, 0x03, 0x06,
|
||||
|
||||
0x07, 0x04, 0x0f, 0x09, 0x05, 0x01, 0x0c, 0x0b,
|
||||
0x00, 0x03, 0x08, 0x0e, 0x02, 0x0a, 0x06, 0x0d,
|
||||
0x09, 0x04, 0x08, 0x00, 0x0a, 0x03, 0x01, 0x0c,
|
||||
0x05, 0x0f, 0x07, 0x02, 0x0b, 0x0e, 0x06, 0x0d,
|
||||
|
||||
0x09, 0x05, 0x04, 0x07, 0x0e, 0x08, 0x03, 0x01,
|
||||
0x0d, 0x0b, 0x0c, 0x02, 0x00, 0x0f, 0x06, 0x0a,
|
||||
0x09, 0x0a, 0x0b, 0x0d, 0x05, 0x03, 0x0f, 0x00,
|
||||
0x01, 0x0c, 0x08, 0x07, 0x06, 0x04, 0x0e, 0x02,
|
||||
};
|
||||
|
||||
static const unsigned char final_shuffle[16] = {
|
||||
0x03, 0x0e, 0x0f, 0x02, 0x0d, 0x0c, 0x04, 0x05,
|
||||
0x09, 0x06, 0x00, 0x01, 0x0b, 0x07, 0x0a, 0x08,
|
||||
};
|
||||
|
||||
/*
|
||||
* verschluesseln des neuen Passworts fuer keyed change password
|
||||
* Verwendung:
|
||||
* - Shuffle (aus nwcrypt.c) altes passwort nach old (16 bytes)
|
||||
* - shuffle neues passwort nach new (16 bytes)
|
||||
* - nwpassencrypt (diese Funktion) zweimal aufrufen fuer je 8 bytes:
|
||||
* nwpassencrypt(old+0, new+0, out+0)
|
||||
* nwpassencrypt(old+8, new+8, out+8)
|
||||
* - NCP-Buffer aufbauen:
|
||||
* 2 byte Laenge im Hi-Lo-Format
|
||||
* 1 byte Funktion (0x4b)
|
||||
* 8 byte (nwcrypt Ergebnis analog login/verify password)
|
||||
* 2 byte Objecttype
|
||||
* 1 byte Objectname-Laenge
|
||||
* n byte Objectname
|
||||
* 1 byte (Laenge des eingegebenen neuen Passworts ^ old[0] ^ old[1])&0x7f|0x40
|
||||
* 16 byte (Ergebnis dieser Funktion doppelt aufgerufen, s.o.)
|
||||
*/
|
||||
|
||||
/*
|
||||
* Encrypt the new password for keyed change password
|
||||
* For info on how to use this function, look at ncp_change_login_passwd
|
||||
* in ncplib.c.
|
||||
*/
|
||||
|
||||
void
|
||||
newpassencrypt(unsigned char *old, unsigned char *npwd)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 16; i++) {
|
||||
int di, ax;
|
||||
unsigned char *p, *bx;
|
||||
unsigned char cl, dl, ch;
|
||||
unsigned char copy[8];
|
||||
|
||||
memcpy(copy, npwd, 8);
|
||||
for (di = 0, ax = 0, p = old; di < 8; di++, ax += 0x20, p++)
|
||||
{
|
||||
cl = newshuffle[(((copy[di] ^ *p) >> 4) & 0x0f) + ax + 0x10] << 4;
|
||||
dl = newshuffle[((copy[di] ^ *p) & 0xf) + ax];
|
||||
copy[di] = cl | dl;
|
||||
}
|
||||
|
||||
ch = old[7];
|
||||
for (bx = old + 7; bx > old; bx--)
|
||||
{
|
||||
*bx = ((bx[-1] >> 4) & 0x0f) | ((*bx) << 4);
|
||||
}
|
||||
*old = ((ch >> 4) & 0x0f) | (*old) << 4;
|
||||
|
||||
memset(npwd, 0, 8);
|
||||
|
||||
for (di = 0; di < 16; di++)
|
||||
{
|
||||
if (final_shuffle[di] & 1)
|
||||
ch = ((copy[final_shuffle[di] / 2] >> 4) & 0x0f);
|
||||
else
|
||||
ch = copy[final_shuffle[di] / 2] & 0x0f;
|
||||
npwd[di / 2] |= ((di & 1) ? ch << 4 : ch);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
2
nwcrypt.h
Executable file → Normal file
2
nwcrypt.h
Executable file → Normal file
@@ -5,3 +5,5 @@ extern void shuffle(unsigned char *lon,
|
||||
|
||||
extern void nw_encrypt(unsigned char *fra,
|
||||
unsigned char *buf,unsigned char *til);
|
||||
|
||||
extern void newpassencrypt(unsigned char *old, unsigned char *npwd);
|
||||
|
||||
11
nwdebug.c
Executable file → Normal file
11
nwdebug.c
Executable file → Normal file
@@ -1,4 +1,4 @@
|
||||
/* nwdebug.c 04-Apr-96 */
|
||||
/* nwdebug.c 21-May-96 */
|
||||
|
||||
/****************************************************************
|
||||
* (C)opyright (C) 1993,1996 Martin Stover, Marburg, Germany *
|
||||
@@ -13,7 +13,7 @@ static int usage(void)
|
||||
return(-1);
|
||||
}
|
||||
|
||||
int func_debug(int argc, char *argv[])
|
||||
int func_debug(int argc, char *argv[], int mode)
|
||||
{
|
||||
uint8 s[200];
|
||||
int module;
|
||||
@@ -29,8 +29,11 @@ int func_debug(int argc, char *argv[])
|
||||
level = atoi(argv[2]);
|
||||
if (level < 0 || level > 99) return(usage());
|
||||
result = ncp_17_02(module, level);
|
||||
if (result < 0) fprintf(stderr, "set debug failed\n");
|
||||
else fprintf(stdout, "Debug level for %s changed from %d to %d\n",
|
||||
if (result < 0) {
|
||||
fprintf(stderr, "set debug failed\n");
|
||||
fprintf(stderr, "perhaps you did not enable FUNC_17_02_IS_DEBUG\n");
|
||||
fprintf(stderr, "in mars_nwe/config.h ?!");
|
||||
} else fprintf(stdout, "Debug level for %s changed from %d to %d\n",
|
||||
s, result, level);
|
||||
return(result < 0 ? result : 0);
|
||||
}
|
||||
|
||||
6
nwtests.c
Executable file → Normal file
6
nwtests.c
Executable file → Normal file
@@ -1,4 +1,4 @@
|
||||
/* nwtests.c 14-Mar-96 */
|
||||
/* nwtests.c 20-May-96 */
|
||||
|
||||
/****************************************************************
|
||||
* (C)opyright (C) 1993,1996 Martin Stover, Marburg, Germany *
|
||||
@@ -8,12 +8,10 @@
|
||||
|
||||
static int usage(void)
|
||||
{
|
||||
fprintf(stderr, "usage:\t%s NCPSERV|NWCONN level\n", funcname);
|
||||
fprintf(stderr, "\tlevel=0 .. 99\n" );
|
||||
return(-1);
|
||||
}
|
||||
|
||||
int func_tests(int argc, char *argv[])
|
||||
int func_tests(int argc, char *argv[], int mode)
|
||||
{
|
||||
int level = ncp_17_02(NWCONN, 6);
|
||||
int dirhandle = alloc_temp_dir_handle(0, "SYS:", 'd', NULL);
|
||||
|
||||
BIN
opt/logo-small.png
Normal file
BIN
opt/logo-small.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 380 KiB |
BIN
opt/logo.png
Normal file
BIN
opt/logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.1 MiB |
68
slist.c
Executable file → Normal file
68
slist.c
Executable file → Normal file
@@ -1,15 +1,63 @@
|
||||
/* map.c 12-Jan-96 */
|
||||
|
||||
/****************************************************************
|
||||
* (C)opyright (C) 1993,1996 Martin Stover, Marburg, Germany *
|
||||
****************************************************************/
|
||||
/* slist.c - list known NetWare file servers, DOS mars-dosutils version */
|
||||
|
||||
#include "net.h"
|
||||
|
||||
int func_slist(int argc, char *argv[])
|
||||
static int usage(void)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
fprintf(stderr, "usage:\t%s [pattern]\n", funcname);
|
||||
return(-1);
|
||||
}
|
||||
|
||||
static void print_net_node(uint8 *addr)
|
||||
{
|
||||
fprintf(stdout, "%08lX %02X%02X%02X%02X%02X%02X",
|
||||
(unsigned long)GET_BE32(addr),
|
||||
addr[4], addr[5], addr[6], addr[7], addr[8], addr[9]);
|
||||
}
|
||||
|
||||
int func_slist(int argc, char *argv[], int mode)
|
||||
{
|
||||
BINDERY_OBJECT obj;
|
||||
uint32 last_id = MAX_U32;
|
||||
uint8 pattern[50];
|
||||
int found = 0;
|
||||
int result;
|
||||
|
||||
(void)mode;
|
||||
|
||||
if (argc > 2) return(usage());
|
||||
|
||||
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");
|
||||
|
||||
while ((result = ncp_17_37(last_id, NCP_BINDERY_FSERVER,
|
||||
pattern, &obj)) == 0) {
|
||||
NW_PROPERTY prop;
|
||||
|
||||
found = 1;
|
||||
last_id = obj.object_id;
|
||||
|
||||
fprintf(stdout, "%-52s", obj.object_name);
|
||||
|
||||
if (!ncp_17_3d(NCP_BINDERY_FSERVER, obj.object_name,
|
||||
1, "NET_ADDRESS", &prop)) {
|
||||
print_net_node(prop.value);
|
||||
}
|
||||
|
||||
fprintf(stdout, "\n");
|
||||
|
||||
if (last_id == MAX_U32) break;
|
||||
}
|
||||
|
||||
if (!found)
|
||||
fprintf(stdout, "No servers found\n");
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
190
teste.c
Executable file → Normal file
190
teste.c
Executable file → Normal file
@@ -1,95 +1,95 @@
|
||||
int main()
|
||||
{
|
||||
char *fn="F.$LN";
|
||||
char *string="ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyz";
|
||||
int result;
|
||||
struct stat stbuff;
|
||||
long offset;
|
||||
char buff[1024];
|
||||
char readbuff[500];
|
||||
int j;
|
||||
int fd=creatnew(fn, S_IREAD |S_IWRITE);
|
||||
if (fd > -1) {
|
||||
printf("Konnte Date erzeugen\n");
|
||||
close(fd);
|
||||
} else {
|
||||
printf("Konnte Datei nicht erzeugen\n");
|
||||
}
|
||||
fd = open(fn, O_RDWR|O_CREAT|O_TRUNC|O_DENYNONE, 0666);
|
||||
memset(buff, 0, sizeof(buff) );
|
||||
strcpy(buff, string);
|
||||
write(fd, buff, strlen(buff));
|
||||
close(fd);
|
||||
_chmod(fn, 1, _chmod(fn, 0) | 0x80 );
|
||||
stat(fn, &stbuff);
|
||||
printf("Filesize <20>ber stat =%ld\n", stbuff.st_size);
|
||||
fd = open(fn, O_RDWR | O_BINARY |O_DENYNONE);
|
||||
|
||||
offset = lseek(fd, 0L, SEEK_END);
|
||||
printf("Filesize <20>ber lseek =%ld\n", offset);
|
||||
write(fd, buff, strlen(buff));
|
||||
|
||||
lseek(fd, 0L, SEEK_SET);
|
||||
for (j=0; j < strlen(buff)*2; j++){
|
||||
read(fd, readbuff, 1);
|
||||
printf("BUFF = %c\n", readbuff[0]);
|
||||
}
|
||||
lseek(fd, 1L, SEEK_SET);
|
||||
for (j = 0; j < 20; j++){
|
||||
write(fd, buff+j, 1);
|
||||
}
|
||||
|
||||
for (j=0; j <60; j++){
|
||||
lseek(fd, (long) j, SEEK_SET);
|
||||
read(fd, readbuff, 2);
|
||||
printf("BUFF = %c, %c \n", readbuff[0], readbuff[1]);
|
||||
}
|
||||
|
||||
lseek(fd, 10L, SEEK_SET);
|
||||
read(fd, buff, 1);
|
||||
printf("BUFF[10] = %c\n", buff[0]);
|
||||
result=lock(fd, 100L, 1L);
|
||||
printf("lock result = %d\n", result);
|
||||
result=unlock(fd, 100L, 1L);
|
||||
printf("unlock result = %d\n", result);
|
||||
close(fd);
|
||||
|
||||
fd = open(fn, O_BINARY|O_RDWR|O_CREAT|O_TRUNC|O_DENYNONE, 0666);
|
||||
if (fd > -1) {
|
||||
int bufflen;
|
||||
strcpy(buff, "d:..\\marlib\\c0l.obj+");
|
||||
strcat(buff, "\r\n");
|
||||
strcat(buff, "x");
|
||||
strcat(buff, "\r\n");
|
||||
strcat(buff, "x");
|
||||
strcat(buff, "\r\n");
|
||||
strcat(buff, "/c/x");
|
||||
strcat(buff, "\r\n");
|
||||
strcat(buff, "d:..\\marlib\\EMU.LIB+");
|
||||
strcat(buff, "\r\n");
|
||||
strcat(buff, "d:..\\marlib\\mathl.lib+");
|
||||
strcat(buff, "\r\n");
|
||||
strcat(buff, "d:..\\marlib\\cl.lib");
|
||||
bufflen=strlen(buff);
|
||||
printf("bufflen = %d, buff=%s\n", bufflen, buff);
|
||||
write(fd, buff, bufflen);
|
||||
close(fd);
|
||||
fd = open(fn, O_TEXT|O_RDONLY);
|
||||
if (fd > -1) {
|
||||
char *p=readbuff;
|
||||
int anz = 0;
|
||||
memset(readbuff, 0, sizeof(readbuff) );
|
||||
while (read(fd, p, 1) == 1){
|
||||
anz++;
|
||||
p++;
|
||||
}
|
||||
printf("read = %d, buff=%s\n", anz, readbuff);
|
||||
close(fd);
|
||||
}
|
||||
}
|
||||
/*
|
||||
result = detach(1);
|
||||
printf("Detach result=0x%x", result);
|
||||
*/
|
||||
return(0);
|
||||
}
|
||||
int main()
|
||||
{
|
||||
char *fn="F.$LN";
|
||||
char *string="ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyz";
|
||||
int result;
|
||||
struct stat stbuff;
|
||||
long offset;
|
||||
char buff[1024];
|
||||
char readbuff[500];
|
||||
int j;
|
||||
int fd=creatnew(fn, S_IREAD |S_IWRITE);
|
||||
if (fd > -1) {
|
||||
printf("Konnte Date erzeugen\n");
|
||||
close(fd);
|
||||
} else {
|
||||
printf("Konnte Datei nicht erzeugen\n");
|
||||
}
|
||||
fd = open(fn, O_RDWR|O_CREAT|O_TRUNC|O_DENYNONE, 0666);
|
||||
memset(buff, 0, sizeof(buff) );
|
||||
strcpy(buff, string);
|
||||
write(fd, buff, strlen(buff));
|
||||
close(fd);
|
||||
_chmod(fn, 1, _chmod(fn, 0) | 0x80 );
|
||||
stat(fn, &stbuff);
|
||||
printf("Filesize <20>ber stat =%ld\n", stbuff.st_size);
|
||||
fd = open(fn, O_RDWR | O_BINARY |O_DENYNONE);
|
||||
|
||||
offset = lseek(fd, 0L, SEEK_END);
|
||||
printf("Filesize <20>ber lseek =%ld\n", offset);
|
||||
write(fd, buff, strlen(buff));
|
||||
|
||||
lseek(fd, 0L, SEEK_SET);
|
||||
for (j=0; j < strlen(buff)*2; j++){
|
||||
read(fd, readbuff, 1);
|
||||
printf("BUFF = %c\n", readbuff[0]);
|
||||
}
|
||||
lseek(fd, 1L, SEEK_SET);
|
||||
for (j = 0; j < 20; j++){
|
||||
write(fd, buff+j, 1);
|
||||
}
|
||||
|
||||
for (j=0; j <60; j++){
|
||||
lseek(fd, (long) j, SEEK_SET);
|
||||
read(fd, readbuff, 2);
|
||||
printf("BUFF = %c, %c \n", readbuff[0], readbuff[1]);
|
||||
}
|
||||
|
||||
lseek(fd, 10L, SEEK_SET);
|
||||
read(fd, buff, 1);
|
||||
printf("BUFF[10] = %c\n", buff[0]);
|
||||
result=lock(fd, 100L, 1L);
|
||||
printf("lock result = %d\n", result);
|
||||
result=unlock(fd, 100L, 1L);
|
||||
printf("unlock result = %d\n", result);
|
||||
close(fd);
|
||||
|
||||
fd = open(fn, O_BINARY|O_RDWR|O_CREAT|O_TRUNC|O_DENYNONE, 0666);
|
||||
if (fd > -1) {
|
||||
int bufflen;
|
||||
strcpy(buff, "d:..\\marlib\\c0l.obj+");
|
||||
strcat(buff, "\r\n");
|
||||
strcat(buff, "x");
|
||||
strcat(buff, "\r\n");
|
||||
strcat(buff, "x");
|
||||
strcat(buff, "\r\n");
|
||||
strcat(buff, "/c/x");
|
||||
strcat(buff, "\r\n");
|
||||
strcat(buff, "d:..\\marlib\\EMU.LIB+");
|
||||
strcat(buff, "\r\n");
|
||||
strcat(buff, "d:..\\marlib\\mathl.lib+");
|
||||
strcat(buff, "\r\n");
|
||||
strcat(buff, "d:..\\marlib\\cl.lib");
|
||||
bufflen=strlen(buff);
|
||||
printf("bufflen = %d, buff=%s\n", bufflen, buff);
|
||||
write(fd, buff, bufflen);
|
||||
close(fd);
|
||||
fd = open(fn, O_TEXT|O_RDONLY);
|
||||
if (fd > -1) {
|
||||
char *p=readbuff;
|
||||
int anz = 0;
|
||||
memset(readbuff, 0, sizeof(readbuff) );
|
||||
while (read(fd, p, 1) == 1){
|
||||
anz++;
|
||||
p++;
|
||||
}
|
||||
printf("read = %d, buff=%s\n", anz, readbuff);
|
||||
close(fd);
|
||||
}
|
||||
}
|
||||
/*
|
||||
result = detach(1);
|
||||
printf("Detach result=0x%x", result);
|
||||
*/
|
||||
return(0);
|
||||
}
|
||||
|
||||
140
tools.c
Executable file → Normal file
140
tools.c
Executable file → Normal file
@@ -5,21 +5,66 @@
|
||||
* (C)opyright (C) 1993,1996 Martin Stover, Marburg, Germany *
|
||||
****************************************************************/
|
||||
|
||||
|
||||
#ifdef __WATCOMC__
|
||||
/*
|
||||
* Borland C compatibility wrappers used by the historical mars-nwe DOS tools.
|
||||
* Open Watcom does not provide getcurdir()/setdisk() under these Borland names.
|
||||
*/
|
||||
int getcurdir(int drive, char *directory)
|
||||
{
|
||||
REGS regs;
|
||||
SREGS sregs;
|
||||
|
||||
regs.h.ah = 0x47; /* DOS: get current directory */
|
||||
regs.h.dl = (unsigned char)drive; /* 0=current, 1=A:, 2=B:, ... */
|
||||
sregs.ds = FP_SEG(directory);
|
||||
regs.x.si = FP_OFF(directory);
|
||||
intdosx(®s, ®s, &sregs);
|
||||
return(regs.x.cflag ? -1 : 0);
|
||||
}
|
||||
|
||||
void setdisk(int drive)
|
||||
{
|
||||
REGS regs;
|
||||
|
||||
regs.h.ah = 0x0e; /* DOS: select default drive */
|
||||
regs.h.dl = (unsigned char)drive; /* 0=A:, 1=B:, ... */
|
||||
intdos(®s, ®s);
|
||||
}
|
||||
#endif
|
||||
|
||||
int key_pressed(void)
|
||||
{
|
||||
#ifdef __WATCOMC__
|
||||
/*
|
||||
* Open Watcom's WORDREGS does not expose x.flags. The old Borland
|
||||
* code checked the BIOS INT 16h ZF bit after AH=01h. Open Watcom's
|
||||
* bios.h provides _bios_keybrd(), which wraps the same BIOS keyboard
|
||||
* service and returns 0 when no key is waiting.
|
||||
*/
|
||||
return(_bios_keybrd(_KEYBRD_READY) != 0);
|
||||
#else
|
||||
REGS regsin, regsout;
|
||||
regsin.h.ah = 0x01; /* read key-press */
|
||||
int86(0x16, ®sin, ®sout);
|
||||
return((regsout.x.flags & 0x40) ? 0 : 1); /* zeroflag != 0 */
|
||||
#endif
|
||||
}
|
||||
|
||||
void clear_kb(void)
|
||||
{
|
||||
#ifdef __WATCOMC__
|
||||
while (key_pressed()) {
|
||||
(void)_bios_keybrd(_KEYBRD_READ);
|
||||
}
|
||||
#else
|
||||
REGS regsin, regsout;
|
||||
while (key_pressed()) { /* zeroflag != 0 */
|
||||
regsin.h.ah = 0x00; /* read key-press */
|
||||
int86(0x16, ®sin, ®sout);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
int ask_user(char *p, ...)
|
||||
@@ -48,6 +93,31 @@ int ask_user(char *p, ...)
|
||||
return(flag);
|
||||
}
|
||||
|
||||
char *xmalloc(uint size)
|
||||
{
|
||||
char *p = (size) ? (char *)malloc(size) : (char*)NULL;
|
||||
if (p == (char *)NULL && size){
|
||||
fprintf(stderr, "not enough core, need %d Bytes\n", size);
|
||||
exit(1);
|
||||
}
|
||||
return(p);
|
||||
}
|
||||
|
||||
char *xcmalloc(uint size)
|
||||
{
|
||||
char *p = xmalloc(size);
|
||||
if (size) memset(p, 0, size);
|
||||
return(p);
|
||||
}
|
||||
|
||||
void x_x_xfree(char **p)
|
||||
{
|
||||
if (*p != (char *)NULL){
|
||||
free(*p);
|
||||
*p = (char*)NULL;
|
||||
}
|
||||
}
|
||||
|
||||
int strmaxcpy(char *dest, char *source, int len)
|
||||
/* copied max. len chars + '\0' Byte */
|
||||
{
|
||||
@@ -69,6 +139,18 @@ char *xadd_char(char *s, int c, int maxlen)
|
||||
return(s);
|
||||
}
|
||||
|
||||
static uint8 down_char(uint8 ch)
|
||||
{
|
||||
if (ch > 64 && ch < 91) return(ch + 32);
|
||||
switch(ch){
|
||||
case 142: ch = 132; break;
|
||||
case 153: ch = 148; break;
|
||||
case 154: ch = 129; break;
|
||||
default :break;
|
||||
}
|
||||
return(ch);
|
||||
}
|
||||
|
||||
static uint8 up_char(uint8 ch)
|
||||
{
|
||||
if (ch > 96 && ch < 123) return(ch - 32);
|
||||
@@ -88,6 +170,64 @@ uint8 *upstr(uint8 *s)
|
||||
return(s);
|
||||
}
|
||||
|
||||
void deb(uint8 *s)
|
||||
{
|
||||
if (!s || !*s) return;
|
||||
else {
|
||||
uint8 *p = s + strlen(s);
|
||||
while (p > s && (*--p==32 || *p==9));;
|
||||
if (*p==32 || *p==9) *p='\0';
|
||||
else *(p+1) = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
void leb(uint8 *s)
|
||||
{
|
||||
if (!s || !*s || (*s != 32 && *s != 9)) return;
|
||||
else {
|
||||
uint8 *p = s;
|
||||
for (;*p && *p!=32 && *p!=9;p++);;
|
||||
strcpy(s, p);
|
||||
}
|
||||
}
|
||||
|
||||
void korrpath(char *s)
|
||||
{
|
||||
if (!s) return;
|
||||
for (;*s;s++) {
|
||||
if (*s=='\\') *s='/';
|
||||
else *s=down_char(*s);
|
||||
}
|
||||
}
|
||||
|
||||
void get_path_fn(char *s, char *p, char *fn)
|
||||
{
|
||||
int j= strlen(s);
|
||||
if (p != (char *)NULL) p[0] = 0;
|
||||
if (fn != (char*) NULL) fn[0] = 0;
|
||||
if (!j) return;
|
||||
if (s[0] == '.' && (s[1] == 0 || (s[1] == '.' && s[2] == 0) ) ) {
|
||||
if (p != (char *)NULL) {
|
||||
strcpy(p, s);
|
||||
strcat(p, "/");
|
||||
}
|
||||
if (fn != (char *)NULL) fn[0] = 0;
|
||||
return;
|
||||
}
|
||||
while (j--){
|
||||
if ((s[j] == '/') || (s[j] == ':') ) {
|
||||
if (fn != (char *)NULL) strcpy(fn, s+j+1);
|
||||
if (p != (char *)NULL) {
|
||||
strncpy(p, s, j+1);
|
||||
p[j+1] = 0;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (fn != (char *)NULL) strcpy(fn, s); /* no path */
|
||||
}
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint16 adr1;
|
||||
uint16 adr2;
|
||||
|
||||
Reference in New Issue
Block a user