Commit c19e515f authored by v0-e's avatar v0-e

copy: Add asn_copy() interface

parent 71b96b59
......@@ -54,6 +54,26 @@ asn_fprint(FILE *stream, const asn_TYPE_descriptor_t *td,
return fflush(stream);
}
/*
* Copy a structuture.
*/
int
asn_copy(const asn_TYPE_descriptor_t *td,
void **struct_dst, const void *struct_src) {
if(!td || !struct_dst || !struct_src) {
errno = EINVAL;
return -1;
}
if(!td->op) {
errno = ENOSYS;
return -1;
}
return td->op->copy_struct(td, struct_dst, struct_src);
}
/* Dump the data into the specified stdio stream */
static int
_print2fp(const void *buffer, size_t size, void *app_key) {
......
......@@ -302,6 +302,17 @@ 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 */
/*
* Copies a source structure (struct_src) into destination structure
* (struct_dst). Allocates memory for the destination structure, if necessary.
* RETURN VALUES:
* 0: Copy OK.
* -1: Problem copying the structure.
*/
int asn_copy(const asn_TYPE_descriptor_t *td, /* ASN.1 type descriptor */
void **struct_dst, /* Structure to be populated */
const void *struct_src); /* Structure to be copied */
#ifdef __cplusplus
}
#endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment