*** empty log message ***
authorJohn Kohl <jtkohl@mit.edu>
Mon, 26 Mar 1990 14:46:11 +0000 (14:46 +0000)
committerJohn Kohl <jtkohl@mit.edu>
Mon, 26 Mar 1990 14:46:11 +0000 (14:46 +0000)
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@415 dc483132-0cff-0310-8789-dd5450dbe970

src/lib/krb5/asn.1/decode.c [new file with mode: 0644]

diff --git a/src/lib/krb5/asn.1/decode.c b/src/lib/krb5/asn.1/decode.c
new file mode 100644 (file)
index 0000000..9127f99
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * $Source$
+ * $Author$
+ *
+ * Copyright 1990 by the Massachusetts Institute of Technology.
+ *
+ * For copying and distribution information, please see the file
+ * <krb5/mit-copyright.h>.
+ *
+ * decoding glue routines.
+ */
+
+#if !defined(lint) && !defined(SABER)
+static char rcsid_decode_c[] =
+"$Id$";
+#endif /* lint || saber */
+
+#include <krb5/copyright.h>
+#include <isode/psap.h>
+#include "KRB5-types.h"
+#include <krb5/krb5.h>
+#include <errno.h>
+#include <krb5/isode_err.h>
+#include "encode.h"
+#include "asn1defs.h"
+
+#include <krb5/ext-proto.h>
+
+#include <stdio.h>
+
+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 */
+}