diff options
author | Simon Josefsson <simon@josefsson.org> | 2006-11-16 09:04:54 +0000 |
---|---|---|
committer | Simon Josefsson <simon@josefsson.org> | 2006-11-16 09:04:54 +0000 |
commit | 7fb4b71c5c3f55e7686209d9993726dfaa219b27 (patch) | |
tree | 7511d256eb7c9560bbdb92f9604176e02e24d27c /src | |
parent | 6cfa79db487699e3ba7116f56df26223cc798f30 (diff) | |
download | libtasn1-7fb4b71c5c3f55e7686209d9993726dfaa219b27.tar.gz libtasn1-7fb4b71c5c3f55e7686209d9993726dfaa219b27.tar.bz2 libtasn1-7fb4b71c5c3f55e7686209d9993726dfaa219b27.zip |
Use read_binary_file to read data, for Windows. Add self-test to test regressions.
Diffstat (limited to 'src')
-rw-r--r-- | src/asn1Decoding.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/src/asn1Decoding.c b/src/asn1Decoding.c index a3db3fe..ebc26ce 100644 --- a/src/asn1Decoding.c +++ b/src/asn1Decoding.c @@ -39,6 +39,7 @@ #include <progname.h> #include <version-etc.h> +#include <read-file.h> static const char help_man[] = "Usage: asn1Decoding [OPTION] DEFINITIONS ENCODED ASN1TYPE\n" @@ -75,8 +76,7 @@ main(int argc,char *argv[]) ASN1_TYPE structure=ASN1_TYPE_EMPTY; char errorDescription[MAX_ERROR_DESCRIPTION_SIZE]; int asn1_result=ASN1_SUCCESS; - FILE *inputFile; - unsigned char der[100*1024]; + unsigned char *der; int der_len=0; /* FILE *outputFile; */ @@ -173,10 +173,14 @@ main(int argc,char *argv[]) } - inputFile=fopen(inputFileDerName,"r"); + { + size_t tmplen; + der = read_binary_file (inputFileDerName, &tmplen); + der_len = tmplen; + } - if(inputFile==NULL){ - printf("asn1Decoding: file '%s' not found\n",inputFileDerName); + if(der==NULL){ + printf("asn1Decoding: could not read '%s'\n",inputFileDerName); asn1_delete_structure(&definitions); free(inputFileAsnName); @@ -201,12 +205,6 @@ main(int argc,char *argv[]) fclose(inputFile); */ - while(fscanf(inputFile,"%c",der+der_len) != EOF){ - der_len++; - } - fclose(inputFile); - - asn1_result=asn1_create_element(definitions,typeName,&structure); /* asn1_print_structure(stdout,structure,"",ASN1_PRINT_ALL); */ @@ -219,6 +217,7 @@ main(int argc,char *argv[]) free(inputFileAsnName); free(inputFileDerName); free(typeName); + free(der); exit(1); } @@ -249,6 +248,8 @@ main(int argc,char *argv[]) asn1_delete_structure(&definitions); asn1_delete_structure(&structure); + free(der); + free(inputFileAsnName); free(inputFileDerName); free(typeName); |