Skip to content

Commit

Permalink
Several fixes. Builds on WIN32. Prints Usage when invalid syntax.
Browse files Browse the repository at this point in the history
  • Loading branch information
nelsonb%netscape.com committed May 8, 2000
1 parent cc6ee05 commit 2f887ce
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions security/nss/cmd/btoa/btoa.c
Expand Up @@ -134,13 +134,15 @@ int main(int argc, char **argv)
inFile = 0;
outFile = 0;
progName = strrchr(argv[0], '/');
if (!progName)
progName = strrchr(argv[0], '\\');
progName = progName ? progName+1 : argv[0];

/* Parse command line arguments */
optstate = PL_CreateOptState(argc, argv, "i:o:");
while ((status = PL_GetNextOpt(optstate)) == PL_OPT_OK) {
switch (optstate->option) {
case '?':
default:
Usage(progName);
break;

Expand All @@ -163,14 +165,16 @@ int main(int argc, char **argv)
break;
}
}
if (status == PL_OPT_BAD)
Usage(progName);
if (!inFile) {
#if defined(WIN32)
/* If we're going to read binary data from stdin, we must put stdin
** into O_BINARY mode or else incoming \r\n's will become \n's.
*/

int smrv = _setmode(_fileno(stdin), _O_BINARY);
if (int smrv == -1) {
if (smrv == -1) {
fprintf(stderr,
"%s: Cannot change stdin to binary mode. Use -i option instead.\n",
progName);
Expand Down

0 comments on commit 2f887ce

Please sign in to comment.