Transformer SDK For C  8.0.2.290852-a608fcd3
datasrc.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright CAPLIN Systems Ltd 2000-2007
4  *
5  *
6  * $Author$
7  * $DateTime$
8  * $Change$
9  * $Id$
10  *
11  *
12  */
13 
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17 
18 
19 #ifndef __DATASRC_H__
20 #define __DATASRC_H__
21 
22 
23 #undef DATASRC_MAJOR_VERSION
24 #undef DATASRC_MINOR_VERSION
25 #undef DATASRC_PATCH_VERSION
26 
27 #define DATASRC_MAJOR_VERSION 8
28 #define DATASRC_MINOR_VERSION 0
29 #define DATASRC_PATCH_VERSION 3
30 
31 
32 #include <stdio.h>
33 #include <stdlib.h>
34 
35 #ifdef WIN32
36 
37 #include <winsock2.h>
38 #include <windows.h>
39 #include <time.h>
40 #include <ws2tcpip.h>
41 #include <direct.h>
42 #include <io.h>
43 #include <mswsock.h>
44 
45 #else /* ! WIN32 */
46 
47 #include <sys/time.h>
48 #include <sys/types.h>
49 #include <unistd.h>
50 #include <netinet/in.h>
51 #include <sys/socket.h>
52 #include <arpa/inet.h>
53 #include <netdb.h>
54 #include <sys/ioctl.h>
55 #include <net/if.h>
56 #include <sys/uio.h>
57 #include <sys/timeb.h>
58 #include <utime.h>
59 
60 #endif /* ! WIN32 */
61 
62 #include <limits.h>
63 #include <sys/stat.h>
64 #include <string.h>
65 #include <fcntl.h>
66 #include <stdarg.h>
67 #include <errno.h>
68 
69 #define EXIT_CODE_NML 0
70 #define EXIT_CODE_CFG 1
71 #define EXIT_CODE_LOG 2
72 #define EXIT_CODE_NET 3
73 #define EXIT_CODE_SYS 4
74 #define EXIT_CODE_LIC 5
75 #define EXIT_CODE_SIG 6
76 #define EXIT_CODE_SVC 7
77 #define EXIT_CODE_SSL 8
78 #define EXIT_CODE_JVM 9
79 
80 /* Reserve codes for binary start-up issues */
81 #define EXIT_CODE_BIN_MISSING 10
82 #define EXIT_CODE_BIN_NOT_EXEC 11
83 #define EXIT_CODE_BIN_EXIT_AFTER_FORK 12
84 #define EXIT_CODE_BIN_BAD_ARCH 126
85 
86 /* Reserve an exit code for Java DataSource blade errors */
87 #define EXIT_CODE_JAVA_DATASOURCE_ERROR 201
88 
89 #define EXIT_CODE_GRACEFUL 202
90 
91 
92 #ifndef WIN32
93 #ifndef DATASRCAPI
94 #define DATASRCAPI
95 #endif
96 #else /* WIN32 */
97 #ifndef DATASRCAPI
98 #ifndef DATASRC_EXPORT
99 #define DATASRCAPI _declspec(dllimport)
100 #else
101 #define DATASRCAPI _declspec(dllexport)
102 #endif
103 #endif
104 #endif /* WIN32 */
105 
106 
107 /* Provide some protection for variadic arguments */
108 #ifdef __GNUC__
109 #define PRINTF(fmt,arg) __attribute__ ((__format__ (__printf__, (fmt), (arg))))
110 #else
111 #define PRINTF(fmt,arg)
112 #endif
113 
114 
120 /* Types */
121 
126 #ifndef WIN32
127 typedef int sock_t;
128 
135 #define INVALID_SOCKET -1
136 
142 #define SOCKET_ERROR -1
143 #else /* WIN32 */
144 
145 typedef SOCKET sock_t;
146 #include <inttypes.h>
147 #endif /* WIN32 */
148 
152 typedef struct _ds_peer_set ds_set_t;
153 
154 typedef uint64_t ds_bitfield_t;
155 
156 typedef struct _ds_data ds_data_t;
157 
158 typedef struct _ds_field ds_field_t;
159 
163 typedef struct _ds_delay ds_delay_t;
164 
165 
169 typedef struct _config_ctx ds_config_ctx_t;
170 
174 typedef struct _ds_log ds_log_t;
175 
190 typedef void (*recv_update_t)(int peer, ds_data_t *pkt);
191 
208 typedef void (*recv_replay_t)(int peer, ds_data_t *pkt, time_t tm);
209 
228 typedef void (*recv_nodata_t)(int peer, char *subject, unsigned short flags);
229 
252 typedef void (*recv_peer_status_t)(int peer, int status, int val, void *data);
253 
272 typedef void (*recv_request_t)(int peer, int count, char **subjects, unsigned short flags);
273 
292 typedef void (*recv_discard_t)(int peer, int count, char **subjects, unsigned short flags);
293 
313 typedef void (*recv_object_status_t)(int peer, char *subject, int status, unsigned short code, char *msgstr);
314 
324 typedef void (*recv_service_status_t)(char *service, int status);
325 
326 
336 typedef void (*recv_map_t)(int peer, char *from, char *to);
337 
338 
356 typedef struct
357  {
360  char *log_root;
361  unsigned short flags;
362  unsigned short type;
378  void (*exit_func)(int exit_code, char *msg);
380  char *logfile;
382  }
383 ds_init_t;
384 
389 #define DS_INITIALISER \
390  { \
391  NULL, /* application_name */ \
392  NULL, /* application_root */ \
393  NULL, /* log_root */ \
394  0, /* flags */ \
395  0, /* type */ \
396  NULL, /* recv_request */ \
397  NULL, /* recv_discard */ \
398  NULL, /* recv_update */ \
399  NULL, /* recv_nodata */ \
400  NULL, /* recv_peer_status */ \
401  NULL, /* recv_object_status */ \
402  NULL, /* recv_service_status */ \
403  NULL, /* recv_map */ \
404  NULL, /* exit_func */ \
405  NULL, /* logfile */ \
406  NULL, /* log */ \
407  }
408 
409 
410 /* datasrc */
411 
412 DATASRCAPI void ds_reserve_std_fds(void);
413 DATASRCAPI void ds_config_init(const char *file, int argc, char **argv);
414 DATASRCAPI int ds_init(ds_init_t *init, int argc, char **argv);
415 DATASRCAPI void ds_thread_init(int event_module, int flags);
416 DATASRCAPI char *ds_filename_expand(const char *format, char *buffer, size_t bufsize);
417 DATASRCAPI ds_log_t *ds_get_event_log(void);
418 
419 
420 /* ds5 */
421 
422 
427 
432  {
438  void (*free)(ds5_namespace_t *nspace);
439 
448  int (*match)(ds5_namespace_t *nspace, const char *subject);
449 
450 
459  char *(*describe)(ds5_namespace_t *nspace, char *buf, size_t buflen);
460 
461  };
462 
463 
464 DATASRCAPI ds5_namespace_t *ds5_create_prefix_namespace(const char *prefix);
465 
466 DATASRCAPI ds5_namespace_t *ds5_create_globbed_namespace(const char *globbed);
467 DATASRCAPI ds5_namespace_t *ds5_create_regex_namespace(const char *expr);
468 DATASRCAPI int ds5_regex_namespace_add_expr(ds5_namespace_t *nspace, const char *expr, int exclude);
469 
470 
471 /* Macros for convenience */
472 
480 #define ds5_namespace_match(nspace, subject) nspace->match(nspace, subject)
481 
486 #define ds5_namespace_free(nspace) nspace->free(nspace)
487 
488 
489 
490 
491 
500 typedef struct _ds5_publisher_s ds5_publisher_t;
501 
502 
503 
504 
505 
506 
507 
518 typedef struct
519  {
538  void (*receive_request)(void *context, int peer, const char *subject);
539 
560  void (*receive_discard)(void *context, int peer, const char *subject);
561  }
563 
564 
565 DATASRCAPI ds5_publisher_t *ds5_create_active_publisher(ds5_namespace_t *nspace, ds5_dataprovider_t *provider, void *context);
566 DATASRCAPI ds5_publisher_t *ds5_create_compatibility_publisher(ds5_namespace_t *nspace, ds5_dataprovider_t *provider, void *context);
567 DATASRCAPI ds5_publisher_t *ds5_create_broadcast_publisher(ds5_namespace_t *nspace);
568 
569 DATASRCAPI void ds5_publish_to_subscribed_peers_no_free(ds5_publisher_t *pub, ds_data_t *dsdata);
570 DATASRCAPI void ds5_publish_to_subscribed_peers(ds5_publisher_t *pub, ds_data_t *dsdata);
571 DATASRCAPI void ds5_publish_response(ds5_publisher_t *pub, ds_data_t *dsdata);
572 DATASRCAPI void ds5_publish_response_no_free(ds5_publisher_t *pub, ds_data_t *dsdata);
573 DATASRCAPI void ds5_publish_status(ds5_publisher_t *pub, const char *subject, int status, const char *message);
574 DATASRCAPI void ds5_publish_status_all(ds5_publisher_t *pub, int status, const char *message);
575 DATASRCAPI void ds5_publish_subject_error(ds5_publisher_t *publisher, const char *subject, int flags);
576 DATASRCAPI void ds5_publish_to_peer(ds5_publisher_t *publisher, int peernum, ds_data_t *dsdata);
577 DATASRCAPI void ds5_publish_to_peer_no_free(ds5_publisher_t *publisher, int peernum, ds_data_t *dsdata);
578 DATASRCAPI void ds5_publish_subject_map(ds5_publisher_t *publisher, const char *subject, const char *mapped_to, int flags);
579 
580 
594 typedef struct
595  {
606  void (*service_status)(void *context, const char *service_name, int state);
607 
619  void (*peer_status)(void *context, int peer_index, const char *peer_name, int state);
620  }
622 
623 
633 typedef struct _ds5_subscription_s ds5_subscription_t;
634 
635 
648 typedef struct
649  {
659  void (*record_updated)(void *context, ds5_subscription_t *sub, int peer, ds_data_t *dsdata);
660 
670  void (*record_type2_updated)(void *context, ds5_subscription_t *sub, int peer, ds_data_t *dsdata);
671 
681  void (*record_type3_updated)(void *context, ds5_subscription_t *sub, int peer, ds_data_t *dsdata);
682 
692  void (*container_updated)(void *context, ds5_subscription_t *sub, int peer, ds_data_t *dsdata);
693 
703  void (*permission_updated)(void *context, ds5_subscription_t *sub, int peer, ds_data_t *dsdata);
704 
714  void (*news_updated)(void *context, ds5_subscription_t *sub, int peer, ds_data_t *dsdata);
715 
725  void (*news_story_updated)(void *context, ds5_subscription_t *sub, int peer, ds_data_t *dsdata);
726 
736  void (*page_updated)(void *context, ds5_subscription_t *sub, int peer, ds_data_t *dsdata);
737 
750  void (*unknown_subject_type_updated)(void *context, ds5_subscription_t *sub, int peer, ds_data_t *dsdata);
751 
752 
763  void (*subscription_error)(void *context, ds5_subscription_t *sub, int peer, const char *subject, short flags);
764 
776  void (*subscription_status)(void *context, ds5_subscription_t *sub, int peer, const char *subject, int status, const char *message);
777  }
779 
780 
781 
782 
783 
784 DATASRCAPI void ds5_config_init(const char *configfile, int argc, char **argv);
785 DATASRCAPI int ds5_init(int argc, char **argv);
786 DATASRCAPI void ds5_add_connectionlistener(ds5_connectionlistener_t *connection_listener, void *context);
787 
788 
789 
790 
791 DATASRCAPI ds5_subscription_t *ds5_create_broadcast_subscription(ds5_namespace_t *nspace, ds5_subscriptionlistener_t *listener, void *context);
792 DATASRCAPI ds5_subscription_t *ds5_create_active_subscription(const char *subject, ds5_subscriptionlistener_t *listener, void *context);
793 DATASRCAPI void ds5_unsubscribe(ds5_subscription_t *sub);
794 
795 
796 
797 /* config */
798 
799 
808 #define DS_OFFSET(t,m) ((void *)&((t *)0)->m)
809 
813 #define DS_CONFIG_BOOL 0x0001
814 
819 #define DS_CONFIG_INT 0x0002
820 
824 #define DS_CONFIG_FLOAT 0x0003
825 
829 #define DS_CONFIG_STR 0x0004
830 
834 #define DS_CONFIG_CHAR 0x0005
835 
839 #define DS_CONFIG_FUNC 0x0006
840 
844 #define DS_CONFIG_FILE 0x0007
845 
849 #define DS_CONFIG_LONG 0x0008
850 
853 #define DS_CONFIG_GROUP 0x0010
854 #define DS_CONFIG_GROUP_END 0x0011
855 #define DS_CONFIG_SECTION 0x0020
856 #define DS_CONFIG_SECTION_END 0x0021
857 
861 #define DS_CONFIG_JAVA 0x0080
862 
866 #define DS_CONFIG_ARRAY 0x0100
867 
872 #define DS_CONFIG_INT_ARRAY (DS_CONFIG_ARRAY|DS_CONFIG_INT)
873 
877 #define DS_CONFIG_FLOAT_ARRAY (DS_CONFIG_ARRAY|DS_CONFIG_FLOAT)
878 
879 
883 #define DS_CONFIG_STR_ARRAY (DS_CONFIG_ARRAY|DS_CONFIG_STR)
884 
888 #define DS_CONFIG_CHAR_ARRAY (DS_CONFIG_ARRAY|DS_CONFIG_CHAR)
889 
893 #define DS_CONFIG_STRICT 0x0200
894 
899 #define DS_CONFIG_DEPRECATED 0x0400
900 
901 
923 typedef struct
924  {
925  const char *name;
926  double value;
927  const char *docstring;
928  }
930 
931 
944 typedef void (*ds_config_func)(char *name, int num, char **values);
945 
946 
947 DATASRCAPI ds_config_ctx_t *ds_config_new_ctx(void);
948 DATASRCAPI void ds_config_free_ctx(ds_config_ctx_t *ctx);
949 DATASRCAPI ds_config_ctx_t *ds_config_set_ctx(ds_config_ctx_t *ctx);
950 DATASRCAPI void ds_config_add_search(const char *path);
951 DATASRCAPI void ds_config_add_file(const char *file);
952 DATASRCAPI void ds_config_add_optional_file(const char *file);
953 DATASRCAPI void ds_config_add_option(char opt, const char *longopt, const char *help, int type, void *value);
954 DATASRCAPI void ds_config_add_bounded_option(char sopt,const char *longopt, const char *help, int type, void *value, void *min, void *max);
955 DATASRCAPI void ds_config_add_option_enum(char opt,const char *longopt, const char *help, int type, void *value, ds_config_enum_t *enums);
956 DATASRCAPI void ds_config_add_bounded_option_enum(char sopt,const char *longopt, const char *help, int type, void *value, ds_config_enum_t *enums, void *min, void *max);
957 DATASRCAPI void ds_config_add_array_option(const char *longopt, const char *help, int type, void *value, int *num);
958 DATASRCAPI void ds_config_add_bounded_array_option(const char *longopt,const char *help, int type, void *value, int *num, void *min, void *max);
959 DATASRCAPI void ds_config_add_array_option_enum(const char *longopt,const char *help, int type, void *value, int *num, ds_config_enum_t *enums);
960 DATASRCAPI void ds_config_add_bounded_array_option_enum(const char *longopt,const char *help, int type, void *value, int *num, ds_config_enum_t *enums, void *min, void *max);
961 DATASRCAPI void ds_config_del_option(const char *longopt);
962 DATASRCAPI void ds_config_add_group(const char *longopt, const char *help, void *base, void *def, size_t size, int *num);
963 DATASRCAPI void ds_config_add_group_with_info(const char *longopt, const char *help, void *base, void *def, size_t size, int *num, int file_offset, int line_offset);
964 DATASRCAPI void ds_config_end_group(const char *longopt,const char *help);
965 DATASRCAPI void ds_config_add_section(const char *longopt,const char *help);
966 DATASRCAPI void ds_config_end_section(const char *longopt,const char *help);
967 DATASRCAPI void ds_config_parse_files(void);
968 DATASRCAPI void ds_config_parse_args(int argc, char **argv, int *retargc);
969 DATASRCAPI int ds_config_parse_file(const char *unresolved_filename);
970 DATASRCAPI void ds_config_list_options(void);
971 DATASRCAPI void ds_config_list_values(void);
972 DATASRCAPI int ds_config_get_enum(const char *value, ds_config_enum_t *enums);
973 DATASRCAPI void ds_config_add_error_message_fmt(const char *fmt,...) PRINTF(1,2);
974 DATASRCAPI void ds_config_add_config_reading_message_fmt(const char *fmt,...) PRINTF(1,2);
975 DATASRCAPI void ds_config_add_error_message(const char *msg);
976 DATASRCAPI char *ds_config_get_filename(void);
977 DATASRCAPI int ds_config_get_linenumber(void);
978 DATASRCAPI void ds_config_set_test(const char *tag, char **value);
979 DATASRCAPI void ds_config_del_test(const char *tag);
980 DATASRCAPI void ds_config_set_option(const char *name, const char *value);
981 
982 
983 /* event */
984 
985 
986 typedef unsigned long ds_reltime_t;
987 
992 typedef struct _ds_timed_event ds_timed_event_t;
993 
994 
999 typedef struct _ds_io_event ds_except_event_t;
1000 
1001 
1002 
1007 typedef struct _ds_io_event ds_read_event_t;
1008 
1009 
1014 typedef struct _ds_io_event ds_write_event_t;
1015 
1016 
1021 typedef struct _ds_io_event ds_generic_event_t;
1022 
1023 
1034 typedef int (*ds_io_event_cb)(sock_t sock, int val, void *data);
1035 
1046 typedef int (*ds_timed_event_cb)(int id, int val, void *data);
1047 
1048 
1049 #define DOUBLE_TO_RELTIME(r,d) r = ((int)(d) << 9) + ((int)(((d) - (int)(d)) * 1000000) >> 11);
1050 #define TIMEVAL_TO_RELTIME(r,tv) r = ((tv).tv_sec << 9) + ((tv).tv_usec >> 11);
1051 
1052 
1053 DATASRCAPI ds_timed_event_t *ds_add_timed_event(int id, double delay, ds_timed_event_cb cb, int val, void *data);
1054 DATASRCAPI ds_read_event_t *ds_add_read_event(sock_t fd, ds_io_event_cb cb, int val, void *data);
1055 DATASRCAPI ds_write_event_t *ds_add_write_event(sock_t fd, ds_io_event_cb cb, int val, void *data);
1056 DATASRCAPI ds_except_event_t *ds_add_except_event(sock_t fd, ds_io_event_cb cb, int val, void *data);
1057 
1058 DATASRCAPI int ds_del_timed_event(ds_timed_event_t *ev);
1059 DATASRCAPI int ds_del_read_event(ds_read_event_t *ev);
1060 DATASRCAPI int ds_del_write_event(ds_write_event_t *ev);
1061 DATASRCAPI int ds_del_except_event(ds_except_event_t *ev);
1062 
1063 DATASRCAPI int ds_del_timed_event_free_data(ds_timed_event_t *ev, void (*free_data)(int, void *));
1064 DATASRCAPI int ds_del_read_event_free_data(ds_read_event_t *ev, void (*free_data)(int, void *));
1065 DATASRCAPI int ds_del_write_event_free_data(ds_write_event_t *ev, void (*free_data)(int, void *));
1066 DATASRCAPI int ds_del_except_event_free_data(ds_except_event_t *ev, void (*free_data)(int, void *));
1067 
1068 DATASRCAPI void ds_timed_event_set_callback(ds_timed_event_t *ev, ds_timed_event_cb cb, int val, void *data);
1069 DATASRCAPI double ds_timed_event_get_fire_time(ds_timed_event_t *ev);
1070 DATASRCAPI void ds_read_event_set_callback(ds_read_event_t *ev, ds_io_event_cb cb, int val, void *data);
1071 DATASRCAPI void ds_write_event_set_callback(ds_write_event_t *ev, ds_io_event_cb cb, int val, void *data);
1072 
1073 DATASRCAPI void ds_set_timed_delay(ds_timed_event_t *ev, double delay);
1074 DATASRCAPI void ds_set_timed_delay_next(ds_timed_event_t *ev, double delay);
1075 
1076 DATASRCAPI void ds_loop(void);
1077 DATASRCAPI void ds_stop(void);
1078 
1079 DATASRCAPI ds_reltime_t ds_get_relative_time(void);
1080 DATASRCAPI time_t ds_get_time(void);
1081 DATASRCAPI struct tm *ds_gmtime(void);
1082 DATASRCAPI struct tm *ds_localtime(void);
1083 DATASRCAPI int ds_get_gmt_offset(time_t t);
1084 DATASRCAPI char *ds_get_timezone(char *buf, int len);
1085 
1086 DATASRCAPI ds_timed_event_t *ds_add_periodic_event(int starttime, int period, int id, ds_timed_event_cb cb, int val, void *data);
1087 DATASRCAPI ds_timed_event_t *ds_add_periodic_event_from_time(time_t then, int starttime, int period, int id, ds_timed_event_cb cb, int val, void *data);
1088 DATASRCAPI int ds_check_periodic_event(int period, ds_timed_event_t **tev);
1089 
1090 
1091 /* cache */
1092 
1097 #define DS_CACHE_DATASRC -1
1098 
1099 DATASRCAPI void ds_cache_add_object(char *subject);
1100 
1101 
1102 /* daemon */
1103 
1104 
1105 DATASRCAPI void ds_daemon_redirect(void);
1106 DATASRCAPI int ds_daemon_disabled(void);
1107 
1108 
1109 /* fields */
1110 
1111 
1119 #define DS_FIELDS_SEPARATOR -65536
1120 
1126 #define DS_FIELDS_NOT_DEFINED (-2147483647 - 1)
1127 
1128 DATASRCAPI int ds_fields_max(void);
1129 DATASRCAPI int ds_fields_add(int num, const char *name, int flags, int dp, const char *fmt);
1130 DATASRCAPI int ds_fields_numbyname(const char *name);
1131 DATASRCAPI char *ds_fields_namebynum(int num);
1132 DATASRCAPI int ds_fields_indexbyname(const char *name);
1133 DATASRCAPI int ds_fields_indexbynum(int num);
1134 DATASRCAPI int ds_fields_numbyindex(int index);
1135 DATASRCAPI char *ds_fields_namebyindex(int index);
1136 DATASRCAPI char *ds_fields_rttpnumbyindex(int index);
1137 DATASRCAPI int ds_fields_getflags(int index);
1138 DATASRCAPI int ds_fields_getdp(int index);
1139 
1140 
1141 
1142 /* log */
1143 
1147 #define DS_LOG_CONFIG 0
1148 #define DS_LOG_ALWAYS 1
1149 
1152 #define DS_LOG_CRIT 2
1153 
1156 #define DS_LOG_ERROR 3
1157 
1160 #define DS_LOG_NOTIFY 4
1161 
1164 #define DS_LOG_WARN 5
1165 
1168 #define DS_LOG_INFO 6
1169 
1172 #define DS_LOG_DEBUG 7
1173 
1176 #define DS_LOG_FINER 8
1177 
1180 #define DS_LOG_FINEST 9
1181 
1184 #define DS_LOG_MONITOR 128
1185 
1188 #define DS_LOG_TERMINAL 256
1189 
1192 #define DS_LOG_SYSLOG 512
1193 #define DS_LOG_FILEONLY 1024
1194 #define DS_LOG_NO_MONITOR 2048
1195 
1203 typedef void (*ds_loglevelchange_t)(ds_log_t *log, int new_level);
1204 
1211 typedef void (*ds_logcycled_t)(ds_log_t *log);
1212 
1213 
1214 
1215 
1216 DATASRCAPI ds_log_t *ds_new_log(const char *name,const char *logname);
1217 DATASRCAPI ds_log_t *ds_new_level_log(const char *name, const char *logname, ds_loglevelchange_t change_cb);
1218 DATASRCAPI ds_log_t *ds_new_headed_log(const char *name, const char *logname, const char *header);
1219 DATASRCAPI void ds_free_log(ds_log_t *log);
1220 DATASRCAPI void ds_write(ds_log_t *log, void *data, size_t len);
1221 #ifndef WIN32
1222 DATASRCAPI void ds_writev(ds_log_t *log, struct iovec *vector, int count);
1223 #endif
1224 DATASRCAPI void ds_printf(ds_log_t *log, const char *fmt, ...) PRINTF(2,3);
1225 DATASRCAPI void ds_printf_time(ds_log_t *log, const char *fmt, ...) PRINTF(2,3);
1226 DATASRCAPI void ds_printf_time_ap(ds_log_t *log, const char *extra, const char *fmt, va_list ap);
1227 DATASRCAPI void ds_syslog(ds_log_t *log, int priority, const char *fmt, ...) PRINTF(3,4);
1228 DATASRCAPI void ds_cycle_all_logs(const char *suffix, long maxsize);
1229 DATASRCAPI int ds_cycle_log(ds_log_t *log, const char *suffix, long maxsize);
1230 DATASRCAPI int ds_debug_level(const char *text);
1231 DATASRCAPI char *ds_debug_string(int level);
1232 DATASRCAPI char *ds_debug_config_string(int level);
1233 DATASRCAPI void ds_log(ds_log_t *log, int level, const char *fmt,...) PRINTF(3,4);
1234 DATASRCAPI int ds_log_set_log_level(ds_log_t *log, const char *level);
1235 DATASRCAPI void ds_log_change_level_callback(ds_log_t *log, ds_loglevelchange_t change_cb);
1236 DATASRCAPI ds_logcycled_t ds_log_cycled_callback(ds_log_t *log, ds_logcycled_t cycle_cb);
1237 DATASRCAPI char *ds_log_getfilename(ds_log_t *log);
1238 DATASRCAPI char *ds_log_getname(ds_log_t *log);
1239 DATASRCAPI int ds_log_get_level(ds_log_t *log);
1240 DATASRCAPI int ds_log_flush(ds_log_t *log);
1241 
1242 
1243 /* lty_chain */
1244 
1245 
1255 DATASRCAPI void ds_add_latency_chain(ds_data_t *dsdata, char suffix, struct timespec *tp);
1256 
1268 DATASRCAPI void ds_add_latency_chain2(ds_data_t *dsdata, char suffix, struct timespec tp, char suffix2, struct timespec *tp2);
1269 
1274 DATASRCAPI void ds_add_latency_initial_timestamp(ds_data_t *dsdata);
1275 
1276 /* monitor */
1277 
1278 
1282 #define TYPE_NONE 0
1283 
1287 #define TYPE_BINARY 1
1288 
1291 #define TYPE_STRING 2
1292 
1295 #define TYPE_SHORT 3
1296 
1299 #define TYPE_USHORT 4
1300 
1303 #define TYPE_LONG 5
1304 
1307 #define TYPE_ULONG 6
1308 
1311 #define TYPE_LLONG 7
1312 
1315 #define TYPE_ULLONG 8
1316 
1319 #define TYPE_DOUBLE 9
1320 
1325 #define TYPE_TIMESTAMP 10
1326 
1331 #define TYPE_BOOLEAN 11
1332 
1336 #define TYPE_RELATION 20
1337 
1341 #define TYPE_SUBSCRIPTION 21
1342 
1343 
1347 #define TYPE_PRIMITIVE_MASK 31
1348 
1352 #define TYPE_ARRAY 32
1353 
1356 #define TYPE_ACTIVE 64
1357 
1367 #define TYPE_ACTIVE2 128
1368 
1371 #define TYPE_METHOD 256
1372 
1375 #define TYPE_KEY 512
1376 
1379 #define TYPE_HIERARCHY 1024
1380 
1386 #define TYPE_OPTIONAL 2048
1387 
1388 
1394 typedef struct {
1395  size_t size;
1396  union _ds_mondata_value {
1397  void *b;
1398  char **c;
1399  int16_t *s;
1400  uint16_t *us;
1401  int32_t *l;
1402  uint32_t *ul;
1403  int64_t *ll;
1404  uint64_t *ull;
1405  double *d;
1406  } data;
1407  }
1408 ds_array_t;
1409 
1415 typedef struct
1416  {
1418  int datatype;
1419  union _ds_mondata_value2
1420  {
1421  void *active_ptr; /* Do not set used by monitoring API */
1422  char *c;
1423  int16_t s;
1424  uint16_t us; /* Also used for TYPE_BOOLEAN */
1425  int32_t l;
1426  uint32_t ul; /* Also used for TYPE_TIMESTAMP */
1427  int64_t ll;
1428  uint64_t ull;
1429  double d;
1430  ds_array_t array;
1431  }
1432  data;
1433  }
1434 ds_monitor_t;
1435 
1436 
1440 typedef struct
1441  {
1443  char *name;
1444  char *description;
1445  char *docstring;
1446  }
1448 
1449 
1464 typedef ds_monitor_t *(*ds_monitor_method_cb)(char *templatename, char *key, char *property, int argc, char *argv[]);
1465 
1475 typedef ds_monitor_t *(*ds_monitor_active_cb)(char *templatename, char *key, char *propertyname);
1476 
1477 
1478 
1483 typedef struct
1484  {
1485  char *username;
1486  char *password;
1487  char *ipaddress;
1488  }
1489 ds_monauth_t;
1490 
1500 typedef int (*ds_monitor_authenticator_t)(ds_monauth_t *credentials);
1501 
1502 
1503 
1504 DATASRCAPI char *ds_monitor_module_name(void);
1505 
1506 
1507 DATASRCAPI void ds_monitor_add_server_type(const char *type, const char *root);
1508 DATASRCAPI void ds_monitor_start_template(const char *templatename, const char *description);
1509 DATASRCAPI void ds_monitor_add_template_member(const char *templatename, const char *propertyname, const char *description, int typeflags, ds_arguments_t *args, void *ptr);
1510 DATASRCAPI void ds_monitor_add_template_relation(const char *templatename, const char *propertyname, const char *targettemplate, const char *description, int thisend_multiple, int thatend_multiple);
1511 DATASRCAPI void ds_monitor_add_template_subscription(const char *templatename, const char *propertyname, const char *targettemplate, const char *description, const char *singleton, ds_monitor_active_cb callback_fn);
1512 
1513 
1514 DATASRCAPI void ds_monitor_add_relation(const char *templatename, const char *key, const char *propertyname, const char *targetkey);
1515 DATASRCAPI void ds_monitor_del_relation(const char *templatename, const char *key, const char *propertyname, const char *targetkey);
1516 
1517 DATASRCAPI void ds_monitor_add_subscription(const char *templatename, const char *key, const char *propertyname, const char *value);
1518 DATASRCAPI void ds_monitor_del_subscription(const char *templatename, const char *key, const char *propertyname, const char *value);
1519 
1520 DATASRCAPI void ds_monitor_end_template(const char *templatename);
1521 
1522 DATASRCAPI void ds_monitor_create_group(const char *templatename, const char *key, const char *brief, const char *description);
1523 DATASRCAPI void ds_monitor_delete_group(const char *templatename, const char *key);
1524 
1525 
1526 
1527 DATASRCAPI void ds_monitor_update(const char *templatename, const char *key, ds_monitor_t *mondata);
1528 DATASRCAPI void ds_monitor_update_string(const char *templatename, const char *key, const char *propertyname, const char *value);
1529 DATASRCAPI void ds_monitor_update_ushort(const char *templatename, const char *key, const char *propertyname, uint16_t);
1530 DATASRCAPI void ds_monitor_update_short(const char *templatename, const char *key, const char *propertyname, int16_t value);
1531 DATASRCAPI void ds_monitor_update_ulong(const char *templatename, const char *key, const char *propertyname, uint32_t value);
1532 DATASRCAPI void ds_monitor_update_long(const char *templatename,const char *key, const char *propertyname, int32_t value);
1533 DATASRCAPI void ds_monitor_update_ullong(const char *templatename, const char *key, const char *propertyname, uint64_t value);
1534 DATASRCAPI void ds_monitor_update_llong(const char *templatename, const char *key, const char *propertyname, int64_t value);
1535 DATASRCAPI void ds_monitor_update_double(const char *templatename, const char *key, const char *propertyname, double value);
1536 DATASRCAPI void ds_monitor_update_timestamp(const char *templatename, const char *key, const char *propertyname, int64_t value);
1537 DATASRCAPI void ds_monitor_update_boolean(const char *templatename, const char *key, const char *propertyname, uint8_t value);
1538 
1539 
1540 
1541 DATASRCAPI ds_monitor_t *ds_monitor_new(const char *propertyname, int type, int datasize, const void *datum);
1542 DATASRCAPI ds_monitor_t *ds_monitor_new_array(const char *propertyname, int type);
1543 DATASRCAPI void ds_monitor_add_data(ds_monitor_t *data, const void *datum);
1544 DATASRCAPI void ds_monitor_free(ds_monitor_t *data); /* Needed by plugin */
1545 
1546 DATASRCAPI void ds_monitor_free_data(ds_monitor_t *data);
1547 
1548 
1549 DATASRCAPI ds_monitor_t *ds_monitor_new_string(const char *templatename, const char *key, const char *propertyname, const char *value);
1550 DATASRCAPI ds_monitor_t *ds_monitor_new_ushort(const char *templatename, const char *key, const char *propertyname, uint16_t value);
1551 DATASRCAPI ds_monitor_t *ds_monitor_new_short(const char *templatename, const char *key, const char *propertyname, int16_t value);
1552 DATASRCAPI ds_monitor_t *ds_monitor_new_ulong(const char *templatename, const char *key, const char *propertyname, uint32_t value);
1553 DATASRCAPI ds_monitor_t *ds_monitor_new_long(const char *templatename,const char *key, const char *propertyname, int32_t value);
1554 DATASRCAPI ds_monitor_t *ds_monitor_new_ullong(const char *templatename, const char *key, const char *propertyname, uint64_t value);
1555 DATASRCAPI ds_monitor_t *ds_monitor_new_llong(const char *templatename, const char *key, const char *propertyname, int64_t value);
1556 DATASRCAPI ds_monitor_t *ds_monitor_new_double(const char *templatename, const char *key, const char *propertyname, double value);
1557 DATASRCAPI ds_monitor_t *ds_monitor_new_timestamp(const char *templatename, const char *key, const char *propertyname, int64_t value);
1558 DATASRCAPI ds_monitor_t *ds_monitor_new_boolean(const char *templatename, const char *key, const char *propertyname, uint8_t value);
1559 
1560 
1561 DATASRCAPI ds_monitor_authenticator_t ds_monitor_set_auth(ds_monitor_authenticator_t authenticator);
1562 
1563 
1564 /* net */
1565 
1566 
1567 DATASRCAPI sock_t ds_listen_socket(const char *addr, int port, int backlog);
1568 DATASRCAPI sock_t ds_accept_socket(sock_t fd);
1569 DATASRCAPI sock_t ds_multicast_listen_socket(const char *p_interface, const char *addr, int port);
1570 DATASRCAPI sock_t ds_udp_listen_socket(const char *p_interface, int port);
1571 DATASRCAPI sock_t ds_client_socket(const char *serv, unsigned short port);
1572 DATASRCAPI sock_t ds_client_socket_nonblocking(const char *serv, unsigned short port);
1573 DATASRCAPI int ds_udp_send(const char *data, int len, const char *addr, int port);
1574 DATASRCAPI int ds_udp_sendto(const char *data, int len, struct sockaddr_storage *serv_addr);
1575 DATASRCAPI sock_t ds_udp_client_socket(const char *addr, int port, struct sockaddr_storage *serv_addr);
1576 DATASRCAPI int ds_udp_bind_client_socket(sock_t sock, const char *addr, int port);
1577 DATASRCAPI char *ds_interface_address(const char *ifname);
1578 DATASRCAPI void ds_setnonblocking(sock_t fd);
1579 DATASRCAPI char *ds_getnameinfo(const struct sockaddr_storage *addr, char *buf, size_t buflen);
1580 DATASRCAPI int ds_compare_sockaddr(struct sockaddr_storage *sa, struct sockaddr_storage *sb);
1581 DATASRCAPI int ds_pipe(sock_t fds[2]);
1582 DATASRCAPI int ds_check_subnet(const char *s_address, const char *s_network, const char *s_netmask);
1583 DATASRCAPI struct sockaddr_storage *ds_gethostsockaddr(const char *name, struct sockaddr_storage *populate);
1584 DATASRCAPI struct addrinfo *ds_gethostsockaddrs(const char *name);
1585 
1586 
1587 
1588 /* Message Types */
1589 
1597 #define DS_MSG_CONNECT 0x0100
1598 
1606 #define DS_MSG_DISCONNECT 0x0200
1607 #define DS_MSG_STATUS 0x0400
1608 
1613 #define DS_MSG_AFFINITY_REMOVED 0x0800
1614 
1615 
1616 /* Peer Types */
1617 
1618 #define DS_T_USERMASK 0x00ff
1619 
1629 #define DS_T_ACTIVE 0x0001
1630 
1641 #define DS_T_CONTRIB 0x0002
1642 
1643 #define DS_T_MSG 0x0100
1644 
1645 
1646 /* Peer Flags */
1647 
1648 #define DS_F_USERMASK 0x00ff
1649 
1665 #define F_SENDFROMSEQ 0x0001
1666 
1667 #define F_SENDFROMFIELD 0x0002
1668 
1669 
1683 #define F_RECVAUTOREPLAY 0x0004
1684 
1685 
1700 #define F_NOCONNECT 0x0008
1701 
1702 #define F_RECONNECT 0x0100
1703 #define F_FAILOVER 0x0200
1704 
1705 #define F_NOFIELDS 0x0400
1706 
1707 
1708 /* No Data Flags */
1709 
1710 #define F_NODATAMASK 0x000f
1711 
1721 #define F_NOTFOUND 0x0001
1722 
1731 #define F_READDENY 0x0002
1732 
1741 #define F_WRITEDENY 0x0003
1742 
1751 #define F_DELETEOBJECT 0x0004
1752 
1761 #define F_UNAVAILABLE 0x0005
1762 #define F_STATUS 0x0006
1763 
1764 
1765 
1771 #define F_IGNOREREQTIMEOUT 0x0008
1772 
1773 /* Object Types */
1774 
1778 #define DS_PAGE_TYPE 221
1779 
1782 #define DS_RECORD_TYPE 222
1783 
1786 #define DS_RECORD_TYPE2 225
1787 
1790 #define DS_RECORD_TYPE3 226
1791 
1794 #define DS_NEWS_TYPE 223
1795 
1798 #define DS_STORY_TYPE 224
1799 
1802 #define DS_CONTAINER_TYPE 228
1803 
1806 #define DS_PERMISSION_TYPE 230
1807 
1814 #define DS_GENERIC_TYPE 231
1815 
1819 #define DS_JSON_TYPE 232
1820 
1821 
1822 /* Data Flags */
1823 
1827 #define F_CREATEOBJECT 0x0010
1828 
1831 #define F_CREATEPARENT 0x0020
1832 #define F_PERSISTENT 0x0040
1833 #define F_CREATEDATA 0x0080
1834 
1838 #define F_CLEAR_PERM 0x0400
1839 
1850 #define F_FILTER_PERM 0x0800
1851 
1856 #define F_AUTHGLOBAL 0x0100
1857 
1861 #define F_CLEAR_TYPE3 0x0100
1862 
1866 #define F_FILTER_TYPE3 0x0200
1867 
1870 #define F_CLEAR_TYPE2 0x0400
1871 
1885 #define F_FILTER_TYPE2 0x0800
1886 
1892 #ifdef __DARWIN_NULL
1893 #undef F_NOCACHE
1894 #endif
1895 #define F_NOCACHE 0x0400
1896 
1903 #define F_DELETE_HEADLINE 0x0100
1904 
1912 #define F_CHANGE_HEADLINE 0x0200
1913 
1918 #define F_IMAGE 0x1000
1919 
1923 #define F_NONACTIVE 0x2000
1924 
1927 #define F_AUTHUPDATE 0x4000
1928 
1929 
1937 #define F_CONSTITUENT_NOAUTH 0x4000
1938 
1945 #define F_CHANGEDFIELDS 0x8000
1946 
1947 /* Field Data Types */
1948 
1949 #define FLOAT32_TYPE 1
1950 #define FLOAT64_TYPE 2
1951 #define INT8_TYPE 3
1952 #define INT16_TYPE 4
1953 #define INT32_TYPE 5
1954 #define INT64_TYPE 6
1955 #define UINT8_TYPE 7
1956 #define UINT16_TYPE 8
1957 #define UINT32_TYPE 9
1958 #define UINT64_TYPE 10
1959 
1960 
1961 /* Object request flags */
1962 
1972 #define DS_REQUEST_FAILOVER 1
1973 
1982 #define DS_REQUEST_CACHE 4
1983 
1984 
1985 
1986 /* Object Status Flags */
1987 
1997 #define S_INFO 0x0000
1998 
2007 #define S_STALE 0x0001
2008 
2017 #define S_NOTSTALE 0x0004
2018 
2030 #define S_UPDCLR 0x0100
2031 
2042 #define S_FAILOVER 0x1101 /* Failover implies S_STALE|S_UPDCLR */
2043 
2044 
2057 #define OBJ_STATUS_INFO 0x0000
2058 
2071 #define OBJ_STATUS_OK 0x0001
2072 
2087 #define OBJ_STATUS_STALE 0x0002
2088 
2089 
2105 #define OBJ_STATUS_LIMITED 0x0008
2106 
2107 
2108 #define OBJ_STATUS_NOTMAPPED 0x0010
2109 
2118 #define SVC_STATUS_OK 0x0001
2119 
2128 #define SVC_STATUS_DOWN 0x0002
2129 
2138 #define SVC_STATUS_LIMITED 0x0008
2139 
2140 
2141 /* Field Macros */
2142 #define DS_MAX_BITFIELD (sizeof(ds_bitfield_t)*8)
2143 
2144 #define DS_BITFIELD_SET(n,p) *(p) |= (1ULL << (n))
2145 #define DS_BITFIELD_CLR(n,p) *(p) &= ~(1ULL << (n))
2146 #define DS_BITFIELD_ISSET(n,p) (*(p) & (1ULL << (n)))
2147 #define DS_BITFIELD_ZERO(p) *(p) = 0
2148 #define DS_BITFIELD_NONZERO(p) memset((char *)(p), 0xffffffff, sizeof(*(p)))
2149 
2150 /* Peer set functions and macros */
2151 
2152 DATASRCAPI int ds_iszero(ds_set_t *p);
2153 DATASRCAPI void ds_not(ds_set_t *p);
2154 DATASRCAPI void ds_or(ds_set_t *p1, ds_set_t *p2, ds_set_t *o);
2155 DATASRCAPI void ds_and(ds_set_t *p1, ds_set_t *p2, ds_set_t *a);
2156 DATASRCAPI int ds_and_iszero(ds_set_t *p1, ds_set_t *p2);
2157 DATASRCAPI int ds_and3_iszero(ds_set_t *p1, ds_set_t *p2, ds_set_t *p3);
2158 DATASRCAPI int ds_and_equal(ds_set_t *a1, ds_set_t *a2, ds_set_t *eq);
2159 DATASRCAPI int ds_isequal(ds_set_t *p1, ds_set_t *p2);
2160 
2165 #define DS_MAX_PEERS 1024
2166 
2171 #define DS_MIN_PEER 0
2172 
2177 #define DS_INTERNAL_DATASRC 1023
2178 
2179 typedef uint32_t dsset_element_t;
2180 
2181 #define DS_NUMBITS (sizeof(dsset_element_t) * 8)
2182 #define DS_NUM_ELEMS (DS_MAX_PEERS+DS_NUMBITS-1)/DS_NUMBITS
2183 #define DS_NUM_BYTES (DS_NUM_ELEMS * sizeof(dsset_element_t))
2184 
2185 struct _ds_peer_set
2186  {
2187  dsset_element_t bits[DS_NUM_ELEMS];
2188  };
2189 
2194 #define DS_SET(n,p) ((p)->bits[(n)/DS_NUMBITS] |= ((unsigned)1 << ((n) % DS_NUMBITS)))
2195 
2200 #define DS_CLR(n,p) ((p)->bits[(n)/DS_NUMBITS] &= ~((unsigned)1 << ((n) % DS_NUMBITS)))
2201 
2206 #define DS_ISSET(n,p) ((p)->bits[(n)/DS_NUMBITS] & ((unsigned)1 << ((n) % DS_NUMBITS)))
2207 
2212 #define DS_ZERO(p) memset((char *)(p)->bits, 0, DS_NUM_BYTES)
2213 
2218 #define DS_NONZERO(p) memset((char *)(p)->bits, 0xff, DS_NUM_BYTES)
2219 
2224 #define DS_NOT(p) ds_not(p)
2225 
2230 #define DS_ISZERO(p) ds_iszero(p)
2231 
2236 #define DS_AND(p1, p2, a) ds_and(p1, p2, a)
2237 
2242 #define DS_OR(p1, p2, o) ds_or(p1, p2, o)
2243 
2248 #define DS_AND_ISZERO(p1, p2) ds_and_iszero(p1, p2)
2249 
2254 #define DS_AND3_ISZERO(p1, p2, p3) ds_and3_iszero(p1, p2, p3)
2255 
2260 #define DS_AND_EQ(a1,a2,eq) ds_and_equal(a1,a2,eq)
2261 
2262 
2267 #define DS_ISEQUAL(p1, p2) ds_isequal(p1, p2)
2268 
2269 DATASRCAPI ds_data_t *ds_init_data(const char *subject, unsigned short type, unsigned short flags);
2270 DATASRCAPI void ds_set_subject(ds_data_t *data, const char *subject);
2271 
2272 DATASRCAPI void ds_add_data(ds_data_t *data, int32_t fieldnum, const char *value);
2273 DATASRCAPI void ds_add_data_fmt(ds_data_t *data, int32_t fieldnum, const char *fmt, ...);
2274 DATASRCAPI void ds_add_data_str(ds_data_t *data, int32_t fieldnum, const char *value);
2275 DATASRCAPI void ds_add_data_float32(ds_data_t *data, int32_t fieldnum, float value);
2276 DATASRCAPI void ds_add_data_float64(ds_data_t *data, int32_t fieldnum, double value);
2277 DATASRCAPI void ds_add_data_int8(ds_data_t *data, int32_t fieldnum, int8_t value);
2278 DATASRCAPI void ds_add_data_int16(ds_data_t *data, int32_t fieldnum, int16_t value);
2279 DATASRCAPI void ds_add_data_int32(ds_data_t *data, int32_t fieldnum, int32_t value);
2280 DATASRCAPI void ds_add_data_int64(ds_data_t *data, int32_t fieldnum, int64_t value);
2281 DATASRCAPI void ds_add_data_uint8(ds_data_t *data, int32_t fieldnum, uint8_t value);
2282 DATASRCAPI void ds_add_data_uint16(ds_data_t *data, int32_t fieldnum, uint16_t value);
2283 DATASRCAPI void ds_add_data_uint32(ds_data_t *data, int32_t fieldnum, uint32_t value);
2284 DATASRCAPI void ds_add_data_uint64(ds_data_t *data, int32_t fieldnum, uint64_t value);
2285 DATASRCAPI void ds_add_data_char(ds_data_t *data, int32_t fieldnum, char value);
2286 
2287 DATASRCAPI ds_data_t *ds_clone_data(ds_data_t *data);
2288 
2289 #define ds_add_data_short(d,f,v) ds_add_data_int16(d,f,v)
2290 #define ds_add_data_int(d,f,v) ds_add_data_int32(d,f,v)
2291 #define ds_add_data_long(d,f,v) ds_add_data_int32(d,f,v)
2292 #define ds_add_data_float(d,f,v) ds_add_data_float32(d,f,v)
2293 #define ds_add_data_double(d,f,v) ds_add_data_float64(d,f,v)
2294 
2295 DATASRCAPI void ds_send_data(ds_data_t *data);
2296 DATASRCAPI void ds_send_data_to_peer(int peer, ds_data_t *data);
2297 DATASRCAPI void ds_send_data_no_free(ds_data_t *data);
2298 DATASRCAPI void ds_send_data_to_peer_no_free(int peer, ds_data_t *data);
2299 DATASRCAPI void ds_send_nodata(const char *subject, unsigned short flags);
2300 DATASRCAPI void ds_send_nodata_to_peer(int peer, const char *subject, unsigned short flags);
2301 DATASRCAPI void ds_free_data(ds_data_t *data);
2302 DATASRCAPI void ds_send_status(const char *subject, unsigned short flags, unsigned short code, const char *msgstr);
2303 DATASRCAPI void ds_send_status_to_peer(int peer,const char *subject, unsigned short flags, unsigned short code, const char *msgstr);
2304 DATASRCAPI void ds_send_data_direct(ds_data_t *data);
2305 DATASRCAPI void ds_send_nodata_direct(const char *subject, unsigned short flags);
2306 DATASRCAPI void ds_send_status_direct(const char *subject, unsigned short flags, unsigned short code, const char *msgstr);
2307 
2308 DATASRCAPI void ds_send_map_to_peer(int peer, const char *subject, const char *mapped, unsigned short flags);
2309 DATASRCAPI void ds_send_map(const char *subject, const char *mapped, unsigned short flags);
2310 
2311 
2322 typedef void (*ds_delay_send_cb)(void *context, ds_data_t *dsdata);
2323 
2324 DATASRCAPI ds_delay_t *ds_new_delay(double delay_time, char *prefix, double batch_time);
2325 DATASRCAPI ds_delay_t *ds_new_delay_with_callback(double delay_time, char *prefix, double batch_time, void *callback_param, ds_delay_send_cb callback_func);
2326 DATASRCAPI void ds_delay_data(ds_delay_t *delay, ds_data_t *dsdata);
2327 
2328 DATASRCAPI int32_t ds_add_record_str(ds_data_t *data, const char *field, const char *value);
2329 DATASRCAPI int32_t ds_add_record_int(ds_data_t *data,const char *field, int value);
2330 DATASRCAPI int32_t ds_add_record_char(ds_data_t *data,const char *field, char value);
2331 DATASRCAPI int32_t ds_add_record_float(ds_data_t *data,const char *field, double value);
2332 DATASRCAPI int32_t ds_add_record_fmt(ds_data_t *data,const char *field, const char *fmt, ...);
2333 
2334 DATASRCAPI ds_data_t *ds_init_page(const char *subject, int rows, int cols, const char *type, unsigned short flags);
2335 DATASRCAPI void ds_add_page_row(ds_data_t *data, int row, int col, const char *str);
2336 DATASRCAPI void ds_add_page_field(ds_data_t *data, int32_t fieldnum, const char *value);
2337 DATASRCAPI void ds_add_page_field_by_name(ds_data_t *data, const char *field, const char *value);
2338 
2339 DATASRCAPI ds_data_t *ds_init_news(const char *subject, unsigned short flags);
2340 DATASRCAPI void ds_add_news_headline(ds_data_t *data, const char *headline);
2341 DATASRCAPI void ds_add_news_storycode(ds_data_t *data, const char *story);
2342 DATASRCAPI void ds_add_news_datetime(ds_data_t *data, const char *datestr);
2343 DATASRCAPI void ds_add_news_authstr(ds_data_t *data, const char *authstr);
2344 DATASRCAPI void ds_add_news_product_code(ds_data_t *data, const char *code);
2345 DATASRCAPI void ds_add_news_topic_code(ds_data_t *data, const char *code);
2346 DATASRCAPI void ds_add_news_company_code(ds_data_t *data, const char *code);
2347 DATASRCAPI void ds_add_news_user_code(ds_data_t *data, int codenum, const char *code);
2348 DATASRCAPI void ds_add_news_field(ds_data_t *dsdata, const char *fieldname, const char *value);
2349 
2350 DATASRCAPI ds_data_t *ds_init_container(const char *subject, const unsigned short flags);
2351 DATASRCAPI void ds_add_container_symbol_and_request(ds_data_t *data, const char *symbol, const int request);
2352 DATASRCAPI void ds_add_container_symbol(ds_data_t *data, const char *symbol);
2353 DATASRCAPI void ds_add_container_symbol_at_position(ds_data_t *data, int position, const char *symbol);
2354 DATASRCAPI void ds_remove_container_symbol(ds_data_t *data, const char *symbol);
2355 DATASRCAPI void ds_cleardown_container_with_prefix(ds_data_t *data, const char *prefix);
2356 
2357 DATASRCAPI ds_data_t *ds_init_permission(const char *subject, const char *key, unsigned short flags);
2358 DATASRCAPI void ds_add_permission_key(ds_data_t *data, const char *key);
2359 
2360 DATASRCAPI void ds_add_binary(ds_data_t *data, int32_t fieldnum, char *value, int len, char type);
2361 DATASRCAPI void ds_add_binary_float32(ds_data_t *data, int32_t fieldnum, float value);
2362 DATASRCAPI void ds_add_binary_float64(ds_data_t *data, int32_t fieldnum, double value);
2363 DATASRCAPI void ds_add_binary_int8(ds_data_t *data, int32_t fieldnum, int8_t value);
2364 DATASRCAPI void ds_add_binary_int16(ds_data_t *data, int32_t fieldnum, int16_t value);
2365 DATASRCAPI void ds_add_binary_int32(ds_data_t *data, int32_t fieldnum, int32_t value);
2366 DATASRCAPI void ds_add_binary_int64(ds_data_t *data, int32_t fieldnum, int64_t value);
2367 DATASRCAPI void ds_add_binary_uint8(ds_data_t *data, int32_t fieldnum, uint8_t value);
2368 DATASRCAPI void ds_add_binary_uint16(ds_data_t *data, int32_t fieldnum, uint16_t value);
2369 DATASRCAPI void ds_add_binary_uint32(ds_data_t *data, int32_t fieldnum, uint32_t value);
2370 DATASRCAPI void ds_add_binary_uint64(ds_data_t *data, int32_t fieldnum, uint64_t value);
2371 DATASRCAPI void ds_add_binary_string(ds_data_t *data, int32_t fieldnum, char *value);
2372 DATASRCAPI void ds_add_binary_opaque(ds_data_t *data, int32_t fieldnum, char *value, int len);
2373 DATASRCAPI void ds_add_binary_time(ds_data_t *data, int32_t fieldnum, time_t value);
2374 DATASRCAPI void ds_add_binary_time_millis(ds_data_t *data, int32_t fieldnum, int64_t value);
2375 DATASRCAPI void ds_add_binary_timeval(ds_data_t *data, int32_t fieldnum, struct timeval value);
2376 DATASRCAPI void ds_add_binary_timespec(ds_data_t *data, int32_t fieldnum, struct timespec value);
2377 
2378 #define ds_add_binary_char(d,f,v) ds_add_binary_int8(d,f,v);
2379 #define ds_add_binary_short(d,f,v) ds_add_binary_int16(d,f,v);
2380 #define ds_add_binary_int(d,f,v) ds_add_binary_int32(d,f,v);
2381 #define ds_add_binary_long(d,f,v) ds_add_binary_int32(d,f,v);
2382 #define ds_add_binary_float(d,f,v) ds_add_binary_float32(d,f,v);
2383 #define ds_add_binary_double(d,f,v) ds_add_binary_float64(d,f,v);
2384 #define ds_add_binary_time_micros(d,f,v) ds_add_binary_timeval(d,f,v);
2385 #define ds_add_binary_time_nanos(d,f,v) ds_add_binary_timespec(d,f,v);
2386 
2387 
2391 #define NEWS_HEADLINE_FIELDNUM 0
2392 
2395 #define NEWS_STORYCODE_FIELDNUM 1
2396 
2399 #define NEWS_DATETIME_FIELDNUM 2
2400 
2403 #define NEWS_AUTHSTR_FIELDNUM 5
2404 
2407 #define NEWS_PRODUCT_CODE_FIELDNUM 100
2408 
2411 #define NEWS_TOPIC_CODE_FIELDNUM 101
2412 
2415 #define NEWS_COMPANY_CODE_FIELDNUM 102
2416 
2419 #define NEWS_USER_CODE_FIELDNUM 200
2420 
2423 #define NEWS_USER_CODE_MAX 10
2424 
2425 #define NEWS_SIZE_FIELDNUM 300
2426 #define NEWS_REASON_FIELDNUM 301
2427 
2428 #define NEWS_REQ_SEARCH 1000
2429 #define NEWS_REQ_STORYCODE 1001
2430 #define NEWS_REQ_DATE_TO 1002
2431 #define NEWS_REQ_DATE_FROM 1003
2432 #define NEWS_REQ_FLAGS 1004
2433 
2434 #define NEWS_GENERIC_FIELDNUM 1024
2435 
2436 /* peer */
2437 
2438 
2439 DATASRCAPI extern int ds_num_peers;
2440 
2441 
2442 DATASRCAPI int ds_peer_details(int peer, char **name);
2443 DATASRCAPI int ds_peer_host_details(int peer, char **addr);
2444 DATASRCAPI int ds_peer_id(int peer);
2445 DATASRCAPI char *ds_peer_name(int peer);
2446 DATASRCAPI int ds_peer_flags(int peer);
2447 DATASRCAPI int ds_peer_local_type(int peer);
2448 DATASRCAPI int ds_peer_type(int peer);
2449 DATASRCAPI int ds_peer_up(int peer);
2450 DATASRCAPI void ds_peer_add_extra_handshake_data(int peer, const char *data);
2451 DATASRCAPI int ds_peer_all_type(int flag);
2452 
2453 DATASRCAPI void ds_set_status_down(void);
2454 DATASRCAPI void ds_set_status_down_to_peer(int peer);
2455 DATASRCAPI void ds_set_status_msg(unsigned short msgid, const char *msgstr);
2456 DATASRCAPI void ds_set_status_msg_to_peer(int peer, unsigned short msgid, const char *msgstr);
2457 DATASRCAPI void ds_set_status_up(void);
2458 DATASRCAPI void ds_set_status_up_to_peer(int peer);
2459 DATASRCAPI int ds_peer_by_label(const char *label);
2460 DATASRCAPI int ds_peer_by_local_label(const char *label);
2461 DATASRCAPI char *ds_peer_label_byindex(int index);
2462 DATASRCAPI int ds_peer_enabled_state(int peer);
2463 
2464 DATASRCAPI int ds_peer_details_r(int peer, char *buffer, size_t buflen);
2465 DATASRCAPI int ds_peer_host_details_r(int peer, char *buffer, size_t buflen);
2466 DATASRCAPI char *ds_peer_name_r(int peer, char *buffer, size_t buflen);
2467 DATASRCAPI char *ds_peer_label_byindex_r(int peer, char *buffer, size_t buflen);
2468 
2469 /* pkt */
2470 
2477 struct _ds_data
2478  {
2479  unsigned short seq;
2480  unsigned short flags;
2481  unsigned short type;
2482  char *subject;
2483  unsigned short count;
2485  time_t time;
2486  };
2487 
2495  {
2496  int32_t fieldnum;
2497  int32_t len;
2498  char *value;
2499  unsigned short flags;
2500  };
2501 
2502 
2503 /* replay */
2504 
2505 
2506 DATASRCAPI void ds_replay(recv_replay_t callback);
2507 DATASRCAPI int ds_replay_from_file(recv_replay_t callback, char *filename);
2508 DATASRCAPI void ds_replay_from_log(recv_replay_t callback, ds_log_t *log);
2509 DATASRCAPI void ds_replay_by_time(time_t t, recv_replay_t callback);
2510 DATASRCAPI int ds_replay_by_time_from_file(time_t t, recv_replay_t callback, char *filename);
2511 DATASRCAPI void ds_replay_by_time_from_log(time_t t, recv_replay_t callback, ds_log_t *log);
2512 DATASRCAPI void ds_replay_by_field(int fieldnum, char *value, recv_replay_t callback);
2513 DATASRCAPI int ds_replay_by_field_from_file(int fieldnum, char *value, recv_replay_t callback, char *filename);
2514 DATASRCAPI void ds_replay_by_field_from_log(int fieldnum, char *value, recv_replay_t callback, ds_log_t *log);
2515 
2516 
2517 /* udp */
2518 
2519 
2524 typedef struct _ds_udp_event ds_udp_event_t;
2525 
2537 typedef int (*ds_udp_event_cb)(int argc, char *argv[], int val, void *data);
2538 
2539 
2540 DATASRCAPI ds_udp_event_t *ds_add_udp_event(const char *command, ds_udp_event_cb cb, int val, void *data);
2541 DATASRCAPI void ds_del_udp_event(ds_udp_event_t *event);
2542 
2543 DATASRCAPI void ds_udpsignal_send(const char *message);
2544 DATASRCAPI void ds_udpsignal_send_argv(const char *message, char *argv[]);
2545 
2546 /* Deprecated methods of handling udp commands */
2547 DATASRCAPI int ds_udpsignal_addjob(const char *cmd,void (*fn)(int argc,char *argv[]), const char *description);
2548 DATASRCAPI int ds_udpsignal_deljob(const char *cmd, void (*fn)(int argc, char *argv[]));
2549 
2550 
2551 /* misc */
2552 
2553 DATASRCAPI void ds_set_productname(const char *name);
2554 
2555 /* advmap */
2556 
2557 DATASRCAPI char *ds_request_object(const char *name);
2558 DATASRCAPI char *ds_request_object_with_flags(const char *name,int flags);
2559 DATASRCAPI int ds_request_objects(int count, char **obs, char ***services);
2560 DATASRCAPI int ds_request_objects_with_flags(int count, char **obs, int flags, char ***services);
2561 DATASRCAPI void ds_discard_object(const char *name);
2562 DATASRCAPI void ds_discard_objects(int count, char **obs);
2563 DATASRCAPI char * ds_get_service(const char *name);
2564 DATASRCAPI int ds_send_contribution(ds_data_t *dsdata);
2565 DATASRCAPI int ds_get_num_services(void);
2566 DATASRCAPI int ds_get_service_by_index(int index, char **name_ptr);
2567 DATASRCAPI int ds_object_available(const char *name);
2568 DATASRCAPI int ds_object_can_contrib(const char *name);
2569 DATASRCAPI void ds_purge_object(const char *name);
2570 DATASRCAPI int ds_required_services_status(char *buf, size_t buflen);
2571 DATASRCAPI int ds_get_service_type(const char *servicename);
2572 DATASRCAPI int ds_get_is_contrib_source(const char *name, int peer);
2573 
2575 DATASRCAPI int ds_set_request_hint(const char *name, int num, char **hints);
2576 DATASRCAPI char **ds_get_request_hints(const char *name, int *ret);
2577 DATASRCAPI char **ds_get_request_hints_dynamic(const char *name, int *ret);
2578 DATASRCAPI void ds_set_object_data(const char *name, void *data);
2579 DATASRCAPI void *ds_get_object_data(const char *name);
2580 
2581 /* signature */
2582 DATASRCAPI int ds_signature_check(char *key_id, char *token);
2583 
2584 /* page */
2585 
2586 #define DS_BIGPAGE_R 25
2587 #define DS_BIGPAGE_C 80
2588 #define DS_BIGPAGE_TYPE "25"
2589 #define DS_SMALLPAGE_R 14
2590 #define DS_SMALLPAGE_C 64
2591 #define DS_SMALLPAGE_TYPE "218"
2592 
2593 
2594 DATASRCAPI int ds_signature_verify_username(char *expected_username, char *token);
2595 
2602 #define DS_SIGNATURE_OK 0
2603 
2609 #define DS_SIGNATURE_INVALID_TOKEN 1
2610 
2616 #define DS_SIGNATURE_UNKNOWN_KEYID 2
2617 
2623 #define DS_SIGNATURE_ALREADY_USED 3
2624 #endif /* __DATASRC_H__ */
2625 
2626 #ifdef __cplusplus
2627 } /* extern "C" */
2628 #endif
2629 
recv_update_t recv_update
Definition: datasrc.h:365
char * log_root
Definition: datasrc.h:360
unsigned short flags
Definition: datasrc.h:2499
Definition: datasrc.h:356
int(* ds_monitor_authenticator_t)(ds_monauth_t *credentials)
Definition of the function type used for monitoring authentication callback.
Definition: datasrc.h:1500
void(* ds_loglevelchange_t)(ds_log_t *log, int new_level)
Callback used when the logging level of a log file is changed.
Definition: datasrc.h:1203
char * application_root
Definition: datasrc.h:359
char * subject
Definition: datasrc.h:2482
struct _ds_delay ds_delay_t
The delay channel object type.
Definition: datasrc.h:163
unsigned short seq
Definition: datasrc.h:2479
ds_monitor_t *(* ds_monitor_active_cb)(char *templatename, char *key, char *propertyname)
Definition of the function type used for active request callbacks.
Definition: datasrc.h:1475
Enumerated types structure.
Definition: datasrc.h:923
A field within a data update.
Definition: datasrc.h:2494
char * application_name
Definition: datasrc.h:358
void(* recv_update_t)(int peer, ds_data_t *pkt)
Definition: datasrc.h:190
int(* ds_timed_event_cb)(int id, int val, void *data)
Definition of the callback for use with timed events.
Definition: datasrc.h:1046
The container object for monitoring array types.
Definition: datasrc.h:1394
DATASRCAPI int ds_set_request_hint(const char *name, int num, char **hints)
const char * name
Definition: datasrc.h:925
void(* ds_logcycled_t)(ds_log_t *log)
Callback used when the log has cycled.
Definition: datasrc.h:1211
int typeflags
Definition: datasrc.h:1442
void(* recv_object_status_t)(int peer, char *subject, int status, unsigned short code, char *msgstr)
Definition: datasrc.h:313
Monitoring credentials object.
Definition: datasrc.h:1483
Definition: datasrc.h:648
unsigned short count
Definition: datasrc.h:2483
recv_object_status_t recv_object_status
Definition: datasrc.h:371
char * docstring
Definition: datasrc.h:1445
recv_service_status_t recv_service_status
Definition: datasrc.h:376
int sock_t
The network socket datatype.
Definition: datasrc.h:127
struct _ds5_subscription_s ds5_subscription_t
Definition: datasrc.h:633
char * description
Definition: datasrc.h:1444
Definition: datasrc.h:594
DATASRCAPI void ds_add_latency_chain2(ds_data_t *dsdata, char suffix, struct timespec tp, char suffix2, struct timespec *tp2)
Function used to add two measurement points to latency chain data.
ds_field_t * fields
Definition: datasrc.h:2484
unsigned short flags
Definition: datasrc.h:361
void(* recv_discard_t)(int peer, int count, char **subjects, unsigned short flags)
Definition: datasrc.h:292
char * name
Definition: datasrc.h:1443
Definition of the interface that you should implement if you require custom subject matching logic...
Definition: datasrc.h:431
struct _ds5_publisher_s ds5_publisher_t
Definition: datasrc.h:500
struct _ds_udp_event ds_udp_event_t
Opaque type defining a udp event.
Definition: datasrc.h:2524
char * propertyname
Definition: datasrc.h:1417
The container object for all monitoring values.
Definition: datasrc.h:1415
unsigned short flags
Definition: datasrc.h:2480
void(* recv_replay_t)(int peer, ds_data_t *pkt, time_t tm)
Definition: datasrc.h:208
Structure defining the arguments for Monitoring methods.
Definition: datasrc.h:1440
struct _ds_log ds_log_t
The log file object.
Definition: datasrc.h:174
unsigned short type
Definition: datasrc.h:362
void(* free)(ds5_namespace_t *nspace)
Invoked when the namespace should be deleted.
Definition: datasrc.h:438
struct _ds_peer_set ds_set_t
Defines a set of DataSource peers.
Definition: datasrc.h:152
void(* recv_peer_status_t)(int peer, int status, int val, void *data)
Definition: datasrc.h:252
struct _ds_timed_event ds_timed_event_t
Opaque type defining a timed event.
Definition: datasrc.h:992
size_t size
Definition: datasrc.h:1395
A data update object.
Definition: datasrc.h:2477
char * value
Definition: datasrc.h:2498
char * username
Definition: datasrc.h:1485
int(* ds_io_event_cb)(sock_t sock, int val, void *data)
Definition of the callback for use with read and write events.
Definition: datasrc.h:1034
void(* recv_request_t)(int peer, int count, char **subjects, unsigned short flags)
Definition: datasrc.h:272
unsigned short type
Definition: datasrc.h:2481
struct _ds_io_event ds_write_event_t
Opaque type defining a write event.
Definition: datasrc.h:1014
double value
Definition: datasrc.h:926
recv_request_t recv_request
Definition: datasrc.h:363
char * password
Definition: datasrc.h:1486
struct _config_ctx ds_config_ctx_t
The configuration context data type.
Definition: datasrc.h:169
recv_map_t recv_map
Definition: datasrc.h:377
Definition: datasrc.h:518
int32_t fieldnum
Definition: datasrc.h:2496
recv_peer_status_t recv_peer_status
Definition: datasrc.h:367
char * logfile
Definition: datasrc.h:380
ds_log_t * log
Definition: datasrc.h:381
struct _ds_io_event ds_except_event_t
Opaque type defining an exception event.
Definition: datasrc.h:999
struct _ds_io_event ds_read_event_t
Opaque type defining a read event.
Definition: datasrc.h:1007
DATASRCAPI void ds_add_latency_initial_timestamp(ds_data_t *dsdata)
Sets the initial time for latency chaining.
DATASRCAPI void ds_add_latency_chain(ds_data_t *dsdata, char suffix, struct timespec *tp)
function used to add a measurement point to latency chain data
void(* ds_delay_send_cb)(void *context, ds_data_t *dsdata)
Definition: datasrc.h:2322
void(* ds_config_func)(char *name, int num, char **values)
Definition of function type used for configuration callbacks.
Definition: datasrc.h:944
int32_t len
Definition: datasrc.h:2497
struct _ds_io_event ds_generic_event_t
Opaque type defining a generic read/write event.
Definition: datasrc.h:1021
recv_nodata_t recv_nodata
Definition: datasrc.h:366
void(* recv_nodata_t)(int peer, char *subject, unsigned short flags)
Definition: datasrc.h:228
char * ipaddress
Definition: datasrc.h:1487
void(* recv_map_t)(int peer, char *from, char *to)
Definition: datasrc.h:336
void(* recv_service_status_t)(char *service, int status)
Definition: datasrc.h:324
int(* ds_udp_event_cb)(int argc, char *argv[], int val, void *data)
Definition of the callback for use with udp events.
Definition: datasrc.h:2537
const char * docstring
Definition: datasrc.h:927
int(* match)(ds5_namespace_t *nspace, const char *subject)
Tests a subject to see if it falls within this namespace.
Definition: datasrc.h:448
int datatype
Definition: datasrc.h:1418
recv_discard_t recv_discard
Definition: datasrc.h:364

Generated on Wed Jul 31 2024 18:00:14 for Transformer SDK For C