--- /dev/null
+/*
+ * $Source$
+ * $Author$
+ * $Id$
+ *
+ * Copyright 1990 by the Massachusetts Institute of Technology.
+ *
+ * For copying and distribution information, please see the file
+ * <krb5/mit-copyright.h>.
+ *
+ * #defines for using generic encoder routine.
+ */
+
+#include <krb5/copyright.h>
+
+#ifndef __KRB5_ENCODE_DEFS__
+#define __KRB5_ENCODE_DEFS__
+
+#define encode_krb5_authenticator(pauth, error) \
+ encode_generic(pauth, error, \
+ encode_KRB5_Authenticator, \
+ krb5_authenticator2KRB5_Authenticator, \
+ free_KRB5_Authenticator)
+#define decode_krb5_authenticator(pauth, error) \
+ (krb5_authenticator *) \
+ decode_generic(pauth, error, \
+ decode_KRB5_Authenticator, \
+ KRB5_Authenticator2krb5_authenticator, \
+ free_KRB5_Authenticator)
+
+#define encode_krb5_ticket(ptick, error) \
+ encode_generic(ptick, error, \
+ encode_KRB5_Ticket, \
+ krb5_ticket2KRB5_Ticket, \
+ free_KRB5_Ticket)
+
+#define decode_krb5_ticket(ptick, error) \
+ (krb5_ticket *) \
+ decode_generic(ptick, error, \
+ decode_KRB5_Ticket, \
+ KRB5_Ticket2krb5_ticket, \
+ free_KRB5_Ticket)
+
+#endif /* __KRB5_ENCODE_DEFS__ */
--- /dev/null
+/*
+ * $Source$
+ * $Author$
+ *
+ * Copyright 1990 by the Massachusetts Institute of Technology.
+ *
+ * For copying and distribution information, please see the file
+ * <krb5/mit-copyright.h>.
+ *
+ * encoding glue routines.
+ */
+
+#ifndef lint
+static char rcsid_glue3_c[] =
+"$Id$";
+#endif lint
+
+#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 <krb5/krb5_err.h>
+#include <krb5/krb5_tc_err.h>
+#include "glue.h"
+#include "gluedefs.h"
+
+#include <stdio.h>
+
+#ifdef __STDC__
+typedef void * pointer;
+#else
+typedef char * pointer;
+#endif
+
+static char encode_buf[BUFSIZ];
+
+krb5_string *
+encode_generic(input, error, encoder, translator, free_translation)
+pointer input;
+int *error;
+int (*encoder)(/* PE, int, int, char *, pointer */);
+pointer (*translator)(/* pointer, int * */);
+void (*free_translation)(/* pointer */);
+{
+ pointer isode_out;
+ PE pe;
+ PS ps;
+ register krb5_string *retval;
+
+ if (!(isode_out = (*translator)(input, error)))
+ return(0);
+ if (!(ps = ps_alloc(str_open))) {
+ *error = ENOMEM;
+ free_translation(isode_out);
+ return(0);
+ }
+ if (str_setup(ps, encode_buf, sizeof(encode_buf), 1) != OK) {
+ *error = ps->ps_errno + ISODE_50_PS_ERR_NONE;
+ errout:
+ ps_free(ps);
+ free_translation(isode_out);
+ return(0);
+ }
+ if ((*encoder)(&pe, 0, 0, 0, isode_out)) {
+ *error = ENOMEM;
+ goto errout;
+ }
+ retval = (krb5_string *)malloc(sizeof(*retval));
+ if (!retval) {
+ *error = ENOMEM;
+ goto errout;
+ }
+ if ((retval->length = ps_get_abs(pe)) > sizeof(encode_buf)) {
+ abort(); /* xxx */
+ }
+ retval->string = malloc(ps_get_abs(pe));
+ if (!retval->string) {
+ *error = ENOMEM;
+ free(retval);
+ goto errout;
+ }
+ if (pe2ps(ps, pe) != OK || ps_flush(ps) != OK) {
+ *error = ps->ps_errno + ISODE_50_PS_ERR_NONE;
+ free(retval->string);
+ free(retval);
+ goto errout;
+ }
+ bcopy(encode_buf, retval->string, retval->length);
+ ps_free(ps);
+ pe_free(pe);
+ free_translation(isode_out);
+ return(retval);
+}
+
+pointer
+decode_generic(input, error, decoder, translator, free_translation)
+krb5_string *input;
+int *error;
+int (*decoder)(/* PE, int, int, char *, pointer */);
+pointer (*translator)(/* pointer, int * */);
+void (*free_translation)(/* pointer */);
+{
+ register pointer krb5_out;
+ pointer isode_temp;
+ PE pe;
+ PS ps;
+
+ if (!(ps = ps_alloc(str_open))) {
+ *error = ENOMEM;
+ return(0);
+ }
+ if (str_setup(ps, input->string, input->length, 1) != OK) {
+ *error = ps->ps_errno + ISODE_50_PS_ERR_NONE;
+ ps_free(ps);
+ return(0);
+ }
+ if (!(pe = ps2pe(ps))) {
+ *error = ps->ps_errno + ISODE_50_PS_ERR_NONE;
+ ps_free(ps);
+ return(0);
+ }
+ if ((*decoder)(pe, 1, 0, 0, &isode_temp) != OK) {
+ *error = ISODE_50_LOCAL_ERR_BADDECODE;
+ pe_free(pe);
+ ps_free(ps);
+ return(0);
+ }
+ krb5_out = (*translator)(isode_temp, error);
+ pe_free(pe);
+ ps_free(ps);
+ free_translation(isode_temp);
+ return(krb5_out); /* may be error if krb5_out
+ failed above */
+}