X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=doc%2Fodr.xml;h=770ad9cd1be24fa56682c1cdb15f54f82d20b4d3;hp=0633205e602cf55012b621e38912aeedbcd90bef;hb=5541b773e8ee0e5c086946016c060f6f629bd410;hpb=db6b40fa96ba3c3cda68d143a17b5b1fd0a20eb4 diff --git a/doc/odr.xml b/doc/odr.xml index 0633205..770ad9c 100644 --- a/doc/odr.xml +++ b/doc/odr.xml @@ -1,6 +1,5 @@ - The ODR Module - + Introduction @@ -95,7 +94,7 @@ - void *odr_malloc(ODR o, int size); + void *odr_malloc(ODR o, size_t size); @@ -105,7 +104,7 @@ - void odr_reset(ODR o, int size); + void odr_reset(ODR o); @@ -121,7 +120,7 @@ - int odr_total(ODR o); + size_t odr_total(ODR o); @@ -259,12 +258,12 @@ data you wish to decode (eg, odr_integer() odr z_APDU()). - + Encoding and decoding functions - int odr_integer(ODR o, int **p, int optional, const char *name); - + int odr_integer(ODR o, Odr_int **p, int optional, const char *name); + int z_APDU(ODR o, Z_APDU **p, int optional, const char *name); @@ -294,7 +293,7 @@ free(2) to release the memory. You can decode several data elements (by repeated calls to odr_setbuf() and your decoding function), and - new memory will be allocated each time. When you do call + new memory will be allocated each time. When you do call odr_reset(), everything decoded since the last call to odr_reset() will be released. @@ -309,36 +308,37 @@ informative operation. - + Printing @@ -378,11 +378,11 @@ void do_nothing_useful(int value) Here the user provides an opaque handle and two handlers, stream_write for writing, and stream_close which is supposed - to close/free resources associated with handle. + to close/free resources associated with handle. The stream_close handler is optional and if NULL for the function is provided, it will not be invoked. The stream_write takes the ODR handle - as parameter, the user defined handle, a type + as parameter, the user defined handle, a type ODR_OCTETSTRING, ODR_VISIBLESTRING which indicates the type of contents is being written. @@ -392,8 +392,8 @@ void do_nothing_useful(int value) const char **odr_get_element_path(ODR o); - which returns a list of current elements that ODR deals with at the - moment. For the returned array, say ar, + which returns a list of current elements that ODR deals with at the + moment. For the returned array, say ar, ar[0] is the top level element, ar[n] is the last. The last element has the property that ar[n+1] == NULL. @@ -403,7 +403,7 @@ void do_nothing_useful(int value) For a database record part of a PresentResponse the array returned by odr_get_element - is presentResponse, databaseOrSurDiagnostics, ?, record, ?, databaseRecord . The question mark appears due to + is presentResponse, databaseOrSurDiagnostics, ?, record, ?, databaseRecord . The question mark appears due to unnamed constructions. @@ -505,7 +505,7 @@ void do_nothing_useful(int value) Summary and Synopsis - #include <odr.h> + #include <yaz/odr.h> ODR odr_createmem(int direction); @@ -513,19 +513,17 @@ void do_nothing_useful(int value) void odr_reset(ODR o); - char *odr_getbuf(ODR o, int *len); + char *odr_getbuf(ODR o, int *len, int *size); - void odr_setbuf(ODR o, char *buf, int len); + void odr_setbuf(ODR o, char *buf, int len, int can_grow); void *odr_malloc(ODR o, int size); - ODR_MEM odr_extract_mem(ODR o); - - void odr_release_mem(ODR_MEM r); + NMEM odr_extract_mem(ODR o); int odr_geterror(ODR o); - void odr_perror(char *message); + void odr_perror(ODR o, const char *message); extern char *odr_errlist[]; @@ -545,11 +543,11 @@ void do_nothing_useful(int value) There is an ASN.1 tutorial available at this site. - This site also has standards for ASN.1 (X.680) and BER (X.690) + This site also has standards for ASN.1 (X.680) and BER (X.690) online. - + The ODR interface is based loosely on that of the Sun Microsystems XDR routines. @@ -562,9 +560,9 @@ void do_nothing_useful(int value) definition for a type once - and you have the functionality of encoding, decoding (and pretty-printing) all in one unit. The resulting C source code is quite compact, and is a pretty - straightforward representation of the source ASN.1 specification. + straightforward representation of the source ASN.1 specification. - + In many cases, the model of the XDR functions works quite well in this role. @@ -588,13 +586,13 @@ void do_nothing_useful(int value) - int odr_integer(ODR o, int **p, int optional, const char *name); + int odr_integer(ODR o, Odr_int **p, int optional, const char *name); - (we don't allow values that can't be contained in a C integer.) + The Odr_int is just a simple integer. - + This form is typical of the primitive &odr; functions. They are named after the type of data that they encode or decode. They take an &odr; @@ -641,7 +639,7 @@ void do_nothing_useful(int value) BOOLEAN -int odr_bool(ODR o, bool_t **p, int optional, const char *name); +int odr_bool(ODR o, Odr_bool **p, int optional, const char *name); @@ -655,7 +653,7 @@ int odr_bool(ODR o, bool_t **p, int optional, const char *name); NULL -int odr_null(ODR o, bool_t **p, int optional, const char *name); +int odr_null(ODR o, Odr_null **p, int optional, const char *name); @@ -759,9 +757,9 @@ int odr_oid(ODR o, Odr_oid **p, int optional, const char *name); The C OID representation is simply an array of integers, terminated by the value -1 (the Odr_oid type is synonymous with - the int type). + the short type). We suggest that you use the OID database module (see - ) to handle object identifiers + ) to handle object identifiers in your application. @@ -771,7 +769,7 @@ int odr_oid(ODR o, Odr_oid **p, int optional, const char *name); The simplest way of tagging a type is to use the - odr_implicit_tag() or + odr_implicit_tag() or odr_explicit_tag() macros: @@ -797,7 +795,7 @@ int odr_explicit_tag(ODR o, Odr_fun fun, int class, int tag, -int myInt(ODR o, int **p, int optional, const char *name) +int myInt(ODR o, Odr_int **p, int optional, const char *name) { return odr_implicit_tag(o, odr_integer, p, ODR_CONTEXT, 210, optional, name); @@ -869,10 +867,10 @@ MySequence ::= SEQUENCE { typedef struct MySequence { - int *intval; - bool_t *boolval; + Odr_int *intval; + Odr_bool *boolval; } MySequence; - + int mySequence(ODR o, MySequence **p, int optional, const char *name) { if (odr_sequence_begin(o, p, sizeof(**p), name) == 0) @@ -1073,7 +1071,7 @@ MyArray ::= SEQUENCE OF INTEGER typedef struct MyArray { int num_elements; - int **elements; + Odr_int **elements; } MyArray; @@ -1197,9 +1195,9 @@ typedef struct MyChoice } which; union { - int *untagged; - int *tagged; - bool_t *other; + Odr_int *untagged; + Odr_int *tagged; + Odr_bool *other; } u; };