Aug 18, 2006 KRB5_STORAGE 3

### NAME

krb5_storage, krb5_storage_emem, krb5_storage_from_data, krb5_storage_from_fd, krb5_storage_from_mem, krb5_storage_set_flags, krb5_storage_clear_flags, krb5_storage_is_flags, krb5_storage_set_byteorder, krb5_storage_get_byteorder, krb5_storage_set_eof_code, krb5_storage_seek, krb5_storage_read, krb5_storage_write, krb5_storage_free, krb5_storage_to_data, krb5_store_int32, krb5_ret_int32, krb5_store_uint32, krb5_ret_uint32, krb5_store_int16, krb5_ret_int16, krb5_store_uint16, krb5_ret_uint16, krb5_store_int8, krb5_ret_int8, krb5_store_uint8, krb5_ret_uint8, krb5_store_data, krb5_ret_data, krb5_store_string, krb5_ret_string, krb5_store_stringnl, krb5_ret_stringnl, krb5_store_stringz, krb5_ret_stringz, krb5_store_principal, krb5_ret_principal, krb5_store_keyblock, krb5_ret_keyblock, krb5_store_times, krb5_ret_times, krb5_store_address, krb5_ret_address, krb5_store_addrs, krb5_ret_addrs, krb5_store_authdata, krb5_ret_authdata, krb5_store_creds, krb5_ret_creds - operates on the Kerberos datatype krb5_storage

### LIBRARY

Kerberos 5 Library (libkrb5, -lkrb5)

### SYNOPSIS

```struct krb5_storage;`

