Classes and functions reading and writing byte streams.
More...
|
typedef bool(* | das_prompt) (const char *sServer, const char *sRealm, const char *sDataset, const char *sMessage, char *sUser, char *sPassword) |
| Function signature for swapping out the user-prompt for credentials acquisition. More...
|
|
|
DAS_API char * | das_b64_encode (const unsigned char *data, size_t input_length, size_t *output_length) |
| Encode provided binary data as base64 characters in a new buffer. More...
|
|
DAS_API char * | das_ssl_getErr (const void *vpSsl, int nRet) |
| Get a new string allocated on the heap explaining an SSL error or NULL in nRet == 0. More...
|
|
DAS_API DasErrCode | DasCodec_init (DasCodec *pThis, DasAry *pAry, const char *sSemantic, const char *sEncType, int16_t uSzEach, ubyte cSep, das_units epoch) |
| Initialize a serial buffer decoder/encoder. More...
|
|
DAS_API int | DasCodec_decode (DasCodec *pThis, const ubyte *pBuf, int nBufLen, int nExpect, int *pValsRead) |
| Read values from a simple buffer into an array. More...
|
|
DAS_API void | DasCodec_deInit (DasCodec *pThis) |
| Release the reference count on the array given to this encoder/decoder.
|
|
DAS_API bool | das_cred_init (das_credential *pCred, const char *sServer, const char *sRealm, const char *sDataset, const char *sHash) |
| Initialize a credential to be cached in the credentials manager. More...
|
|
Classes and functions reading and writing byte streams.
◆ das_prompt
typedef bool(* das_prompt) (const char *sServer, const char *sRealm, const char *sDataset, const char *sMessage, char *sUser, char *sPassword) |
Function signature for swapping out the user-prompt for credentials acquisition.
- Parameters
-
sServer | The server name |
sRealm | The authorization realm on this server, can be same as the dataset |
sDataset | The name of the dataset on this server |
sMessage | An additional message that may be supplied, such as "The user name cannot contain a colon, ':', character" |
sUser | a pointer to 128 bytes of storage to hold the username |
sPassword | a pointer to 128 bytes of storage to hold the password |
- Returns
- true if the user entered a user name and password (even empty ones) and false if the prompt was canceled.
◆ das_b64_encode()
DAS_API char* das_b64_encode |
( |
const unsigned char * |
data, |
|
|
size_t |
input_length, |
|
|
size_t * |
output_length |
|
) |
| |
Encode provided binary data as base64 characters in a new buffer.
(Credit: stackoverflow user ryyst)
- Parameters
-
data | A pointer to the data to encode |
input_length | The number of input bytes to encode |
output_length | a pointer to location to receive the encoded length |
- Returns
- A pointer to a newly allocated buffer of at least size output_length, or NULL if calloc failed.
◆ das_ssl_getErr()
DAS_API char* das_ssl_getErr |
( |
const void * |
vpSsl, |
|
|
int |
nRet |
|
) |
| |
Get a new string allocated on the heap explaining an SSL error or NULL in nRet == 0.
To prevent memory leaks, caller must free string if return is NON null.
◆ DasCodec_init()
Initialize a serial buffer decoder/encoder.
- Parameters
-
pThis | A pointer to the memory area to initialize |
pAry | A pointer to the array which either receive or supply values. Values will be encoded so that they match the value type of the array. |
- Warning
- If the basic parameters of this array, such as it's value type or rank are changed, then DasCodec_init() must be re-called.
- Parameters
-
sSemantic | The purpose of the data to store in the buffer, should be one of 'bool','int','real','datatime','string'. This determines the kinds of calculations that may be performed on the data once in memory. |
sEncType | The basic encoding type of data in the buffer, one of:
- byte : 8-bit signed integer
- ubyte : 8-bit un-signed integer
- BEint : A signed integer 2+ bytes long, most significant byte first
- BEuint : An un-signed integer 2+ bytes long MSB first
- LEint : Little-endian version of BEint
- LEuint : Little-endian version of BEuint
- BEreal : An IEEE-754 floating point value, MSB first
- LEreal : An IEEE-754 floating point value, LSB first
- utf8 : A string of text bytes
|
nSzEach | the number of bytes in an item. For variable length items (which is common with the utf8 encoding) use -1. |
cSep | A single byte used to mark the end of a byte sequence for string data. By default any space character marks the end of a string. Use 0 to ignore. |
epoch | If time data needs to be converted from UTC strings an epoch will be needed. Otherwise this field can be NULL |
- Returns
- DAS_OKAY if an decoder/encoder for can be created for the given arguments, an error code otherwise.
- Note
- For 'string' semantic data where the last index in the array is ragged DasAry_markEnd() will be called after each string is read. Otherwise, no string larger then the last index will be written and zeros will be appended to fill out the last index when reading data.
◆ DasCodec_decode()
DAS_API int DasCodec_decode |
( |
DasCodec * |
pThis, |
|
|
const ubyte * |
pBuf, |
|
|
int |
nBufLen, |
|
|
int |
nExpect, |
|
|
int * |
pValsRead |
|
) |
| |
Read values from a simple buffer into an array.
Unlike the old das2 version, this encoder doesn't have a built-in number of values it will always expect to read. If no pre-determined number of values is given in nExpect, then it will read until the buffer is exhausted.
To control the number of bytes read control nBufLen
- Parameters
-
pThis | An encoder. The pointer isn't constant because the encoder may have to allocate some memory for long, variable length text values. |
pBuf | A pointer to the memory to read |
nBufLen | The length of the buffer parse into the array. Note that even for string data the function trys to read nLen bytes. Null values do not terminate parsing but do indicate the end of an individual utf-8 encoded item. |
nExpect | The number of values to try and read. Reading less then this does not trigger an error return. If the caller considers reading less values then expect to be an error, compare *pRead with the number provided for nExpect. If any number of values can be read, set this to -1. |
pValsRead | A pointer to a location to hold the number of values read or NULL. If NULL, the number of values read will not be returned |
- Returns
- the number of unread bytes or a negative ERR code if a data conversion error occured.
◆ das_cred_init()
DAS_API bool das_cred_init |
( |
das_credential * |
pCred, |
|
|
const char * |
sServer, |
|
|
const char * |
sRealm, |
|
|
const char * |
sDataset, |
|
|
const char * |
sHash |
|
) |
| |
Initialize a credential to be cached in the credentials manager.
- Parameters
-
pCred | A pointer to a das_credentials structure |
sServer | The name of the server, ex: 'jupiter.physics.uiowa.edu' |
sRealm | The authentication realm. This is provided in the dsdf files under the securityRealm keyword. |
sDataset | The dataset, ex: 'Juno/WAV/Survey' The dataset is typically determined by the http module by URL inspection. If this credentials manager is used for a general URL then the http module will not specify the the dataset. To match those sites, use NULL here. |
sHash | The hash value. Currently the library only supports HTTP Basic Authentication hashes. i.e. a USERNAME:PASSWORD string that has been base64 encoded. |