diff options
-rw-r--r-- | src/asn1Coding.c | 45 | ||||
-rw-r--r-- | src/asn1Decoding.c | 23 | ||||
-rw-r--r-- | src/asn1Parser.c | 17 | ||||
-rwxr-xr-x | tests/crlf | 2 |
4 files changed, 50 insertions, 37 deletions
diff --git a/src/asn1Coding.c b/src/asn1Coding.c index 00057be..0a6a996 100644 --- a/src/asn1Coding.c +++ b/src/asn1Coding.c @@ -194,7 +194,7 @@ main (int argc, char *argv[]) if (optind == argc || optind == argc - 1) { free (outputFileName); - fprintf (stderr, "asn1Coding: input files missing\n"); + fputs ("asn1Coding: input files missing\n", stderr); usage (EXIT_FAILURE); } @@ -210,18 +210,20 @@ main (int argc, char *argv[]) switch (asn1_result) { case ASN1_SUCCESS: - printf ("Parse: done.\n"); + fputs ("Parse: done.\n", stderr); break; case ASN1_FILE_NOT_FOUND: - printf ("asn1Coding: FILE %s NOT FOUND\n", inputFileAsnName); + fprintf (stderr, "asn1Coding: FILE %s NOT FOUND\n", + inputFileAsnName); break; case ASN1_SYNTAX_ERROR: case ASN1_IDENTIFIER_NOT_FOUND: case ASN1_NAME_TOO_LONG: - printf ("asn1Coding: %s\n", errorDescription); + fprintf (stderr, "asn1Coding: %s\n", errorDescription); break; default: - printf ("libtasn1 ERROR: %s\n", asn1_strerror (asn1_result)); + fprintf (stderr, "libtasn1 ERROR: %s\n", + asn1_strerror (asn1_result)); } if (asn1_result != ASN1_SUCCESS) @@ -236,18 +238,19 @@ main (int argc, char *argv[]) if (inputFile == NULL) { - printf ("asn1Coding: file '%s' not found\n", inputFileAssignmentName); + fprintf (stderr, "asn1Coding: file '%s' not found\n", + inputFileAssignmentName); free (inputFileAsnName); free (inputFileAssignmentName); exit (1); } - printf ("\n"); + putc ('\n', stderr); while (readAssignment (inputFile, varName, value) == ASSIGNMENT_SUCCESS) { - printf ("var=%s, value=%s\n", varName, value); + fprintf (stderr, "var=%s, value=%s\n", varName, value); if (structure == NULL) { asn1_result = asn1_create_element (definitions, value, &structure); @@ -257,7 +260,8 @@ main (int argc, char *argv[]) if (asn1_result != ASN1_SUCCESS) { - printf ("libtasn1 ERROR: %s\n", asn1_strerror (asn1_result)); + fprintf (stderr, "libtasn1 ERROR: %s\n", + asn1_strerror (asn1_result)); asn1_delete_structure (&definitions); asn1_delete_structure (&structure); @@ -271,8 +275,8 @@ main (int argc, char *argv[]) } fclose (inputFile); - printf ("\n"); - asn1_print_structure (stdout, structure, "", ASN1_PRINT_NAME_TYPE_VALUE); + putc ('\n', stderr); + asn1_print_structure (stderr, structure, "", ASN1_PRINT_NAME_TYPE_VALUE); der_len = 0; asn1_result = asn1_der_coding (structure, "", der, &der_len, @@ -283,10 +287,10 @@ main (int argc, char *argv[]) asn1_result = asn1_der_coding (structure, "", der, &der_len, errorDescription); } - printf ("\nCoding: %s\n\n", asn1_strerror (asn1_result)); + fprintf (stderr, "\nCoding: %s\n\n", asn1_strerror (asn1_result)); if (asn1_result != ASN1_SUCCESS) { - printf ("asn1Coding: %s\n", errorDescription); + fprintf (stderr, "asn1Coding: %s\n", errorDescription); free (der); @@ -300,10 +304,10 @@ main (int argc, char *argv[]) } /* Print the 'Certificate1' DER encoding */ - printf ("-----------------\nNumber of bytes=%i\n", der_len); + fprintf (stderr, "-----------------\nNumber of bytes=%i\n", der_len); for (k = 0; k < der_len; k++) - printf ("%02x ", der[k]); - printf ("\n-----------------\n"); + fprintf (stderr, "%02x ", der[k]); + fputs ("\n-----------------\n", stderr); asn1_delete_structure (&definitions); asn1_delete_structure (&structure); @@ -313,14 +317,15 @@ main (int argc, char *argv[]) if (outputFileName == NULL) createFileName (inputFileAssignmentName, &outputFileName); - printf ("\nOutputFile=%s\n", outputFileName); + fprintf (stderr, "\nOutputFile=%s\n", outputFileName); outputFile = fopen (outputFileName, "w"); if (outputFile == NULL) { - printf ("asn1Coding: output file '%s' not available\n", - outputFileName); + fprintf (stderr, + "asn1Coding: output file '%s' not available\n", + outputFileName); free (der); free (inputFileAsnName); free (inputFileAssignmentName); @@ -331,7 +336,7 @@ main (int argc, char *argv[]) for (k = 0; k < der_len; k++) fprintf (outputFile, "%c", der[k]); fclose (outputFile); - printf ("\nWriting: done.\n"); + fputs ("\nWriting: done.\n", stderr); } free (der); diff --git a/src/asn1Decoding.c b/src/asn1Decoding.c index ee09e18..00156c5 100644 --- a/src/asn1Decoding.c +++ b/src/asn1Decoding.c @@ -144,18 +144,20 @@ main (int argc, char *argv[]) switch (asn1_result) { case ASN1_SUCCESS: - printf ("Parse: done.\n"); + fprintf (stderr, "Parse: done.\n"); break; case ASN1_FILE_NOT_FOUND: - printf ("asn1Decoding: FILE %s NOT FOUND\n", inputFileAsnName); + fprintf (stderr, "asn1Decoding: FILE %s NOT FOUND\n", + inputFileAsnName); break; case ASN1_SYNTAX_ERROR: case ASN1_IDENTIFIER_NOT_FOUND: case ASN1_NAME_TOO_LONG: - printf ("asn1Decoding: %s\n", errorDescription); + fprintf (stderr, "asn1Decoding: %s\n", errorDescription); break; default: - printf ("libtasn1 ERROR: %s\n", asn1_strerror (asn1_result)); + fprintf (stderr, "libtasn1 ERROR: %s\n", + asn1_strerror (asn1_result)); } if (asn1_result != ASN1_SUCCESS) @@ -175,7 +177,8 @@ main (int argc, char *argv[]) if (der == NULL) { - printf ("asn1Decoding: could not read '%s'\n", inputFileDerName); + fprintf (stderr, "asn1Decoding: could not read '%s'\n", + inputFileDerName); asn1_delete_structure (&definitions); free (inputFileAsnName); @@ -238,7 +241,8 @@ char errorDescription[ASN1_MAX_ERROR_DESCRIPTION_SIZE]; if (asn1_result != ASN1_SUCCESS) { - printf ("Structure creation: %s\n", asn1_strerror (asn1_result)); + fprintf (stderr, "Structure creation: %s\n", + asn1_strerror (asn1_result)); asn1_delete_structure (&structure); return asn1_result; } @@ -246,17 +250,18 @@ char errorDescription[ASN1_MAX_ERROR_DESCRIPTION_SIZE]; asn1_result = asn1_der_decoding (&structure, der, der_len, errorDescription); - if (!benchmark) printf ("\nDecoding: %s\n", asn1_strerror (asn1_result)); + if (!benchmark) + fprintf (stderr, "\nDecoding: %s\n", asn1_strerror (asn1_result)); if (asn1_result != ASN1_SUCCESS) { - printf ("asn1Decoding: %s\n", errorDescription); + fprintf (stderr, "asn1Decoding: %s\n", errorDescription); asn1_delete_structure (&structure); return asn1_result; } if (!benchmark) { - printf ("\nDECODING RESULT:\n"); + fprintf (stderr, "\nDECODING RESULT:\n"); asn1_print_structure (stdout, structure, "", ASN1_PRINT_NAME_TYPE_VALUE); } asn1_delete_structure (&structure); diff --git a/src/asn1Parser.c b/src/asn1Parser.c index 430ac7f..f19a9ef 100644 --- a/src/asn1Parser.c +++ b/src/asn1Parser.c @@ -100,10 +100,11 @@ main (int argc, char *argv[]) switch (option_result) { case 0: - printf ("option %s", long_options[option_index].name); + fprintf (stderr, "option %s", + long_options[option_index].name); if (optarg) - printf (" with arg %s", optarg); - printf ("\n"); + fprintf (stderr, " with arg %s", optarg); + putc ('\n', stderr); break; case 'h': /* HELP */ free (outputFileName); @@ -170,18 +171,20 @@ main (int argc, char *argv[]) switch (parse_result) { case ASN1_SUCCESS: - printf ("Done.\n"); + fputs ("Done.\n", stderr); break; case ASN1_FILE_NOT_FOUND: - printf ("asn1Parser: FILE %s NOT FOUND\n", inputFileName); + fprintf (stderr, "asn1Parser: FILE %s NOT FOUND\n", + inputFileName); break; case ASN1_SYNTAX_ERROR: case ASN1_IDENTIFIER_NOT_FOUND: case ASN1_NAME_TOO_LONG: - printf ("asn1Parser: %s\n", errorDescription); + fprintf (stderr, "asn1Parser: %s\n", errorDescription); break; default: - printf ("libtasn1 ERROR: %s\n", asn1_strerror (parse_result)); + fprintf (stderr, "libtasn1 ERROR: %s\n", + asn1_strerror (parse_result)); } @@ -32,4 +32,4 @@ ASN1DECODING=../src/asn1Decoding${EXEEXT} $ASN1DECODING \ $srcdir/../examples/pkix.asn \ $srcdir/crlf.cer \ - PKIX1Implicit88.Certificate >/dev/null + PKIX1Implicit88.Certificate >/dev/null 2>&1 |