UM C API  6.16
lbmpdm.h
Go to the documentation of this file.
1 
17 /*
18  All of the documentation and software included in this and any
19  other Informatica Inc. Ultra Messaging Releases
20  Copyright (C) Informatica Inc. All rights reserved.
21 
22  Redistribution and use in source and binary forms, with or without
23  modification, are permitted only as covered by the terms of a
24  valid software license agreement with Informatica Inc.
25 
26  (C) Copyright 2007,2023 Informatica Inc. All Rights Reserved.
27 
28  THE SOFTWARE IS PROVIDED "AS IS" AND INFORMATICA DISCLAIMS ALL WARRANTIES
29  EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF
30  NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR
31  PURPOSE. INFORMATICA DOES NOT WARRANT THAT USE OF THE SOFTWARE WILL BE
32  UNINTERRUPTED OR ERROR-FREE. INFORMATICA SHALL NOT, UNDER ANY CIRCUMSTANCES, BE
33  LIABLE TO LICENSEE FOR LOST PROFITS, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR
34  INDIRECT DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE
35  TRANSACTIONS CONTEMPLATED HEREUNDER, EVEN IF INFORMATICA HAS BEEN APPRISED OF
36  THE LIKELIHOOD OF SUCH DAMAGES.
37 
38  The LBM Pre-Defined Message(PDM) API provides a framework for applications
39  to create message definitions and messages from those definitions.
40  A PDM definition contains a list of field information describing the fields
41  that will be contained in a message. A PDM message contains one or more \b fields with
42  each field corresponding to a specific field information object in the definition.
43  Field info consists of:
44  - A name (string names or integer names are supported).
45  - A type (discussed below).
46  - If the field is required.
47  Message fields consist of:
48  - A handle to the corresponding field info.
49  - A value (particular to the field type).
50  Each named field may only appear once in a message. If multiple fields of the same name
51  and type are needed, an array field can be used to store multiple values for that field.
52  PDM messages can be added as a field to other PDM messages by using the field type PDM_MESSAGE.
53 
54  \par Field types
55  The following field types (and arrays thereof) are supported by PDM:
56  <table>
57  <tr>
58  <td>Description</td>
59  <td>PDM Type</td>
60  <td>C Type</td>
61  </tr>
62  <tr>
63  <td>Boolean</td>
64  <td>PDM_TYPE_BOOLEAN</td>
65  <td><tt>uint8_t</tt></td>
66  </tr>
67  <tr>
68  <td>8-bit signed integer</td>
69  <td>PDM_TYPE_INT8</td>
70  <td><tt>int8_t</tt></td>
71  </tr>
72  <tr>
73  <td>8-bit unsigned integer</td>
74  <td>PDM_TYPE_UINT8</td>
75  <td><tt>uint8_t</tt></td>
76  </tr>
77  <tr>
78  <td>16-bit signed integer</td>
79  <td>PDM_TYPE_INT16</td>
80  <td><tt>int16_t</tt></td>
81  </tr>
82  <tr>
83  <td>16-bit unsigned integer</td>
84  <td>PDM_TYPE_UINT16</td>
85  <td><tt>uint16_t</tt></td>
86  </tr>
87  <tr>
88  <td>32-bit signed integer</td>
89  <td>PDM_TYPE_INT32</td>
90  <td><tt>int32_t</tt></td>
91  </tr>
92  <tr>
93  <td>32-bit unsigned integer</td>
94  <td>PDM_TYPE_UINT32</td>
95  <td><tt>uint32_t</tt></td>
96  </tr>
97  <tr>
98  <td>64-bit signed integer</td>
99  <td>PDM_TYPE_INT64</td>
100  <td><tt>int64_t</tt></td>
101  </tr>
102  <tr>
103  <td>64-bit unsigned integer</td>
104  <td>PDM_TYPE_UINT64</td>
105  <td><tt>uint64_t</tt></td>
106  </tr>
107  <tr>
108  <td>Single-precision floating point</td>
109  <td>PDM_TYPE_FLOAT</td>
110  <td><tt>float</tt></td>
111  </tr>
112  <tr>
113  <td>Double-precision floating point</td>
114  <td>PDM_TYPE_DOUBLE</td>
115  <td><tt>double</tt></td>
116  </tr>
117  <tr>
118  <td>Decimal</td>
119  <td>PDM_TYPE_DECIMAL</td>
120  <td><tt>struct decimal</tt></td>
121  </tr>
122  <tr>
123  <td>Timestamp</td>
124  <td>PDM_TYPE_TIMESTAMP</td>
125  <td><tt>struct timestamp</tt></td>
126  </tr>
127  <tr>
128  <td>Fixed Length String</td>
129  <td>PDM_TYPE_FIX_STRING</td>
130  <td><tt>char *</tt></td>
131  </tr>
132  <tr>
133  <td>String</td>
134  <td>PDM_TYPE_STRING</td>
135  <td><tt>char *</tt></td>
136  </tr>
137  <tr>
138  <td>Fixed Length Unicode</td>
139  <td>PDM_TYPE_FIX_UNICODE</td>
140  <td><tt>char *</tt></td>
141  </tr>
142  <tr>
143  <td>Unicode</td>
144  <td>PDM_TYPE_UNICODE</td>
145  <td><tt>char *</tt></td>
146  </tr>
147  <tr>
148  <td>Nested PDM message</td>
149  <td>PDM_TYPE_MESSAGE</td>
150  <td><tt>lbmpdm_msg_t *</tt></td>
151  </tr>
152  <tr>
153  <td>Binary large object (BLOB)</td>
154  <td>PDM_TYPE_BLOB</td>
155  <td><tt>void *</tt></td>
156  </tr>
157  </table>
158  \par
159  Note that arrays are homogeneous.
160  \par Creating a message definition
161  A message definition must be defined (via lbmpdm_defn_create())
162  before a message can be created. After creating the definition, field info
163  can be added. Once all field information has been added to a definition, the definition
164  must be finalized (lbmpdm_defn_finalize()). Each definition must be given an id
165  to identify that definition (and messages created with the definition) to all
166  consumers of the message. This allows all messaging participants to define the
167  message and for PDM to quickly deserialize the messages.
168  As an example, we will create a simple definition with two fields, a 32-bit signed
169  integer and a string array. We will give the definition an id of 1000.
170  \code
171 lbmpdm_defn_t *defn;
172 lbmpdm_field_handle_t h1;
173 lbmpdm_field_handle_t h2;
174 lbmpdm_field_info_attr_t info_attr;
175 
176 if (lbmpdm_defn_create(&defn, 2, 1000, 1, 0, PDM_DEFN_STR_FIELD_NAMES) != PDM_SUCCESS) {
177  printf("Failed to create the definition");
178  return;
179 }
180 
181 info_attr.flags = 0;
182 
183 h1 = lbmpdm_defn_add_field_info_by_str_name(defn, "Field1", PDM_TYPE_INT32, NULL);
184 
185 info_attr.flags |= PDM_FIELD_INFO_FLAG_REQ;
186 info_attr.req = PDM_FALSE;
187 h2 = lbmpdm_defn_add_field_info_by_str_name(defn, "Field2", PDM_TYPE_STRING_ARR, &info_attr);
188 
189 lbmpdm_defn_finalize(defn);
190  \endcode
191  \par
192  The values of the info_attr struct will only be examined if the corresponding PDM_FIELD_INFO_FLAG_*
193  has been set when it is passed to the add_field_info function. If NULL is passed instead of an
194  info_attr pointer or any of the flags are not set, then default values will be used when adding
195  the field info(which are: required = PDM_TRUE, fixed string length = 0,
196  and number of array elements = 0).
197  \par
198  Once the definition exists, a message can be created and field values can be
199  set in the message. The fields can be set by using the field handle
200  that was returned from the call to the definition to add field info
201  (or the field handle can be looked up from the definition).
202  \par Sample code
203  Checking of return codes has been omitted but should be done during actual usage of pdm.
204  \code
205 {
206 int rc;
207 lbmpdm_msg_t *msg1;
208 lbmpdm_msg_t *msg2;
209 char *msg_buffer;
210 int msg_len;
211 
212 int32_t quant = 50;
213 char *str_arr[3] = {"s1", "str2", "string3"};
214 size_t str_len_arr[3] = {3, 5, 8};
215 size_t str_arr_num_elem = 3;
216 
217 int32_t rcv_quant;
218 size_t rcv_quant_sz = sizeof(int32_t);
219 char *rcv_str_arr[3];
220 rcv_str_arr[0] = malloc(3);
221 rcv_str_arr[1] = malloc(5);
222 rcv_str_arr[2] = malloc(8);
223 
224 lbmpdm_msg_create(&msg1, defn, 0);
225 
226 rc = lbmpdm_msg_set_field_value(msg1, h1, &quant, 0);
227 rc = lbmpdm_msg_set_field_value_vec(msg1, h2, str_arr, str_len_arr, str_arr_num_elem);
228 
229 msg_len = lbmpdm_msg_get_length(msg1);
230 msg_buffer = malloc(msg_len);
231 rc = lbmpdm_msg_serialize(msg1, msg_buffer);
232 
233 rc = lbmpdm_msg_create(&msg2, defn, 0);
234 rc = lbmpdm_msg_deserialize(msg2, msg_buffer, msg_len);
235 
236 rc = lbmpdm_msg_get_field_value(msg2, h1, &rcv_quant, &rcv_quant_sz);
237 rc = lbmpdm_msg_get_field_value_vec(msg2, h2, rcv_str_arr, str_len_arr, &str_arr_num_elem);
238 
239 printf("rcv_quant = %d\n", rcv_quant);
240 printf("rcv_str_arr[0] = %s\n", rcv_str_arr[0]);
241 printf("rcv_str_arr[1] = %s\n", rcv_str_arr[1]);
242 printf("rcv_str_arr[2] = %s\n", rcv_str_arr[2]);
243 
244 free(rcv_str_arr[0]);
245 free(rcv_str_arr[1]);
246 free(rcv_str_arr[2]);
247 
248 free(msg_buffer);
249 
250 lbmpdm_msg_delete(msg1);
251 lbmpdm_msg_delete(msg2);
252 lbmpdm_defn_delete(defn);
253 }
254  \endcode
255  \par Creating a message
256  Messages are created from definitions. The line above that is used to create the message:
257  \code
258 lbmpdm_msg_create(&msg1, defn, 0);
259  \endcode
260  \par Setting field values in a message
261  Scalar (non-array) fields are added to a message via the
262  <tt>lbmpdm_msg_set_field_value()</tt> to set a field's value using its handle.
263  \par
264  When setting a field's value, data of the appropriate type must be supplied.
265  A 0 length can be supplied for fixed length fields but it is recommended to pass
266  the correct size in bytes to ensure the correct number of bytes are copied into
267  the message. As an example, to set a 32-bit signed integer field to a message:
268  \code
269 rc = lbmpdm_msg_set_field_value(msg1, h1, &quant, 0);
270  \endcode
271  \par
272  Setting a string value is done by passing the char * and the actual size
273  of the string in bytes (normally this is the num_chars + 1 to account for the null character
274  but for UNICODE types this value will be larger). For the MESSAGE type, the value argument
275  should be a lbmpdm_msg_t * and the length argument should be sizeof(lbmpdm_msg_t *) because
276  the setter will attempt to access the lbmpdm_msg_t via the pointer and then serialize it
277  to bytes via its serialize method.
278  \par Setting the value of array fields in a message
279  To set an array's value in a message, call the
280  <tt>lbmpdm_msg_set_field_value_vec()</tt> API function.
281  \par
282  As an example, the code that sets the string array field value is:
283  \code
284 rc = lbmpdm_msg_set_field_value_vec(msg1, h2, str_arr, str_len_arr, str_arr_num_elem);
285  \endcode
286  \par
287  Setting an array field value requires an addition number of elements parameter and expects
288  an array of lengths (one for each element in the array). Again, string types should pass a length
289  array that indicates the size in bytes of each string rather than the number of characters as
290  shown in the example code which uses sizes a length array of {3, 5, 8}.
291  \par Serializing the message
292  Once a PDM message is constructed, it must be serialized for transmission.
293  The API function lbmpdm_msg_serialize() serializes the message to
294  the buffer provided. The length of the serialized data may be obtained via the API function
295  lbmpdm_msg_get_length().
296  For example, a constructed message may be sent by:
297  \code
298 rc = lbmpdm_msg_serialize(msg1, msg_buffer);
299 rc = lbm_src_send(src, msg_buffer, msg_len, 0);
300  \endcode
301  \par Deserializing a message
302  When the bytes for a pdm message are received, they must be deserialized so that individual fields can be
303  accessed. The lbmpdm_msg_t should be reused when possible to deserialize multiple incoming messages.
304  This is done via the lbmpdm_msg_deserialize() API function:
305  \code
306 rc = lbmpdm_msg_deserialize(msg2, msg_buffer, msg_len);
307 // Deserializing an lbm message would be the following
308 //rc = lbmpdm_msg_deserialize(msg2, lbmmsg->data, lbmmsg->len);
309  \endcode
310  \par Fetching fields from a message
311  When fetching a field from a message, the field should be accessed by its handle.
312  \par
313  Scalar (non-array) fields may be retrieved via the <tt>lbmpdm_msg_get_field_value()</tt>.
314  \code
315 rc = lbmpdm_msg_get_field_value(msg2, h1, &rcv_quant, &rcv_quant_sz);
316  \endcode
317  \par
318  Array fields may be retrieved via the <tt>lbmpdm_msg_get_field_value_vec()</tt>.
319  \code
320 rc = lbmpdm_msg_get_field_value_vec(msg2, h2, rcv_str_arr, str_len_arr, &str_arr_num_elem);
321  \endcode
322  \par
323  When accessing a field, it is expected that value pointer being provided already points
324  to an area of sufficient size to hold the field's value. The len argument should indicate
325  the size or sizes (for array types) of the available space. If the size is not sufficient,
326  a PDM_FAILURE will be returned and the failing len argument will be updated to indicate the
327  actual size needed. For array types, the same logic applies to the number of elements argument,
328  where if the number of allocated elements indicated by the input parameter is insufficient, the
329  call will fail and the value will be updated to indicate the needed number of elements.
330  For the MESSAGE type, the value argument should be a lbmpdm_msg_t * that points to an empty
331  lbmpdm_msg_t which has been created with a NULL definition. The length argument should be sizeof(lbmpdm_msg_t *) because
332  the setter will attempt to access the lbmpdm_msg_t via the pointer and then deserialize the bytes
333  into it.
334  \par Disposing of a message and definition
335  Once a PDM message (created by either the lbmpdm_msg_create() or
336  lbmpdm_msg_deserialize() API calls) is no longer needed,
337  it must be deleted to avoid a resource leak.
338  This is done via the lbmpdm_msg_delete() API call.
339  \code
340 lbmpdm_msg_delete(msg1);
341 lbmpdm_msg_delete(msg2);
342 lbmpdm_defn_delete(defn);
343  \endcode
344  \par Error information
345  All functions return a value to indicate the success of failure of the operation.
346  Most return PDM_SUCCESS to indicate success, or PDM_FAILURE otherwise.
347  Consult the individual function documentation for exceptions.
348  \par
349  The function lbmpdm_errmsg() will return a descriptive error message.
350  \par Additional Information
351  When adding arrays to a definition, an array length can be specified in the info attributes.
352  A 0 length means that the array's length is variable and will be determined when the
353  array is set in the actual message. A positive number for the array length
354  will create a fixed array of that size.
355  \par
356  When adding PDM_TYPE_FIX_STRING, PDM_TYPE_FIX_STRING_ARR, PDM_TYPE_FIX_UNICODE, or PDM_TYPE_FIX_UNICODE_ARR,
357  field information to a definition, a fixed string length must be specified in the info attributes.
358  The value should be the number of characters in the string (excluding the null character). The
359  appropriate amount of space will be then allocated in the message for each of the expected fixed strings
360  (for the FIX_STRING types, there will be num_chars + 1 bytes allocated per string and for the FIX_UNICODE types,
361  there will be 4 * num_chars + 1 bytes allocated per string). By using fixed strings for a field, as
362  well as making the field required (and specifying a fixed size for the array types), the best performance
363  and size can be achieved because the field will be optimized as a "fixed required" field.
364  \par
365  When setting and getting field values of type FIX_STRING and FIX_UNICODE (and the corresponding arrays),
366  extra care should be made to ensure the len parameters are correct. When setting the value, the len should
367  indicate the actual number of bytes represented by the string that should be copied
368  (which should include the null character). If this is less than the size indicated to the definition when
369  setting up the field information, the rest of the space will be zeroed out. When getting the value, enough
370  space should be allocated for the entire size of the fixed string field, which as described above should be
371  the number of characters + 1 for the string types and 4 * the number of characters + 1 for the unicode types.
372  \par
373  An additional way to get a field value from a message is by using the lbmpdm_msg_get_field_value_stct method,
374  which does not require the storage and lengths to be allocated beforehand but instead will allocate everything
375  during the call and set all of the appropriate values of the provided lbmpdm_field_value_t. Although simpler to use,
376  the drawback is not being able to use preallocated space to hold the field value as the other get_field_value methods
377  are able to do. It also requires the application to manage the field_value_t and call the field_value_stct_delete
378  method when finished to clean up the allocated memory inside the field_value_t.
379 */
380 
383 #ifndef _LBMPDM_H_
384 #define _LBMPDM_H_
385 
386 #if defined(__cplusplus)
387 extern "C" {
388 #endif
389 
390 #if HAVE_STDINT_H
391  #include <stdint.h>
392 #endif
393 #include <stdlib.h>
394 
395 /* Directives to show how we treat exporting functions with Windows from the DLL */
396 #if defined(_WIN32)
397  #if defined(_DLL) && defined(LBM_EXPORT_SYMS)
398  #define LBMPDMExpDLL __declspec(dllexport)
399  #elif defined(LBM_STATIC_LIB)
400  #define LBMPDMExpDLL
401  #else
402  #define LBMPDMExpDLL __declspec(dllimport)
403  #endif
404 #elif defined(__TANDEM)
405  #if defined(LBM_EXPORT_SYMS)
406  #define LBMPDMExpDLL export$
407  #else
408  #define LBMPDMExpDLL import$
409  #endif
410 #else
411  #define LBMPDMExpDLL
412 #endif
413 
414 #if defined(_WIN32)
415 #if !defined(DONT_TYPEDEF_INT_T)
416  typedef __int8 int8_t;
417  typedef __int16 int16_t;
418  typedef __int32 int32_t;
419  typedef __int64 int64_t;
420 
421  typedef unsigned __int8 uint8_t;
422  typedef unsigned __int16 uint16_t;
423  typedef unsigned __int32 uint32_t;
424  typedef unsigned __int64 uint64_t;
425 #endif
426  /* C99 printf format macros missing from VC. */
427 #if (_MSC_VER < 1900)
428  #define PRId8 "d"
429  #define PRId16 "d"
430  #define PRId32 "d"
431  #define PRId64 "I64d"
432  #define PRIu8 "u"
433  #define PRIu16 "u"
434  #define PRIu32 "u"
435  #define PRIu64 "I64u"
436  #define PRIx8 "x"
437  #define PRIx16 "x"
438  #define PRIx32 "x"
439  #define PRIx64 "I64x"
440 
441  /* C99 scanf format macros missing from VC. */
442  #define SCNd8 "d"
443  #define SCNd16 "hd"
444  #define SCNd32 "ld"
445  #define SCNd64 "I64d"
446  #define SCNu8 "u"
447  #define SCNu16 "hu"
448  #define SCNu32 "lu"
449  #define SCNu64 "I64u"
450  #define SCNx64 "I64x"
451 #endif
452  #define PRIuSZ "Iu"
453  #define SCNuSZ "Iu"
454 
455 #elif defined(__VMS)
456  #include <inttypes.h>
457  /* C99 printf format macros missing from OpenVMS. */
458  #define PRId8 "d"
459  #define PRId16 "d"
460  #define PRId32 "d"
461  #define PRId64 "lld"
462  #define PRIu8 "u"
463  #define PRIu16 "u"
464  #define PRIu32 "u"
465  #define PRIu64 "llu"
466  #define PRIuSZ "zu"
467  /* C99 scanf format macros missing from OpenVMS. */
468  #define SCNd8 "hhd"
469  #define SCNd16 "hd"
470  #define SCNd32 "d"
471  #define SCNd64 "lld"
472  #define SCNu8 "hhu"
473  #define SCNu16 "hu"
474  #define SCNu32 "u"
475  #define SCNu64 "llu"
476  #define SCNuSZ "zu"
477 #else
478  #include <inttypes.h>
479  #ifndef PRIuSZ
480  #define PRIuSZ "zu"
481  #endif
482  #ifndef SCNuSZ
483  #define SCNuSZ "zu"
484  #endif
485 #endif
486 
493 typedef int32_t lbmpdm_field_handle_t;
494 
503 typedef struct {
505  int64_t mant;
507  int8_t exp;
509 
516 typedef struct {
518  int32_t tv_secs;
520  int32_t tv_usecs;
522 
523 struct lbmpdm_msg_strct_t;
526 typedef struct lbmpdm_msg_stct_t lbmpdm_msg_t;
527 
528 struct lbmpdm_defn_stct_t;
531 typedef struct lbmpdm_defn_stct_t lbmpdm_defn_t;
532 
537  int flags;
539  uint8_t req;
541  uint32_t fixed_str_len;
543  uint32_t num_arr_elem;
544  /* Fill for external pdm struct for future binary compatibility. */
545  char fill[256];
546 };
548 
554  uint16_t field_type;
556  uint8_t is_array;
558  uint8_t is_fixed;
560  size_t len;
562  char *value;
564  uint32_t num_arr_elem;
566  size_t *len_arr;
568  char **value_arr;
569  /* Fill for external pdm struct for future binary compatibility. */
570  char fill[256];
571 };
573 
574 struct lbmpdm_iter_stct_t;
577 typedef struct lbmpdm_iter_stct_t lbmpdm_iter_t;
578 
580 #define PDM_FALSE (uint8_t) 0
581 
583 #define PDM_TRUE (uint8_t) 1
584 
586 #define PDM_FIELD_INFO_FLAG_REQ 0x1
587 
589 #define PDM_FIELD_INFO_FLAG_FIXED_STR_LEN 0x2
590 
592 #define PDM_FIELD_INFO_FLAG_NUM_ARR_ELEM 0x4
593 
595 #define PDM_MSG_FLAG_VAR_OR_OPT_FLDS_SET 0x1
596 
598 #define PDM_MSG_FLAG_INCL_DEFN 0x2
599 
601 #define PDM_MSG_FLAG_USE_MSG_DEFN_IF_NEEDED 0x4
602 
604 #define PDM_MSG_FLAG_TRY_LOAD_DEFN_FROM_CACHE 0x8
605 
607 #define PDM_MSG_FLAG_NEED_BYTE_SWAP 0x10
608 
610 #define PDM_MSG_FLAG_DEL_DEFN_WHEN_REPLACED 0x20
611 
613 #define PDM_MSG_VER_POLICY_EXACT 0
614 
616 #define PDM_MSG_VER_POLICY_BEST 1
617 
619 #define PDM_SUCCESS 0
620 
622 #define PDM_FAILURE -1
623 
625 #define PDM_ERR_FIELD_IS_NULL 1
626 
628 #define PDM_ERR_NO_MORE_FIELDS 2
629 
631 #define PDM_ERR_INSUFFICIENT_BUFFER_LENGTH 3
632 
634 #define PDM_ERR_EINVAL 4
635 
637 #define PDM_ERR_FIELD_NOT_FOUND 5
638 
640 #define PDM_ERR_MSG_INVALID 6
641 
643 #define PDM_ERR_DEFN_INVALID 7
644 
646 #define PDM_ERR_NOMEM 8
647 
649 #define PDM_ERR_REQ_FIELD_NOT_SET 9
650 
652 #define PDM_ERR_CREATE_SECTION 10
653 
655 #define PDM_ERR_CREATE_BUFFER 11
656 
658 #define PDM_INTERNAL_TYPE_INVALID -1
659 
661 #define PDM_TYPE_BOOLEAN 0
662 
664 #define PDM_TYPE_INT8 1
665 
667 #define PDM_TYPE_UINT8 2
668 
670 #define PDM_TYPE_INT16 3
671 
673 #define PDM_TYPE_UINT16 4
674 
676 #define PDM_TYPE_INT32 5
677 
679 #define PDM_TYPE_UINT32 6
680 
682 #define PDM_TYPE_INT64 7
683 
685 #define PDM_TYPE_UINT64 8
686 
688 #define PDM_TYPE_FLOAT 9
689 
691 #define PDM_TYPE_DOUBLE 10
692 
694 #define PDM_TYPE_DECIMAL 11
695 
697 #define PDM_TYPE_TIMESTAMP 12
698 
700 #define PDM_TYPE_FIX_STRING 13
701 
703 #define PDM_TYPE_STRING 14
704 
706 #define PDM_TYPE_FIX_UNICODE 15
707 
709 #define PDM_TYPE_UNICODE 16
710 
712 #define PDM_TYPE_BLOB 17
713 
715 #define PDM_TYPE_MESSAGE 18
716 
718 #define PDM_TYPE_BOOLEAN_ARR 19
719 
721 #define PDM_TYPE_INT8_ARR 20
722 
724 #define PDM_TYPE_UINT8_ARR 21
725 
727 #define PDM_TYPE_INT16_ARR 22
728 
730 #define PDM_TYPE_UINT16_ARR 23
731 
733 #define PDM_TYPE_INT32_ARR 24
734 
736 #define PDM_TYPE_UINT32_ARR 25
737 
739 #define PDM_TYPE_INT64_ARR 26
740 
742 #define PDM_TYPE_UINT64_ARR 27
743 
745 #define PDM_TYPE_FLOAT_ARR 28
746 
748 #define PDM_TYPE_DOUBLE_ARR 29
749 
751 #define PDM_TYPE_DECIMAL_ARR 30
752 
754 #define PDM_TYPE_TIMESTAMP_ARR 31
755 
757 #define PDM_TYPE_FIX_STRING_ARR 32
758 
760 #define PDM_TYPE_STRING_ARR 33
761 
763 #define PDM_TYPE_FIX_UNICODE_ARR 34
764 
766 #define PDM_TYPE_UNICODE_ARR 35
767 
769 #define PDM_TYPE_BLOB_ARR 36
770 
772 #define PDM_TYPE_MESSAGE_ARR 37
773 
775 #define PDM_DEFN_STR_FIELD_NAMES 0
776 
778 #define PDM_DEFN_INT_FIELD_NAMES 1
779 
781 #define PDM_ITER_INVALID_FIELD_HANDLE -1
782 
787 
792 LBMPDMExpDLL const char *lbmpdm_errmsg();
793 
800 LBMPDMExpDLL int lbmpdm_cache_init(uint32_t cache_size);
801 
808 
815 
823 LBMPDMExpDLL int lbmpdm_cache_struct_remove_by_version(int32_t id, uint8_t vers_major, uint8_t vers_minor);
824 
833 LBMPDMExpDLL int lbmpdm_cache_struct_find(lbmpdm_defn_t **defn, int32_t id);
834 
845 LBMPDMExpDLL int lbmpdm_cache_struct_find_by_version(lbmpdm_defn_t **defn, int32_t id, uint8_t vers_major, uint8_t vers_minor);
846 
851 
852 
858 LBMPDMExpDLL lbmpdm_field_handle_t lbmpdm_defn_get_field_handle_by_str_name(lbmpdm_defn_t *defn, const char *str_name);
859 
865 LBMPDMExpDLL lbmpdm_field_handle_t lbmpdm_defn_get_field_handle_by_int_name(lbmpdm_defn_t *defn, int32_t int_name);
866 
891 LBMPDMExpDLL int lbmpdm_defn_create(lbmpdm_defn_t **defn, int32_t num_fields, int32_t id, int8_t vrs_mjr, int8_t vrs_mnr, uint8_t field_names_type);
892 
898 
905 
913 LBMPDMExpDLL lbmpdm_field_handle_t lbmpdm_defn_add_field_info_by_str_name(lbmpdm_defn_t *defn, const char *str_name, int16_t type, lbmpdm_field_info_attr_t *info_attr);
914 
922 LBMPDMExpDLL lbmpdm_field_handle_t lbmpdm_defn_add_field_info_by_int_name(lbmpdm_defn_t *defn, int32_t int_name, int16_t type, lbmpdm_field_info_attr_t *info_attr);
923 
931 
937 
943 
949 
955 
962 
968 
974 LBMPDMExpDLL const char *lbmpdm_defn_get_field_info_str_name(lbmpdm_defn_t *defn, lbmpdm_field_handle_t handle);
975 
981 LBMPDMExpDLL int32_t lbmpdm_defn_get_field_info_int_name(lbmpdm_defn_t *defn, lbmpdm_field_handle_t handle);
982 
988 LBMPDMExpDLL int16_t lbmpdm_defn_get_field_info_type(lbmpdm_defn_t *defn, lbmpdm_field_handle_t handle);
989 
998 LBMPDMExpDLL int lbmpdm_defn_serialize(lbmpdm_defn_t *defn, char *buffer, uint32_t *defn_len);
999 
1016 LBMPDMExpDLL int lbmpdm_defn_deserialize(lbmpdm_defn_t *defn, const char *bufptr, uint32_t buflen, uint8_t swap_bytes);
1017 
1024 LBMPDMExpDLL int lbmpdm_msg_create(lbmpdm_msg_t **message, lbmpdm_defn_t *defn, uint32_t flags);
1025 
1034 
1043 
1050 LBMPDMExpDLL uint32_t lbmpdm_msg_get_length(const lbmpdm_msg_t *message);
1051 
1057 
1063 LBMPDMExpDLL uint8_t lbmpdm_msg_is_field_set(lbmpdm_msg_t *message, lbmpdm_field_handle_t handle);
1064 
1071 LBMPDMExpDLL int lbmpdm_msg_get_field_value_stct(lbmpdm_msg_t *message, lbmpdm_field_handle_t handle, lbmpdm_field_value_t *field_value);
1072 
1081 LBMPDMExpDLL int lbmpdm_msg_get_field_value(lbmpdm_msg_t *message, lbmpdm_field_handle_t handle, void *value, size_t *len);
1082 
1093 LBMPDMExpDLL int lbmpdm_msg_get_field_value_vec(lbmpdm_msg_t *message, lbmpdm_field_handle_t handle, void *value, size_t len[], size_t *num_arr_elem);
1094 
1103 LBMPDMExpDLL int lbmpdm_msg_set_field_value(lbmpdm_msg_t *message, lbmpdm_field_handle_t handle, void *value, size_t len);
1104 
1114 LBMPDMExpDLL int lbmpdm_msg_set_field_value_vec(lbmpdm_msg_t *message, lbmpdm_field_handle_t handle, void *value, size_t len[], size_t num_arr_elem);
1115 
1121 LBMPDMExpDLL int lbmpdm_msg_remove_field_value(lbmpdm_msg_t *message, lbmpdm_field_handle_t handle);
1122 
1128 
1134 
1143 
1151 LBMPDMExpDLL int lbmpdm_msg_serialize(lbmpdm_msg_t *message, char *buffer);
1152 
1166 LBMPDMExpDLL int lbmpdm_msg_deserialize(lbmpdm_msg_t *message, const char *bufptr, uint32_t buflen);
1167 
1176 
1183 
1190 LBMPDMExpDLL int lbmpdm_iter_create_from_field_handle(lbmpdm_iter_t **iter, lbmpdm_msg_t *message, lbmpdm_field_handle_t field_handle);
1191 
1197 
1202 LBMPDMExpDLL lbmpdm_field_handle_t lbmpdm_iter_get_current(lbmpdm_iter_t *iter);
1203 
1209 
1215 
1221 
1227 
1234 
1241 LBMPDMExpDLL int lbmpdm_iter_set_current_field_value(lbmpdm_iter_t *iter, void *value, size_t len);
1242 
1251 LBMPDMExpDLL int lbmpdm_iter_set_current_field_value_vec(lbmpdm_iter_t *iter, void *value, size_t len[], size_t num_arr_elem);
1252 
1260 LBMPDMExpDLL int lbmpdm_iter_get_current_field_value(lbmpdm_iter_t *iter, void *value, size_t *len);
1261 
1270 LBMPDMExpDLL int lbmpdm_iter_get_current_field_value_vec(lbmpdm_iter_t *iter, void *value, size_t len[], size_t *num_arr_elem);
1271 
1272 #if defined(__cplusplus)
1273 }
1274 #endif /* __cplusplus */
1275 
1276 #endif /* _LBMPDM_H_ */
1277 
LBMPDMExpDLL int8_t lbmpdm_defn_get_msg_vers_major(lbmpdm_defn_t *defn)
Gets the message major version number from the definition.
LBMPDMExpDLL int32_t lbmpdm_defn_get_field_info_int_name(lbmpdm_defn_t *defn, lbmpdm_field_handle_t handle)
Gets the integer field name from a given definition&#39;s field handle.
uint32_t num_arr_elem
Definition: lbmpdm.h:543
LBMPDMExpDLL int lbmpdm_iter_create(lbmpdm_iter_t **iter, lbmpdm_msg_t *message)
Creates a pdm iterator to iterate through the fields in a message.
LBMPDMExpDLL int8_t lbmpdm_defn_get_msg_vers_minor(lbmpdm_defn_t *defn)
Gets the message minor version number from the definition.
LBMPDMExpDLL const char * lbmpdm_errmsg()
Return an ASCII string containing the error message last encountered by this thread.
LBMPDMExpDLL int lbmpdm_iter_get_current_field_value_vec(lbmpdm_iter_t *iter, void *value, size_t len[], size_t *num_arr_elem)
Gets an array of field values from the iterator&#39;s current field.
int32_t lbmpdm_field_handle_t
Type representing a handle to a message field. Field handles are returned when adding a field to a de...
Definition: lbmpdm.h:493
LBMPDMExpDLL int lbmpdm_iter_set_msg(lbmpdm_iter_t *iter, lbmpdm_msg_t *message)
Sets the message used to step through by this iterator.
LBMPDMExpDLL int lbmpdm_defn_create(lbmpdm_defn_t **defn, int32_t num_fields, int32_t id, int8_t vrs_mjr, int8_t vrs_mnr, uint8_t field_names_type)
Create a definition, with the passed number of fields. The num_fields is required to be at least 1...
uint32_t fixed_str_len
Definition: lbmpdm.h:541
LBMPDMExpDLL uint8_t lbmpdm_iter_is_current_set(lbmpdm_iter_t *iter)
Checks to see if the current field is set.
LBMPDMExpDLL int lbmpdm_msg_and_defn_delete(lbmpdm_msg_t *message)
Delete an lbmpdm_msg_t object and all associated resources (including the defn) This deletes a previo...
LBMPDMExpDLL int lbmpdm_msg_remove_field_value(lbmpdm_msg_t *message, lbmpdm_field_handle_t handle)
Removes a field value from a message (marking it unset)
LBMPDMExpDLL int32_t lbmpdm_defn_get_id(lbmpdm_defn_t *defn)
Gets the id of the definition.
LBMPDMExpDLL int lbmpdm_msg_delete(lbmpdm_msg_t *message)
Delete an lbmpdm_msg_t object and all associated resources (except the defn) This deletes a previousl...
uint32_t num_arr_elem
Definition: lbmpdm.h:564
LBMPDMExpDLL uint8_t lbmpdm_msg_is_field_set(lbmpdm_msg_t *message, lbmpdm_field_handle_t handle)
Gets whether or not the field value has been set.
LBMPDMExpDLL int lbmpdm_field_value_stct_delete(lbmpdm_field_value_t *field_value)
Deletes the allocated resources inside the field value struct. This does NOT free the actual field va...
LBMPDMExpDLL int lbmpdm_defn_deserialize(lbmpdm_defn_t *defn, const char *bufptr, uint32_t buflen, uint8_t swap_bytes)
Deserialize the associated buffer into a newly created defn.
LBMPDMExpDLL uint8_t lbmpdm_defn_get_field_names_type(lbmpdm_defn_t *defn)
Gets the field names type (either PDM_DEFN_STR_FIELD_NAMES or PDM_DEFN_INT_FIELD_NAMES) from the defi...
LBMPDMExpDLL int lbmpdm_iter_first(lbmpdm_iter_t *iter)
Sets the iterator back to the first field.
LBMPDMExpDLL int lbmpdm_msg_create(lbmpdm_msg_t **message, lbmpdm_defn_t *defn, uint32_t flags)
creates a message with the specified definition
LBMPDMExpDLL lbmpdm_defn_t * lbmpdm_msg_get_defn(const lbmpdm_msg_t *message)
Gets a pointer to the message definition.
Attribute struct to be passed along with the name when adding field info to a definition.
Definition: lbmpdm.h:536
struct lbmpdm_defn_stct_t lbmpdm_defn_t
Structure to hold a pdm definition.
Definition: lbmpdm.h:531
struct lbmpdm_msg_stct_t lbmpdm_msg_t
Structure to hold a pdm message.
Definition: lbmpdm.h:526
LBMPDMExpDLL int lbmpdm_msg_get_field_value_vec(lbmpdm_msg_t *message, lbmpdm_field_handle_t handle, void *value, size_t len[], size_t *num_arr_elem)
Gets an array of field values from the message.
LBMPDMExpDLL uint8_t lbmpdm_iter_has_next(lbmpdm_iter_t *iter)
Checks to see if the iterator has another field to step to.
LBMPDMExpDLL uint8_t lbmpdm_defn_is_finalized(lbmpdm_defn_t *defn)
Gets whether or not the definition has been finalized (either PDM_TRUE or PDM_FALSE).
LBMPDMExpDLL uint32_t lbmpdm_defn_get_length(lbmpdm_defn_t *defn)
Gets the exact length of the serialized defn. This can be used to allocate a buffer of the exact leng...
LBMPDMExpDLL lbmpdm_field_handle_t lbmpdm_defn_get_field_handle_by_int_name(lbmpdm_defn_t *defn, int32_t int_name)
Retrieve a field handle from a definition via name.
LBMPDMExpDLL int lbmpdm_msg_unset_incl_defn_flag(lbmpdm_msg_t *message)
Unsets the message include definition flag.
LBMPDMExpDLL char * lbmpdm_msg_get_data(lbmpdm_msg_t *message)
Serialize a message to a buffer and return the buffer. The message that is passed in is serialized in...
LBMPDMExpDLL int lbmpdm_cache_struct_find(lbmpdm_defn_t **defn, int32_t id)
find a given definition structure by id and return the structure for it. Returns PDM_FAILURE for noth...
LBMPDMExpDLL int lbmpdm_msg_serialize(lbmpdm_msg_t *message, char *buffer)
Serialize a message to a buffer. The message that is passed in is serialized into the caller&#39;s suppli...
int32_t tv_usecs
Definition: lbmpdm.h:520
LBMPDMExpDLL int lbmpdm_msg_deserialize(lbmpdm_msg_t *message, const char *bufptr, uint32_t buflen)
Deserialize the associated buffer into a newly created message.
LBMPDMExpDLL lbmpdm_field_handle_t lbmpdm_defn_add_field_info_by_str_name(lbmpdm_defn_t *defn, const char *str_name, int16_t type, lbmpdm_field_info_attr_t *info_attr)
adds field info to the definition by string name
LBMPDMExpDLL lbmpdm_field_handle_t lbmpdm_iter_get_current(lbmpdm_iter_t *iter)
Gets the current field handle from the iterator.
LBMPDMExpDLL int lbmpdm_defn_finalize(lbmpdm_defn_t *defn)
make this definition final. This needs to be done before using it in a message.
LBMPDMExpDLL int32_t lbmpdm_defn_get_num_fields(lbmpdm_defn_t *defn)
Gets the number of fields in the definition.
LBMPDMExpDLL int lbmpdm_msg_set_field_value_vec(lbmpdm_msg_t *message, lbmpdm_field_handle_t handle, void *value, size_t len[], size_t num_arr_elem)
Sets an array of field values in a message.
size_t len
Definition: lbmpdm.h:560
LBMPDMExpDLL uint32_t lbmpdm_msg_get_length(const lbmpdm_msg_t *message)
Gets the exact length of the serialized message. This can be used to allocate a buffer of the exact l...
LBMPDMExpDLL int lbmpdm_msg_get_field_value_stct(lbmpdm_msg_t *message, lbmpdm_field_handle_t handle, lbmpdm_field_value_t *field_value)
Populates a field value struct with the value from the message.
int8_t exp
Definition: lbmpdm.h:507
LBMPDMExpDLL int lbmpdm_cache_struct_remove_by_version(int32_t id, uint8_t vers_major, uint8_t vers_minor)
delete a definition structure from the cache by its id and version. Does not error if the structure d...
LBMPDMExpDLL const char * lbmpdm_defn_get_field_info_str_name(lbmpdm_defn_t *defn, lbmpdm_field_handle_t handle)
Gets the string field name from a given definition&#39;s field handle.
LBMPDMExpDLL int lbmpdm_msg_get_field_value(lbmpdm_msg_t *message, lbmpdm_field_handle_t handle, void *value, size_t *len)
Gets a field value from the message.
LBMPDMExpDLL lbmpdm_field_handle_t lbmpdm_defn_get_field_handle_by_str_name(lbmpdm_defn_t *defn, const char *str_name)
Retrieve a field handle from a definition via name.
char * value
Definition: lbmpdm.h:562
LBMPDMExpDLL int lbmpdm_iter_create_from_field_handle(lbmpdm_iter_t **iter, lbmpdm_msg_t *message, lbmpdm_field_handle_t field_handle)
Creates a pdm iterator to iterate through the fields in a message starting at a particular field...
Structure to hold a timestamp value.
Definition: lbmpdm.h:516
LBMPDMExpDLL int lbmpdm_iter_next(lbmpdm_iter_t *iter)
Steps the iterator to the next first field.
char ** value_arr
Definition: lbmpdm.h:568
LBMPDMExpDLL int lbmpdm_errnum()
Return the error number last encountered by this thread.
LBMPDMExpDLL int lbmpdm_defn_serialize(lbmpdm_defn_t *defn, char *buffer, uint32_t *defn_len)
Serialize a defn to a buffer. In normal usage this is not needed as the defn is either known in advan...
LBMPDMExpDLL int lbmpdm_cache_struct_add(lbmpdm_defn_t *defn)
add a definition structure to the cache. It is assumed that the structure has a unique id...
LBMPDMExpDLL int lbmpdm_cache_clear_all()
nuke the whole cache, this deletes all the structures within the cache as well.
LBMPDMExpDLL int lbmpdm_iter_set_current_field_value_vec(lbmpdm_iter_t *iter, void *value, size_t len[], size_t num_arr_elem)
Sets the current field values to the passed array of values.
LBMPDMExpDLL int lbmpdm_cache_struct_remove(int32_t id)
delete a definition structure from the cache. Does not error if the structure doesn&#39;t exist...
LBMPDMExpDLL int16_t lbmpdm_defn_get_field_info_type(lbmpdm_defn_t *defn, lbmpdm_field_handle_t handle)
Gets the PDM field type from a given definition&#39;s field handle.
LBMPDMExpDLL int lbmpdm_msg_set_field_value(lbmpdm_msg_t *message, lbmpdm_field_handle_t handle, void *value, size_t len)
Sets a field value in a message.
LBMPDMExpDLL lbmpdm_field_handle_t lbmpdm_defn_add_field_info_by_int_name(lbmpdm_defn_t *defn, int32_t int_name, int16_t type, lbmpdm_field_info_attr_t *info_attr)
adds field info to the definition by integer name
LBMPDMExpDLL int lbmpdm_iter_get_current_field_value(lbmpdm_iter_t *iter, void *value, size_t *len)
Gets a field value from the iterator&#39;s current field.
LBMPDMExpDLL int lbmpdm_defn_delete(lbmpdm_defn_t *defn)
delete a given definition.
int32_t tv_secs
Definition: lbmpdm.h:518
LBMPDMExpDLL int lbmpdm_msg_set_incl_defn_flag(lbmpdm_msg_t *message)
Sets the message include definition flag.
uint16_t field_type
Definition: lbmpdm.h:554
LBMPDMExpDLL int lbmpdm_iter_set_current_field_value(lbmpdm_iter_t *iter, void *value, size_t len)
Sets the current field value to the value passed in.
size_t * len_arr
Definition: lbmpdm.h:566
LBMPDMExpDLL int lbmpdm_cache_struct_find_by_version(lbmpdm_defn_t **defn, int32_t id, uint8_t vers_major, uint8_t vers_minor)
find a given definition structure by id, major version, and minor version and return the structure fo...
LBMPDMExpDLL int lbmpdm_cache_init(uint32_t cache_size)
initialize the cache for a given number of buckets. If 0 is given the the cache will default...
LBMPDMExpDLL int lbmpdm_iter_delete(lbmpdm_iter_t *iter)
Deletes the iterator.
uint8_t is_fixed
Definition: lbmpdm.h:558
int64_t mant
Definition: lbmpdm.h:505
uint8_t is_array
Definition: lbmpdm.h:556
Structure to hold a scaled decimal number. A scaled decimal number consists of a mantissa and an exp...
Definition: lbmpdm.h:503
struct lbmpdm_iter_stct_t lbmpdm_iter_t
Iterator structure that is used to traverse the fields of a message.
Definition: lbmpdm.h:577
#define LBMPDMExpDLL
PDM API function return codes.
Definition: lbmpdm.h:411
uint8_t req
Definition: lbmpdm.h:539
Field value struct that can be populated with a field value when passed to the lbmpdm_msg_get_field_v...
Definition: lbmpdm.h:552