```krb5_storage *` krb5_storage_from_fd(```int fd`)
```krb5_storage *` krb5_storage_emem(```void`)
```krb5_storage *` krb5_storage_from_mem(```void *buf``, size_t len`)
```krb5_storage *` krb5_storage_from_data(```krb5_data *data`)
```void` krb5_storage_set_flags(```krb5_storage *sp``, krb5_flags flags`)
```void` krb5_storage_clear_flags(```krb5_storage *sp``, krb5_flags flags`)
```krb5_boolean` krb5_storage_is_flags(```krb5_storage *sp``, krb5_flags flags`)
```void` krb5_storage_set_byteorder(```krb5_storage *sp``, krb5_flags byteorder`)
```krb5_flags` krb5_storage_get_byteorder(```krb5_storage *sp``, krb5_flags byteorder`)
```void` krb5_storage_set_eof_code(```krb5_storage *sp``, int code`)
```off_t` krb5_storage_seek(```krb5_storage *sp``, off_t offset``, int whence`)
```krb5_ssize_t` krb5_storage_read(```krb5_storage *sp``, void *buf``, size_t len`)
```krb5_ssize_t` krb5_storage_write(```krb5_storage *sp``, const void *buf``, size_t len`)
```krb5_error_code` krb5_storage_free(```krb5_storage *sp`)
```krb5_error_code` krb5_storage_to_data(```krb5_storage *sp``, krb5_data *data`)
```krb5_error_code` krb5_store_int32(```krb5_storage *sp``, int32_t value`)
```krb5_error_code` krb5_ret_int32(```krb5_storage *sp``, int32_t *value`)
```krb5_error_code` krb5_ret_uint32(```krb5_storage *sp``, uint32_t *value`)
```krb5_error_code` krb5_store_uint32(```krb5_storage *sp``, uint32_t value`)
```krb5_error_code` krb5_store_int16(```krb5_storage *sp``, int16_t value`)
```krb5_error_code` krb5_ret_int16(```krb5_storage *sp``, int16_t *value`)
```krb5_error_code` krb5_store_uint16(```krb5_storage *sp``, uint16_t value`)
```krb5_error_code` krb5_ret_uint16(```krb5_storage *sp``, u_int16_t *value`)
```krb5_error_code` krb5_store_int8(```krb5_storage *sp``, int8_t value`)
```krb5_error_code` krb5_ret_int8(```krb5_storage *sp``, int8_t *value`)
```krb5_error_code` krb5_store_uint8(```krb5_storage *sp``, u_int8_t value`)
```krb5_error_code` krb5_ret_uint8(```krb5_storage *sp``, u_int8_t *value`)
```krb5_error_code` krb5_store_data(```krb5_storage *sp``, krb5_data data`)
```krb5_error_code` krb5_ret_data(```krb5_storage *sp``, krb5_data *data`)
```krb5_error_code` krb5_store_string(```krb5_storage *sp``, const char *s`)
```krb5_error_code` krb5_ret_string(```krb5_storage *sp``, char **string`)
```krb5_error_code` krb5_store_stringnl(```krb5_storage *sp``, const char *s`)
```krb5_error_code` krb5_ret_stringnl(```krb5_storage *sp``, char **string`)
```krb5_error_code` krb5_store_stringz(```krb5_storage *sp``, const char *s`)
```krb5_error_code` krb5_ret_stringz(```krb5_storage *sp``, char **string`)
```krb5_error_code` krb5_store_principal(```krb5_storage *sp``, krb5_const_principal p`)
```krb5_error_code` krb5_ret_principal(```krb5_storage *sp``, krb5_principal *princ`)
```krb5_error_code` krb5_store_keyblock(```krb5_storage *sp``, krb5_keyblock p`)
```krb5_error_code` krb5_ret_keyblock(```krb5_storage *sp``, krb5_keyblock *p`)
```krb5_error_code` krb5_store_times(```krb5_storage *sp``, krb5_times times`)
```krb5_error_code` krb5_ret_times(```krb5_storage *sp``, krb5_times *times`)
```krb5_error_code` krb5_store_address(```krb5_storage *sp``, krb5_address p`)
```krb5_error_code` krb5_ret_address(```krb5_storage *sp``, krb5_address *adr`)
```krb5_error_code` krb5_store_addrs(```krb5_storage *sp``, krb5_addresses p`)
```krb5_error_code` krb5_ret_addrs(```krb5_storage *sp``, krb5_addresses *adr`)
```krb5_error_code` krb5_store_authdata(```krb5_storage *sp``, krb5_authdata auth`)
```krb5_error_code` krb5_ret_authdata(```krb5_storage *sp``, krb5_authdata *auth`)
```krb5_error_code` krb5_store_creds(```krb5_storage *sp``, krb5_creds *creds`)
```krb5_error_code` krb5_ret_creds(```krb5_storage *sp``, krb5_creds *creds`)

### DESCRIPTION

The ```krb5_storage` structure holds a storage element that is used for data manipulation. The structure contains no public accessible elements.

krb5_storage_emem(``) create a memory based krb5 storage unit that dynamicly resized to the ammount of data stored in. The storage never returns errors, on memory allocation errors exit(3) will be called.

krb5_storage_from_data(``) create a krb5 storage unit that will read is data from a ```krb5_data`. There is no copy made of the ```data`, so the caller must not free ```data` until the storage is freed.

krb5_storage_from_fd(``) create a krb5 storage unit that will read is data from a file descriptor. The descriptor must be seekable if krb5_storage_seek(``) is used. Caller must not free the file descriptor before the storage is freed.

krb5_storage_from_mem(``) create a krb5 storage unit that will read is data from a memory region. There is no copy made of the ```data`, so the caller must not free ```data` until the storage is freed.

krb5_storage_set_flags(``) and krb5_storage_clear_flags(``) modifies the behavior of the storage functions. krb5_storage_is_flags(``) tests if the ```flags` are set on the ```krb5_storage`. Valid flags to set, is and clear is are:

KRB5_STORAGE_PRINCIPAL_WRONG_NUM_COMPONENTS
  Stores the number of principal componets one too many when storing principal namees, used for compatibility with version 1 of file keytabs and version 1 of file credential caches.
