Commit 8a3f55c4 authored by Robert Sprowson's avatar Robert Sprowson
Browse files

Removed verbose mode

With LanManFS in ROM it's not actually possible to enable verbose mode, since it relies on command arguments being passed to it on initialisation. Since RMREINIT doesn't allow that you can't ever pass '-v'. Even the RAM loaded case isn't that useful, since the verbose text is output via printf() which doesn't appear in the desktop (with OmniClient).
Swap the few uses of verbose mode to route via DebugLib instead, controlled via the 'DEBUG' predefine.
Also
  Makefile ammended so debug version has a rule to make the resources area.
Built, but not tested.

Version 2.41. Tagged as 'LanManFS-2_41'
parent e3559214
......@@ -39,7 +39,7 @@ endif
include CModule
# Static dependencies
MyResObj.o: LocalRes:ROM.Sprites ${MERGEDMSGS} ${DIRS}
o.MyResObj od.MyResObj: LocalRes:ROM.Sprites ${MERGEDMSGS} ${DIRS}
${RESGEN} ${RES_AREA} $@ ${MERGEDMSGS} ${RES_PATH}.Messages LocalRes:ROM.Sprites ${RES_PATH}.Sprites
# Dynamic dependencies:
/* (2.40)
/* (2.41)
*
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1.
*
*/
#define Module_MajorVersion_CMHG 2.40
#define Module_MajorVersion_CMHG 2.41
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 03 Oct 2013
#define Module_MajorVersion "2.40"
#define Module_Version 240
#define Module_MajorVersion "2.41"
#define Module_Version 241
#define Module_MinorVersion ""
#define Module_Date "03 Oct 2013"
......@@ -18,6 +18,6 @@
#define Module_ComponentName "LanManFS"
#define Module_ComponentPath "castle/RiscOS/Sources/Networking/Omni/Protocols/LanManFS"
#define Module_FullVersion "2.40"
#define Module_HelpVersion "2.40 (03 Oct 2013)"
#define Module_LibraryVersionInfo "2:40"
#define Module_FullVersion "2.41"
#define Module_HelpVersion "2.41 (03 Oct 2013)"
#define Module_LibraryVersionInfo "2:41"
/* Copyright 1998 Acorn Computers Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
*
* C.LMTest -- Test of LanMan SWIs
*
* 26/Apr/96
*
* Copyright (C) Ian Harvey for Ant Limited, 1996
*
*/
#include <stdio.h>
#include "swis.h"
#include "os.h"
/*
This demonstates the use of the two SWIs provided by LanManFS v1.68,
LanMan_NameOp and LanMan_Transact. These are as follows:
*/
#define LanMan_SWI_base (XOS_Bit|0x49240)
#define SWI_LanMan_NameOp (LanMan_SWI_base + 2)
#define SWI_LanMan_Transact (LanMan_SWI_base + 3)
/*
* LanMan_NameOp is used for retrieving the names of machines and other
* items on the network. It is called with:
*
* R0 = reason code, 0-3
* R1 = pointer to name in, or NULL (use depends on reason code)
* R2 = pointer to a 16-byte buffer which is to receive the name
* returned from the call. Network names are up to 15 characters,
* (generally in upper-case, although no LanManFS calls are case
* sensitive), plus a terminating zero.
*
* If there is no error, all registers are unchanged. Else, V is set
* and R0 points to an error block.
*
* The reason codes are as follows:
*
* R0 = 0: Get local machine name
* R1 is ignored. The network name of this machine is copied to the
* buffer at R2.
*
* R0 = 1: Get logged-on workgroup/domain name
* R1 is ignored. The name of the workgroup or domain which was set
* with the *LMLOGON command is copied to the buffer at R2.
*
* R0 = 2: Get master browser for workgroup
* R1 is the address of a ASCIIZ string containing a workgroup name.
* The master browser for that workgroup (a server which maintains
* an up-to-date list of all the other servers in the group) is
* located, and its name is copied to the buffer at R2. If R1 is NULL
* on entry, the currently selected workgroup name (as set with *LMLogon)
* is used. You can use this call to find the name of a server from which
* to get lists of other servers.
*
* R0 = 3: Get domain controller
* R1 is the address of a ASCIIZ string containing a domain name.
* The domain controller for that domain is located, and its name is
* copied to the buffer at R2. If R1 is NULL on entry, the currently
* selected workgroup or domain name (as set with *LMLogon) is used.
*
* If the master browser or domain controller can't be found, the error
* 'Can't find given server' is returned.
*/
#define NAMEOP_GETLOCAL 0
#define NAMEOP_GETWG 1
#define NAMEOP_GETBROWSER 2
#define NAMEOP_GETDC 3
/*
* LanMan_Transact
*
* This is used to execute remote-procedure-calls on a network server.
* Typically, the server will be able to perform all the calls in
* the Microsoft's Lan Manager Programmer's Reference via this mechanism.
* Although MS document the C interface to these calls, they do not
* make available information as to how the calls are converted to
* the network parameter format used by the Transact call. Thus, a
* certain amount of analysis of network packets and other black arts
* is required.
*
* Anyway, all calls made via the Transact interface send information
* to the server at the start of the call, and retrieve information back
* afterwards. The information sent and returned is divided into
* Parameters (typically 16 or 32-bit integer values) and Data (typically
* structures, strings, etc) - exactly what each of these are varies from
* call to call and is sometimes A Mystery. Making a call consists of
* assembling the parameters and data into a buffer, then setting up a
* structure containing the addresses and lengths of these, together with
* addresses and lengths for where to put the results.
*
* The parameters to LanMan_Transact are as follows:
*
* R0 = ASCIIZ name of server on which to make the call (this is not
* case sensitive; only the first 15 characters of this name are
* significant).
*
* R1 = Transaction name (identifies the process on the server which is
* servicing the call). For Lan Manager API transactions, this
* should point to the ASCIIZ string "\PIPE\LANMAN".
*
* R2 = Pointer to parameters-and-results structure. This is a 10-word
* structure as follows:
*
* [R2+0]: Length of parameters to be sent to server
* [R2+4]: Address of parameters to be sent to server
* [R2+8]: Length of data to be sent to server
* [R2+12]: Address of data to be sent to server
*
* [R2+16]: Maximum length of parameters to be returned from server
* [R2+20]: Address of buffer to receive returned parameters
* [R2+24]: this will be filled in (by LanMan_Transact) with the actual
* length of parameters returned from the server.
* [R2+28]: Maximum length of data to be returned from server
* [R2+32]: Address of buffer to receive returned data
* [R2+36]: actual length of data returned from the server (filled in by
* LanMan_Transact).
*
* Note that the 'returned' parameters and data can occupy the same
* memory buffer as the 'sent' ones, if required. If any 'length'
* field is zero, its associated pointer need not be defined.
*
* The SWI may return a variety of errors. In particular, if LanManFS
* is not currently connected to the given server, it will have to
* establish a connection using the user ID and password set with
* *LMLogon. If these are not valid, you may get an 'Access denied'
* error.
*/
typedef unsigned char uchar;
struct TransactParms
{
int parms_in_len; /* Params & data sent to server */
uchar *parms_in;
int data_in_len;
uchar *data_in;
int parms_out_maxlen; /* Results & data returned from server */
uchar *parms_out;
int parms_out_len; /* Filled in by Transact SWI */
int data_out_maxlen;
uchar *data_out;
int data_out_len; /* Filled in by Transact SWI */
};
/* ----------------------------------- */
#define MAX_TRANSACT_SIZE 4096
uchar TransactBuf[MAX_TRANSACT_SIZE];
struct TransactParms TP;
/* ------- */
static void addword ( int value )
{
uchar *p = TP.parms_in + TP.parms_in_len;
*p++ = (value & 0xFF);
*p++ = (value >> 8 );
TP.parms_in_len += 2;
}
/* ---------- */
static void addlong ( int value )
{
uchar *p = TP.parms_in + TP.parms_in_len;
*p++ = (value & 0xFF);
*p++ = (value >> 8 );
*p++ = (value >> 16 );
*p++ = (value >> 24 );
TP.parms_in_len += 4;
}
/* ---------- */
static void addstring ( char *str )
{
uchar *p = TP.parms_in + TP.parms_in_len;
int c;
do
{
*p++ = c = *str++;
TP.parms_in_len++;
}
while (c != 0);
}
/* ----------------- */
static int getword ( int offset )
{
uchar *p = TP.parms_out + offset;
return ( p[0] + (p[1] << 8));
}
/* ----------------- */
static int getlong ( int offset )
{
uchar *p = TP.parms_out + offset;
return ( p[0] + (p[1] << 8) + (p[2] << 16)+ (p[3] << 24));
}
/* ------------------- */
static uchar *getstring ( uchar *p )
{
int ptr_val;
/* String pointers are kept in a slightly odd format in the
returned data. This code may be slightly inaccurate.
*/
ptr_val = p[0] + (p[1] << 8); /* Value returned from server */
/* ptr_val is almost an offset into the returned data block -
conceptually it's as though a data buffer the size of
data_out_maxlen was allocated by the server. The normal data
returned by the call is put at the start of the buffer, and
all the strings are put right at the end. The string pointers
given are the offsets from the start of the buffer. Then, when
the data is actually sent, all the unused bytes in the middle
of the buffer are chopped out */
ptr_val -= TP.data_out_maxlen - TP.data_out_len; /* Adjust it */
if ( ptr_val <= 0 || ptr_val >= TP.data_out_len )
return (uchar *)""; /* Null string */
return TP.data_out + ptr_val;
}
/* -------------- */
char * ShareTypes[4] = { "Disk", "Printer", "COM port", "IPC" };
/* -------------- */
int main ( int argc, char *argv[] )
{
char namebuf[16];
os_error *p;
int n;
uchar *pb;
(void) argc;
(void) argv;
/* Display some names */
p = _swix(SWI_LanMan_NameOp, _INR(0,2), NAMEOP_GETLOCAL, NULL, (int)namebuf);
if ( p != NULL )
printf("Couldn't find local machine name - %s\n", p->errmess );
else
printf("Local machine name %s\n", namebuf );
p = _swix(SWI_LanMan_NameOp, _INR(0,2), NAMEOP_GETWG, NULL, (int)namebuf);
if ( p != NULL )
printf("Couldn't find workgroup name - %s\n", p->errmess );
else
printf("Workgroup/domain %s\n", namebuf );
p = _swix(SWI_LanMan_NameOp, _INR(0,2), NAMEOP_GETDC, NULL, (int)namebuf);
if ( p != NULL )
printf("Couldn't find local machine name - %s\n", p->errmess );
else
printf("Domain controller %s\n", namebuf );
p = _swix(SWI_LanMan_NameOp, _INR(0,2), NAMEOP_GETBROWSER, NULL, (int)namebuf);
if ( p != NULL )
{
printf("Couldn't find master browser - %s\n", p->errmess );
return 0;
}
printf("Master browser %s\n", namebuf );
/* Now do a Transact call */
TP.parms_in = TransactBuf;
TP.parms_in_len = 0;
TP.data_in = TransactBuf;
TP.data_in_len = 0;
TP.parms_out = TransactBuf;
TP.parms_out_maxlen = 8; /* Size of data returned from this call */
TP.data_out = TP.parms_out + TP.parms_out_maxlen;
TP.data_out_maxlen = MAX_TRANSACT_SIZE - TP.parms_out_maxlen;
addword ( 0x0000 ); /* Reason code for 'NetShareEnum' */
addstring ( "WrLeh" ); /* Sent parameters format */
addstring ( "B13BWz" ); /* Return parameters format */
addword ( 0x0001 ); /* 'sLevel' detail-level parameter */
addword ( TP.data_out_maxlen ); /* Max data size returned */
/* Do the call. The master browser name is in namebuf already */
printf("\n\nFinding share information for '%s'\n", namebuf );
p = _swix(SWI_LanMan_Transact, _INR(0,2), (int) namebuf, (int) "\\PIPE\\LANMAN", (int)&TP);
if ( p != NULL )
{
printf("Error from Transact SWI - %s\n", p->errmess );
return 0;
}
/* Check returned status */
if ( TP.parms_out_len < 8 )
{
printf("Server returned insufficient result bytes\n");
return 0;
}
n = getword ( 0 ); /* Return code from call */
if ( n != 0 )
{
printf("Server gave error code %Xh\n", n );
return 0;
}
n = getword ( 4 ); /* Number of returned records */
if ( n*20 > TP.data_out_len )
n = TP.data_out_len / 20;
/* Display returned records */
printf("%d share(s) available:\n", n);
pb = TP.data_out;
while ( n-- > 0 )
{
/* pb points to a share_info_1 structure (see Lan Manager programmer's
reference). The first 13 bytes are an ASCIIZ share name string.
Bytes 14..15 contains a share type field in the range 0..3. Bytes
16..19 are a pointer to a share comment */
printf("%-12s %-8s %s\n", pb, ShareTypes[pb[14] & 3], getstring(pb+16) );
pb += 20;
}
return 0;
}
......@@ -498,12 +498,6 @@ static void SetDefaultVars ( void )
char *name;
char fs_name [ FSERVER_LEN+1 ];
#ifdef DEBUG
LM_Vars.verbose = true; /* DEBUG NAS */
#else
LM_Vars.verbose = false;
#endif
LM_Vars.initialised = LMInitState_Uninitialised;
LM_Vars.namemode = NM_FIRSTCAPS;
......@@ -584,6 +578,7 @@ static _kernel_oserror *Cmd_LMLogon( const char *args )
/* --------------------- */
#ifdef DEBUG
static char *LM_Status(void)
{
switch (LM_Vars.initialised) {
......@@ -594,6 +589,7 @@ static char *LM_Status(void)
default: return "Dead";
}
}
#endif
/* --------------------- */
......@@ -601,11 +597,10 @@ static _kernel_oserror *Cmd_LMInfo ( const char *args )
{
(void) args;
Omni_Debug();
if (LM_Vars.verbose)
{
printf("Status: %s\n", LM_Status());
Stat_Show();
}
#ifdef DEBUG
debug1("Status: %s\n", LM_Status());
Stat_Show();
#endif
return NULL;
}
......@@ -966,10 +961,6 @@ static err_t ProcessCmdLine ( const char *_line )
line = copy_space ( LM_Vars.drivername, line+1, NAME_LIMIT );
break;
case 'V': /* -v enable verbose mode */
LM_Vars.verbose = true;
break;
case 'N': /* -n disable network browsing */
Lgn_Logoff();
break;
......@@ -1009,9 +1000,7 @@ void LM_Boot(void)
char fs_name [ FSERVER_LEN+1 ];
if (LM_Vars.initialised < LMInitState_FullyInited) {
if (LM_Vars.verbose) {
printf("LanManFS: LM_Boot called, but cannot comply: %s\n", LM_Status());
}
debug1("LM_Boot called, but cannot comply: %s\n", LM_Status());
LM_Vars.initialised = LMInitState_Boot;
return;
}
......@@ -1020,9 +1009,7 @@ void LM_Boot(void)
if ( strlen(fs_name) == 0 )
{
if (LM_Vars.verbose) {
printf("Auto-boot: server name has not been set...\n");
}
debug0("Auto-boot: server name has not been set...\n");
return;
}
......@@ -1033,8 +1020,7 @@ void LM_Boot(void)
if ( serv_name == NULL )
serv_name = fs_name;
if ( LM_Vars.verbose )
printf(" Server name '%s'\n", serv_name );
debug1( "Server name '%s'\n", serv_name );
/* Wash'n'go... */
......@@ -1155,8 +1141,7 @@ static _kernel_oserror *LM_init_phase_2(void)
want_boot = (LM_Vars.initialised == LMInitState_Boot);
if (LM_Vars.verbose)
printf("Initialising...\n");
debug0("Initialising...\n");
if (!FS_Init() || !SMB_Init()) goto initfailed;
shutdowns[ctr++] = (pfnShutdown) SMB_Shutdown;
......@@ -1171,8 +1156,7 @@ static _kernel_oserror *LM_init_phase_2(void)
/* Try to start various modules */
if (LM_Vars.verbose)
printf("Starting network transport...\n");
debug0("Starting network transport...\n");
err = MsgError( NB_Startup() );
if (err != NULL)
......@@ -1182,12 +1166,11 @@ static _kernel_oserror *LM_init_phase_2(void)
}
#if 0
if (LM_Vars.verbose)
printf( "Starting filing system...\n");
debug0("Starting filing system...\n");
err = LM_Declare();
if (err != NULL) {
if (LM_Vars.verbose) printf("LanManFS: %s\n", err->errmess);
debug1("LanManFS: %s\n", err->errmess);
NB_Shutdown();
goto abort;
}
......@@ -1205,33 +1188,24 @@ static _kernel_oserror *LM_init_phase_2(void)
/*LM_StartupBoot();*/
if (want_boot) {
if (LM_Vars.verbose) printf("Booting...\n");
debug0("Booting...\n");
LM_Boot();
}
if ( LM_Vars.verbose )
printf("All done...\n");
debug0("All done...\n");
return NULL;
initfailed:
err = MsgError(EINITFAILED);
#ifdef DEBUG
if (LM_Vars.verbose) {
printf("LanManFS: %s (%s)\n", err->errmess, LM_Status());
}
#endif
debug2("LanManFS: %s (%s)\n", err->errmess, LM_Status());
while (--ctr >= 0) (shutdowns[ctr])();
return err;
abort:
LM_Vars.initialised = oldstate;
while (--ctr >= 0) (shutdowns[ctr])();
#ifdef DEBUG
if (LM_Vars.verbose) {
printf("LanManFS: %s\n", LM_Status());
}
#endif
debug1("LanManFS: %s\n", LM_Status());
return NULL;
/* abort used to use this, but that assumes deterministic module startup, *
......
......@@ -2090,8 +2090,7 @@ EXPORT err_t _NB_Startup(void)
struct sockaddr_in sa;
struct ifreq IFR;
if ( LM_Vars.verbose )
printf(" Starting TCP/IP transport\n");
debug0("Starting TCP/IP transport\n");
/* Clear out name table & session table */
......@@ -2131,11 +2130,8 @@ EXPORT err_t _NB_Startup(void)
if ( socketioctl ( NBNS_Socket, SIOCGIFADDR, (char *)&IFR ) < 0 )
{
if ( LM_Vars.verbose )
{
printf(" Couldn't find IP address for interface '%s'\n",
LM_Vars.drivername );
}
debug1("Couldn't find IP address for interface '%s'\n",
LM_Vars.drivername);
(void) socketclose(NBNS_Socket);
NBNS_Socket = INVALID_SOCKET;
return ENOIFADDR;
......@@ -2154,12 +2150,11 @@ EXPORT err_t _NB_Startup(void)
iab.nb[0], iab.nb[1], iab.nb[2], iab.nb[3] );
}
if ( LM_Vars.verbose )
{
show_scope(NB_ScopeID);
printf(" Machine name is '%s', IP address %s\n", LM_Vars.machinename,
inet_ntoa ( NB_IPAddress ) );
}
#ifdef DEBUG
show_scope(NB_ScopeID);
debug2("Machine name is '%s', IP address %s\n", LM_Vars.machinename,
inet_ntoa ( NB_IPAddress ));
#endif
/* Bind socket */
sa.sin_family = AF_INET;
......
......@@ -1250,8 +1250,7 @@ EXPORT err_t _NB_Startup(void)
NBSESSION *pS;
NAME_ENTRY *pN;
if ( LM_Vars.verbose )
printf(" Initialising NetBEUI transport\n");
debug0("Initialising NetBEUI transport\n");
/* First, clear out all our session & name tables */
......@@ -1281,8 +1280,7 @@ EXPORT err_t _NB_Startup(void)
/* Now find network driver */
if ( LM_Vars.verbose )
printf(" Looking for driver '%s'\n", LM_Vars.drivername);
debug1("Looking for driver '%s'\n", LM_Vars.drivername);
res = LLC_AttachDriver(LM_Vars.drivername, &Multi_Addr);
if ( res != OK )
......@@ -1302,8 +1300,7 @@ EXPORT err_t _NB_Startup(void)
p[0], p[1], p[2], p[3], p[4], p[5] );
}
if ( LM_Vars.verbose )
printf(" Setting machine name to '%s'\n", LM_Vars.machinename );
debug1( "Setting machine name to '%s'\n", LM_Vars.machinename );
res = _NB_AddLocalName( ntMACHINE, LM_Vars.machinename, &NB_MachineName );
if (res != OK)
......
......@@ -31,7 +31,6 @@ struct LMvars
int namemode;
bool logged_on;
char *password_ptr; /* Default password e.g. none */
bool verbose;
int initialised; /* Initialisation state */