InternalFuncs


Functions

int write_option_string (ntar_option *option, void *buffer, size_t *buffer_size)
 This fcn writes a string option in a caller provided buffer.
int write_option_raw (ntar_option *option, void *buffer, size_t *buffer_size, void *raw_data, u_int16 raw_data_size)
 This fcn writes a raw buffer option in a caller provided buffer.
int write_option_uint64 (ntar_option *option, void *buffer, size_t *buffer_size)
 This fcn writes a 64-bit integer option in a caller provided buffer.
int write_option_uint32 (ntar_option *option, void *buffer, size_t *buffer_size)
 This fcn writes a 32-bit integer option in a caller provided buffer.
int write_null_option (void *buffer, size_t *buffer_size)
 This fcn writes the NULL (aka END OPTION) in a buffer.
int read_option_string (option_header *oh, int byte_order, void *buffer, size_t *buffer_length)
 This function reads a string out of an option and copies it to a caller provided buffer.
int read_option_uint64 (option_header *oh, int byte_order, void *buffer, size_t *buffer_length)
 This function reads a 64-bit integer out of an option and copies it to a caller provided buffer in host byte order.
int read_option_uint32 (option_header *oh, int byte_order, void *buffer, size_t *buffer_length)
 This function reads a 32-bit integer out of an option and copies it to a caller provided buffer in host byte order.
int read_option_raw (option_header *oh, int byte_order, void *buffer, size_t *buffer_length)
 This function reads the data of an option as a raw buffer, and copies it to a caller provided buffer without applying any byte order fixup.
int reallocate_memory (void **buffer, size_t *buffer_size, size_t new_size)
 This fcn reallocates a given buffer if it's too small.
int ntar_convert_errno (int local_errno)
 This fcn converts an errno value to the corresponding ntar error code.
int ntar_native_file_write (void *handle, void *buffer, size_t size)
int ntar_native_file_read (void *handle, void *buffer, size_t size, size_t *read_bytes)
int ntar_native_file_seek (void *handle, ntar_foff new_position, int origin, ntar_foff *old_position)
int ntar_native_file_close (ntar_file_handlers file_handlers)
int ntar_native_file_open (char *filename, char *flags, ntar_file_handlers *file_handlers)


Function Documentation

int ntar_convert_errno int  local_errno  ) 
 

This fcn converts an errno value to the corresponding ntar error code.

Parameters:
local_errno errno code.
Returns:

int ntar_native_file_close ntar_file_handlers  file_handlers  ) 
 

int ntar_native_file_open char *  filename,
char *  flags,
ntar_file_handlers file_handlers
 

int ntar_native_file_read void *  handle,
void *  buffer,
size_t  size,
size_t *  read_bytes
 

int ntar_native_file_seek void *  handle,
ntar_foff  new_position,
int  origin,
ntar_foff old_position
 

int ntar_native_file_write void *  handle,
void *  buffer,
size_t  size
 

int read_option_raw option_header *  oh,
int  byte_order,
void *  buffer,
size_t *  buffer_length
 

This function reads the data of an option as a raw buffer, and copies it to a caller provided buffer without applying any byte order fixup.

Parameters:
oh Pointer to the option header containing the raw data.
byte_order Byte order of the current section. Possible values are
buffer Caller provided buffer that will be filled with the raw data associated with the option on output.
buffer_length Pointer to an integer. On input, it contains the size of the buffer. On output it contains the effective number of bytes used in buffer (if the buffer was big enough) or the number of requested bytes (if the buffer was not big enough).
Returns:
Note:
  • All the values in the parameter oh are already written in host byte order.
  • This function does not make any assumption on the content of the raw data in the option. It's the caller responsibility to check if the raw data has the right size, and to perform byte order fixups.

int read_option_string option_header *  oh,
int  byte_order,
void *  buffer,
size_t *  buffer_length
 

This function reads a string out of an option and copies it to a caller provided buffer.

Parameters:
oh Pointer to the option header containing the string.
byte_order Byte order of the current section. Possible values are
buffer Caller provided buffer that will be filled with the NULL terminated string of the option on output.
buffer_length Pointer to an integer. On input, it contains the size of the buffer. On output it contains the effective number of bytes used in buffer (if the buffer was big enough) or the number of requested bytes (if the buffer was not big enough).
Returns:
Note:
  • All the values in the parameter oh are already written in host byte order.
  • This function supposes that the string is stored right after the end of the option header oh.

int read_option_uint32 option_header *  oh,
int  byte_order,
void *  buffer,
size_t *  buffer_length
 

This function reads a 32-bit integer out of an option and copies it to a caller provided buffer in host byte order.

Parameters:
oh Pointer to the option header containing the 32-bit integer.
byte_order Byte order of the current section. Possible values are
buffer Caller provided buffer that will be filled with the 64-bit integer of the option on output.
buffer_length Pointer to an integer. On input, it contains the size of the buffer. On output it contains the effective number of bytes used in buffer (if the buffer was big enough) or the number of requested bytes (if the buffer was not big enough).
Returns:
Note:
  • All the values in the parameter oh are already written in host byte order.
  • This function supposes that the integer is stored right after the end of the option header oh.