KRB5_STORAGE_PRINCIPAL_NO_NAME_TYPE
  Doesn't store the name type in when storing a principal name, used for compatibility with version 1 of file keytabs and version 1 of file credential caches.
KRB5_STORAGE_KEYBLOCK_KEYTYPE_TWICE
  Stores the keyblock type twice storing a keyblock, used for compatibility version 3 of file credential caches.
KRB5_STORAGE_BYTEORDER_MASK
  bitmask that can be used to and out what type of byte order order is used.
KRB5_STORAGE_BYTEORDER_BE
  Store integers in in big endian byte order, this is the default mode.
KRB5_STORAGE_BYTEORDER_LE
  Store integers in in little endian byte order.
KRB5_STORAGE_BYTEORDER_HOST
  Stores the integers in host byte order, used for compatibility with version 1 of file keytabs and version 1 and 2 of file credential caches.
KRB5_STORAGE_CREDS_FLAGS_WRONG_BITORDER
  Store the credential flags in a krb5_creds in the reverse bit order.

krb5_storage_set_byteorder(``) and krb5_storage_get_byteorder(``) modifies the byte order used in the storage for integers. The flags used is same as above. The valid flags are ```KRB5_STORAGE_BYTEORDER_BE`, ```KRB5_STORAGE_BYTEORDER_LE` and ```KRB5_STORAGE_BYTEORDER_HOST`.

krb5_storage_set_eof_code(``) sets the error code that will be returned on end of file condition to ```code`.

krb5_storage_seek(``) seeks ```offset` bytes in the storage
`` The ```whence` argument is one of

SEEK_SET
  offset is from begining of storage.
SEEK_CUR
  offset is relative from current offset.
SEEK_END
  offset is from end of storage.

krb5_storage_read(``) reads ```len` (or less bytes in case of end of file) into ```buf` from the current offset in the storage
``

krb5_storage_write(``) writes ```len` or (less bytes in case of end of file) from ```buf` from the current offset in the storage
``

krb5_storage_free(``) frees the storage
``

krb5_storage_to_data(``) converts the data in storage
`` into a ```krb5_data` structure. ```data` must be freed with krb5_data_free(``) by the caller when done with the ```data`.

All ```krb5_store` and ```krb5_ret` functions move the current offset forward when the functions returns.

krb5_store_int32(``), krb5_ret_int32(``), krb5_store_uint32(``), krb5_ret_uint32(``), krb5_store_int16(``), krb5_ret_int16(``), krb5_store_uint16(``), krb5_ret_uint16(``), krb5_store_int8(``), krb5_ret_int8(``) krb5_store_uint8(``), and krb5_ret_uint8(``) stores and reads an integer from
`` in the byte order specified by the flags set on the
``

krb5_store_data(``) and krb5_ret_data(``) store and reads a krb5_data. The length of the data is stored with krb5_store_int32(``).

krb5_store_string(``) and krb5_ret_string(``) store and reads a string by storing the length of the string with krb5_store_int32(``) followed by the string itself.

krb5_store_stringnl(``) and krb5_ret_stringnl(``) store and reads a string by storing string followed by a ```'0`.

krb5_store_stringz(``) and krb5_ret_stringz(``) store and reads a string by storing string followed by a ```NUL`.

krb5_store_principal(``) and krb5_ret_principal(``) store and reads a principal.

krb5_store_keyblock(``) and krb5_ret_keyblock(``) store and reads a ```krb5_keyblock`.

krb5_store_times(``) krb5_ret_times(``) store and reads ```krb5_times` structure .

krb5_store_address(``) and krb5_ret_address(``) store and reads a ```krb5_address`.

krb5_store_addrs(``) and krb5_ret_addrs(``) store and reads a ```krb5_addresses`.

krb5_store_authdata(``) and krb5_ret_authdata(``) store and reads a ```krb5_authdata`.

krb5_store_creds(``) and krb5_ret_creds(``) store and reads a ```krb5_creds`.

### SEE ALSO

krb5(3), krb5_data(3), kerberos(8)