make the krb5_storage opaque, and add function wrappers for

store/fetch/seek, and also make the eof-code configurable


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@10931 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Johan Danielsson
2002-04-18 14:00:44 +00:00
parent fe181a304d
commit ce19f448ae
6 changed files with 103 additions and 34 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997-2001 Kungliga Tekniska H<>gskolan
* Copyright (c) 1997-2002 Kungliga Tekniska H<>gskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
@@ -32,6 +32,7 @@
*/
#include "krb5_locl.h"
#include "store-int.h"
RCSID("$Id$");
@@ -72,6 +73,29 @@ krb5_storage_get_byteorder(krb5_storage *sp, krb5_flags byteorder)
return sp->flags & KRB5_STORAGE_BYTEORDER_MASK;
}
off_t
krb5_storage_seek(krb5_storage *sp, off_t offset, int whence)
{
return (*sp->seek)(sp, offset, whence);
}
ssize_t
krb5_storage_read(krb5_storage *sp, void *buf, size_t len)
{
return sp->fetch(sp, buf, len);
}
ssize_t
krb5_storage_write(krb5_storage *sp, const void *buf, size_t len)
{
return sp->store(sp, buf, len);
}
void
krb5_storage_set_eof_code(krb5_storage *sp, int code)
{
sp->eof_code = code;
}
ssize_t
_krb5_put_int(void *buffer, unsigned long value, size_t size)
@@ -142,7 +166,7 @@ krb5_store_int(krb5_storage *sp,
_krb5_put_int(v, value, len);
ret = sp->store(sp, v, len);
if (ret != len)
return (ret<0)?errno:KRB5_CC_END;
return (ret<0)?errno:sp->eof_code;
return 0;
}
@@ -167,7 +191,7 @@ krb5_ret_int(krb5_storage *sp,
unsigned long w;
ret = sp->fetch(sp, v, len);
if(ret != len)
return (ret<0)?errno:KRB5_CC_END;
return (ret<0)?errno:sp->eof_code;
_krb5_get_int(v, &w, len);
*value = w;
return 0;
@@ -223,7 +247,7 @@ krb5_store_int8(krb5_storage *sp,
ret = sp->store(sp, &value, sizeof(value));
if (ret != sizeof(value))
return (ret<0)?errno:KRB5_CC_END;
return (ret<0)?errno:sp->eof_code;
return 0;
}
@@ -235,7 +259,7 @@ krb5_ret_int8(krb5_storage *sp,
ret = sp->fetch(sp, value, sizeof(*value));
if (ret != sizeof(*value))
return (ret<0)?errno:KRB5_CC_END;
return (ret<0)?errno:sp->eof_code;
return 0;
}
@@ -251,7 +275,7 @@ krb5_store_data(krb5_storage *sp,
if(ret != data.length){
if(ret < 0)
return errno;
return KRB5_CC_END;
return sp->eof_code;
}
return 0;
}
@@ -272,7 +296,7 @@ krb5_ret_data(krb5_storage *sp,
if (size) {
ret = sp->fetch(sp, data->data, size);
if(ret != size)
return (ret < 0)? errno : KRB5_CC_END;
return (ret < 0)? errno : sp->eof_code;
}
return 0;
}
@@ -315,7 +339,7 @@ krb5_store_stringz(krb5_storage *sp, const char *s)
if(ret < 0)
return ret;
else
return KRB5_CC_END;
return sp->eof_code;
}
return 0;
}
@@ -346,7 +370,7 @@ krb5_ret_stringz(krb5_storage *sp,
if(ret != 1){
free(s);
if(ret == 0)
return KRB5_CC_END;
return sp->eof_code;
return ret;
}
*string = s;
@@ -593,37 +617,35 @@ krb5_store_creds(krb5_storage *sp, krb5_creds *creds)
int ret;
ret = krb5_store_principal(sp, creds->client);
if (ret)
if(ret)
return ret;
ret = krb5_store_principal(sp, creds->server);
if (ret)
if(ret)
return ret;
ret = krb5_store_keyblock(sp, creds->session);
if (ret)
if(ret)
return ret;
ret = krb5_store_times(sp, creds->times);
if (ret)
if(ret)
return ret;
ret = krb5_store_int8(sp, 0); /* this is probably the
enc-tkt-in-skey bit from KDCOptions */
if (ret)
if(ret)
return ret;
ret = krb5_store_int32(sp, creds->flags.i);
if (ret)
if(ret)
return ret;
ret = krb5_store_addrs(sp, creds->addresses);
if (ret)
if(ret)
return ret;
ret = krb5_store_authdata(sp, creds->authdata);
if (ret)
if(ret)
return ret;
ret = krb5_store_data(sp, creds->ticket);
if (ret)
if(ret)
return ret;
ret = krb5_store_data(sp, creds->second_ticket);
if (ret)
return ret;
return 0;
return ret;
}
krb5_error_code
@@ -655,10 +677,10 @@ krb5_ret_creds(krb5_storage *sp, krb5_creds *creds)
if(ret) goto cleanup;
ret = krb5_ret_data (sp, &creds->second_ticket);
cleanup:
if(ret)
if(ret) {
#if 0
krb5_free_creds_contents(context, creds) /* XXX */
krb5_free_creds_contents(context, creds); /* XXX */
#endif
;
}
return ret;
}