Commit eb1a4c25 authored by ROOL's avatar ROOL 🤖 Committed by Robert Sprowson
Browse files

Review edits

Detail:
  Split off common part of NMHid in Messages.
  Use named error from NewErrors.h instead of 1E4.
  LowerCase/Lower case => Lowercase/
  Avoid single letter structure name.
parent 5791309b
......@@ -29,6 +29,13 @@ Prns:Printers
Mnt:Mount
On:on server
User:as user
NMMode:Capitalisation of DOS short file names
NMMode0:Preserved
NMMode1:Lowercase
NMMode2:First caps
NMHid:Hidden files and directories
Exc:Excluded
Inc:Included
D00:EnumShares could not log on to %s
D01:EnumShares call on %s
D02:Can't find master browser or DC for %s
......@@ -110,9 +117,3 @@ E59:Could not connect to home directory
E60:User name not recognised
E61:User account has been disabled
E62:LanManFS in use
NMMode:Capitalisation of DOS short file names
NMMode0:Preserved
NMMode1:Lower case
NMMode2:First caps
NMHid0:Hidden files and directories: Excluded
NMHid1:Hidden files and directories: Included
......@@ -607,65 +607,66 @@ static _kernel_oserror *Cmd_LMInfo ( const char *args )
static _kernel_oserror *Cmd_LMNameMode ( const char *args )
{
int mode = -1;
int hidden = -1;
int flags = 0;
int i, mode, hidden, flags = 0;
__packed struct
{
int flags[6];
char zero;
char type;
int mode;
char spare[3]; /* required for sizeof(a) to work with readargs */
} a;
} parsed;
_kernel_oserror *e;
e =_swix(OS_ReadArgs, _INR(0,3),
"/e,preservecase/s,lowercase/s,firstcaps/s,includehidden/s,excludehidden/s",
args, &a, sizeof(a));
e = _swix(OS_ReadArgs, _INR(0,3),
"/e,preservecase/s,lowercase/s,firstcaps/s,includehidden/s,excludehidden/s",
args, &parsed, sizeof(parsed));
if (e != NULL)
{
/* Convert buffer overflow to bad parameters */
return e->errnum == 0x1e4 ? MsgError(EBADPARAM) : e;
return e->errnum == ErrorNumber_BuffOverflow ? MsgError(EBADPARAM) : e;
}
for (int i = 0; i < (sizeof(a.flags)/sizeof(a.flags[0])); i++)
for (i = 0; i < (sizeof(parsed.flags) / sizeof(parsed.flags[0])); i++)
{
if (a.flags[i]) flags |= (1 << i);
if (parsed.flags[i]) flags |= (1 << i);
}
if (flags == 0)
{
printf("%s: ", MsgLookup("NMMode"));
const char *token;
/* No arguments given, show the current state */
switch (LM_Vars.namemode & NM_MODE)
{
case NM_LOWERCASE: printf("%s\n", MsgLookup("NMMode1"));
break;
case NM_FIRSTCAPS: printf("%s\n", MsgLookup("NMMode2"));
break;
default: /* Preserve case */
printf("%s\n", MsgLookup("NMMode0"));
break;
default: /* Preserve case */
token = "NMMode0";
break;
case NM_LOWERCASE: token = "NMMode1";
break;
case NM_FIRSTCAPS: token = "NMMode2";
break;
}
if (LM_Vars.namemode & NM_HIDDEN)
printf("%s\n", MsgLookup("NMHid1"));
else
printf("%s\n", MsgLookup("NMHid0"));
printf("%s: ", MsgLookup("NMMode"));
printf("%s\n", MsgLookup(token));
printf("%s: ", MsgLookup("NMHid"));
printf("%s\n", MsgLookup((LM_Vars.namemode & NM_HIDDEN) ? "Inc" : "Exc"));
return NULL;
}
mode = hidden = -1;
switch (flags & 0xf)
{
case 1: /* Mode */
if (a.zero != 0 || a.mode > 2 || a.mode < 0)
case 1: /* Numeric mode */
if (parsed.type != 0 /* Integer */ || parsed.mode > 2 || parsed.mode < 0)
{
return MsgError(EBADPARAM);
}
mode = a.mode;
mode = parsed.mode;
break;
case 2: /* PreserveCase */
case 4: /* LowerCase */
case 4: /* Lowercase */
case 8: /* FirstCaps */
mode = (flags >> 2) & NM_MODE;
break;
......@@ -673,14 +674,13 @@ static _kernel_oserror *Cmd_LMNameMode ( const char *args )
switch (flags & 0x30)
{
case 0x10: /* includehidden */
hidden = NM_HIDDEN;
break;
case 0x20: /* excludehidden */
hidden = 0;
break;
case 0x30:
return MsgError(EBADPARAM);
case 0x10: /* IncludeHidden */
hidden = NM_HIDDEN;
break;
case 0x20: /* ExcludeHidden */
hidden = 0;
break;
case 0x30: return MsgError(EBADPARAM);
}
if (mode == -1 && hidden == -1)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment