Commit 49aac30b authored by Robert Sprowson's avatar Robert Sprowson
Browse files

LanmanFS help syntax corrected and tidied

Change lmls command to ListFS in line with NFS
Supress LF when ListFS is issued but there are no servers present.
Cast a few things to shut some compiler warnings up.
Addition of MimeMap lookups where the file has no ",ttt" style type
appended.Previously any such files were all reported as text files so
viewing a machine would typically show whole directories full of
identical filetypes.

Version 2.23. Tagged as 'LanManFS-2_23'
parent 70c45671
/* (2.22)
/* (2.23)
*
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.68.
*
*/
#define Module_MajorVersion_CMHG 2.22
#define Module_MajorVersion_CMHG 2.23
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 08 Jun 2001
#define Module_Date_CMHG 14 Dec 2002
#define Module_MajorVersion "2.22"
#define Module_Version 222
#define Module_MajorVersion "2.23"
#define Module_Version 223
#define Module_MinorVersion ""
#define Module_Date "08 Jun 2001"
#define Module_Date "14 Dec 2002"
#define Module_ApplicationDate2 "08-Jun-01"
#define Module_ApplicationDate4 "08-Jun-2001"
#define Module_ApplicationDate "14-Dec-02"
#define Module_ComponentName "LanManFS"
#define Module_ComponentPath "RiscOS/Sources/Networking/Omni/Protocols/LanManFS"
#define Module_FullVersion "2.22"
#define Module_HelpVersion "2.22 (08 Jun 2001)"
#define Module_FullVersion "2.23"
#define Module_HelpVersion "2.23 (14 Dec 2002)"
#define Module_LibraryVersionInfo "2:23"
......@@ -29,6 +29,7 @@
#include <string.h>
#include "kernel.h"
#include "Global/FileTypes.h"
/* Our includes */
......@@ -70,27 +71,40 @@ static void GetDefaultType ( char *leafname, RISCOS_ATTRIBS *ra )
{
struct ext_type *pET;
int ftype;
_kernel_swi_regs rset ;
/* See if OmniFiler can help us */
if ( Omni_GetDefaultType(leafname, &ftype) == OK )
{
debug1("Omni gave default type %X\n", ftype );
debug2("Omni gave default type %X for '%s'\n", ftype, leafname );
ra->loadaddr = (ra->loadaddr & 0xFFF000FF) |
((ftype << 8) & 0x000FFF00);
return;
}
else
debug1("Omni wouldn't translate '%s'", leafname );
/* Get extension */
leafname = strchr(leafname, '.');
if ( leafname == NULL ) /* No extension */
return;
{
debug1("No suffix,assuming DOS filetype for '%s'\n", leafname );
ra->loadaddr = FileType_MSDOS << 8;
return;
}
leafname++; /* Skip '.' */
/* Have a look in the mimemap */
rset.r[0] = MMM_TYPE_DOT_EXTN;
rset.r[1] = (int)leafname;
rset.r[2] = MMM_TYPE_RISCOS;
if (_kernel_swi(MimeMap_Translate, &rset, &rset) == NULL)
{
ra->loadaddr = rset.r[3] << 8;
debug2("Mimemap gave type %X for '%s'\n", rset.r[3], leafname );
return;
}
/* Look through the feable small table */
for ( pET = FTypes; pET->ext != NULL; pET++ )
{
if ( strcmp ( pET->ext, leafname ) == 0 )
......
......@@ -316,7 +316,7 @@ static int GetArgs ( const char *args, char *argv_out[], int maxargs )
/* --------------------- */
static _kernel_oserror *Cmd_LANMAN ( const char *args )
static _kernel_oserror *Cmd_LanMan ( const char *args )
{
/* No args! */
_kernel_swi_regs r;
......@@ -345,7 +345,7 @@ static char *(LM_local_num)(char *buf)
}
#endif
static _kernel_oserror *Cmd_FREE ( const char *args )
static _kernel_oserror *Cmd_Free ( const char *args )
{
_kernel_swi_regs r;
_kernel_oserror *e;
......@@ -393,7 +393,7 @@ static _kernel_oserror *Cmd_FREE ( const char *args )
}
/* --------------------- */
static _kernel_oserror *Cmd_LMLS ( const char *args )
static _kernel_oserror *Cmd_ListFS ( const char *args )
{
char *argv[1];
......@@ -407,7 +407,7 @@ static _kernel_oserror *Cmd_LMLS ( const char *args )
/* --------------------- */
static _kernel_oserror *Cmd_CONNECT ( const char *args )
static _kernel_oserror *Cmd_LMConnect ( const char *args )
{
char *argv[5];
err_t res;
......@@ -436,7 +436,7 @@ static _kernel_oserror *Cmd_CONNECT ( const char *args )
/* --------------------- */
static _kernel_oserror *Cmd_DISCONNECT ( const char *args )
static _kernel_oserror *Cmd_LMDisconnect ( const char *args )
{
char *argv[1];
int mountID;
......@@ -514,7 +514,7 @@ static void SetDefaultVars ( void )
/* --------------------- */
static _kernel_oserror *Cmd_LOGOFF( const char *args )
static _kernel_oserror *Cmd_LMLogoff( const char *args )
{
(void) args;
Lgn_Logoff();
......@@ -523,7 +523,7 @@ static _kernel_oserror *Cmd_LOGOFF( const char *args )
/* --------------------- */
static _kernel_oserror *Cmd_LOGON( const char *args )
static _kernel_oserror *Cmd_LMLogon( const char *args )
{
char *argv[3];
if ( GetArgs(args, argv, 3) < 2 )
......@@ -537,7 +537,7 @@ static _kernel_oserror *Cmd_LOGON( const char *args )
/* --------------------- */
static _kernel_oserror *Cmd_LMINFO ( const char *args )
static _kernel_oserror *Cmd_LMInfo ( const char *args )
{
(void) args;
Omni_Debug();
......@@ -548,7 +548,7 @@ static _kernel_oserror *Cmd_LMINFO ( const char *args )
/* --------------------- */
static _kernel_oserror *Cmd_LMNAMEMODE ( const char *args )
static _kernel_oserror *Cmd_LMNameMode ( const char *args )
{
char *argv[1];
int tmp;
......@@ -570,7 +570,7 @@ static _kernel_oserror *Cmd_LMNAMEMODE ( const char *args )
/* --------------------- */
static _kernel_oserror *Cmd_LMSERVER ( const char *args )
static _kernel_oserror *Cmd_LMServer ( const char *args )
{
char *argv[MAX_ARGS];
int i;
......@@ -594,7 +594,7 @@ static _kernel_oserror *Cmd_LMSERVER ( const char *args )
/* --------------------- */
static _kernel_oserror *Cmd_LMPRINTERS ( const char *args )
static _kernel_oserror *Cmd_LMPrinters ( const char *args )
{
char *argv[MAX_ARGS];
int i;
......@@ -619,7 +619,7 @@ static _kernel_oserror *Cmd_LMPRINTERS ( const char *args )
/* --------------------- */
static _kernel_oserror *Cmd_LMSTATS ( const char *args )
static _kernel_oserror *Cmd_LMStats ( const char *args )
{
(void) args;
Stat_Show();
......@@ -655,7 +655,7 @@ static _kernel_oserror *Cmd_FS ( const char *args )
/* --------------------- */
static _kernel_oserror *Cmd_LMTRANSPORT ( const char *args )
static _kernel_oserror *Cmd_LMTransport ( const char *args )
{
/* This is a *Configure/Status command handler */
char *argv[1];
......@@ -681,7 +681,6 @@ static _kernel_oserror *Cmd_LMTRANSPORT ( const char *args )
return NULL;
}
#endif
if ( GetArgs( args, argv, 1 ) < 1 )
return Xlt_Error ( EBADPARAM );
......@@ -699,7 +698,7 @@ static _kernel_oserror *Cmd_LMTRANSPORT ( const char *args )
}
/* --------------------- */
static _kernel_oserror *Cmd_NBNSIP( const char *args )
static _kernel_oserror *Cmd_LMNameServer( const char *args )
{
/* This is a *Configure/Status command handler - it's therefore unusual */
char *argv[1];
......@@ -737,10 +736,10 @@ static _kernel_oserror *Cmd_NBNSIP( const char *args )
{
unsigned long b0, b1, b2, b3;
b0 = (address.s_addr & 0x000000ff);
b1 = (address.s_addr & 0x0000ff00) >> 8;
b2 = (address.s_addr & 0x00ff0000) >> 16;
b3 = (address.s_addr & 0xff000000) >> 24;
b0 = (unsigned long)(address.s_addr & 0x000000ff);
b1 = (unsigned long)(address.s_addr & 0x0000ff00) >> 8;
b2 = (unsigned long)(address.s_addr & 0x00ff0000) >> 16;
b3 = (unsigned long)(address.s_addr & 0xff000000) >> 24;
if ( ((b0 != 127) && (b0 <= 223)) && ((b3 != 255)) )
{
......@@ -759,52 +758,27 @@ static _kernel_oserror *Cmd_NBNSIP( const char *args )
typedef _kernel_oserror * (*CommandFnPtr) ( const char *args );
#define MAX_CMDS 15
static CommandFnPtr Cmd_Dispatch[MAX_CMDS] =
#define CmdEntry(X) [CMD_##X] = Cmd_##X
static CommandFnPtr Cmd_Dispatch[] =
{
Cmd_LANMAN,
Cmd_CONNECT,
Cmd_DISCONNECT,
Cmd_LOGON,
Cmd_LMINFO,
Cmd_LMNAMEMODE,
Cmd_LOGOFF,
Cmd_LMSERVER,
Cmd_LMPRINTERS,
Cmd_LMSTATS,
Cmd_FS,
Cmd_LMTRANSPORT,
Cmd_NBNSIP,
Cmd_FREE,
Cmd_LMLS
CmdEntry(LanMan),
CmdEntry(LMConnect),
CmdEntry(LMDisconnect),
CmdEntry(LMLogon),
CmdEntry(LMInfo),
CmdEntry(LMNameMode),
CmdEntry(LMLogoff),
CmdEntry(LMServer),
CmdEntry(LMPrinters),
CmdEntry(LMStats),
CmdEntry(FS),
CmdEntry(LMTransport),
CmdEntry(LMNameServer),
CmdEntry(Free),
CmdEntry(ListFS)
};
#ifdef TRACE
static void chk_a_command(CommandFnPtr ptr, int num)
{
if (Cmd_Dispatch[num] != ptr) {
fprintf(stderr, "Command-table error (%d)\n", num);
}
}
static void chk_commands(void)
{
chk_a_command(Cmd_LANMAN, CMD_LanMan);
chk_a_command(Cmd_CONNECT, CMD_LMConnect);
chk_a_command(Cmd_DISCONNECT, CMD_LMDisconnect);
chk_a_command(Cmd_LOGON, CMD_LMLogon);
chk_a_command(Cmd_LMINFO, CMD_LMInfo);
chk_a_command(Cmd_LMNAMEMODE, CMD_LMNameMode);
chk_a_command(Cmd_LOGOFF, CMD_LMLogoff);
chk_a_command(Cmd_LMSERVER, CMD_LMServer);
chk_a_command(Cmd_LMPRINTERS, CMD_LMPrinters);
chk_a_command(Cmd_LMSTATS, CMD_LMStats);
chk_a_command(Cmd_FS, CMD_FS);
chk_a_command(Cmd_LMTRANSPORT, CMD_LMTransport);
chk_a_command(Cmd_NBNSIP, CMD_LMNameServer);
chk_a_command(Cmd_FREE, CMD_Free);
chk_a_command(Cmd_LMLS, CMD_LMls);
}
#endif
#define MAX_CMDS (sizeof Cmd_Dispatch / sizeof Cmd_Dispatch[0])
/* --------------------- */
......@@ -1095,10 +1069,6 @@ _kernel_oserror *LM_Initialise(const char *cmd_tail, int pod_base, void *pw)
if (R.r[1] < 0xA2)
return Xlt_Error(ERISCOSVER);
#ifdef TRACE
chk_commands();
#endif
if (cmd_tail != NULL)
{
err = Xlt_Error(ProcessCmdLine(cmd_tail));
......@@ -1107,10 +1077,12 @@ if (cmd_tail != NULL)
}
err = LM_Declare();
if (err != NULL)
return err;
LM_Vars.initialised = LMInitState_PreInit;
(void) LM_init_phase_2();
#ifndef NO_NETBEUI
......
......@@ -1582,22 +1582,22 @@ void Omni_AddInfo ( int flags, char *serv_name, char *string, char *comment )
return;
case OAI_DISK:
tag = D_VALID_TAG;
tag = (int)D_VALID_TAG;
list = &pNLsrv->u.server.known_disks;
break;
case OAI_PRINTER:
tag = P_VALID_TAG;
tag = (int)P_VALID_TAG;
list = &pNLsrv->u.server.known_printers;
break;
case OAI_IPC:
tag = I_VALID_TAG;
tag = (int)I_VALID_TAG;
list = &pNLsrv->u.server.known_ipc;
break;
case OAI_DEVICE:
tag = C_VALID_TAG;
tag = (int)C_VALID_TAG;
list = &pNLsrv->u.server.known_comms;
break;
......@@ -1717,7 +1717,8 @@ void Omni_Debug ( void )
printf("\n Printers : ");
showlist(pNL->u.server.known_printers);
}
printf("\n\n");
if (ServerList != NULL) printf("\n\n");
for ( pNL = MountsList; pNL != NULL; pNL = pNL->next )
{
......@@ -1751,5 +1752,4 @@ void Omni_Debug ( void )
printf("\n%d error(s) locating network resources:\nLast error - %s\n",
RPC_ErrorCount, RPC_DebugMsg );
printf("\n");
}
......@@ -204,7 +204,7 @@ static err_t RPC_EnumSharesOnConnection ( char drv, char *server )
are a share name + null termination. If the share name
ends in '$', it is hidden and should not be listed.
[sbrodie: ... except if it's an IPC share, I've decided. Also
we store the comments too for *lanman:lmls to display. Why is there
we store the comments too for *lanman:listfs to display. Why is there
a mystical word in the returned param block which is subtracted from
the offset field? Dunno, but SAMBA does it and Windows 98 needs it.]
*/
......
......@@ -30,6 +30,8 @@
#include "kernel.h"
#include "stdtypes.h"
#include "Global/FileTypes.h"
#include "Xlate.h"
#include "attr.h"
#include "omni.h"
......@@ -1184,56 +1186,97 @@ err_t Xlt_SplitLeafnameX2 ( char *leafname, RISCOS_ATTRIBS *pRA,
char **terminator)
{
int type, len;
char *term;
char *term, *oldname;
err_t res = ENOTPRESENT;
_kernel_swi_regs rset;
*terminator = NULL;
if (leafname == NULL) {
if (leafname == NULL)
{
/* Oh dear - don't understand this - just claim it's text */
pRA->loadaddr |= 0xFFFFFF00;
return res;
}
debug1("Xlt_SplitLeafnameX2(\"%s\",....)\n", leafname);
}
debug1("Xlt_SplitLeafnameX2('%s',...)\n", leafname);
term = strchr(leafname, '\0');
if ((term - leafname) < 5) {
/* Name too short? Must be text. */
pRA->loadaddr |= 0xFFFFFF00;
return res;
}
leafname = term - 4;
if (leafname[0] != FileChar_TypedNamePrefix) {
/* Not an extension? Must be text */
pRA->loadaddr |= 0xFFFFFF00;
return res;
}
if (stricmp(leafname+1, FileString_UntypedFile) == 0) {
debug0("File is untyped (,lxa)\n");
pRA->loadaddr = untyped_load;
pRA->execaddr = untyped_exec;
*terminator = leafname;
res = OK;
}
else if (stricmp(leafname+1, FileString_DeadFile) == 0) {
pRA->loadaddr = pRA->execaddr = deaddead;
debug0("File is DEADDEAD\n");
*terminator = leafname;
res = OK;
}
else if (sscanf(leafname+1, "%x%n", &type, &len) == 1 && len == 3) {
/* note. sscanf returns the number of conversions which were
* successfully performed. the %n conversion never fails and
* does not count towards the total number of conversions, but
* holds the number of characters consumed from the source
* string. Therefore, provided that len was 3, then we have
* consumed three hex digits.
*/
pRA->loadaddr = ENCODE_FILETYPE(pRA->loadaddr, type);
*terminator = leafname;
debug3("Filetype is %#03x; load/exec=%#08x %#08x\n", type,
pRA->loadaddr, pRA->execaddr);
res = OK;
}
return res;
oldname = leafname;
if ((term - leafname) > 4)
{
/* Ah good,it's at least 5 letters long */
leafname = term - 4;
if (leafname[0] == FileChar_TypedNamePrefix)
{
/* At least 5 letters long and of the form ",ttt" */
if (stricmp(leafname+1, FileString_UntypedFile) == 0)
{
debug0("File is untyped (,lxa)\n");
pRA->loadaddr = untyped_load;
pRA->execaddr = untyped_exec;
*terminator = leafname;
res = OK;
}
else
{
if (stricmp(leafname+1, FileString_DeadFile) == 0)
{
pRA->loadaddr = pRA->execaddr = deaddead;
debug0("File is DEADDEAD\n");
*terminator = leafname;
res = OK;
}
else
{
if (sscanf(leafname+1, "%x%n", &type, &len) == 1 && len == 3)
{
/* note. sscanf returns the number of conversions which were
* successfully performed. the %n conversion never fails and
* does not count towards the total number of conversions, but
* holds the number of characters consumed from the source
* string. Therefore, provided that len was 3, then we have
* consumed three hex digits.
*/
pRA->loadaddr = ENCODE_FILETYPE(pRA->loadaddr, type);
*terminator = leafname;
debug3("Filetype is %#03x; load/exec=%#08x %#08x\n", type,
pRA->loadaddr, pRA->execaddr);
res = OK;
}
}
}
}
}
if (res != OK)
{
/* No ",ttt" was found,try the mimemap for ".ext" */
leafname = oldname;
term = strchr(leafname, '/');
if (term != NULL)
{
/* A dot was found so try to lookup the dos style extension */
term++; /* Skip '.' */
rset.r[0] = MMM_TYPE_DOT_EXTN;
rset.r[1] = (int)term;
rset.r[2] = MMM_TYPE_RISCOS;
if (_kernel_swi(MimeMap_Translate, &rset, &rset) == NULL)
{
pRA->loadaddr = ENCODE_FILETYPE(pRA->loadaddr, rset.r[3]);
debug2("Mimemap gave type %X for '%s'\n", rset.r[3], leafname );
*terminator = strchr(leafname, '\0'); /* Safe to point to that null on exit */
res = OK;
}
}
}
if (res != OK)
{
/* No ",ttt" and no mimemap lookup - mark as a DOS file */
pRA->loadaddr = ENCODE_FILETYPE(pRA->loadaddr, FileType_MSDOS);
}
return res;
}
#endif
......
......@@ -60,70 +60,70 @@ command-keyword-table: LM_Command
LanMan(min-args:0, max-args:0,
help-text: "*LanMan selects Lan Manager as the current filing system\r"
"Syntax:\t*LanMan\r",
"Syntax:\t*LanMan",
invalid-syntax: "Syntax:\t*LanMan\r" ),
LMConnect(min-args:3, max-args:5,
help-text: "*LMConnect sets up a connection to a file server\r"
"Syntax:\t*LMConnect <name> <server> <dir-name> [<user-name> <password>]\r",
"Syntax:\t*LMConnect <name> <server> <dir-name> [<user-name> <password>]",
fs-command:,
invalid-syntax: "Syntax:\t*LMConnect <name> <server> <dir-name> <user>"
" <password>\r", ),
LMDisconnect(min-args:1, max-args:1,
help-text: "*LMDisconnect disconnects from a file server\r"
"Syntax:\t*LMDisconnect <name>\r",
"Syntax:\t*LMDisconnect <name>",
fs-command:,
invalid-syntax: "Syntax:\t*LMDisconnect <name>\r", ),
LMLogon(min-args:2, max-args:3,
help-text: "*LMLogon sets default information about the network\r"
"Syntax:\t*LMLogon <workgroup> <username> <password>\r",
"Syntax:\t*LMLogon <workgroup> <username> <password>",
fs-command:,
invalid-syntax: "Syntax:\t*LMLogon <workgroup> <username> <password>\r", ),
LMInfo(min-args:0, max-args:0,
help-text: "*LMInfo displays debugging information\r"
"Syntax:\t*LMInfo\r",
"Syntax:\t*LMInfo",
fs-command:,
invalid-syntax: "Syntax:\t*LMInfo\r", ),
LMNameMode(min-args:1, max-args:1,
help-text: "*LMNameMode sets the way LanManFS capitalises names on DOS shares\r"
"It does not affect long filename shares\r"
"Syntax:\t*LMNameMode [0|1|2]\r",
"Syntax:\t*LMNameMode [0|1|2]",
fs-command:,
invalid-syntax: "Syntax:\t*LMNameMode [0|1|2]\r", ),
LMLogoff(min-args:0, max-args:0,
help-text: "*LMLogoff clears the workgroup and default user settings "
"and disables network browsing\rSyntax:\t*LMLogoff\r",
"and disables network browsing\rSyntax:\t*LMLogoff",
fs-command:,
invalid-syntax: "Syntax:\t*LMLogoff\r" ),
LMServer(min-args:1, max-args:17,
help-text: "*LMserver adds a server name and list of shared drives\r"
"Syntax:\t*LMServer server [sharename] [sharename] ...\r",
"Syntax:\t*LMServer server [sharename] [sharename] ...",
fs-command:,
invalid-syntax: "Syntax:\t*LMServer server [sharename] [sharename] ...\r", ),
LMPrinters(min-args:1, max-args:17,
help-text: "*LMPrinters adds a server name and list of printers\r"
"Syntax:\t*LMPrinters server [printername] [printername] ...\r",
"Syntax:\t*LMPrinters server [printername] [printername] ...",
fs-command:,
invalid-syntax: "Syntax:\t*LMPrinters server [printername] [printername] ...\r",
),
LMStats(min-args:0, max-args:0,
help-text: "*LMStats shows network statistics\r"
"Syntax:\t*LMStats\r",
"Syntax:\t*LMStats",
fs-command:,
invalid-syntax: "Syntax:\t*LMStats",
),
FS(min-args:0, max-args:1,
help-text: "*Configure FS <name> sets the file server or domain name from "
"which LanManFS will attempt to boot\r",
"which LanManFS will attempt to boot\rSyntax:\t*Configure FS file-server-name",
invalid-syntax: "Syntax:\t*Configure FS file-server-name\r",
configure:,
status:,
......@@ -131,31 +131,32 @@ command-keyword-table: LM_Command
LMTransport(min-args:0, max-args:1,
help-text: "*Configure LMTransport sets whether LanManFS should use "
"NetBEUI or TCP/IP as transport protocol\r",
"NetBEUI or TCP/IP as transport protocol\rSyntax:\t*Configure LMTransport [IP|NetBEUI]",
invalid-syntax: "Syntax:\t*Configure LMTransport [IP|NetBEUI]\r",
configure:,
status:,
),
LMNameServer(min-args:0, max-args:1,
help-text: "*Configure LMNameServer <IP address> sets the address of a"
"NetBIOS over IP nameserver for LanManFS to use\r",
help-text: "*Configure LMNameServer <IP address> sets the address of a "
"NetBIOS over IP nameserver for LanManFS to use\rSyntax:\t*Configure LMNameServer [IP address]",
invalid-syntax: "Syntax:\t*Configure LMNameServer [IP address]\r",
configure:,
status:,
),
Free(min-args:0, max-args:1,
help-text: "*Free displays the total free space on a LanManFS share",
invalid-syntax: "Syntax:\t*Free [<disc spec.>]\r",
fs-command:,
),