Function anjay_execute_get_arg_value
Defined in File io.h
Function Documentation
-
int anjay_execute_get_arg_value(anjay_execute_ctx_t *ctx, size_t *out_bytes_read, char *out_buf, size_t buf_size)
Attempts to read currently processed argument’s value (or part of it). Read data is written as null-terminated string into
out_buf.Returns ANJAY_ERR_BAD_REQUEST to indicate the message is malformed and user should forward this code as the return value of anjay_dm_resource_execute_t .
Function might return 0 when there is nothing more to read or because argument does not have associated value with it, or because the value has already been read / skipped entirely.
When the output buffer is not big enough to contain whole message content + terminating nullbyte, ANJAY_BUFFER_TOO_SHORT is returned, after which further calls can be made, to retrieve more data.
In case of an error following values are returned:
-1 if buf_size < 2 or out_buf is NULL
ANJAY_ERR_BAD_REQUEST in case of malformed message
In such cases all data read up to this point should be considered invalid.
- Parameters:
ctx – Execute context
out_bytes_read – Pointer to a variable that, on successful exit, will be set to the number of bytes read (not counting the terminating null-byte). May be NULL if not needed.
out_buf – Buffer where read bytes will be stored
buf_size – Size of the buffer
- Returns:
0 on success, a negative value in case of error, ANJAY_BUFFER_TOO_SHORT if the buffer is not big enough to contain whole message content + terminating nullbyte.