diff --git a/doc/docsrc/asn_dec_rval.inc b/doc/docsrc/asn_dec_rval.inc new file mode 100644 index 0000000000000000000000000000000000000000..82b855135127145308d269dfd2fd53131244de78 --- /dev/null +++ b/doc/docsrc/asn_dec_rval.inc @@ -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}. + diff --git a/skeletons/constr_TYPE.c b/skeletons/constr_TYPE.c index 7a135ce23188547295aeb862663598eb846aead9..aefaefdb718a315c68ec88f0ebcc49a4912d8b77 100644 --- a/skeletons/constr_TYPE.c +++ b/skeletons/constr_TYPE.c @@ -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 */ diff --git a/skeletons/constr_TYPE.h b/skeletons/constr_TYPE.h index d9d55c206c7a2dd7914cc68aa6579ad69bea31cc..31102f55f156432655e891b12cf6df28285df05e 100644 --- a/skeletons/constr_TYPE.h +++ b/skeletons/constr_TYPE.h @@ -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 }