int read_option_uint64 option_header *  oh,
int  byte_order,
void *  buffer,
size_t *  buffer_length
 

This function reads a 64-bit integer out of an option and copies it to a caller provided buffer in host byte order.

Parameters:
oh Pointer to the option header containing the 64-bit integer.
byte_order Byte order of the current section. Possible values are
buffer Caller provided buffer that will be filled with the 64-bit integer of the option on output.
buffer_length Pointer to an integer. On input, it contains the size of the buffer. On output it contains the effective number of bytes used in buffer (if the buffer was big enough) or the number of requested bytes (if the buffer was not big enough).
Returns:
Note:
  • All the values in the parameter oh are already written in host byte order.
  • This function supposes that the integer is stored right after the end of the option header oh.

int reallocate_memory void **  buffer,
size_t *  buffer_size,
size_t  new_size
 

This fcn reallocates a given buffer if it's too small.

Parameters:
buffer Address of a user allocated pointer to the current buffer. On return it contains the pointer to the new buffer.
buffer_size Address of an integer containing the current size of the buffer. On return it contains the size of the newly allocated buffer.
new_size Requested new size of the buffer.
Returns:
Note:
This fcn does not reallocate the buffer if is large enough.

int write_null_option void *  buffer,
size_t *  buffer_size
 

This fcn writes the NULL (aka END OPTION) in a buffer.

Parameters:
buffer Caller provided buffer that will be filled with the NULL option
buffer_size Pointer to an integer. On input, it contains the size of the buffer. On output it contains the effective number of bytes used in buffer (if the buffer was big enough) or the number of requested bytes (if the buffer was not big enough).
Returns:
Note:
  • This fcn writes both the option header, and the option value. After writing the option, It alignes the stuff to 32bits (as specified in the draft, options should be 32-bit aligned) As a consequence, buffer_size will always contain a 32-bit aligned value on return.

int write_option_raw ntar_option option,
void *  buffer,
size_t *  buffer_size,
void *  raw_data,
u_int16  raw_data_size
 

This fcn writes a raw buffer option in a caller provided buffer.

Parameters:
option Pointer to the option that should be written.
buffer Caller provided buffer that will be filled with the string option.
buffer_size Pointer to an integer. On input, it contains the size of the buffer. On output it contains the effective number of bytes used in buffer (if the buffer was big enough) or the number of requested bytes (if the buffer was not big enough).
raw_data Pointer to the raw_data associated with the option.
raw_data_size Length of the raw_data associated with the option.
Returns:
Note:
  • This fcn writes both the option header, and the option value. After writing the option, It alignes the stuff to 32bits (as specified in the draft, options should be 32-bit aligned) As a consequence, buffer_size will always contain a 32-bit aligned value on return.

raw_data_size is 16bit, and not size_t, since the maximum option length is on 16 bits.

int write_option_string ntar_option option,
void *  buffer,
size_t *  buffer_size
 

This fcn writes a string option in a caller provided buffer.

Parameters:
option Pointer to the option that should be written.
buffer Caller provided buffer that will be filled with the string option.
buffer_size Pointer to an integer. On input, it contains the size of the buffer. On output it contains the effective number of bytes used in buffer (if the buffer was big enough) or the number of requested bytes (if the buffer was not big enough).
Returns:
Note:
  • This fcn writes both the option header, and the option value. After writing the option, It alignes the stuff to 32bits (as specified in the draft, options should be 32-bit aligned) As a consequence, buffer_size will always contain a 32-bit aligned value on return.

int write_option_uint32 ntar_option option,
void *  buffer,
size_t *  buffer_size
 

This fcn writes a 32-bit integer option in a caller provided buffer.

Parameters:
option Pointer to the option that should be written.
buffer Caller provided buffer that will be filled with the 32-bit integer option.
buffer_size Pointer to an integer. On input, it contains the size of the buffer. On output it contains the effective number of bytes used in buffer (if the buffer was big enough) or the number of requested bytes (if the buffer was not big enough).
Returns:
Note:
  • This fcn writes both the option header, and the option value. After writing the option, It alignes the stuff to 32bits (as specified in the draft, options should be 32-bit aligned) As a consequence, buffer_size will always contain a 32-bit aligned value on return.

int write_option_uint64 ntar_option option,
void *  buffer,
size_t *  buffer_size
 

This fcn writes a 64-bit integer option in a caller provided buffer.

Parameters:
option Pointer to the option that should be written.
buffer Caller provided buffer that will be filled with the 64-bit integer option.
buffer_size Pointer to an integer. On input, it contains the size of the buffer. On output it contains the effective number of bytes used in buffer (if the buffer was big enough) or the number of requested bytes (if the buffer was not big enough).
Returns:
Note:
  • This fcn writes both the option header, and the option value. After writing the option, It alignes the stuff to 32bits (as specified in the draft, options should be 32-bit aligned) As a consequence, buffer_size will always contain a 32-bit aligned value on return.


NTAR documentation. Copyright (c) 2004 - 2005 Condor Engineering, Inc. All rights reserved.