The "p" Package
These routines are meant to provide a low level means of converting C data
types to the "network" data format (ie. big endian, IEEE 754).
These are memory to memory routines only. Although they are made public,
their use is NOT recommended.
When reading or writing raw data from and to files or connections, the
pio routines are suggested.
Library: karma
Link With: -lkarma
Functions
Functions
flag
p_write_buf_float (char *buffer, float data)
Write a floating point number to a buffer.
Parameters:
- buffer :
A pointer to the buffer. This buffer must be at least 4 bytes long
- data :
The data. This must be in host natural byte order. The data will be
converted to IEEE network format prior to writing.
Returns: TRUE on success, else FALSE.
Multithreading Level: Unsafe
EXPERIMENTAL FUNCTION: subject to change without notice
flag
p_write_buf_float_trap (char *buffer, float data, flag blank_to_nan)
This routine will write a floating point number to a buffer
and will optionally convert blank values (TOOBIGs) to IEEE Not-A-Number
(NaN) values.
Parameters:
- buffer :
A pointer to the buffer. This buffer must be at least 4 bytes long
- data :
The data. This must be in host natural byte order. The data will be
converted to IEEE network format prior to writing.
- blank_to_nan :
If TRUE, TOOBIG values are converted to NaNs.
Returns: TRUE on success, else FALSE.
Multithreading Level: Unsafe
flag
p_read_buf_float (CONST char *buffer, float *data)
Read a floating point number from a buffer.
Parameters:
- buffer :
A pointer to the buffer. This buffer must be at least 4 bytes long
- data :
The output data will be written here. This will be in host natural
byte order. The data will be converted from network byte order after
reading.
Returns: TRUE on success, else FALSE.
Multithreading Level: Unsafe
Note: - The data will be converted from IEEE network format after reading.
EXPERIMENTAL FUNCTION: subject to change without notice
flag
p_read_buf_floats (CONST char *buffer, uaddr num_values, float *data,
uaddr *num_nan)
This routine will read many floating point numbers from a buffer
and will optionally trap IEEE Not-A-Number (NaN) values. Trapped NaNs are
converted to the TOOBIG value.
Parameters:
- buffer :
A pointer to the buffer. This buffer must be at least
4 * num_values bytes long
- num_values :
The number of values to read.
- data :
The data will be written here. This will be written in host natural
format. The data will be converted from IEEE network format prior to
writing.
- num_nan :
The number of NaN values found will be written here. If this is
NULL then NaN values are not trapped.
Returns: TRUE on success, else FALSE.
Multithreading Level: Unsafe
flag
p_write_buf_double (char *buffer, double data)
Write a double precision floating point number to a buffer.
Parameters:
- buffer :
A pointer to the buffer. This buffer must be at least 8 bytes long
- data :
The data. This must be in host natural byte order. The data will be
converted to IEEE network format prior to writing.
Returns: TRUE on success, else FALSE.
Multithreading Level: Unsafe
EXPERIMENTAL FUNCTION: subject to change without notice
flag
p_write_buf_double_trap (char *buffer, double data, flag blank_to_nan)
This routine will write a double precision floating point number
to a buffer and will optionally convert blank values (TOOBIGs) to IEEE
Not-A-Number (NaN) values.
Parameters:
- buffer :
A pointer to the buffer. This buffer must be at least 8 bytes long
- data :
The data. This must be in host natural byte order. The data will be
converted to IEEE network format prior to writing.
- blank_to_nan :
If TRUE, TOOBIG values are converted to NaNs.
Returns: TRUE on success, else FALSE.
Multithreading Level: Unsafe
flag
p_read_buf_double (CONST char *buffer, double *data)
Read a double precision floating point number from a buffer.
Parameters:
- buffer :
A pointer to the buffer. This buffer must be at least 8 bytes long
- data :
The output data will be written here. This will be in host natural
byte order. The data will be converted from network byte order after
reading.
Returns: TRUE on success, else FALSE.
Multithreading Level: Unsafe
Note: - The data will be converted from IEEE network format after reading.
EXPERIMENTAL FUNCTION: subject to change without notice
flag
p_read_buf_doubles (CONST char *buffer, uaddr num_values, double *data,
uaddr *num_nan)
This routine will read many double precision floating point
numbers from a buffer and will optionally trap IEEE Not-A-Number (NaN)
values. Trapped NaNs are converted to the TOOBIG value.
Parameters:
- buffer :
A pointer to the buffer. This buffer must be at least
8 * num_values bytes long
- num_values :
The number of values to read.
- data :
The data will be written here. This will be written in host natural
format. The data will be converted from IEEE network format prior to
writing.
- num_nan :
The number of NaN values found will be written here. If this is
NULL then NaN values are not trapped.
Returns: TRUE on success, else FALSE.
Multithreading Level: Unsafe
flag
p_write_buf16s (char *buffer, long data)
Write 16 bits of signed data to a buffer,
Parameters:
- buffer :
A pointer to the buffer. This buffer must be at least 2 bytes long
- data :
The data. This must be in host natural byte order. The data will be
converted to network byte order prior to writing.
Returns: TRUE on success, else FALSE.
Multithreading Level: Unsafe
flag
p_read_buf16s (char *buffer, long *data)
Read 16 bits of signed data from a buffer.
Parameters:
- buffer :
A pointer to the buffer. This buffer must be at least 2 bytes long
- data :
The output data will be written here. This will be in host natural
byte order. The data will be converted from network byte order after
reading.
Returns: TRUE on success, else FALSE.
Multithreading Level: Unsafe
flag
p_write_buf32s (char *buffer, long data)
Write 32 bits of signed data to a buffer,
Parameters:
- buffer :
A pointer to the buffer. This buffer must be at least 2 bytes long
- data :
The data. This must be in host natural byte order. The data will be
converted to network byte order prior to writing.
Returns: TRUE on success, else FALSE.
Multithreading Level: Unsafe
flag
p_read_buf32s (char *buffer, long *data)
Read 32 bits of signed data from a buffer.
Parameters:
- buffer :
A pointer to the buffer. This buffer must be at least 2 bytes long
- data :
The output data will be written here. This will be in host natural
byte order. The data will be converted from network byte order after
reading.
Returns: TRUE on success, else FALSE.
Multithreading Level: Unsafe
flag
p_write_buf16 (char *buffer, unsigned long data)
Write 16 bits of unsigned data to a buffer,
Parameters:
- buffer :
A pointer to the buffer. This buffer must be at least 2 bytes long
- data :
The data. This must be in host natural byte order. The data will be
converted to network byte order prior to writing.
Returns: TRUE on success, else FALSE.
Multithreading Level: Unsafe
flag
p_read_buf16 (char *buffer, unsigned long *data)
Read 16 bits of unsigned data from a buffer.
Parameters:
- buffer :
A pointer to the buffer. This buffer must be at least 2 bytes long
- data :
The output data will be written here. This will be in host natural
byte order. The data will be converted from network byte order after
reading.
Returns: TRUE on success, else FALSE.
Multithreading Level: Unsafe
flag
p_write_buf32 (char *buffer, unsigned long data)
Write 32 bits of unsigned data to a buffer,
Parameters:
- buffer :
A pointer to the buffer. This buffer must be at least 4 bytes long
- data :
The data. This must be in host natural byte order. The data will be
converted to network byte order prior to writing.
Returns: TRUE on success, else FALSE.
Multithreading Level: Unsafe
flag
p_read_buf32 (char *buffer, unsigned long *data)
Read 32 bits of unsigned data from a buffer.
Parameters:
- buffer :
A pointer to the buffer. This buffer must be at least 4 bytes long
- data :
The output data will be written here. This will be in host natural
byte order. The data will be converted from network byte order after
reading.
Returns: TRUE on success, else FALSE.
Multithreading Level: Unsafe
flag
p_write_buf64 (char *buffer, unsigned long data)
Write 64 bits of data to a buffer.
Parameters:
- buffer :
A pointer to the buffer. This buffer must be at least 8 bytes long
- data :
The data. This must be in host natural byte order. The data will be
converted to network byte order prior to writing.
Returns: TRUE on success, else FALSE.
Multithreading Level: Unsafe
flag
p_read_buf64 (char *buffer, unsigned long *data)
Read 64 bits of signed data from a buffer.
Parameters:
- buffer :
A pointer to the buffer. This buffer must be at least 8 bytes long
- data :
The output data will be written here. This will be in host natural
byte order. The data will be converted from network byte order after
reading.
Returns: TRUE on success, else FALSE.
Multithreading Level: Unsafe
Back to Karma Home Page
Contact: Richard Gooch
Web Development: Ariel Internet Services