constness

This commit is contained in:
Lev Walkin 2017-11-07 04:20:52 -08:00
parent ec4b7af9ef
commit cf573ec13c
3 changed files with 42 additions and 17 deletions

View File

@ -0,0 +1,23 @@
The return value is returned in a compound structure:
\begin{codesample}
typedef struct {
enum {
RC_OK, /* Decoded successfully */
RC_WMORE, /* More data expected, call again */
RC_FAIL /* Failure to decode data */
} code; /* Result code */
size_t consumed; /* Number of bytes consumed */
} asn_dec_rval_t;
\end{codesample}
The \code{.code} member specifies the decoding outcome.
\begin{description}[labelindent=\parindent]
\item[RC\_OK] Decoded successfully and completely
\item[RC\_WMORE] More data expected, call again
\item[RC\_FAIL] Failed for good
\end{description}
The \code{.consumed} member specifies the amount of \code{buffer} data
that was used during parsing, irrespectively of the \code{.code}.

View File

@ -33,22 +33,25 @@ asn_TYPE_outmost_tag(const asn_TYPE_descriptor_t *type_descriptor,
* Print the target language's structure in human readable form.
*/
int
asn_fprint(FILE *stream, asn_TYPE_descriptor_t *td, const void *struct_ptr) {
if(!stream) stream = stdout;
if(!td || !struct_ptr) {
errno = EINVAL;
return -1;
asn_fprint(FILE *stream, const asn_TYPE_descriptor_t *td,
const void *struct_ptr) {
if(!stream) stream = stdout;
if(!td || !struct_ptr) {
errno = EINVAL;
return -1;
}
/* Invoke type-specific printer */
if(td->op->print_struct(td, struct_ptr, 1, _print2fp, stream))
return -1;
if(td->op->print_struct(td, struct_ptr, 1, _print2fp, stream)) {
return -1;
}
/* Terminate the output */
if(_print2fp("\n", 1, stream))
return -1;
/* Terminate the output */
if(_print2fp("\n", 1, stream)) {
return -1;
}
return fflush(stream);
return fflush(stream);
}
/* Dump the data into the specified stdio stream */

View File

@ -242,17 +242,16 @@ typedef struct asn_TYPE_tag2member_s {
} asn_TYPE_tag2member_t;
/*
* This function is a wrapper around (td)->print_struct, which prints out
* the contents of the target language's structure (struct_ptr) into the
* file pointer (stream) in human readable form.
* This function prints out the contents of the target language's structure
* (struct_ptr) into the file pointer (stream) in human readable form.
* RETURN VALUES:
* 0: The structure is printed.
* -1: Problem dumping the structure.
* (See also xer_fprint() in xer_encoder.h)
*/
int asn_fprint(FILE *stream, /* Destination stream descriptor */
asn_TYPE_descriptor_t *td, /* ASN.1 type descriptor */
const void *struct_ptr); /* Structure to be printed */
int asn_fprint(FILE *stream, /* Destination stream descriptor */
const asn_TYPE_descriptor_t *td, /* ASN.1 type descriptor */
const void *struct_ptr); /* Structure to be printed */
#ifdef __cplusplus
}