From: John Kohl Date: Mon, 26 Mar 1990 14:46:11 +0000 (+0000) Subject: *** empty log message *** X-Git-Tag: krb5-1.0-alpha2~973 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=a68c4e2c1c848f31a13c756168a20c0945d7158c;p=krb5.git *** empty log message *** git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@415 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/lib/krb5/asn.1/decode.c b/src/lib/krb5/asn.1/decode.c new file mode 100644 index 000000000..9127f99c1 --- /dev/null +++ b/src/lib/krb5/asn.1/decode.c @@ -0,0 +1,69 @@ +/* + * $Source$ + * $Author$ + * + * Copyright 1990 by the Massachusetts Institute of Technology. + * + * For copying and distribution information, please see the file + * . + * + * decoding glue routines. + */ + +#if !defined(lint) && !defined(SABER) +static char rcsid_decode_c[] = +"$Id$"; +#endif /* lint || saber */ + +#include +#include +#include "KRB5-types.h" +#include +#include +#include +#include "encode.h" +#include "asn1defs.h" + +#include + +#include + +krb5_error_code +decode_generic(input, output, decoder, translator, free_translation) +krb5_data *input; +register krb5_pointer *output; +int (*decoder) PROTOTYPE((PE, int, int, char *, krb5_pointer)); +krb5_pointer (*translator) PROTOTYPE((krb5_pointer, int * )); +void (*free_translation) PROTOTYPE((krb5_pointer )); +{ + krb5_pointer isode_temp; + PE pe; + PS ps; + krb5_error_code error = 0; + + if (!(ps = ps_alloc(str_open))) { + return(ENOMEM); + } + if (str_setup(ps, input->data, input->length, 1) != OK) { + error = ps->ps_errno + ISODE_50_PS_ERR_NONE; + ps_free(ps); + return(error); + } + if (!(pe = ps2pe(ps))) { + error = ps->ps_errno + ISODE_50_PS_ERR_NONE; + ps_free(ps); + return(error); + } + if ((*decoder)(pe, 1, 0, 0, &isode_temp) != OK) { + error = ISODE_50_LOCAL_ERR_BADDECODE; + pe_free(pe); + ps_free(ps); + return(error); + } + *output = (*translator)(isode_temp, &error); + pe_free(pe); + ps_free(ps); + free_translation(isode_temp); + return(error); /* may be error if output + failed above */ +}