2N/A/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2N/A * Copyright 2008 Massachusetts Institute of Technology. 2N/A * All Rights Reserved. 2N/A * Export of this software from the United States of America may 2N/A * require a specific license from the United States Government. 2N/A * It is the responsibility of any person or organization contemplating 2N/A * export to obtain such a license before exporting. 2N/A * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and 2N/A * distribute this software and its documentation for any purpose and 2N/A * without fee is hereby granted, provided that the above copyright 2N/A * notice appear in all copies and that both that copyright notice and 2N/A * this permission notice appear in supporting documentation, and that 2N/A * the name of M.I.T. not be used in advertising or publicity pertaining 2N/A * to distribution of the software without specific, written prior 2N/A * permission. Furthermore if you modify this software you must label 2N/A * your software as modified software and not distribute it in such a 2N/A * fashion that it might be confused with the original M.I.T. software. 2N/A * M.I.T. makes no representations about the suitability of 2N/A * this software for any purpose. It is provided "as is" without express 2N/A * or implied warranty. 2N/A * k5buf string buffer module interface 2N/A/* The k5buf module is intended to allow multi-step string 2N/A construction in a fixed or dynamic buffer without the need to check 2N/A for a failure at each step (and without aborting on malloc 2N/A failure). If an allocation failure occurs or if the fixed buffer 2N/A runs out of room, the error will be discovered when the caller 2N/A retrieves the C string value or checks the length of the resulting 2N/A k5buf structures are stack-allocated, but are intended to be 2N/A opaque, so do not access the fields directly. This is a tool, not 2N/A a way of life, so do not put k5buf structure pointers into the 2N/A public API or into significant internal APIs. */ 2N/A/* We must define the k5buf structure here to allow stack allocation. 2N/A The structure is intended to be opaque, so the fields have funny 2N/A/* Initialize a k5buf using a fixed-sized, existing buffer. SPACE 2N/A must be more than zero, or an assertion failure will result. */ 2N/A/* Initialize a k5buf using an internally allocated dynamic buffer. 2N/A The buffer contents must be freed with krb5int_free_buf. */ 2N/A/* Add a C string to BUF. */ 2N/A/* Add a counted set of bytes to BUF. If is okay for DATA[0..LEN-1] 2N/A to contain null bytes if you are prepared to deal with that in the 2N/A output (use krb5int_buf_len to retrieve the length of the output). */ 2N/A/* Add sprintf-style formatted data to BUF. */ 2N/A/* Truncate BUF. LEN must be between 0 and the existing buffer 2N/A length, or an assertion failure will result. */ 2N/A/* Retrieve the byte array value of BUF, or NULL if there has been an 2N/A allocation failure or the fixed buffer ran out of room. 2N/A The byte array will be a C string unless binary data was added with 2N/A krb5int_buf_add_len; it will be null-terminated regardless. 2N/A Modifying the byte array does not invalidate the buffer, as long as 2N/A its length is not changed. 2N/A For a fixed buffer, the return value will always be equal to the 2N/A passed-in value of DATA at initialization time if it is not NULL. 2N/A For a dynamic buffer, any buffer modification operation except 2N/A krb5int_buf_truncate may invalidate the byte array address. */ 2N/A/* Retrieve the length of BUF, or -1 if there has been an allocation 2N/A failure or the fixed buffer ran out of room. The length is equal 2N/A to strlen(krb5int_buf_data(buf)) unless binary data was added with 2N/A krb5int_buf_add_len. */ 2N/A/* Free the storage used in the dynamic buffer BUF. The caller may 2N/A choose to take responsibility for freeing the return value of 2N/A krb5int_buf_data instead of using this function. If BUF is a fixed 2N/A buffer, an assertion failure will result. It is unnecessary 2N/A (though harmless) to free a buffer after an error is detected; the 2N/A storage will already have been freed in that case. */ 2N/A#
endif /* K5_BUF_H */