diff options
author | Dariusz Michaluk <d.michaluk@samsung.com> | 2024-02-13 15:44:51 +0100 |
---|---|---|
committer | Dariusz Michaluk <d.michaluk@samsung.com> | 2024-02-14 10:46:44 +0100 |
commit | c28e9eeaa4dccef63b3b237ebe8a8b5abb23e335 (patch) | |
tree | 504a1953b56446487f4759d3a5f348bbeb925461 /src/asn1Coding.c | |
parent | 1778d37a3eec1209d7c9c064318f3ff8c5132490 (diff) | |
parent | 031996ef501f8c3d0532f7df1c38cf2e540a4f11 (diff) | |
download | libtasn1-tizen.tar.gz libtasn1-tizen.tar.bz2 libtasn1-tizen.zip |
Upgrade to libtasn1 4.19.0HEADaccepted/tizen/unified/20240214.164006tizenaccepted/tizen_unified
Change-Id: I893fd2c90c487d6e13b0b10e25b2cafc408da180
Diffstat (limited to 'src/asn1Coding.c')
-rw-r--r-- | src/asn1Coding.c | 60 |
1 files changed, 31 insertions, 29 deletions
diff --git a/src/asn1Coding.c b/src/asn1Coding.c index 86c1d07..deb90d3 100644 --- a/src/asn1Coding.c +++ b/src/asn1Coding.c @@ -1,5 +1,5 @@ /* asn1Coding.c --- program to generate a DER coding of an ASN1 definition. - * Copyright (C) 2002-2014 Free Software Foundation, Inc. + * Copyright (C) 2002-2022 Free Software Foundation, Inc. * * This file is part of LIBTASN1. * @@ -29,13 +29,14 @@ #include <libtasn1.h> -#define program_name "asn1Coding" +#include "progname.h" +#include "version-etc.h" /* This feature is available in gcc versions 2.5 and later. */ #if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) -#define ATTR_NO_RETRUN +# define ATTR_NO_RETRUN #else -#define ATTR_NO_RETRUN __attribute__ ((__noreturn__)) +# define ATTR_NO_RETRUN __attribute__ ((__noreturn__)) #endif ATTR_NO_RETRUN static void @@ -57,7 +58,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\ -o, --output=FILE output file\n\ -h, --help display this help and exit\n\ -v, --version output version information and exit\n"); - printf ("Report bugs to "PACKAGE_BUGREPORT); + emit_bug_reporting_address (); } exit (status); } @@ -72,13 +73,13 @@ readAssignment (FILE * file, char *varName, char *value) int ret; - ret = fscanf (file, "%s", varName); + ret = fscanf (file, "%1023s", varName); if (ret == EOF) return ASSIGNMENT_EOF; if (!strcmp (varName, "''")) varName[0] = 0; - ret = fscanf (file, "%s", value); + ret = fscanf (file, "%1023s", value); if (ret == EOF) return ASSIGNMENT_ERROR; @@ -113,8 +114,8 @@ createFileName (char *inputFileName, char **outputFileName) strlen (".out")); if (*outputFileName == NULL) { - fprintf(stderr, "Memory error\n"); - exit(1); + fprintf (stderr, "Memory error\n"); + exit (1); } memcpy (*outputFileName, inputFileName, dot_p - inputFileName); @@ -152,6 +153,8 @@ main (int argc, char *argv[]) int k; int last_ra; + set_program_name (argv[0]); + opterr = 0; /* disable error messages from getopt */ while (1) @@ -170,9 +173,8 @@ main (int argc, char *argv[]) usage (EXIT_SUCCESS); break; case 'v': /* VERSION */ - printf(program_name" "PACKAGE" " VERSION"\n"); - printf("Copyright (C) 2017-2019 Free Software Foundation, Inc.\n\n"); - printf("Written by Fabio Fiorina\n"); + version_etc (stdout, program_name, PACKAGE, VERSION, + "Fabio Fiorina", NULL); free (outputFileName); exit (0); break; @@ -180,12 +182,12 @@ main (int argc, char *argv[]) checkSyntaxOnly = 1; break; case 'o': /* OUTPUT */ - assert(optarg != NULL); - outputFileName = strdup(optarg); + assert (optarg != NULL); + outputFileName = strdup (optarg); if (outputFileName == NULL) { - fprintf(stderr, "Memory error\n"); - exit(1); + fprintf (stderr, "Memory error\n"); + exit (1); } break; case '?': /* UNKNOW OPTION */ @@ -198,7 +200,7 @@ main (int argc, char *argv[]) default: fprintf (stderr, "asn1Coding: ?? getopt returned character code Ox%x ??\n", - (unsigned)option_result); + (unsigned) option_result); } } @@ -209,18 +211,18 @@ main (int argc, char *argv[]) usage (EXIT_FAILURE); } - inputFileAsnName = strdup(argv[optind]); + inputFileAsnName = strdup (argv[optind]); if (inputFileAsnName == NULL) { - fprintf(stderr, "Memory error\n"); - exit(1); + fprintf (stderr, "Memory error\n"); + exit (1); } - inputFileAssignmentName = strdup(argv[optind+1]); + inputFileAssignmentName = strdup (argv[optind + 1]); if (inputFileAssignmentName == NULL) { - fprintf(stderr, "Memory error\n"); - exit(1); + fprintf (stderr, "Memory error\n"); + exit (1); } asn1_result = @@ -274,8 +276,8 @@ main (int argc, char *argv[]) asn1_result = asn1_create_element (definitions, value, &structure); } else - { - if (strcmp(value, "(NULL)") == 0) + { + if (strcmp (value, "(NULL)") == 0) asn1_result = asn1_write_value (structure, varName, NULL, 0); else asn1_result = asn1_write_value (structure, varName, value, 0); @@ -313,10 +315,10 @@ main (int argc, char *argv[]) { der = malloc (der_len); if (der == NULL) - { - fprintf(stderr, "Memory error\n"); - exit(1); - } + { + fprintf (stderr, "Memory error\n"); + exit (1); + } asn1_result = asn1_der_coding (structure, "", der, &der_len, errorDescription); } |