#define FREE(x) ((void) free((char *) (x)))
-struct krb5_rc_typelist
- {
- const krb5_rc_ops *ops;
- struct krb5_rc_typelist *next;
- };
+struct krb5_rc_typelist {
+ const krb5_rc_ops *ops;
+ struct krb5_rc_typelist *next;
+};
static struct krb5_rc_typelist krb5_rc_typelist_dfl = { &krb5_rc_dfl_ops, 0 };
static struct krb5_rc_typelist *typehead = &krb5_rc_typelist_dfl;
krb5_error_code krb5_rc_register_type(krb5_context context,
const krb5_rc_ops *ops)
{
- struct krb5_rc_typelist *t;
- for (t = typehead;t && strcmp(t->ops->type,ops->type);t = t->next)
- ;
- if (t)
- return KRB5_RC_TYPE_EXISTS;
- if (!(t = (struct krb5_rc_typelist *) malloc(sizeof(struct krb5_rc_typelist))))
- return KRB5_RC_MALLOC;
- t->next = typehead;
- t->ops = ops;
- typehead = t;
- return 0;
+ struct krb5_rc_typelist *t;
+ for (t = typehead;t && strcmp(t->ops->type,ops->type);t = t->next)
+ ;
+ if (t)
+ return KRB5_RC_TYPE_EXISTS;
+ t = (struct krb5_rc_typelist *) malloc(sizeof(struct krb5_rc_typelist));
+ if (t == NULL)
+ return KRB5_RC_MALLOC;
+ t->next = typehead;
+ t->ops = ops;
+ typehead = t;
+ return 0;
}
-krb5_error_code krb5_rc_resolve_type(krb5_context context, krb5_rcache *id, char *type)
+krb5_error_code krb5_rc_resolve_type(krb5_context context, krb5_rcache *id,
+ char *type)
{
- struct krb5_rc_typelist *t;
- for (t = typehead;t && strcmp(t->ops->type,type);t = t->next)
- ;
- if (!t)
- return KRB5_RC_TYPE_NOTFOUND;
- /* allocate *id? nah */
- (*id)->ops = t->ops;
- return 0;
+ struct krb5_rc_typelist *t;
+ for (t = typehead;t && strcmp(t->ops->type,type);t = t->next)
+ ;
+ if (!t)
+ return KRB5_RC_TYPE_NOTFOUND;
+ /* allocate *id? nah */
+ (*id)->ops = t->ops;
+ return 0;
}
char * krb5_rc_get_type(krb5_context context, krb5_rcache id)
{
- return id->ops->type;
+ return id->ops->type;
}
char * krb5_rc_default_type(krb5_context context)
{
- char *s;
- if ((s = getenv("KRB5RCACHETYPE")))
- return s;
- else
- return "dfl";
+ char *s;
+ if ((s = getenv("KRB5RCACHETYPE")))
+ return s;
+ else
+ return "dfl";
}
char * krb5_rc_default_name(krb5_context context)
{
- char *s;
- if ((s = getenv("KRB5RCACHENAME")))
- return s;
- else
- return (char *) 0;
+ char *s;
+ if ((s = getenv("KRB5RCACHENAME")))
+ return s;
+ else
+ return (char *) 0;
}
krb5_error_code
return retval;
}
if ((retval = krb5_rc_resolve(context, *id,
- krb5_rc_default_name(context))))
+ krb5_rc_default_name(context))))
FREE(*id);
(*id)->magic = KV5M_RCACHE;
return retval;