Skip to content

Commit 0a0d55e

Browse files
Piotr DurlejPerditionC
authored andcommitted
SYS: Reduce verbosity when the verbose flag is not set
1 parent 49d3c8d commit 0a0d55e

1 file changed

Lines changed: 32 additions & 21 deletions

File tree

sys/sys.c

Lines changed: 32 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ void dumpBS(const char *, int);
506506
void restoreBS(const char *, int);
507507
void put_boot(SYSOptions *opts);
508508
BOOL check_space(COUNT, ULONG);
509-
BOOL copy(const BYTE *source, COUNT drive, const BYTE * filename);
509+
BOOL copy(SYSOptions *opts, const BYTE *source, COUNT drive, const BYTE * filename);
510510

511511
void showHelpAndExit(void)
512512
{
@@ -895,7 +895,8 @@ void initOptions(int argc, char *argv[], SYSOptions *opts)
895895
OEM_FD;
896896
#endif
897897

898-
printf(msgDOS[opts->flavor]);
898+
if (opts->verbose)
899+
printf(msgDOS[opts->flavor]);
899900

900901
/* set compatibility settings not explicitly set */
901902
if (!opts->kernel.kernel) opts->kernel.kernel = bootFiles[opts->flavor].kernel;
@@ -975,8 +976,6 @@ int main(int argc, char **argv)
975976
SYSOptions opts; /* boot options and other flags */
976977
BYTE srcFile[SYS_MAXPATH]; /* full path+name of [kernel] file [to copy] */
977978

978-
printf(SYS_NAME SYS_VERSION ", " __DATE__ "\n");
979-
980979
#ifdef FDCONFIG
981980
if (argc > 1 && memicmp(argv[1], "CONFIG", 6) == 0)
982981
{
@@ -986,15 +985,20 @@ int main(int argc, char **argv)
986985

987986
initOptions(argc, argv, &opts);
988987

989-
printf("Processing boot sector...\n");
988+
if (opts.verbose)
989+
printf(SYS_NAME SYS_VERSION ", " __DATE__ "\n");
990+
991+
if (opts.verbose)
992+
printf("Processing boot sector...\n");
990993
put_boot(&opts);
991994

992995
if (opts.copyKernel)
993996
{
994-
printf("Now copying system files...\n");
997+
if (opts.verbose)
998+
printf("Now copying system files...\n");
995999

9961000
sprintf(srcFile, "%s%s", opts.srcDrive, (opts.fnKernel)?opts.fnKernel:opts.kernel.kernel);
997-
if (!copy(srcFile, opts.dstDrive, opts.kernel.kernel))
1001+
if (!copy(&opts, srcFile, opts.dstDrive, opts.kernel.kernel))
9981002
{
9991003
printf("%s: cannot copy \"%s\"\n", pgm, srcFile);
10001004
exit(1);
@@ -1003,7 +1007,7 @@ int main(int argc, char **argv)
10031007
if (opts.kernel.dos)
10041008
{
10051009
sprintf(srcFile, "%s%s", opts.srcDrive, opts.kernel.dos);
1006-
if (!copy(srcFile, opts.dstDrive, opts.kernel.dos) && opts.kernel.minsize)
1010+
if (!copy(&opts, srcFile, opts.dstDrive, opts.kernel.dos) && opts.kernel.minsize)
10071011
{
10081012
printf("%s: cannot copy \"%s\"\n", pgm, srcFile);
10091013
exit(1);
@@ -1013,24 +1017,27 @@ int main(int argc, char **argv)
10131017

10141018
if (opts.copyShell)
10151019
{
1016-
printf("Copying shell (command interpreter)...\n");
1020+
if (opts.verbose)
1021+
printf("Copying shell (command interpreter)...\n");
10171022

10181023
/* copy command.com, 1st try source path, then try %COMSPEC% */
10191024
sprintf(srcFile, "%s%s", opts.srcDrive, (opts.fnCmd)?opts.fnCmd:"COMMAND.COM");
1020-
if (!copy(srcFile, opts.dstDrive, "COMMAND.COM"))
1025+
if (!copy(&opts, srcFile, opts.dstDrive, "COMMAND.COM"))
10211026
{
10221027
char *comspec = getenv("COMSPEC");
10231028
if (!opts.fnCmd && (comspec != NULL))
10241029
printf("%s: Trying shell from %%COMSPEC%%=\"%s\"\n", pgm, comspec);
1025-
if (opts.fnCmd || (comspec == NULL) || !copy(comspec, opts.dstDrive, "COMMAND.COM"))
1030+
if (opts.fnCmd || (comspec == NULL) || !copy(&opts, comspec, opts.dstDrive, "COMMAND.COM"))
10261031
{
10271032
printf("\n%s: failed to find command interpreter (shell) file %s\n", pgm, (opts.fnCmd)?opts.fnCmd:"COMMAND.COM");
10281033
exit(1);
10291034
}
10301035
} /* copy shell */
10311036
}
10321037

1033-
printf("\nSystem transferred.\n");
1038+
if (opts.verbose)
1039+
printf("\n");
1040+
printf("System transferred.\n\n");
10341041
return 0;
10351042
}
10361043

@@ -1520,7 +1527,8 @@ void put_boot(SYSOptions *opts)
15201527

15211528
if (fs == FAT32)
15221529
{
1523-
printf("FAT type: FAT32\n");
1530+
if (opts->verbose)
1531+
printf("FAT type: FAT32\n");
15241532
/* get default bpb (but not for floppies) */
15251533
if (opts->dstDrive >= 2 &&
15261534
generic_block_ioctl(opts->dstDrive + 1, 0x4860, default_bpb) == 0)
@@ -1547,7 +1555,8 @@ void put_boot(SYSOptions *opts)
15471555
}
15481556
else
15491557
{ /* copy the FAT12/16 CHS+LBA boot sector */
1550-
printf("FAT type: FAT1%c\n", fs + '0' - 10);
1558+
if (opts->verbose)
1559+
printf("FAT type: FAT1%c\n", fs + '0' - 10);
15511560
if (opts->dstDrive >= 2 &&
15521561
generic_block_ioctl(opts->dstDrive + 1, 0x860, default_bpb) == 0)
15531562
correct_bpb((struct bootsectortype *)(default_bpb + 7 - 11), bs, opts->verbose);
@@ -1854,7 +1863,7 @@ int alloc_dos_mem(ULONG memsize, UWORD *theseg)
18541863
#endif
18551864

18561865
/* copies file (path+filename specified by srcFile) to drive:\filename */
1857-
BOOL copy(const BYTE *source, COUNT drive, const BYTE * filename)
1866+
BOOL copy(SYSOptions *opts, const BYTE *source, COUNT drive, const BYTE * filename)
18581867
{
18591868
static BYTE src[SYS_MAXPATH];
18601869
static BYTE dest[SYS_MAXPATH];
@@ -1872,14 +1881,16 @@ BOOL copy(const BYTE *source, COUNT drive, const BYTE * filename)
18721881
struct ftime ftime;
18731882
#endif
18741883

1875-
printf("Copying %s...\n", source);
1884+
if (opts->verbose)
1885+
printf("Copying %s...\n", source);
18761886

18771887
truename(src, source);
18781888
sprintf(dest, "%c:\\%s", 'A' + drive, filename);
18791889
if (stricmp(src, dest) == 0)
18801890
{
1881-
printf("%s: source and destination are identical: skipping \"%s\"\n",
1882-
pgm, source);
1891+
if (opts->verbose)
1892+
printf("%s: source and destination are identical: skipping \"%s\"\n",
1893+
pgm, source);
18831894
return TRUE;
18841895
}
18851896

@@ -1927,7 +1938,7 @@ BOOL copy(const BYTE *source, COUNT drive, const BYTE * filename)
19271938
{
19281939
ULONG filesize;
19291940
UWORD theseg;
1930-
BYTE far *buffer; BYTE far *bufptr;
1941+
BYTE far *buffer, far *bufptr;
19311942
UWORD offs;
19321943
unsigned chunk_size;
19331944

@@ -2015,8 +2026,8 @@ BOOL copy(const BYTE *source, COUNT drive, const BYTE * filename)
20152026
/* and close input file, usually same drive as next action will access */
20162027
close(fdin);
20172028

2018-
2019-
printf("%lu Bytes transferred\n", copied);
2029+
if (opts->verbose)
2030+
printf("%lu Bytes transferred\n", copied);
20202031

20212032
return TRUE;
20222033
} /* copy */

0 commit comments

Comments
 (0)