DataSource for C SDK  6.2.20.310828
datasrc.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright CAPLIN Systems Ltd 2000-2007
4  *
5  *
6  * $Author: build $
7  * $DateTime: 2017/10/06 12:01:18 $
8  * $Change: 310159 $
9  * $Id: //CDev/V-6_2/datasrc/src/datasrc.h#33 $
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 6
28 #define DATASRC_MINOR_VERSION 2
29 #define DATASRC_PATCH_VERSION 20
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 <sys/timeb.h>
41 #include <ws2tcpip.h>
42 #include <direct.h>
43 #include <io.h>
44 #include <mswsock.h>
45 
46 #else /* ! WIN32 */
47 
48 #include <sys/time.h>
49 #include <sys/types.h>
50 #include <unistd.h>
51 #include <netinet/in.h>
52 #include <sys/socket.h>
53 #include <arpa/inet.h>
54 #include <netdb.h>
55 #include <sys/ioctl.h>
56 #include <net/if.h>
57 #include <sys/uio.h>
58 #include <sys/timeb.h>
59 #include <utime.h>
60 
61 #endif /* ! WIN32 */
62 
63 #include <limits.h>
64 #include <sys/stat.h>
65 #include <string.h>
66 #include <fcntl.h>
67 #include <stdarg.h>
68 #include <errno.h>
69 
70 
71 
72 #define EXIT_CODE_NML 0
73 #define EXIT_CODE_CFG 1
74 #define EXIT_CODE_LOG 2
75 #define EXIT_CODE_NET 3
76 #define EXIT_CODE_SYS 4
77 #define EXIT_CODE_LIC 5
78 #define EXIT_CODE_SIG 6
79 #define EXIT_CODE_SVC 7
80 #define EXIT_CODE_SSL 8
81 #define EXIT_CODE_JVM 9
82 
83 /* Reserve codes for binary start-up issues */
84 #define EXIT_CODE_BIN_MISSING 10
85 #define EXIT_CODE_BIN_NOT_EXEC 11
86 #define EXIT_CODE_BIN_EXIT AFTER_FORK 12
87 #define EXIT_CODE_BIN_BAD_ARCH 126
88 
89 /* Reserve an exit code for Java DataSource blade errors */
90 #define EXIT_CODE_JAVA_DATASOURCE_ERROR 201
91 
92 
93 #ifndef WIN32
94 #ifndef DATASRCAPI
95 #define DATASRCAPI
96 #endif
97 #else /* WIN32 */
98 #ifndef DATASRCAPI
99 #ifndef DATASRC_EXPORT
100 #define DATASRCAPI _declspec(dllimport)
101 #else
102 #define DATASRCAPI _declspec(dllexport)
103 #endif
104 #endif
105 #endif /* WIN32 */
106 
107 
108 /* Provide some protection for variadic arguments */
109 #ifdef __GNUC__
110 #define PRINTF(fmt,arg) __attribute__ ((__format__ (__printf__, (fmt), (arg))))
111 #else
112 #define PRINTF(fmt,arg)
113 #endif
114 
115 
121 /* Types */
122 
127 #ifndef WIN32
128 typedef int sock_t;
129 
136 #define INVALID_SOCKET -1
137 
143 #define SOCKET_ERROR -1
144 #else /* WIN32 */
145 
146 typedef SOCKET sock_t;
147 #ifdef __MINGW32__
148 #include <inttypes.h>
149 #else
150 typedef __int8 int8_t;
151 typedef __int16 int16_t;
152 typedef __int32 int32_t;
153 typedef __int64 int64_t;
154 typedef unsigned __int8 uint8_t;
155 typedef unsigned __int16 uint16_t;
156 typedef unsigned __int32 uint32_t;
157 typedef unsigned __int64 uint64_t;
158 #endif
159 #endif /* WIN32 */
160 
164 typedef struct _ds_peer_set ds_set_t;
165 
166 typedef uint64_t ds_bitfield_t;
167 
168 typedef struct _ds_data ds_data_t;
169 
170 typedef struct _ds_field ds_field_t;
171 
175 typedef struct _ds_delay ds_delay_t;
176 
177 
181 typedef struct _config_ctx ds_config_ctx_t;
182 
186 typedef struct _ds_log ds_log_t;
187 
202 typedef void (*recv_update_t)(int peer, ds_data_t *pkt);
203 
220 typedef void (*recv_replay_t)(int peer, ds_data_t *pkt, time_t tm);
221 
240 typedef void (*recv_nodata_t)(int peer, char *subject, unsigned short flags);
241 
264 typedef void (*recv_peer_status_t)(int peer, int status, int val, void *data);
265 
284 typedef void (*recv_request_t)(int peer, int count, char **subjects, unsigned short flags);
285 
304 typedef void (*recv_discard_t)(int peer, int count, char **subjects, unsigned short flags);
305 
325 typedef void (*recv_object_status_t)(int peer, char *subject, int status, unsigned short code, char *msgstr);
326 
336 typedef void (*recv_service_status_t)(char *service, int status);
337 
338 
348 typedef void (*recv_map_t)(int peer, char *from, char *to);
349 
350 
368 typedef struct
369  {
372  char *log_root;
373  unsigned short flags;
374  unsigned short type;
390  void (*exit_func)(int exit_code, char *msg);
392  char *logfile;
394  }
395 ds_init_t;
396 
401 #define DS_INITIALISER \
402  { \
403  NULL, /* application_name */ \
404  NULL, /* application_root */ \
405  NULL, /* log_root */ \
406  0, /* flags */ \
407  0, /* type */ \
408  NULL, /* recv_request */ \
409  NULL, /* recv_discard */ \
410  NULL, /* recv_update */ \
411  NULL, /* recv_nodata */ \
412  NULL, /* recv_peer_status */ \
413  NULL, /* recv_object_status */ \
414  NULL, /* recv_service_status */ \
415  NULL, /* recv_map */ \
416  NULL, /* exit_func */ \
417  NULL, /* logfile */ \
418  NULL, /* log */ \
419  }
420 
421 
422 /* datasrc */
423 
424 DATASRCAPI void ds_reserve_std_fds();
425 DATASRCAPI void ds_config_init(const char *file, int argc, char **argv);
426 DATASRCAPI int ds_init(ds_init_t *init, int argc, char **argv);
427 DATASRCAPI void ds_thread_init(int event_module, int flags);
428 DATASRCAPI char *ds_filename_expand(const char *format, char *buffer, size_t bufsize);
429 DATASRCAPI ds_log_t *ds_get_event_log(void);
430 
431 
432 /* ds5 */
433 
434 
439 
444  {
450  void (*free)(ds5_namespace_t *nspace);
451 
460  int (*match)(ds5_namespace_t *nspace, const char *subject);
461 
462 
471  char *(*describe)(ds5_namespace_t *nspace, char *buf, size_t buflen);
472 
473  };
474 
475 
476 DATASRCAPI ds5_namespace_t *ds5_create_prefix_namespace(const char *prefix);
477 
478 DATASRCAPI ds5_namespace_t *ds5_create_globbed_namespace(const char *globbed);
479 DATASRCAPI ds5_namespace_t *ds5_create_regex_namespace(const char *expr);
480 DATASRCAPI int ds5_regex_namespace_add_expr(ds5_namespace_t *nspace, const char *expr, int exclude);
481 
482 
483 /* Macros for convenience */
484 
492 #define ds5_namespace_match(nspace, subject) nspace->match(nspace, subject)
493 
498 #define ds5_namespace_free(nspace) nspace->free(nspace)
499 
500 
501 
502 
503 
512 typedef struct _ds5_publisher_s ds5_publisher_t;
513 
514 
515 
516 
517 
518 
519 
530 typedef struct
531  {
550  void (*receive_request)(void *context, int peer, const char *subject);
551 
572  void (*receive_discard)(void *context, int peer, const char *subject);
573  }
575 
576 
577 DATASRCAPI ds5_publisher_t *ds5_create_active_publisher(ds5_namespace_t *nspace, ds5_dataprovider_t *provider, void *context);
578 DATASRCAPI ds5_publisher_t *ds5_create_compatibility_publisher(ds5_namespace_t *nspace, ds5_dataprovider_t *provider, void *context);
580 
582 DATASRCAPI void ds5_publish_to_subscribed_peers(ds5_publisher_t *pub, ds_data_t *dsdata);
583 DATASRCAPI void ds5_publish_response(ds5_publisher_t *pub, ds_data_t *dsdata);
584 DATASRCAPI void ds5_publish_response_no_free(ds5_publisher_t *pub, ds_data_t *dsdata);
585 DATASRCAPI void ds5_publish_status(ds5_publisher_t *pub, const char *subject, int status, const char *message);
586 DATASRCAPI void ds5_publish_subject_error(ds5_publisher_t *publisher, const char *subject, int flags);
587 DATASRCAPI void ds5_publish_to_peer(ds5_publisher_t *publisher, int peernum, ds_data_t *dsdata);
588 DATASRCAPI void ds5_publish_to_peer_no_free(ds5_publisher_t *publisher, int peernum, ds_data_t *dsdata);
589 DATASRCAPI void ds5_publish_subject_map(ds5_publisher_t *publisher, const char *subject, const char *mapped_to, int flags);
590 
591 
605 typedef struct
606  {
617  void (*service_status)(void *context, const char *service_name, int state);
618 
630  void (*peer_status)(void *context, int peer_index, const char *peer_name, int state);
631  }
633 
634 
644 typedef struct _ds5_subscription_s ds5_subscription_t;
645 
646 
659 typedef struct
660  {
670  void (*record_updated)(void *context, ds5_subscription_t *sub, int peer, ds_data_t *dsdata);
671 
681  void (*record_type2_updated)(void *context, ds5_subscription_t *sub, int peer, ds_data_t *dsdata);
682 
692  void (*record_type3_updated)(void *context, ds5_subscription_t *sub, int peer, ds_data_t *dsdata);
693 
703  void (*container_updated)(void *context, ds5_subscription_t *sub, int peer, ds_data_t *dsdata);
704 
714  void (*permission_updated)(void *context, ds5_subscription_t *sub, int peer, ds_data_t *dsdata);
715 
725  void (*news_updated)(void *context, ds5_subscription_t *sub, int peer, ds_data_t *dsdata);
726 
736  void (*news_story_updated)(void *context, ds5_subscription_t *sub, int peer, ds_data_t *dsdata);
737 
747  void (*page_updated)(void *context, ds5_subscription_t *sub, int peer, ds_data_t *dsdata);
748 
761  void (*unknown_subject_type_updated)(void *context, ds5_subscription_t *sub, int peer, ds_data_t *dsdata);
762 
763 
774  void (*subscription_error)(void *context, ds5_subscription_t *sub, int peer, const char *subject, short flags);
775 
787  void (*subscription_status)(void *context, ds5_subscription_t *sub, int peer, const char *subject, int status, const char *message);
788  }
790 
791 
792 
793 
794 
795 DATASRCAPI void ds5_config_init(const char *configfile, int argc, char **argv);
796 DATASRCAPI int ds5_init(int argc, char **argv);
797 DATASRCAPI void ds5_add_connectionlistener(ds5_connectionlistener_t *connection_listener, void *context);
798 
799 
800 
801 
803 DATASRCAPI ds5_subscription_t *ds5_create_active_subscription(const char *subject, ds5_subscriptionlistener_t *listener, void *context);
804 DATASRCAPI void ds5_unsubscribe(ds5_subscription_t *sub);
805 
806 
807 
808 /* config */
809 
810 
819 #define DS_OFFSET(t,m) ((void *)&((t *)0)->m)
820 
824 #define DS_CONFIG_BOOL 0x0001
825 
830 #define DS_CONFIG_INT 0x0002
831 
835 #define DS_CONFIG_FLOAT 0x0003
836 
840 #define DS_CONFIG_STR 0x0004
841 
845 #define DS_CONFIG_CHAR 0x0005
846 
850 #define DS_CONFIG_FUNC 0x0006
851 
855 #define DS_CONFIG_FILE 0x0007
856 
859 #define DS_CONFIG_GROUP 0x0010
860 #define DS_CONFIG_GROUP_END 0x0011
861 #define DS_CONFIG_SECTION 0x0020
862 #define DS_CONFIG_SECTION_END 0x0021
863 
867 #define DS_CONFIG_JAVA 0x0080
868 
872 #define DS_CONFIG_ARRAY 0x0100
873 
878 #define DS_CONFIG_INT_ARRAY (DS_CONFIG_ARRAY|DS_CONFIG_INT)
879 
883 #define DS_CONFIG_FLOAT_ARRAY (DS_CONFIG_ARRAY|DS_CONFIG_FLOAT)
884 
885 
889 #define DS_CONFIG_STR_ARRAY (DS_CONFIG_ARRAY|DS_CONFIG_STR)
890 
894 #define DS_CONFIG_CHAR_ARRAY (DS_CONFIG_ARRAY|DS_CONFIG_CHAR)
895 
899 #define DS_CONFIG_STRICT 0x0200
900 
905 #define DS_CONFIG_DEPRECATED 0x0400
906 
907 
929 typedef struct
930  {
931  char *name;
932  double value;
933  char *docstring;
934  }
936 
937 
950 typedef void (*ds_config_func)(char *name, int num, char **values);
951 
952 
953 DATASRCAPI ds_config_ctx_t *ds_config_new_ctx();
954 DATASRCAPI void ds_config_free_ctx(ds_config_ctx_t *ctx);
956 DATASRCAPI void ds_config_add_search(const char *path);
957 DATASRCAPI void ds_config_add_file(const char *file);
958 DATASRCAPI void ds_config_add_optional_file(const char *file);
959 DATASRCAPI void ds_config_add_option(char opt, const char *longopt, const char *help, int type, void *value);
960 DATASRCAPI void ds_config_add_bounded_option(char sopt,const char *longopt, const char *help, int type, void *value, void *min, void *max);
961 DATASRCAPI void ds_config_add_option_enum(char opt,const char *longopt, const char *help, int type, void *value, ds_config_enum_t *enums);
962 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);
963 DATASRCAPI void ds_config_add_array_option(const char *longopt, const char *help, int type, void *value, int *num);
964 DATASRCAPI void ds_config_add_bounded_array_option(const char *longopt,const char *help, int type, void *value, int *num, void *min, void *max);
965 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);
966 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);
967 DATASRCAPI void ds_config_del_option(const char *longopt);
968 DATASRCAPI void ds_config_add_group(const char *longopt, const char *help, void *base, void *def, size_t size, int *num);
969 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);
970 DATASRCAPI void ds_config_end_group(const char *longopt,const char *help);
971 DATASRCAPI void ds_config_add_section(const char *longopt,const char *help);
972 DATASRCAPI void ds_config_end_section(const char *longopt,const char *help);
973 DATASRCAPI void ds_config_parse_files();
974 DATASRCAPI void ds_config_parse_args(int argc, char **argv, int *retargc);
975 DATASRCAPI int ds_config_parse_file(const char *unresolved_filename);
976 DATASRCAPI void ds_config_list_options();
977 DATASRCAPI void ds_config_list_values();
978 DATASRCAPI int ds_config_get_enum(const char *value, ds_config_enum_t *enums);
979 DATASRCAPI void ds_config_add_error_message_fmt(const char *fmt,...) PRINTF(1,2);
980 DATASRCAPI void ds_config_add_config_reading_message_fmt(const char *fmt,...) PRINTF(1,2);
981 DATASRCAPI void ds_config_add_error_message(const char *msg);
982 DATASRCAPI char *ds_config_get_filename();
983 DATASRCAPI int ds_config_get_linenumber();
984 DATASRCAPI void ds_config_set_test(const char *tag, char **value);
985 DATASRCAPI void ds_config_del_test(const char *tag);
986 DATASRCAPI void ds_config_set_option(const char *name, const char *value);
987 
988 
989 /* event */
990 
991 
992 typedef unsigned long ds_reltime_t;
993 
998 typedef struct _ds_timed_event ds_timed_event_t;
999 
1000 
1005 typedef struct _ds_io_event ds_except_event_t;
1006 
1007 
1008 
1013 typedef struct _ds_io_event ds_read_event_t;
1014 
1015 
1020 typedef struct _ds_io_event ds_write_event_t;
1021 
1022 
1027 typedef struct _ds_io_event ds_generic_event_t;
1028 
1029 
1040 typedef int (*ds_io_event_cb)(sock_t sock, int val, void *data);
1041 
1052 typedef int (*ds_timed_event_cb)(int id, int val, void *data);
1053 
1054 
1055 #define DOUBLE_TO_RELTIME(r,d) r = ((int)(d) << 9) + ((int)(((d) - (int)(d)) * 1000000) >> 11);
1056 #define TIMEVAL_TO_RELTIME(r,tv) r = ((tv).tv_sec << 9) + ((tv).tv_usec >> 11);
1057 
1058 
1059 DATASRCAPI ds_timed_event_t *ds_add_timed_event(int id, double delay, ds_timed_event_cb cb, int val, void *data);
1060 DATASRCAPI ds_read_event_t *ds_add_read_event(sock_t fd, ds_io_event_cb cb, int val, void *data);
1061 DATASRCAPI ds_write_event_t *ds_add_write_event(sock_t fd, ds_io_event_cb cb, int val, void *data);
1062 DATASRCAPI ds_except_event_t *ds_add_except_event(sock_t fd, ds_io_event_cb cb, int val, void *data);
1063 
1064 DATASRCAPI int ds_del_timed_event(ds_timed_event_t *ev);
1065 DATASRCAPI int ds_del_read_event(ds_read_event_t *ev);
1066 DATASRCAPI int ds_del_write_event(ds_write_event_t *ev);
1067 DATASRCAPI int ds_del_except_event(ds_except_event_t *ev);
1068 
1069 DATASRCAPI int ds_del_timed_event_free_data(ds_timed_event_t *ev, void (*free_data)(int, void *));
1070 DATASRCAPI int ds_del_read_event_free_data(ds_read_event_t *ev, void (*free_data)(int, void *));
1071 DATASRCAPI int ds_del_write_event_free_data(ds_write_event_t *ev, void (*free_data)(int, void *));
1072 DATASRCAPI int ds_del_except_event_free_data(ds_except_event_t *ev, void (*free_data)(int, void *));
1073 
1074 DATASRCAPI void ds_timed_event_set_callback(ds_timed_event_t *ev, ds_timed_event_cb cb, int val, void *data);
1075 DATASRCAPI void ds_read_event_set_callback(ds_read_event_t *ev, ds_io_event_cb cb, int val, void *data);
1076 DATASRCAPI void ds_write_event_set_callback(ds_write_event_t *ev, ds_io_event_cb cb, int val, void *data);
1077 
1078 DATASRCAPI void ds_set_timed_delay(ds_timed_event_t *ev, double delay);
1079 DATASRCAPI void ds_set_timed_delay_next(ds_timed_event_t *ev, double delay);
1080 
1081 DATASRCAPI void ds_loop();
1082 DATASRCAPI void ds_stop();
1083 
1084 DATASRCAPI ds_reltime_t ds_get_relative_time();
1085 DATASRCAPI time_t ds_get_time();
1086 DATASRCAPI struct tm *ds_gmtime();
1087 DATASRCAPI struct tm *ds_localtime();
1088 DATASRCAPI int ds_get_gmt_offset(time_t t);
1089 DATASRCAPI char *ds_get_timezone(char *buf, int len);
1090 
1091 DATASRCAPI ds_timed_event_t *ds_add_periodic_event(int starttime, int period, int id, ds_timed_event_cb cb, int val, void *data);
1092 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);
1093 DATASRCAPI int ds_check_periodic_event(int period, ds_timed_event_t **tev);
1094 
1095 
1096 /* cache */
1097 
1102 #define DS_CACHE_DATASRC -1
1103 
1104 DATASRCAPI void ds_cache_add_object(char *subject);
1105 
1106 
1107 /* daemon */
1108 
1109 
1110 DATASRCAPI void ds_daemon_redirect();
1111 DATASRCAPI int ds_daemon_disabled();
1112 
1113 
1114 /* fields */
1115 
1116 
1124 #define DS_FIELDS_SEPARATOR -65536
1125 
1131 #define DS_FIELDS_NOT_DEFINED (-2147483647 - 1)
1132 
1133 DATASRCAPI int ds_fields_max();
1134 DATASRCAPI int ds_fields_add(int num, const char *name, int flags, int dp, const char *fmt);
1135 DATASRCAPI int ds_fields_numbyname(const char *name);
1136 DATASRCAPI char *ds_fields_namebynum(int num);
1137 DATASRCAPI int ds_fields_indexbyname(const char *name);
1138 DATASRCAPI int ds_fields_indexbynum(int num);
1139 DATASRCAPI int ds_fields_numbyindex(int index);
1140 DATASRCAPI char *ds_fields_namebyindex(int index);
1141 DATASRCAPI char *ds_fields_rttpnumbyindex(int index);
1142 DATASRCAPI int ds_fields_getflags(int index);
1143 DATASRCAPI int ds_fields_getdp(int index);
1144 
1145 
1146 
1147 /* log */
1148 
1152 #define DS_LOG_CONFIG 0
1153 #define DS_LOG_ALWAYS 1
1154 
1157 #define DS_LOG_CRIT 2
1158 
1161 #define DS_LOG_ERROR 3
1162 
1165 #define DS_LOG_NOTIFY 4
1166 
1169 #define DS_LOG_WARN 5
1170 
1173 #define DS_LOG_INFO 6
1174 
1177 #define DS_LOG_DEBUG 7
1178 
1181 #define DS_LOG_FINER 8
1182 
1185 #define DS_LOG_FINEST 9
1186 
1189 #define DS_LOG_MONITOR 128
1190 
1193 #define DS_LOG_TERMINAL 256
1194 
1197 #define DS_LOG_SYSLOG 512
1198 #define DS_LOG_FILEONLY 1024
1199 #define DS_LOG_NO_MONITOR 2048
1200 
1208 typedef void (*ds_loglevelchange_t)(ds_log_t *log, int new_level);
1209 
1216 typedef void (*ds_logcycled_t)(ds_log_t *log);
1217 
1218 
1219 
1220 
1221 DATASRCAPI ds_log_t *ds_new_log(const char *name,const char *logname);
1222 DATASRCAPI ds_log_t *ds_new_level_log(const char *name, const char *logname, ds_loglevelchange_t change_cb);
1223 DATASRCAPI ds_log_t *ds_new_headed_log(const char *name, const char *logname, const char *header);
1224 DATASRCAPI void ds_free_log(ds_log_t *log);
1225 DATASRCAPI void ds_write(ds_log_t *log, void *data, size_t len);
1226 #ifndef WIN32
1227 DATASRCAPI void ds_writev(ds_log_t *log, struct iovec *vector, int count);
1228 #endif
1229 DATASRCAPI void ds_printf(ds_log_t *log, const char *fmt, ...) PRINTF(2,3);
1230 DATASRCAPI void ds_printf_time(ds_log_t *log, const char *fmt, ...) PRINTF(2,3);
1231 DATASRCAPI void ds_printf_time_ap(ds_log_t *log, const char *extra, const char *fmt, va_list ap);
1232 DATASRCAPI void ds_syslog(ds_log_t *log, int priority, const char *fmt, ...) PRINTF(3,4);
1233 DATASRCAPI void ds_cycle_all_logs(const char *suffix, long maxsize);
1234 DATASRCAPI int ds_cycle_log(ds_log_t *log, const char *suffix, long maxsize);
1235 DATASRCAPI char *ds_log_getfilename(ds_log_t *log);
1236 DATASRCAPI int ds_debug_level(const char *text);
1237 DATASRCAPI char *ds_debug_string(int level);
1238 DATASRCAPI char *ds_debug_config_string(int level);
1239 DATASRCAPI void ds_log(ds_log_t *log, int level, const char *fmt,...) PRINTF(3,4);
1240 DATASRCAPI int ds_log_set_log_level(ds_log_t *log, const char *level);
1241 DATASRCAPI void ds_log_change_level_callback(ds_log_t *log, ds_loglevelchange_t change_cb);
1243 DATASRCAPI int ds_log_get_level(ds_log_t *log);
1244 
1245 
1246 /* lty_chain */
1247 
1248 
1255 DATASRCAPI void ds_add_latency_chain(ds_data_t *dsdata, char suffix, int64_t millis);
1256 
1265 DATASRCAPI void ds_add_latency_chain2(ds_data_t *dsdata, char suffix, int64_t millis, char suffix2, int64_t
1266 millis2);
1267 
1268 
1269 /* monitor */
1270 
1271 
1275 #define TYPE_NONE 0
1276 
1280 #define TYPE_BINARY 1
1281 
1284 #define TYPE_STRING 2
1285 
1288 #define TYPE_SHORT 3
1289 
1292 #define TYPE_USHORT 4
1293 
1296 #define TYPE_LONG 5
1297 
1300 #define TYPE_ULONG 6
1301 
1304 #define TYPE_LLONG 7
1305 
1308 #define TYPE_ULLONG 8
1309 
1312 #define TYPE_DOUBLE 9
1313 
1318 #define TYPE_TIMESTAMP 10
1319 
1324 #define TYPE_BOOLEAN 11
1325 
1329 #define TYPE_RELATION 20
1330 
1334 #define TYPE_SUBSCRIPTION 21
1335 
1336 
1340 #define TYPE_PRIMITIVE_MASK 31
1341 
1345 #define TYPE_ARRAY 32
1346 
1349 #define TYPE_ACTIVE 64
1350 
1360 #define TYPE_ACTIVE2 128
1361 
1364 #define TYPE_METHOD 256
1365 
1368 #define TYPE_KEY 512
1369 
1372 #define TYPE_HIERARCHY 1024
1373 
1379 #define TYPE_OPTIONAL 2048
1380 
1381 
1387 typedef struct {
1388  size_t size;
1389  union _ds_mondata_value {
1390  void *b;
1391  char **c;
1392  int16_t *s;
1393  uint16_t *us;
1394  int32_t *l;
1395  uint32_t *ul;
1396  int64_t *ll;
1397  uint64_t *ull;
1398  double *d;
1399  } data;
1400  }
1401 ds_array_t;
1402 
1408 typedef struct
1409  {
1411  int datatype;
1412  union _ds_mondata_value2
1413  {
1414  void *active_ptr; /* Do not set used by monitoring API */
1415  char *c;
1416  int16_t s;
1417  uint16_t us; /* Also used for TYPE_BOOLEAN */
1418  int32_t l;
1419  uint32_t ul; /* Also used for TYPE_TIMESTAMP */
1420  int64_t ll;
1421  uint64_t ull;
1422  double d;
1423  ds_array_t array;
1424  }
1425  data;
1426  }
1427 ds_monitor_t;
1428 
1429 
1433 typedef struct
1434  {
1436  char *name;
1437  char *description;
1438  char *docstring;
1439  }
1441 
1442 
1457 typedef ds_monitor_t *(*ds_monitor_method_cb)(char *templatename, char *key, char *property, int argc, char *argv[]);
1458 
1468 typedef ds_monitor_t *(*ds_monitor_active_cb)(char *templatename, char *key, char *propertyname);
1469 
1470 
1471 
1476 typedef struct
1477  {
1478  char *username;
1479  char *password;
1480  char *ipaddress;
1481  }
1482 ds_monauth_t;
1483 
1493 typedef int (*ds_monitor_authenticator_t)(ds_monauth_t *credentials);
1494 
1495 
1496 
1497 DATASRCAPI char *ds_monitor_module_name();
1498 
1499 
1500 DATASRCAPI void ds_monitor_add_server_type(const char *type, const char *root);
1501 DATASRCAPI void ds_monitor_start_template(const char *templatename, const char *description);
1502 DATASRCAPI void ds_monitor_add_template_member(const char *templatename, const char *propertyname, const char *description, int typeflags, ds_arguments_t *args, void *ptr);
1503 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);
1504 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);
1505 
1506 
1507 DATASRCAPI void ds_monitor_add_relation(const char *templatename, const char *key, const char *propertyname, const char *targetkey);
1508 DATASRCAPI void ds_monitor_del_relation(const char *templatename, const char *key, const char *propertyname, const char *targetkey);
1509 
1510 DATASRCAPI void ds_monitor_add_subscription(const char *templatename, const char *key, const char *propertyname, const char *value);
1511 DATASRCAPI void ds_monitor_del_subscription(const char *templatename, const char *key, const char *propertyname, const char *value);
1512 
1513 DATASRCAPI void ds_monitor_end_template(const char *templatename);
1514 
1515 DATASRCAPI void ds_monitor_create_group(const char *templatename, const char *key, const char *brief, const char *description);
1516 DATASRCAPI void ds_monitor_delete_group(const char *templatename, const char *key);
1517 
1518 
1519 
1520 DATASRCAPI void ds_monitor_update(const char *templatename, const char *key, ds_monitor_t *mondata);
1521 DATASRCAPI void ds_monitor_update_string(const char *templatename, const char *key, const char *propertyname, const char *value);
1522 DATASRCAPI void ds_monitor_update_ushort(const char *templatename, const char *key, const char *propertyname, uint16_t);
1523 DATASRCAPI void ds_monitor_update_short(const char *templatename, const char *key, const char *propertyname, int16_t value);
1524 DATASRCAPI void ds_monitor_update_ulong(const char *templatename, const char *key, const char *propertyname, uint32_t value);
1525 DATASRCAPI void ds_monitor_update_long(const char *templatename,const char *key, const char *propertyname, int32_t value);
1526 DATASRCAPI void ds_monitor_update_ullong(const char *templatename, const char *key, const char *propertyname, uint64_t value);
1527 DATASRCAPI void ds_monitor_update_llong(const char *templatename, const char *key, const char *propertyname, int64_t value);
1528 DATASRCAPI void ds_monitor_update_double(const char *templatename, const char *key, const char *propertyname, double value);
1529 DATASRCAPI void ds_monitor_update_timestamp(const char *templatename, const char *key, const char *propertyname, int64_t value);
1530 DATASRCAPI void ds_monitor_update_boolean(const char *templatename, const char *key, const char *propertyname, uint8_t value);
1531 
1532 
1533 
1534 DATASRCAPI ds_monitor_t *ds_monitor_new(const char *propertyname, int type, int datasize, const void *datum);
1535 DATASRCAPI ds_monitor_t *ds_monitor_new_array(const char *propertyname, int type);
1536 DATASRCAPI void ds_monitor_add_data(ds_monitor_t *data, const void *datum);
1537 DATASRCAPI void ds_monitor_free(ds_monitor_t *data); /* Needed by plugin */
1538 
1539 DATASRCAPI void ds_monitor_free_data(ds_monitor_t *data);
1540 
1541 
1542 DATASRCAPI ds_monitor_t *ds_monitor_new_string(const char *templatename, const char *key, const char *propertyname, const char *value);
1543 DATASRCAPI ds_monitor_t *ds_monitor_new_ushort(const char *templatename, const char *key, const char *propertyname, uint16_t value);
1544 DATASRCAPI ds_monitor_t *ds_monitor_new_short(const char *templatename, const char *key, const char *propertyname, int16_t value);
1545 DATASRCAPI ds_monitor_t *ds_monitor_new_ulong(const char *templatename, const char *key, const char *propertyname, uint32_t value);
1546 DATASRCAPI ds_monitor_t *ds_monitor_new_long(const char *templatename,const char *key, const char *propertyname, int32_t value);
1547 DATASRCAPI ds_monitor_t *ds_monitor_new_ullong(const char *templatename, const char *key, const char *propertyname, uint64_t value);
1548 DATASRCAPI ds_monitor_t *ds_monitor_new_llong(const char *templatename, const char *key, const char *propertyname, int64_t value);
1549 DATASRCAPI ds_monitor_t *ds_monitor_new_double(const char *templatename, const char *key, const char *propertyname, double value);
1550 DATASRCAPI ds_monitor_t *ds_monitor_new_timestamp(const char *templatename, const char *key, const char *propertyname, int64_t value);
1551 DATASRCAPI ds_monitor_t *ds_monitor_new_boolean(const char *templatename, const char *key, const char *propertyname, uint8_t value);
1552 
1553 
1555 
1556 
1557 /* net */
1558 
1559 
1560 DATASRCAPI int ds_getaddr(const char *name, struct in_addr *addr);
1561 DATASRCAPI sock_t ds_listen_socket(struct in_addr *addr, int port, int backlog);
1562 DATASRCAPI sock_t ds_accept_socket(sock_t fd);
1563 DATASRCAPI sock_t ds_multicast_listen_socket(const char *p_interface, const char *addr, int port);
1564 DATASRCAPI sock_t ds_udp_listen_socket(const char *p_interface, int port);
1565 DATASRCAPI sock_t ds_client_socket(const char *serv, unsigned short port);
1566 DATASRCAPI sock_t ds_client_socket_nonblocking(const char *serv, unsigned short port);
1567 DATASRCAPI int ds_udp_send(const char *data, int len, const char *addr, int port);
1568 DATASRCAPI int ds_udp_sendto(const char *data, int len, struct sockaddr_in *serv_addr);
1569 DATASRCAPI sock_t ds_udp_client_socket(const char *addr, int port, struct sockaddr_in *serv_addr);
1570 DATASRCAPI int ds_udp_bind_client_socket(sock_t sock, const char *addr, int port);
1571 DATASRCAPI char *ds_interface_address(const char *ifname);
1572 DATASRCAPI int ds_inet_aton(const char *cp, struct in_addr *inp);
1573 DATASRCAPI void ds_setnonblocking(sock_t fd);
1574 DATASRCAPI int ds_pipe(sock_t fds[2]);
1575 DATASRCAPI int ds_check_subnet(const char *s_address, const char *s_network, const char *s_netmask);
1576 DATASRCAPI struct sockaddr *ds_gethostsockaddr(const char *name, struct sockaddr *populate);
1577 
1578 
1579 
1580 /* Message Types */
1581 
1589 #define DS_MSG_CONNECT 0x0100
1590 
1598 #define DS_MSG_DISCONNECT 0x0200
1599 #define DS_MSG_STATUS 0x0400
1600 
1601 
1602 /* Peer Types */
1603 
1604 #define DS_T_USERMASK 0x00ff
1605 
1615 #define DS_T_ACTIVE 0x0001
1616 
1627 #define DS_T_CONTRIB 0x0002
1628 
1629 #define DS_T_MSG 0x0100
1630 
1631 
1632 /* Peer Flags */
1633 
1634 #define DS_F_USERMASK 0x00ff
1635 
1651 #define F_SENDFROMSEQ 0x0001
1652 
1653 #define F_SENDFROMFIELD 0x0002
1654 
1655 
1669 #define F_RECVAUTOREPLAY 0x0004
1670 
1671 
1686 #define F_NOCONNECT 0x0008
1687 
1688 #define F_RECONNECT 0x0100
1689 #define F_FAILOVER 0x0200
1690 
1691 
1692 /* No Data Flags */
1693 
1694 #define F_NODATAMASK 0x000f
1695 
1705 #define F_NOTFOUND 0x0001
1706 
1715 #define F_READDENY 0x0002
1716 
1725 #define F_WRITEDENY 0x0003
1726 
1735 #define F_DELETEOBJECT 0x0004
1736 
1745 #define F_UNAVAILABLE 0x0005
1746 #define F_STATUS 0x0006
1747 
1748 
1749 
1755 #define F_IGNOREREQTIMEOUT 0x0008
1756 
1757 /* Object Types */
1758 
1762 #define DS_PAGE_TYPE 221
1763 
1766 #define DS_RECORD_TYPE 222
1767 
1770 #define DS_RECORD_TYPE2 225
1771 
1774 #define DS_RECORD_TYPE3 226
1775 
1778 #define DS_NEWS_TYPE 223
1779 
1782 #define DS_STORY_TYPE 224
1783 
1786 #define DS_CONTAINER_TYPE 228
1787 
1790 #define DS_PERMISSION_TYPE 230
1791 
1798 #define DS_GENERIC_TYPE 231
1799 
1800 
1801 /* Data Flags */
1802 
1806 #define F_CREATEOBJECT 0x0010
1807 
1810 #define F_CREATEPARENT 0x0020
1811 #define F_PERSISTENT 0x0040
1812 #define F_CREATEDATA 0x0080
1813 
1817 #define F_CLEAR_PERM 0x0400
1818 
1829 #define F_FILTER_PERM 0x0800
1830 
1835 #define F_AUTHGLOBAL 0x0100
1836 
1840 #define F_CLEAR_TYPE3 0x0100
1841 
1845 #define F_FILTER_TYPE3 0x0200
1846 
1849 #define F_CLEAR_TYPE2 0x0400
1850 
1864 #define F_FILTER_TYPE2 0x0800
1865 
1871 #ifdef __DARWIN_NULL
1872 #undef F_NOCACHE
1873 #endif
1874 #define F_NOCACHE 0x0400
1875 
1882 #define F_DELETE_HEADLINE 0x0100
1883 
1891 #define F_CHANGE_HEADLINE 0x0200
1892 
1897 #define F_IMAGE 0x1000
1898 
1902 #define F_NONACTIVE 0x2000
1903 
1906 #define F_AUTHUPDATE 0x4000
1907 
1908 
1916 #define F_CONSTITUENT_NOAUTH 0x4000
1917 
1924 #define F_CHANGEDFIELDS 0x8000
1925 
1926 /* Field Data Types */
1927 
1928 #define FLOAT32_TYPE 1
1929 #define FLOAT64_TYPE 2
1930 #define INT8_TYPE 3
1931 #define INT16_TYPE 4
1932 #define INT32_TYPE 5
1933 #define INT64_TYPE 6
1934 
1935 
1936 /* Object request flags */
1937 
1947 #define DS_REQUEST_FAILOVER 1
1948 
1957 #define DS_REQUEST_CACHE 4
1958 
1959 
1960 
1961 /* Object Status Flags */
1962 
1972 #define S_INFO 0x0000
1973 
1982 #define S_STALE 0x0001
1983 
1992 #define S_NOTSTALE 0x0004
1993 
2005 #define S_UPDCLR 0x0100
2006 
2017 #define S_FAILOVER 0x1101 /* Failover implies S_STALE|S_UPDCLR */
2018 
2019 
2032 #define OBJ_STATUS_INFO 0x0000
2033 
2046 #define OBJ_STATUS_OK 0x0001
2047 
2062 #define OBJ_STATUS_STALE 0x0002
2063 
2064 
2080 #define OBJ_STATUS_LIMITED 0x0008
2081 
2082 
2083 #define OBJ_STATUS_NOTMAPPED 0x0010
2084 
2093 #define SVC_STATUS_OK 0x0001
2094 
2103 #define SVC_STATUS_DOWN 0x0002
2104 
2113 #define SVC_STATUS_LIMITED 0x0008
2114 
2115 
2116 /* Field Macros */
2117 #define DS_MAX_BITFIELD (sizeof(ds_bitfield_t)*8)
2118 
2119 #define DS_BITFIELD_SET(n,p) *(p) |= (1ULL << (n))
2120 #define DS_BITFIELD_CLR(n,p) *(p) &= ~(1ULL << (n))
2121 #define DS_BITFIELD_ISSET(n,p) (*(p) & (1ULL << (n)))
2122 #define DS_BITFIELD_ZERO(p) *(p) = 0
2123 #define DS_BITFIELD_NONZERO(p) memset((char *)(p), 0xffffffff, sizeof(*(p)))
2124 
2125 /* Peer set functions and macros */
2126 
2127 DATASRCAPI int ds_iszero(ds_set_t *p);
2128 DATASRCAPI void ds_or(ds_set_t *p1, ds_set_t *p2, ds_set_t *o);
2129 DATASRCAPI void ds_and(ds_set_t *p1, ds_set_t *p2, ds_set_t *a);
2130 DATASRCAPI int ds_and_iszero(ds_set_t *p1, ds_set_t *p2);
2131 DATASRCAPI int ds_and3_iszero(ds_set_t *p1, ds_set_t *p2, ds_set_t *p3);
2132 DATASRCAPI int ds_isequal(ds_set_t *p1, ds_set_t *p2);
2133 
2138 #define DS_MAX_PEERS 1024
2139 
2144 #define DS_MIN_PEER 0
2145 
2150 #define DS_INTERNAL_DATASRC 1023
2151 
2152 typedef uint32_t dsset_element_t;
2153 
2154 #define DS_NUMBITS (sizeof(dsset_element_t) * 8)
2155 #define DS_NUM_ELEMS (DS_MAX_PEERS+DS_NUMBITS-1)/DS_NUMBITS
2156 #define DS_NUM_BYTES (DS_NUM_ELEMS * sizeof(dsset_element_t))
2157 
2158 struct _ds_peer_set
2159  {
2160  dsset_element_t bits[DS_NUM_ELEMS];
2161  };
2162 
2167 #define DS_SET(n,p) ((p)->bits[(n)/DS_NUMBITS] |= ((unsigned)1 << ((n) % DS_NUMBITS)))
2168 
2173 #define DS_CLR(n,p) ((p)->bits[(n)/DS_NUMBITS] &= ~((unsigned)1 << ((n) % DS_NUMBITS)))
2174 
2179 #define DS_ISSET(n,p) ((p)->bits[(n)/DS_NUMBITS] & ((unsigned)1 << ((n) % DS_NUMBITS)))
2180 
2185 #define DS_ZERO(p) memset((char *)(p)->bits, 0, DS_NUM_BYTES)
2186 
2191 #define DS_NONZERO(p) memset((char *)(p)->bits, 0xff, DS_NUM_BYTES)
2192 
2197 #define DS_ISZERO(p) ds_iszero(p)
2198 
2203 #define DS_AND(p1, p2, a) ds_and(p1, p2, a)
2204 
2209 #define DS_OR(p1, p2, o) ds_or(p1, p2, o)
2210 
2215 #define DS_AND_ISZERO(p1, p2) ds_and_iszero(p1, p2)
2216 
2221 #define DS_AND3_ISZERO(p1, p2, p3) ds_and3_iszero(p1, p2, p3)
2222 
2227 #define DS_ISEQUAL(p1, p2) ds_isequal(p1, p2)
2228 
2229 DATASRCAPI ds_data_t *ds_init_data(const char *subject, unsigned short type, unsigned short flags);
2230 DATASRCAPI void ds_set_subject(ds_data_t *data, const char *subject);
2231 
2232 DATASRCAPI void ds_add_data(ds_data_t *data, int32_t fieldnum, const char *value);
2233 DATASRCAPI void ds_add_data_fmt(ds_data_t *data, int32_t fieldnum, const char *fmt, ...);
2234 DATASRCAPI void ds_add_data_str(ds_data_t *data, int32_t fieldnum, const char *value);
2235 DATASRCAPI void ds_add_data_float32(ds_data_t *data, int32_t fieldnum, float value);
2236 DATASRCAPI void ds_add_data_float64(ds_data_t *data, int32_t fieldnum, double value);
2237 DATASRCAPI void ds_add_data_int8(ds_data_t *data, int32_t fieldnum, int8_t value);
2238 DATASRCAPI void ds_add_data_int16(ds_data_t *data, int32_t fieldnum, int16_t value);
2239 DATASRCAPI void ds_add_data_int32(ds_data_t *data, int32_t fieldnum, int32_t value);
2240 DATASRCAPI void ds_add_data_int64(ds_data_t *data, int32_t fieldnum, int64_t value);
2241 DATASRCAPI void ds_add_data_char(ds_data_t *data, int32_t fieldnum, char value);
2242 
2243 DATASRCAPI ds_data_t *ds_clone_data(ds_data_t *data);
2244 
2245 #define ds_add_data_short(d,f,v) ds_add_data_int16(d,f,v)
2246 #define ds_add_data_int(d,f,v) ds_add_data_int32(d,f,v)
2247 #define ds_add_data_long(d,f,v) ds_add_data_int32(d,f,v)
2248 #define ds_add_data_float(d,f,v) ds_add_data_float32(d,f,v)
2249 #define ds_add_data_double(d,f,v) ds_add_data_float64(d,f,v)
2250 
2251 DATASRCAPI void ds_send_data(ds_data_t *data);
2252 DATASRCAPI void ds_send_data_to_peer(int peer, ds_data_t *data);
2253 DATASRCAPI void ds_send_data_no_free(ds_data_t *data);
2254 DATASRCAPI void ds_send_data_to_peer_no_free(int peer, ds_data_t *data);
2255 DATASRCAPI void ds_send_nodata(const char *subject, unsigned short flags);
2256 DATASRCAPI void ds_send_nodata_to_peer(int peer, const char *subject, unsigned short flags);
2257 DATASRCAPI void ds_free_data(ds_data_t *data);
2258 DATASRCAPI void ds_send_status(const char *subject, unsigned short flags, unsigned short code, const char *msgstr);
2259 DATASRCAPI void ds_send_status_to_peer(int peer,const char *subject, unsigned short flags, unsigned short code, const char *msgstr);
2260 DATASRCAPI void ds_send_data_direct(ds_data_t *data);
2261 DATASRCAPI void ds_send_nodata_direct(const char *subject, unsigned short flags);
2262 DATASRCAPI void ds_send_status_direct(const char *subject, unsigned short flags, unsigned short code, const char *msgstr);
2263 
2264 DATASRCAPI void ds_send_map_to_peer(int peer, const char *subject, const char *mapped, unsigned short flags);
2265 DATASRCAPI void ds_send_map(const char *subject, const char *mapped, unsigned short flags);
2266 
2267 
2278 typedef void (*ds_delay_send_cb)(void *context, ds_data_t *dsdata);
2279 
2280 DATASRCAPI ds_delay_t *ds_new_delay(double delay_time, char *prefix, double batch_time);
2281 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);
2282 DATASRCAPI void ds_delay_data(ds_delay_t *delay, ds_data_t *dsdata);
2283 
2284 DATASRCAPI int32_t ds_add_record_str(ds_data_t *data, const char *field, const char *value);
2285 DATASRCAPI int32_t ds_add_record_int(ds_data_t *data,const char *field, int value);
2286 DATASRCAPI int32_t ds_add_record_char(ds_data_t *data,const char *field, char value);
2287 DATASRCAPI int32_t ds_add_record_float(ds_data_t *data,const char *field, double value);
2288 DATASRCAPI int32_t ds_add_record_fmt(ds_data_t *data,const char *field, const char *fmt, ...);
2289 
2290 DATASRCAPI ds_data_t *ds_init_page(const char *subject, int rows, int cols, const char *type, unsigned short flags);
2291 DATASRCAPI void ds_add_page_row(ds_data_t *data, int row, int col, const char *str);
2292 DATASRCAPI void ds_add_page_field(ds_data_t *data, int32_t fieldnum, const char *value);
2293 DATASRCAPI void ds_add_page_field_by_name(ds_data_t *data, const char *field, const char *value);
2294 
2295 DATASRCAPI ds_data_t *ds_init_news(const char *subject, unsigned short flags);
2296 DATASRCAPI void ds_add_news_headline(ds_data_t *data, const char *headline);
2297 DATASRCAPI void ds_add_news_storycode(ds_data_t *data, const char *story);
2298 DATASRCAPI void ds_add_news_datetime(ds_data_t *data, const char *datestr);
2299 DATASRCAPI void ds_add_news_authstr(ds_data_t *data, const char *authstr);
2300 DATASRCAPI void ds_add_news_product_code(ds_data_t *data, const char *code);
2301 DATASRCAPI void ds_add_news_topic_code(ds_data_t *data, const char *code);
2302 DATASRCAPI void ds_add_news_company_code(ds_data_t *data, const char *code);
2303 DATASRCAPI void ds_add_news_user_code(ds_data_t *data, int codenum, const char *code);
2304 DATASRCAPI void ds_add_news_field(ds_data_t *dsdata, const char *fieldname, const char *value);
2305 
2306 DATASRCAPI ds_data_t *ds_init_container(const char *subject, const unsigned short flags);
2307 DATASRCAPI void ds_add_container_symbol_and_request(ds_data_t *data, const char *symbol, const int request);
2308 DATASRCAPI void ds_add_container_symbol(ds_data_t *data, const char *symbol);
2309 DATASRCAPI void ds_add_container_symbol_at_position(ds_data_t *data, int position, const char *symbol);
2310 DATASRCAPI void ds_remove_container_symbol(ds_data_t *data, const char *symbol);
2311 DATASRCAPI void ds_cleardown_container_with_prefix(ds_data_t *data, const char *prefix);
2312 
2313 DATASRCAPI ds_data_t *ds_init_permission(const char *subject, const char *key, unsigned short flags);
2314 DATASRCAPI void ds_add_permission_key(ds_data_t *data, const char *key);
2315 
2316 DATASRCAPI void ds_add_binary(ds_data_t *data, int32_t fieldnum, char *value, int len, char type);
2317 DATASRCAPI void ds_add_binary_float32(ds_data_t *data, int32_t fieldnum, float value);
2318 DATASRCAPI void ds_add_binary_float64(ds_data_t *data, int32_t fieldnum, double value);
2319 DATASRCAPI void ds_add_binary_int8(ds_data_t *data, int32_t fieldnum, int8_t value);
2320 DATASRCAPI void ds_add_binary_int16(ds_data_t *data, int32_t fieldnum, int16_t value);
2321 DATASRCAPI void ds_add_binary_int32(ds_data_t *data, int32_t fieldnum, int32_t value);
2322 DATASRCAPI void ds_add_binary_int64(ds_data_t *data, int32_t fieldnum, int64_t value);
2323 DATASRCAPI void ds_add_binary_uint8(ds_data_t *data, int32_t fieldnum, uint8_t value);
2324 DATASRCAPI void ds_add_binary_uint16(ds_data_t *data, int32_t fieldnum, uint16_t value);
2325 DATASRCAPI void ds_add_binary_uint32(ds_data_t *data, int32_t fieldnum, uint32_t value);
2326 DATASRCAPI void ds_add_binary_uint64(ds_data_t *data, int32_t fieldnum, uint64_t value);
2327 DATASRCAPI void ds_add_binary_string(ds_data_t *data, int32_t fieldnum, char *value);
2328 DATASRCAPI void ds_add_binary_opaque(ds_data_t *data, int32_t fieldnum, char *value, int len);
2329 DATASRCAPI void ds_add_binary_time(ds_data_t *data, int32_t fieldnum, time_t value);
2330 DATASRCAPI void ds_add_binary_time_millis(ds_data_t *data, int32_t fieldnum, int64_t value);
2331 DATASRCAPI void ds_add_binary_timeval(ds_data_t *data, int32_t fieldnum, struct timeval value);
2332 
2333 #define ds_add_binary_char(d,f,v) ds_add_binary_int8(d,f,v);
2334 #define ds_add_binary_short(d,f,v) ds_add_binary_int16(d,f,v);
2335 #define ds_add_binary_int(d,f,v) ds_add_binary_int32(d,f,v);
2336 #define ds_add_binary_long(d,f,v) ds_add_binary_int32(d,f,v);
2337 #define ds_add_binary_float(d,f,v) ds_add_binary_float32(d,f,v);
2338 #define ds_add_binary_double(d,f,v) ds_add_binary_float64(d,f,v);
2339 #define ds_add_binary_time_micros(d,f,v) ds_add_binary_timeval(d,f,v);
2340 
2341 
2345 #define NEWS_HEADLINE_FIELDNUM 0
2346 
2349 #define NEWS_STORYCODE_FIELDNUM 1
2350 
2353 #define NEWS_DATETIME_FIELDNUM 2
2354 
2357 #define NEWS_AUTHSTR_FIELDNUM 5
2358 
2361 #define NEWS_PRODUCT_CODE_FIELDNUM 100
2362 
2365 #define NEWS_TOPIC_CODE_FIELDNUM 101
2366 
2369 #define NEWS_COMPANY_CODE_FIELDNUM 102
2370 
2373 #define NEWS_USER_CODE_FIELDNUM 200
2374 
2377 #define NEWS_USER_CODE_MAX 10
2378 
2379 #define NEWS_SIZE_FIELDNUM 300
2380 #define NEWS_REASON_FIELDNUM 301
2381 
2382 #define NEWS_REQ_SEARCH 1000
2383 #define NEWS_REQ_STORYCODE 1001
2384 #define NEWS_REQ_DATE_TO 1002
2385 #define NEWS_REQ_DATE_FROM 1003
2386 #define NEWS_REQ_FLAGS 1004
2387 
2388 #define NEWS_GENERIC_FIELDNUM 1024
2389 
2390 /* peer */
2391 
2392 
2393 DATASRCAPI extern int ds_num_peers;
2394 
2395 
2396 DATASRCAPI int ds_peer_details(int peer, char **name);
2397 DATASRCAPI int ds_peer_host_details(int peer, char **addr);
2398 DATASRCAPI int ds_peer_id(int peer);
2399 DATASRCAPI char *ds_peer_name(int peer);
2400 DATASRCAPI int ds_peer_flags(int peer);
2401 DATASRCAPI int ds_peer_local_type(int peer);
2402 DATASRCAPI int ds_peer_type(int peer);
2403 DATASRCAPI int ds_peer_up(int peer);
2404 DATASRCAPI void ds_peer_add_extra_handshake_data(int peer, const char *data);
2405 DATASRCAPI int ds_peer_all_type(int flag);
2406 
2407 DATASRCAPI void ds_set_status_down();
2408 DATASRCAPI void ds_set_status_down_to_peer(int peer);
2409 DATASRCAPI void ds_set_status_msg(unsigned short msgid, const char *msgstr);
2410 DATASRCAPI void ds_set_status_msg_to_peer(int peer, unsigned short msgid, const char *msgstr);
2411 DATASRCAPI void ds_set_status_up();
2412 DATASRCAPI void ds_set_status_up_to_peer(int peer);
2413 DATASRCAPI int ds_peer_by_label(const char *label);
2414 DATASRCAPI char *ds_peer_label_byindex(int index);
2415 DATASRCAPI int ds_peer_enabled_state(int peer);
2416 
2417 /* pkt */
2418 
2425 struct _ds_data
2426  {
2427  unsigned short seq;
2428  unsigned short flags;
2429  unsigned short type;
2430  char *subject;
2431  unsigned short count;
2433  time_t time;
2434  };
2435 
2443  {
2444  int32_t fieldnum;
2445  int32_t len;
2446  char *value;
2447  unsigned short flags;
2448  };
2449 
2450 
2451 /* replay */
2452 
2453 
2454 DATASRCAPI void ds_replay(recv_replay_t callback);
2455 DATASRCAPI int ds_replay_from_file(recv_replay_t callback, char *filename);
2456 DATASRCAPI void ds_replay_from_log(recv_replay_t callback, ds_log_t *log);
2457 DATASRCAPI void ds_replay_by_time(time_t t, recv_replay_t callback);
2458 DATASRCAPI int ds_replay_by_time_from_file(time_t t, recv_replay_t callback, char *filename);
2459 DATASRCAPI void ds_replay_by_time_from_log(time_t t, recv_replay_t callback, ds_log_t *log);
2460 DATASRCAPI void ds_replay_by_field(int fieldnum, char *value, recv_replay_t callback);
2461 DATASRCAPI int ds_replay_by_field_from_file(int fieldnum, char *value, recv_replay_t callback, char *filename);
2462 DATASRCAPI void ds_replay_by_field_from_log(int fieldnum, char *value, recv_replay_t callback, ds_log_t *log);
2463 
2464 
2465 /* udp */
2466 
2467 
2472 typedef struct _ds_udp_event ds_udp_event_t;
2473 
2485 typedef int (*ds_udp_event_cb)(int argc, char *argv[], int val, void *data);
2486 
2487 
2488 DATASRCAPI ds_udp_event_t *ds_add_udp_event(const char *command, ds_udp_event_cb cb, int val, void *data);
2489 DATASRCAPI void ds_del_udp_event(ds_udp_event_t *event);
2490 
2491 DATASRCAPI void ds_udpsignal_send(const char *message);
2492 DATASRCAPI void ds_udpsignal_send_argv(const char *message, char *argv[]);
2493 
2494 /* Deprecated methods of handling udp commands */
2495 DATASRCAPI int ds_udpsignal_addjob(const char *cmd,void (*fn)(int argc,char *argv[]), const char *description);
2496 DATASRCAPI int ds_udpsignal_deljob(const char *cmd, void (*fn)(int argc, char *argv[]));
2497 
2498 
2499 /* misc */
2500 
2501 DATASRCAPI void ds_set_productname(const char *name);
2502 
2503 /* advmap */
2504 
2505 DATASRCAPI char *ds_request_object(const char *name);
2506 DATASRCAPI char *ds_request_object_with_flags(const char *name,int flags);
2507 DATASRCAPI int ds_request_objects(int count, char **obs, char ***services);
2508 DATASRCAPI int ds_request_objects_with_flags(int count, char **obs, int flags, char ***services);
2509 DATASRCAPI void ds_discard_object(const char *name);
2510 DATASRCAPI void ds_discard_objects(int count, char **obs);
2511 DATASRCAPI char * ds_get_service(const char *name);
2512 DATASRCAPI int ds_send_contribution(ds_data_t *dsdata);
2513 DATASRCAPI int ds_get_num_services();
2514 DATASRCAPI int ds_get_service_by_index(int index, char **name_ptr);
2515 DATASRCAPI int ds_object_available(const char *name);
2516 DATASRCAPI int ds_object_can_contrib(const char *name);
2517 DATASRCAPI void ds_purge_object(const char *name);
2518 DATASRCAPI int ds_required_services_status(char *buf, size_t buflen);
2519 DATASRCAPI int ds_get_service_type(const char *servicename);
2520 
2522 DATASRCAPI int ds_set_request_hint(const char *name, int num, char **hints);
2523 DATASRCAPI char **ds_get_request_hints(const char *name, int *ret);
2524 DATASRCAPI void ds_set_object_data(const char *name, void *data);
2525 DATASRCAPI void *ds_get_object_data(const char *name);
2526 
2527 /* signature */
2528 DATASRCAPI int ds_signature_check(char *key_id, char *token);
2529 DATASRCAPI int ds_signature_verify_username(char *expected_username, char *token);
2530 
2531 
2538 #define DS_SIGNATURE_OK 0
2539 
2545 #define DS_SIGNATURE_INVALID_TOKEN 1
2546 
2552 #define DS_SIGNATURE_UNKNOWN_KEYID 2
2553 
2559 #define DS_SIGNATURE_ALREADY_USED 3
2560 #endif /* __DATASRC_H__ */
2561 
2562 #ifdef __cplusplus
2563 } /* extern "C" */
2564 #endif
2565 
2566 
2567 
DATASRCAPI void ds_add_binary_time_millis(ds_data_t *data, int32_t fieldnum, int64_t value)
Add a value to a data object in the form of a timestamp.
Definition: binary.c:592
DATASRCAPI int ds_del_except_event(ds_except_event_t *ev)
Remove a socket except event.
Definition: event.c:691
DATASRCAPI char * ds_log_getfilename(ds_log_t *log)
Get the filename of a log object.
Definition: log.c:1273
DATASRCAPI void ds_add_binary_opaque(ds_data_t *data, int32_t fieldnum, char *value, int len)
Add a value to a data object in the form of an opaque value.
Definition: binary.c:546
recv_update_t recv_update
Definition: datasrc.h:377
DATASRCAPI void ds_monitor_update_long(const char *templatename, const char *key, const char *propertyname, int32_t value)
Post an update to the monitoring system for a long value.
Definition: monitor.c:1296
DATASRCAPI ds_data_t * ds_init_container(const char *subject, const unsigned short flags)
Initialise a container object.
Definition: container.c:35
char * log_root
Definition: datasrc.h:372
DATASRCAPI void ds_add_data_float32(ds_data_t *data, int32_t fieldnum, float value)
Add a value to a data object in the form of a floating point number.
Definition: api.c:173
DATASRCAPI void ds_add_page_field_by_name(ds_data_t *data, const char *field, const char *value)
Add an arbitrary field to a page.
Definition: page.c:163
DATASRCAPI void ds_add_data_int16(ds_data_t *data, int32_t fieldnum, int16_t value)
Add a value to a data object in the form of a 16 bit integer.
Definition: api.c:261
DATASRCAPI sock_t ds_client_socket_nonblocking(const char *serv, unsigned short port)
Creates a client socket with which to connect to a host.
Definition: net.c:633
DATASRCAPI ds5_subscription_t * ds5_create_active_subscription(const char *subject, ds5_subscriptionlistener_t *listener, void *context)
Create a subscription that matches a single subject.
Definition: dsv5_subscription.c:131
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)
Add an enumerated option to the configuration context.
Definition: config.c:692
DATASRCAPI int ds_isequal(ds_set_t *p1, ds_set_t *p2)
Check 2 peersets are equal.
Definition: peerset.c:162
DATASRCAPI int ds_replay_by_field_from_file(int fieldnum, char *value, recv_replay_t callback, char *filename)
Replays all data in a file that arrived after an update with the specified value for the specified fi...
Definition: replay.c:597
DATASRCAPI void ds5_publish_status(ds5_publisher_t *pub, const char *subject, int status, const char *message)
Publishes a subscription status event for a subject.
Definition: dsv5_publisher.c:325
unsigned short flags
Definition: datasrc.h:2447
void ds_printf(ds_log_t *log, const char *fmt,...)
Write a formatted string to a log object.
Definition: log.c:893
Defines the DataSource initialisation object.
Definition: datasrc.h:368
DATASRCAPI void ds_add_container_symbol(ds_data_t *data, const char *symbol)
Add an object to the container.
Definition: container.c:54
DATASRCAPI void ds_write(ds_log_t *log, void *data, size_t len)
Write binary data to a log object.
Definition: log.c:856
DATASRCAPI int ds_and_iszero(ds_set_t *p1, ds_set_t *p2)
Check if the bitwise and of 2 peer sets is 0.
Definition: peerset.c:103
DATASRCAPI int ds_replay_from_file(recv_replay_t callback, char *filename)
Replays all data in a file.
Definition: replay.c:144
DATASRCAPI int ds_fields_add(int num, const char *name, int flags, int dp, const char *fmt)
Add a new field to the field list.
Definition: fields.c:333
DATASRCAPI ds_config_ctx_t * ds_config_new_ctx()
Create a new configuration context.
Definition: config.c:200
struct _ds5_publisher_s ds5_publisher_t
Represents a data publisher that publishers to remote DataSource peers on behalf of a ds5_dataprovide...
Definition: datasrc.h:512
void(* recv_request_t)(int peer, int count, char **subjects, unsigned short flags)
Definition of the function type used for handling data requests.
Definition: datasrc.h:284
DATASRCAPI void DATASRCAPI void DATASRCAPI void ds_config_add_error_message(const char *msg)
Add a configuration error to the logfile.
Definition: config.c:3428
DATASRCAPI int ds5_init(int argc, char **argv)
Parses the DataSource configuration files and initialises the DataSource library. The configuration i...
Definition: dsv5.c:108
DATASRCAPI void ds_monitor_update_string(const char *templatename, const char *key, const char *propertyname, const char *value)
Post an update to the monitoring system for a string value.
Definition: monitor.c:1197
DATASRCAPI void ds_monitor_free_data(ds_monitor_t *data)
Deallocate memory used by the contents of a ds_monitor_t object.
Definition: monitor.c:495
DATASRCAPI int32_t ds_add_record_char(ds_data_t *data, const char *field, char value)
Add a character value to a record object.
Definition: record.c:123
DATASRCAPI void ds_config_init(const char *file, int argc, char **argv)
Set up the configuration of the DataSource.
Definition: datasrc.c:214
int(* ds_monitor_authenticator_t)(ds_monauth_t *credentials)
Definition of the function type used for monitoring authentication callback.
Definition: datasrc.h:1493
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:1208
DATASRCAPI int ds_required_services_status(char *buf, size_t buflen)
Return whether all required services are ready.
Definition: advmap.c:4520
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)
Add a subscription info into the template.
Definition: monitor.c:952
DATASRCAPI char * ds_peer_label_byindex(int index)
Return the peer label for a peer index.
Definition: peer.c:4805
DATASRCAPI ds_monitor_t * ds_monitor_new_double(const char *templatename, const char *key, const char *propertyname, double value)
Create a new ds_monitor_t object from an input double.
Definition: monitor.c:1600
char * application_root
Definition: datasrc.h:371
DATASRCAPI int ds_fields_max()
Return the number of fields that have been defined.
Definition: fields.c:315
DATASRCAPI void ds_send_data_to_peer(int peer, ds_data_t *data)
Send the data object to a specific peer.
Definition: api.c:469
DATASRCAPI int32_t ds_add_record_int(ds_data_t *data, const char *field, int value)
Add an integer value to a record object.
Definition: record.c:87
DATASRCAPI int ds_pipe(sock_t fds[2])
Creates a UNIX-style pipe.
Definition: net.c:1037
DATASRCAPI void ds_add_binary_float32(ds_data_t *data, int32_t fieldnum, float value)
Add a value to a data object in the form of a floating point number.
Definition: binary.c:223
DATASRCAPI ds_data_t * ds_clone_data(ds_data_t *data)
Create a clone of a data object.
Definition: api.c:969
DATASRCAPI void ds_setnonblocking(sock_t fd)
Set a socket to be non-blocking.
Definition: net.c:1003
char * subject
Definition: datasrc.h:2430
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)
Add a relationship to a template.
Definition: monitor.c:873
DATASRCAPI int ds_signature_check(char *key_id, char *token)
Provides a mechanism for validating a KeyMaster-generated encrypted single-use token.
Definition: signature.c:492
DATASRCAPI int32_t ds_add_record_str(ds_data_t *data, const char *field, const char *value)
Add a string value to a record object.
Definition: record.c:49
DATASRCAPI void ds5_publish_to_peer(ds5_publisher_t *publisher, int peernum, ds_data_t *dsdata)
Publish an update for a subject to the specified peer.
Definition: dsv5_publisher.c:258
DATASRCAPI void ds_set_status_down_to_peer(int peer)
Causes the DataSource to disconnect and not accept connections for this peer.
Definition: peer.c:3516
DATASRCAPI ds_data_t * ds_init_data(const char *subject, unsigned short type, unsigned short flags)
Initialise a data object for use.
Definition: api.c:60
DATASRCAPI void DATASRCAPI int ds_log_set_log_level(ds_log_t *log, const char *level)
Set the log level for a particular logfile.
Definition: log.c:1870
DATASRCAPI void ds_config_add_optional_file(const char *file)
Add an optional configuration file to the current configuration context.
Definition: config.c:355
DATASRCAPI void ds_config_add_section(const char *longopt, const char *help)
Adds a new configuration section to the current configuration context.
Definition: config.c:909
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)
Add an enumerated option to the configuration context.
Definition: config.c:656
unsigned short seq
Definition: datasrc.h:2427
DATASRCAPI ds_write_event_t * ds_add_write_event(sock_t fd, ds_io_event_cb cb, int val, void *data)
Add a socket write event.
Definition: event.c:436
DATASRCAPI ds_timed_event_t * ds_add_periodic_event(int starttime, int period, int id, ds_timed_event_cb cb, int val, void *data)
Add a timed event, starting at a particular time.
Definition: event.c:1537
DATASRCAPI int ds_del_timed_event(ds_timed_event_t *ev)
Remove a timed event.
Definition: event.c:989
DATASRCAPI ds_read_event_t * ds_add_read_event(sock_t fd, ds_io_event_cb cb, int val, void *data)
Add a socket read event.
Definition: event.c:405
DATASRCAPI void ds_replay_by_time(time_t t, recv_replay_t callback)
Replays all data in the current packet log file that arrived after a specified time.
Definition: replay.c:478
DATASRCAPI void ds_and(ds_set_t *p1, ds_set_t *p2, ds_set_t *a)
Combine 2 peersets using bitwise and.
Definition: peerset.c:78
DATASRCAPI void ds_add_news_topic_code(ds_data_t *data, const char *code)
Add a topic code to the news headline message.
Definition: news.c:141
DATASRCAPI sock_t ds_listen_socket(struct in_addr *addr, int port, int backlog)
Creates a listen socket on the specified local address and TCP port.
Definition: net.c:375
DATASRCAPI char * ds_config_get_filename()
Return the current line number being parsed in the configuration file.
Definition: config.c:3565
DATASRCAPI void ds5_publish_to_peer_no_free(ds5_publisher_t *publisher, int peernum, ds_data_t *dsdata)
Publish an update for a subject to the specified peer. The update will not be freed.
Definition: dsv5_publisher.c:276
DATASRCAPI int ds_object_can_contrib(const char *name)
Determine whether contributions can be sent for this object.
Definition: advmap.c:4247
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:1468
DATASRCAPI void ds_add_container_symbol_and_request(ds_data_t *data, const char *symbol, const int request)
Add an object to the container, indicating whether it should then be requested.
Definition: container.c:73
DATASRCAPI void ds_config_set_option(const char *name, const char *value)
Set a particular configuration option.
Definition: config.c:2157
DATASRCAPI void ds_config_add_file(const char *file)
Add a mandatory configuration file to the current configuration context.
Definition: config.c:337
DATASRCAPI void ds_free_data(ds_data_t *data)
Deallocates the memory used by a data object.
Definition: api.c:767
void(* recv_update_t)(int peer, ds_data_t *pkt)
Definition of the function type used for receiving updates from a DataSource peer.
Definition: datasrc.h:202
DATASRCAPI ds_except_event_t * ds_add_except_event(sock_t fd, ds_io_event_cb cb, int val, void *data)
Add a socket exception event.
Definition: event.c:473
DATASRCAPI ds_data_t * ds_init_permission(const char *subject, const char *key, unsigned short flags)
Initialise a data object as a permission object.
Definition: permission.c:77
DATASRCAPI ds5_namespace_t * ds5_create_regex_namespace(const char *expr)
Creates a DataSource namespace which will match subject names using a regular expression.
Definition: dsv5_namespace.c:265
DATASRCAPI char * ds_get_service(const char *name)
Return the service for an object.
Definition: advmap.c:4101
DATASRCAPI void ds_udpsignal_send_argv(const char *message, char *argv[])
Send a UDP message.
Definition: udpsignal.c:377
DATASRCAPI void ds_monitor_update_double(const char *templatename, const char *key, const char *propertyname, double value)
Post an update to the monitoring system for a double value.
Definition: monitor.c:1377
DATASRCAPI struct tm * ds_gmtime()
Get the current time in GMT.
Definition: event.c:873
DATASRCAPI void ds_add_binary_int8(ds_data_t *data, int32_t fieldnum, int8_t value)
Add a value to a data object in the form of an 8 bit integer.
Definition: binary.c:293
DATASRCAPI void ds_monitor_end_template(const char *templatename)
End the definition of a template.
Definition: monitor.c:844
DATASRCAPI int ds_inet_aton(const char *cp, struct in_addr *inp)
Converts an IP address in string format into binary data.
Definition: net.c:979
DATASRCAPI void ds_config_add_group(const char *longopt, const char *help, void *base, void *def, size_t size, int *num)
Add a configuration group to the current configuration context.
Definition: config.c:788
DATASRCAPI int ds_peer_by_label(const char *label)
Return the peer index for a label.
Definition: peer.c:4782
DATASRCAPI void ds_config_free_ctx(ds_config_ctx_t *ctx)
Free a configuration context.
Definition: config.c:226
Enumerated types structure.
Definition: datasrc.h:929
DATASRCAPI void ds5_config_init(const char *configfile, int argc, char **argv)
Sets up the configuration of the DataSource.
Definition: dsv5.c:79
DATASRCAPI void ds_add_binary_int32(ds_data_t *data, int32_t fieldnum, int32_t value)
Add a value to a data object in the form of a 32 bit integer.
Definition: binary.c:343
DATASRCAPI void ds_send_data_no_free(ds_data_t *data)
Send the data object to all connected DataSource peers.
Definition: api.c:532
DATASRCAPI ds_data_t * ds_init_news(const char *subject, unsigned short flags)
Create a news headline message.
Definition: news.c:35
A field within a data update.
Definition: datasrc.h:2442
DATASRCAPI int ds_config_get_enum(const char *value, ds_config_enum_t *enums)
Get the value of an enumerated member.
Definition: config.c:1473
char * application_name
Definition: datasrc.h:370
DATASRCAPI int ds_peer_flags(int peer)
Gets the flags of a peer.
Definition: peer.c:1026
DATASRCAPI void ds_write_event_set_callback(ds_write_event_t *ev, ds_io_event_cb cb, int val, void *data)
Change the callback and callback values for a socket write event.
Definition: event.c:769
DATASRCAPI int32_t ds_add_record_fmt(ds_data_t *data, const char *field, const char *fmt,...)
Add a formatted string to a record object.
Definition: record.c:197
DATASRCAPI ds_monitor_t * ds_monitor_new_long(const char *templatename, const char *key, const char *propertyname, int32_t value)
Create a new ds_monitor_t object from an input long.
Definition: monitor.c:1510
DATASRCAPI ds5_namespace_t * ds5_create_prefix_namespace(const char *prefix)
Creates a DataSource namespace which will match subject names based on their prefix.
Definition: dsv5_namespace.c:86
DATASRCAPI char * ds_fields_namebyindex(int index)
Return the field name of this index.
Definition: fields.c:578
DATASRCAPI void ds_monitor_create_group(const char *templatename, const char *key, const char *brief, const char *description)
Create a new monitoring group.
Definition: monitor.c:1125
DATASRCAPI void DATASRCAPI void ds_cycle_all_logs(const char *suffix, long maxsize)
Cycle all log files in the application.
Definition: log.c:1146
DATASRCAPI int ds_udp_send(const char *data, int len, const char *addr, int port)
Sends data to a UDP address.
Definition: net.c:756
DATASRCAPI int ds_fields_getflags(int index)
Return the field flags of this index.
Definition: fields.c:618
DATASRCAPI void ds_monitor_start_template(const char *templatename, const char *description)
Start the defintion of a template.
Definition: monitor.c:753
DATASRCAPI void ds_add_permission_key(ds_data_t *data, const char *key)
Set the key for a permission object. Must be called either first, or immediately after inserting a se...
Definition: permission.c:101
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)
Add an enumerated option to the configuration context.
Definition: config.c:483
DATASRCAPI sock_t ds_udp_listen_socket(const char *p_interface, int port)
Creates a UDP listen socket.
Definition: net.c:542
DATASRCAPI void ds_config_add_option(char opt, const char *longopt, const char *help, int type, void *value)
Add a configuration option to the current configuration context.
Definition: config.c:388
DATASRCAPI void ds_add_binary_uint8(ds_data_t *data, int32_t fieldnum, uint8_t value)
Add a value to a data object in the form of an unsigned 8 bit integer.
Definition: binary.c:408
DATASRCAPI void ds_monitor_del_subscription(const char *templatename, const char *key, const char *propertyname, const char *value)
Delete a subscription between two groups.
Definition: monitor.c:1099
int(* ds_timed_event_cb)(int id, int val, void *data)
Definition of the callback for use with timed events.
Definition: datasrc.h:1052
DATASRCAPI void ds_add_news_datetime(ds_data_t *data, const char *datestr)
Add a date stamp to the news headline message.
Definition: news.c:87
The container object for monitoring array types.
Definition: datasrc.h:1387
DATASRCAPI void ds_monitor_delete_group(const char *templatename, const char *key)
Delete a group from the monitoring system.
Definition: monitor.c:1144
DATASRCAPI void ds_config_parse_args(int argc, char **argv, int *retargc)
Parse the configuration options from the command line arguments given.
Definition: config.c:2251
DATASRCAPI int ds_set_request_hint(const char *name, int num, char **hints)
Set the objects hint peers.
Definition: advmap.c:4327
DATASRCAPI void ds_config_set_test(const char *tag, char **value)
Adds a conditional test to the configuration file.
Definition: config.c:1037
DATASRCAPI void ds_config_list_options()
Print the options in the current configuration context to standard output.
Definition: config.c:3282
DATASRCAPI int ds_peer_local_type(int peer)
Gets the local type of a DataSource peer.
Definition: peer.c:1066
DATASRCAPI ds_udp_event_t * ds_add_udp_event(const char *command, ds_udp_event_cb cb, int val, void *data)
Add a udp event.
Definition: test_license.c:54
void(* recv_nodata_t)(int peer, char *subject, unsigned short flags)
Definition of the function type used for receiving "nodata" messages.
Definition: datasrc.h:240
DATASRCAPI char * ds_peer_name(int peer)
Gets the name of a peer.
Definition: peer.c:983
DATASRCAPI void ds_set_subject(ds_data_t *data, const char *subject)
Sets a new name for the data object.
Definition: api.c:83
DATASRCAPI ds_log_t * ds_new_log(const char *name, const char *logname)
Create a new log object.
Definition: log.c:478
DATASRCAPI void ds5_add_connectionlistener(ds5_connectionlistener_t *connection_listener, void *context)
Adds a connection listener. The listener receives status events about the state of the DataSource app...
Definition: dsv5.c:261
void ds_config_add_config_reading_message_fmt(const char *fmt,...)
Handle a configuration loading message. Add a formatted message to the list of messages to be logged...
Definition: config.c:3378
void(* ds_logcycled_t)(ds_log_t *log)
Callback used when the log has cycled.
Definition: datasrc.h:1216
DATASRCAPI int ds_check_subnet(const char *s_address, const char *s_network, const char *s_netmask)
Check whether an address falls into a given network and netmask.
Definition: net.c:1143
int typeflags
Definition: datasrc.h:1435
DATASRCAPI ds5_namespace_t * ds5_create_globbed_namespace(const char *globbed)
Creates a DataSource namespace which will match subject names using globbing.
Definition: dsv5_namespace.c:138
DATASRCAPI void ds_monitor_del_relation(const char *templatename, const char *key, const char *propertyname, const char *targetkey)
Delete a relationship between two groups.
Definition: monitor.c:1040
void(* recv_peer_status_t)(int peer, int status, int val, void *data)
Definition of the function type used for receiving peer status messages.
Definition: datasrc.h:264
DATASRCAPI int ds_num_peers
The number of DataSource peers in your configuration.
Definition: peer.c:46
DATASRCAPI void ds_add_binary_uint16(ds_data_t *data, int32_t fieldnum, uint16_t value)
Add a value to a data object in the form of an unsigned 16 bit integer.
Definition: binary.c:431
DATASRCAPI void ds_add_news_company_code(ds_data_t *data, const char *code)
Add a company code to the news headline message.
Definition: news.c:158
DATASRCAPI char * ds_interface_address(const char *ifname)
Get the local IP address for the specified interface name.
Definition: net.c:917
DATASRCAPI char * ds_debug_string(int level)
This function will convert a debug level into an appropriate string.
Definition: log.c:1677
DATASRCAPI int ds_object_available(const char *name)
Determine whether this object can theoretically be requested.
Definition: advmap.c:4191
DATASRCAPI int ds_fields_numbyname(const char *name)
Return the field number of this field.
Definition: fields.c:445
DATASRCAPI void ds_add_data_fmt(ds_data_t *data, int32_t fieldnum, const char *fmt,...)
Add a sprintf style format string to a data object.
Definition: api.c:127
DATASRCAPI void ds_set_timed_delay_next(ds_timed_event_t *ev, double delay)
Alter the next fire time for an existing timed event.
Definition: event.c:1121
DATASRCAPI int ds_request_objects(int count, char **obs, char ***services)
Request a number of objects in one go.
Definition: advmap.c:3786
DATASRCAPI int ds_peer_type(int peer)
Gets the type of a DataSource peer.
Definition: peer.c:1046
DATASRCAPI void ds_monitor_update_llong(const char *templatename, const char *key, const char *propertyname, int64_t value)
Post an update to the monitoring system for a long long value.
Definition: monitor.c:1335
DATASRCAPI void ds5_publish_subject_map(ds5_publisher_t *publisher, const char *subject, const char *mapped_to, int flags)
Publishes a subscription map event for a subject.
Definition: dsv5_publisher.c:341
DATASRCAPI void ds_add_data_int32(ds_data_t *data, int32_t fieldnum, int32_t value)
Add a value to a data object in the form of a 32 bit integer.
Definition: api.c:291
Monitoring credentials object.
Definition: datasrc.h:1476
An implementation of this interface allows applications to receive events raised for a ds5_subscripti...
Definition: datasrc.h:659
DATASRCAPI ds_monitor_t * ds_monitor_new(const char *propertyname, int type, int datasize, const void *datum)
Create a new ds_monitor_t object from input parameters.
Definition: monitor.c:545
DATASRCAPI void ds_add_binary_int64(ds_data_t *data, int32_t fieldnum, int64_t value)
Add a value to a data object in the form of a 64 bit integer.
Definition: binary.c:370
DATASRCAPI void ds_send_status_direct(const char *subject, unsigned short flags, unsigned short code, const char *msgstr)
Sends a user defined status message about a particular object.
Definition: api.c:819
DATASRCAPI void ds_add_binary(ds_data_t *data, int32_t fieldnum, char *value, int len, char type)
Adds a binary value to a data object.
Definition: binary.c:198
void ds_monitor_update_boolean(const char *templatename, const char *key, const char *propertyname, unsigned char value)
Post an update to the monitoring system for a boolean value.
Definition: monitor.c:1238
DATASRCAPI void ds_add_binary_int16(ds_data_t *data, int32_t fieldnum, int16_t value)
Add a value to a data object in the form of a 16 bit integer.
Definition: binary.c:316
DATASRCAPI int ds_peer_up(int peer)
Check to see if a peer is up.
Definition: peer.c:1110
DATASRCAPI void ds_add_data_char(ds_data_t *data, int32_t fieldnum, char value)
Add a value to a data object in the form of a character.
Definition: api.c:348
DATASRCAPI void ds_config_end_section(const char *longopt, const char *help)
Ends a configuration section.
Definition: config.c:951
DATASRCAPI ds_logcycled_t ds_log_cycled_callback(ds_log_t *log, ds_logcycled_t cycle_cb)
Set the cycle callback for a given logfile.
Definition: log.c:1991
unsigned short count
Definition: datasrc.h:2431
DATASRCAPI void ds_config_add_array_option(const char *longopt, const char *help, int type, void *value, int *num)
Adds a configuration option to the current configuration context.
Definition: config.c:587
DATASRCAPI char * ds_request_object(const char *name)
Request an object.
Definition: advmap.c:3730
DATASRCAPI void ds_monitor_add_server_type(const char *type, const char *root)
Define The Server Type.
Definition: monitor.c:707
DATASRCAPI int ds_config_get_linenumber()
Return the name of current configuration file being parsed.
Definition: config.c:3595
struct _ds5_subscription_s ds5_subscription_t
Represents a subscription to a DataSource subject (see ds_create_active_subscription()) or to a names...
Definition: datasrc.h:644
DATASRCAPI int ds_udp_bind_client_socket(sock_t sock, const char *addr, int port)
Binds a UDP socket to a local address.
Definition: net.c:869
DATASRCAPI void ds_monitor_add_subscription(const char *templatename, const char *key, const char *propertyname, const char *value)
Add a subscription between two groups.
Definition: monitor.c:1075
DATASRCAPI int ds_signature_verify_username(char *expected_username, char *token)
Verify that the supplied token is for the expected username.
Definition: signature.c:807
recv_object_status_t recv_object_status
Definition: datasrc.h:383
DATASRCAPI sock_t ds_udp_client_socket(const char *addr, int port, struct sockaddr_in *serv_addr)
Creates a UDP client socket.
Definition: net.c:831
DATASRCAPI void ds_set_status_down()
Causes the DataSource to disconnect and stop listening for connections.
Definition: peer.c:3446
DATASRCAPI void ds_reserve_std_fds()
Reserves the standard sockets for the std streams.
Definition: datasrc.c:168
DATASRCAPI void ds_cache_add_object(char *subject)
Add a new object to the cache.
Definition: cache.c:293
char * name
Definition: datasrc.h:931
char * docstring
Definition: datasrc.h:1438
recv_service_status_t recv_service_status
Definition: datasrc.h:388
DATASRCAPI void ds_send_nodata_direct(const char *subject, unsigned short flags)
Send a "no data" message to all connected DataSource peers.
Definition: api.c:680
DATASRCAPI void DATASRCAPI void DATASRCAPI void ds_printf_time_ap(ds_log_t *log, const char *extra, const char *fmt, va_list ap)
Write a formatted string prefixed with a timestamp string to a log object.
Definition: log.c:982
DATASRCAPI int ds_del_timed_event_free_data(ds_timed_event_t *ev, void(*free_data)(int, void *))
Remove a timed event.
Definition: event.c:1030
DATASRCAPI void ds_add_binary_uint32(ds_data_t *data, int32_t fieldnum, uint32_t value)
Add a value to a data object in the form of an unsigned 32 bit integer.
Definition: binary.c:458
DATASRCAPI void ds_log_change_level_callback(ds_log_t *log, ds_loglevelchange_t change_cb)
Set the level change callback for a given logfile.
Definition: log.c:1975
DATASRCAPI void ds_monitor_add_template_member(const char *templatename, const char *propertyname, const char *description, int typeflags, ds_arguments_t *args, void *ptr)
Add a memeber to a template.
Definition: monitor.c:789
char * docstring
Definition: datasrc.h:933
int sock_t
The network socket datatype.
Definition: datasrc.h:128
char * description
Definition: datasrc.h:1437
Implement this interface to receive connection status information when using the DSv5 API...
Definition: datasrc.h:605
DATASRCAPI int ds_fields_indexbynum(int num)
Return the index of this field.
Definition: fields.c:535
void(* recv_replay_t)(int peer, ds_data_t *pkt, time_t tm)
Definition of the function type used for receiving updates from a the DataSource library when calling...
Definition: datasrc.h:220
DATASRCAPI void ds_monitor_add_data(ds_monitor_t *data, const void *datum)
Add an element to an array within a ds_monitor_t.
Definition: monitor.c:407
DATASRCAPI sock_t ds_client_socket(const char *serv, unsigned short port)
Creates a client socket with which to connect to a host.
Definition: net.c:709
ds_field_t * fields
Definition: datasrc.h:2432
DATASRCAPI void ds_discard_object(const char *name)
Discard an object.
Definition: advmap.c:3919
unsigned short flags
Definition: datasrc.h:373
DATASRCAPI void ds_replay(recv_replay_t callback)
Replays all data in the current packet log file.
Definition: replay.c:179
DATASRCAPI void ds_set_status_up_to_peer(int peer)
Causes the DataSource to connect and accept connections.
Definition: peer.c:3755
DATASRCAPI int ds_replay_by_time_from_file(time_t t, recv_replay_t callback, char *filename)
Replays all data in a file that arrived after a specified time.
Definition: replay.c:504
DATASRCAPI void ds_monitor_update(const char *templatename, const char *key, ds_monitor_t *mondata)
Post an update to the monitoring system for a string value.
Definition: monitor.c:1169
DATASRCAPI void ds_config_end_group(const char *longopt, const char *help)
Ends a configuration group.
Definition: config.c:868
DATASRCAPI char * ds_fields_namebynum(int num)
Return the field name of this field number.
Definition: fields.c:475
DATASRCAPI void ds_send_nodata(const char *subject, unsigned short flags)
Send a "no data" message to all connected DataSource peers.
Definition: api.c:657
DATASRCAPI void ds_config_add_bounded_array_option(const char *longopt, const char *help, int type, void *value, int *num, void *min, void *max)
Adds a configuration option to the current configuration context.
Definition: config.c:621
DATASRCAPI void ds_monitor_add_relation(const char *templatename, const char *key, const char *propertyname, const char *targetkey)
Add a relationship between two groups.
Definition: monitor.c:1015
DATASRCAPI void ds_thread_init(int event_module, int flags)
Initialise the event loop for this thread.
Definition: datasrc.c:906
char * name
Definition: datasrc.h:1436
DATASRCAPI struct sockaddr * ds_gethostsockaddr(const char *name, struct sockaddr *populate)
Return the socket address for a given hostname.
Definition: net.c:278
Definition of the interface that you should implement if you require custom subject matching logic...
Definition: datasrc.h:443
DATASRCAPI int ds_del_write_event_free_data(ds_write_event_t *ev, void(*free_data)(int, void *))
Remove a socket write event.
Definition: event.c:666
DATASRCAPI int ds_getaddr(const char *name, struct in_addr *addr)
Gets a network address.
Definition: net.c:254
DATASRCAPI void ds_monitor_update_ullong(const char *templatename, const char *key, const char *propertyname, uint64_t value)
Post an update to the monitoring system for an unsigned long long value.
Definition: monitor.c:1316
DATASRCAPI void ds_set_timed_delay(ds_timed_event_t *ev, double delay)
Alter the delay for an existing timed event.
Definition: event.c:1101
DATASRCAPI void ds_config_del_test(const char *tag)
Delete a conditional test.
Definition: config.c:1071
DATASRCAPI void ds_add_news_headline(ds_data_t *data, const char *headline)
Add a news headline to the news headline message.
Definition: news.c:53
DATASRCAPI ds5_subscription_t * ds5_create_broadcast_subscription(ds5_namespace_t *nspace, ds5_subscriptionlistener_t *listener, void *context)
Create a subscription that matches multiple subjects.
Definition: dsv5_subscription.c:98
DATASRCAPI void ds_send_status(const char *subject, unsigned short flags, unsigned short code, const char *msgstr)
Sends a user defined status message about a particular object.
Definition: api.c:792
struct _ds_udp_event ds_udp_event_t
Opaque type defining a udp event.
Definition: datasrc.h:2472
DATASRCAPI void ds_delay_data(ds_delay_t *delay, ds_data_t *dsdata)
Add a data object to a delay channel.
Definition: delay.c:290
void(* recv_object_status_t)(int peer, char *subject, int status, unsigned short code, char *msgstr)
Definition of the function type used for handling objectstatus messages.
Definition: datasrc.h:325
DATASRCAPI ds_log_t * ds_new_level_log(const char *name, const char *logname, ds_loglevelchange_t change_cb)
Create a new log object.
Definition: log.c:501
DATASRCAPI void ds_add_news_storycode(ds_data_t *data, const char *story)
Add a story code to the news object.
Definition: news.c:70
DATASRCAPI void ds_send_data_direct(ds_data_t *data)
Send the data object to all connected DataSource peers.
Definition: api.c:404
DATASRCAPI void ds_add_data_float64(ds_data_t *data, int32_t fieldnum, double value)
Add a value to a data object in the form of a floating point number.
Definition: api.c:201
DATASRCAPI void ds_add_binary_time(ds_data_t *data, int32_t fieldnum, time_t value)
Add a value to a data object in the form of a timestamp.
Definition: binary.c:569
DATASRCAPI ds_monitor_t * ds_monitor_new_llong(const char *templatename, const char *key, const char *propertyname, int64_t value)
Create a new ds_monitor_t object from an input long long.
Definition: monitor.c:1554
DATASRCAPI void ds_config_del_option(const char *longopt)
Remove an option from the current configuration context.
Definition: config.c:729
char * propertyname
Definition: datasrc.h:1410
DATASRCAPI int ds_udp_sendto(const char *data, int len, struct sockaddr_in *serv_addr)
Sends data to a UDP address.
Definition: net.c:798
void(* recv_discard_t)(int peer, int count, char **subjects, unsigned short flags)
Definition of the function type used for handling data discard requests.
Definition: datasrc.h:304
The container object for all monitoring values.
Definition: datasrc.h:1408
DATASRCAPI void * ds_get_object_data(const char *name)
Get an objects user data.
Definition: advmap.c:4494
DATASRCAPI void ds5_publish_subject_error(ds5_publisher_t *publisher, const char *subject, int flags)
Publishes a subscription error event for a subject.
Definition: dsv5_publisher.c:357
DATASRCAPI void ds_read_event_set_callback(ds_read_event_t *ev, ds_io_event_cb cb, int val, void *data)
Change the callback and callback values for a socket read event.
Definition: event.c:752
DATASRCAPI void ds_add_news_field(ds_data_t *dsdata, const char *fieldname, const char *value)
Add a custom field to a news headline message.
Definition: news.c:200
unsigned short flags
Definition: datasrc.h:2428
DATASRCAPI int ds_peer_host_details(int peer, char **addr)
Gets details of the remote side of a peer.
Definition: peer.c:941
Structure defining the arguments for Monitoring methods.
Definition: datasrc.h:1433
void(* ds_delay_send_cb)(void *context, ds_data_t *dsdata)
Definition of the callback for sending delayed data.
Definition: datasrc.h:2278
DATASRCAPI int ds_cycle_log(ds_log_t *log, const char *suffix, long maxsize)
Cycle a specific log file.
Definition: log.c:1177
struct _ds_log ds_log_t
The log file object.
Definition: datasrc.h:186
unsigned short type
Definition: datasrc.h:374
DATASRCAPI void ds_add_news_authstr(ds_data_t *data, const char *authstr)
Add an authorisation string to the news headline message.
Definition: news.c:107
DATASRCAPI ds_monitor_t * ds_monitor_new_short(const char *templatename, const char *key, const char *propertyname, int16_t value)
Create a new ds_monitor_t object from an input short.
Definition: monitor.c:1466
DATASRCAPI void ds_add_data_str(ds_data_t *data, int32_t fieldnum, const char *value)
Adds a string value to a data object.
Definition: api.c:154
void(* free)(ds5_namespace_t *nspace)
Invoked when the namespace should be deleted.
Definition: datasrc.h:450
DATASRCAPI void ds_replay_by_field(int fieldnum, char *value, recv_replay_t callback)
Replays all data in the current packet log file that arrived after an update with the specified value...
Definition: replay.c:569
DATASRCAPI ds_timed_event_t * ds_add_timed_event(int id, double delay, ds_timed_event_cb cb, int val, void *data)
Add a timed event.
Definition: event.c:920
DATASRCAPI void ds_send_data(ds_data_t *data)
Send the data object to all connected DataSource peers.
Definition: api.c:379
struct _ds_peer_set ds_set_t
Defines a set of DataSource peers.
Definition: datasrc.h:164
DATASRCAPI void ds_writev(ds_log_t *log, struct iovec *vector, int count)
Write binary data to a log object.
Definition: log.c:875
DATASRCAPI void ds_send_data_to_peer_no_free(int peer, ds_data_t *data)
Send the data object to a specific peer.
Definition: api.c:596
DATASRCAPI void ds_stop()
Definition: event.c:817
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)
Add a configuration group to the current configuration context.
Definition: config.c:816
ds_monitor_t * ds_monitor_new_boolean(const char *templatename, const char *key, const char *propertyname, unsigned char value)
Create a new ds_monitor_t object from an input boolean value.
Definition: monitor.c:1444
DATASRCAPI int ds_fields_getdp(int index)
Return the decimal precision of this index.
Definition: fields.c:635
DATASRCAPI void ds_set_status_msg_to_peer(int peer, unsigned short msgid, const char *msgstr)
Send a user-defined status message to peer.
Definition: peer.c:3613
struct _ds_timed_event ds_timed_event_t
Opaque type defining a timed event.
Definition: datasrc.h:998
DATASRCAPI void ds_monitor_update_short(const char *templatename, const char *key, const char *propertyname, int16_t value)
Post an update to the monitoring system for a short value.
Definition: monitor.c:1257
void ds_config_add_error_message_fmt(const char *fmt,...)
Add a formatted error message to the logfile.
Definition: config.c:3346
DATASRCAPI void ds_monitor_free(ds_monitor_t *data)
Deallocate memory used by a ds_monitor_t object.
Definition: monitor.c:473
DATASRCAPI void ds_add_binary_timeval(ds_data_t *data, int32_t fieldnum, struct timeval value)
Add a value to a data object in the form of a timestamp.
Definition: binary.c:626
DATASRCAPI ds_log_t * ds_new_headed_log(const char *name, const char *logname, const char *header)
Create a new log object with a header.
Definition: log.c:753
DATASRCAPI void ds_send_status_to_peer(int peer, const char *subject, unsigned short flags, unsigned short code, const char *msgstr)
Sends a user defined status message about a particular object.
Definition: api.c:880
DATASRCAPI int ds5_regex_namespace_add_expr(ds5_namespace_t *nspace, const char *expr, int exclude)
Adds a regular expression to a namespace.
Definition: dsv5_namespace.c:230
DATASRCAPI char ** ds_get_request_hints(const char *name, int *ret)
Return an objects request hints.
Definition: advmap.c:4406
DATASRCAPI ds_monitor_t * ds_monitor_new_ullong(const char *templatename, const char *key, const char *propertyname, uint64_t value)
Create a new ds_monitor_t object from an input unsigned long long.
Definition: monitor.c:1532
size_t size
Definition: datasrc.h:1388
DATASRCAPI void ds_set_status_up()
Causes the DataSource to connect and listen for connections.
Definition: peer.c:3716
DATASRCAPI int ds_check_periodic_event(int period, ds_timed_event_t **tev)
Check a periodic to ensure that it runs at the appropriate time regardless of summertime.
Definition: event.c:1817
DATASRCAPI void ds_loop()
Start the DataSource event loop.
Definition: event.c:790
DATASRCAPI void ds_udpsignal_send(const char *message)
Send a udp message.
Definition: udpsignal.c:359
A data update object.
Definition: datasrc.h:2425
DATASRCAPI void ds_add_news_product_code(ds_data_t *data, const char *code)
Add a product code to the news headline message.
Definition: news.c:124
DATASRCAPI void ds5_unsubscribe(ds5_subscription_t *sub)
Unsubscribe from the DataSource subject or namespace of DataSource subjects.
Definition: dsv5_subscription.c:534
DATASRCAPI int ds_debug_level(const char *text)
This function will convert a string into an appropriate debug level.
Definition: log.c:1642
DATASRCAPI int ds_iszero(ds_set_t *p)
Check if any peer is set.
Definition: peerset.c:28
DATASRCAPI void ds5_publish_to_subscribed_peers_no_free(ds5_publisher_t *pub, ds_data_t *dsdata)
Publish an update for a subject to all peers that have subscribed. The update will not be freed...
Definition: dsv5_publisher.c:242
DATASRCAPI ds_delay_t * ds_new_delay(double delay_time, char *prefix, double batch_time)
Create a new delay channel.
Definition: delay.c:200
DATASRCAPI void ds_purge_object(const char *name)
Purge an object from our cache.
Definition: advmap.c:4295
DATASRCAPI int ds_request_objects_with_flags(int count, char **obs, int flags, char ***services)
Request a number of objects in one go.
Definition: advmap.c:3811
void(* recv_map_t)(int peer, char *from, char *to)
Definition of the function type used for handling map messages.
Definition: datasrc.h:348
DATASRCAPI int ds_peer_enabled_state(int peer)
Gets the enabled/disabled state of a DataSource peer.
Definition: peer.c:1084
void(* recv_service_status_t)(char *service, int status)
Definition of the function type used for handling service status messages.
Definition: datasrc.h:336
DATASRCAPI int ds_fields_indexbyname(const char *name)
Return the index of this field.
Definition: fields.c:502
DATASRCAPI void ds5_publish_to_subscribed_peers(ds5_publisher_t *pub, ds_data_t *dsdata)
Publish an update for a subject to all peers that have subscribed.
Definition: dsv5_publisher.c:225
DATASRCAPI ds_monitor_t * ds_monitor_new_string(const char *templatename, const char *key, const char *propertyname, const char *value)
Create a new ds_monitor_t object from an input string.
Definition: monitor.c:1400
DATASRCAPI void ds_add_news_user_code(ds_data_t *data, int codenum, const char *code)
Add a user defined code to the news headline message.
Definition: news.c:178
char * value
Definition: datasrc.h:2446
DATASRCAPI void ds_config_parse_files()
Parse all configuration files within the current configuration context.
Definition: config.c:2086
DATASRCAPI void ds_config_add_option_enum(char opt, const char *longopt, const char *help, int type, void *value, ds_config_enum_t *enums)
Add an enumerated option to the configuration context.
Definition: config.c:455
DATASRCAPI void ds5_publish_response(ds5_publisher_t *pub, ds_data_t *dsdata)
Publish an initial response (for example, an image of the subject&#39;s data) following a request for a s...
Definition: dsv5_publisher.c:293
DATASRCAPI void ds_remove_container_symbol(ds_data_t *data, const char *symbol)
Remove an object from the container.
Definition: container.c:100
char * username
Definition: datasrc.h:1478
DATASRCAPI sock_t ds_accept_socket(sock_t fd)
Accepts a connection from a listen socket.
Definition: net.c:448
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:1040
DATASRCAPI ds5_publisher_t * ds5_create_broadcast_publisher(ds5_namespace_t *nspace)
Creates a data publisher that allows a DataSource application to broadcast updates to remote DataSour...
Definition: dsv5_publisher.c:739
DATASRCAPI void ds_add_data_int64(ds_data_t *data, int32_t fieldnum, int64_t value)
Add a value to a data object in the form of a 64 bit integer.
Definition: api.c:321
DATASRCAPI ds_monitor_t * ds_monitor_new_array(const char *propertyname, int type)
Create a new ds_monitor_t of an array type.
Definition: monitor.c:385
DATASRCAPI void ds5_publish_response_no_free(ds5_publisher_t *pub, ds_data_t *dsdata)
Publish an initial response (for example, an image of the subject&#39;s data) following a request for a s...
Definition: dsv5_publisher.c:309
DATASRCAPI void ds_config_add_search(const char *path)
Add a directory in which to search for configuration files.
Definition: config.c:280
unsigned short type
Definition: datasrc.h:2429
DATASRCAPI ds5_publisher_t * ds5_create_compatibility_publisher(ds5_namespace_t *nspace, ds5_dataprovider_t *provider, void *context)
Creates a data publisher that, for a given subject sends multiple subscription requests and multiple ...
Definition: dsv5_publisher.c:179
DATASRCAPI void ds_replay_by_time_from_log(time_t t, recv_replay_t callback, ds_log_t *log)
Replays all data in a log object that arrived after a specified time.
Definition: replay.c:523
DATASRCAPI void ds_replay_from_log(recv_replay_t callback, ds_log_t *log)
Replays all data in a packet log file.
Definition: replay.c:158
DATASRCAPI ds_monitor_t * ds_monitor_new_timestamp(const char *templatename, const char *key, const char *propertyname, int64_t value)
Create a new ds_monitor_t object from an input timestamp.
Definition: monitor.c:1576
DATASRCAPI void ds_set_status_msg(unsigned short msgid, const char *msgstr)
Send a user-defined status message to all connected peers.
Definition: peer.c:3549
struct _ds_io_event ds_write_event_t
Opaque type defining a write event.
Definition: datasrc.h:1020
DATASRCAPI char * ds_filename_expand(const char *format, char *buffer, size_t bufsize)
Expand a filename pattern into a fully qualified filename.
Definition: datasrc.c:1153
double value
Definition: datasrc.h:932
DATASRCAPI ds_log_t * ds_get_event_log(void)
Returns a handle to the event log used by Datasource for C.
Definition: datasrc.c:1294
recv_request_t recv_request
Definition: datasrc.h:375
DATASRCAPI ds_config_ctx_t * ds_config_set_ctx(ds_config_ctx_t *ctx)
Sets a configuration context as the current one.
Definition: config.c:259
char * password
Definition: datasrc.h:1479
struct _config_ctx ds_config_ctx_t
The configuration context data type.
Definition: datasrc.h:181
DATASRCAPI void ds_del_udp_event(ds_udp_event_t *event)
Remove a timed event.
Definition: udpsignal.c:182
DATASRCAPI int ds_send_contribution(ds_data_t *dsdata)
Contribute an object back to the peers that supplied it and support it.
Definition: advmap.c:4026
recv_map_t recv_map
Definition: datasrc.h:389
DATASRCAPI void ds_config_list_values()
Print the options and values in the current configuration context to standard output.
Definition: config.c:3296
Interface that must be implemented in order to receive subscirption request and subscription discard ...
Definition: datasrc.h:530
DATASRCAPI int ds_peer_all_type(int flag)
Checks if a DataSource peer of the given type is in your configuration file.
Definition: peer.c:1136
int32_t fieldnum
Definition: datasrc.h:2444
recv_peer_status_t recv_peer_status
Definition: datasrc.h:379
char * logfile
Definition: datasrc.h:392
DATASRCAPI void ds_add_latency_chain(ds_data_t *dsdata, char suffix, int64_t millis)
function used to add a measurement point to latency chain data
Definition: lty_chain.c:257
DATASRCAPI void ds_monitor_update_ulong(const char *templatename, const char *key, const char *propertyname, uint32_t value)
Post an update to the monitoring system for an unsigned long value.
Definition: monitor.c:1277
ds_log_t * log
Definition: datasrc.h:393
DATASRCAPI ds_monitor_authenticator_t ds_monitor_set_auth(ds_monitor_authenticator_t authenticator)
Register a new authentication handler.
Definition: monitor.c:1621
struct _ds_io_event ds_except_event_t
Opaque type defining an exception event.
Definition: datasrc.h:1005
DATASRCAPI char * ds_request_object_with_flags(const char *name, int flags)
Request an object.
Definition: advmap.c:3749
struct _ds_io_event ds_read_event_t
Opaque type defining a read event.
Definition: datasrc.h:1013
DATASRCAPI void ds_add_data_int8(ds_data_t *data, int32_t fieldnum, int8_t value)
Add a value to a data object in the form of an 8 bit integer.
Definition: api.c:231
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)
Add a timed event, starting at a particular offset from a given time.
Definition: event.c:1722
DATASRCAPI int ds_daemon_disabled()
Check whether the application is running in daemon mode.
Definition: daemon.c:159
DATASRCAPI void ds_daemon_redirect()
Redirects the std* streams.
Definition: daemon.c:139
DATASRCAPI void ds_add_binary_string(ds_data_t *data, int32_t fieldnum, char *value)
Add a value to a data object in the form of a string.
Definition: binary.c:520
DATASRCAPI char * ds_debug_config_string(int level)
This function will convert a debug level into an appropriate string.
Definition: log.c:1709
void(* ds_config_func)(char *name, int num, char **values)
Definition of function type used for configuration callbacks.
Definition: datasrc.h:950
DATASRCAPI int ds_config_parse_file(const char *unresolved_filename)
Parse a single configuration file within the configuration context.
Definition: config.c:2482
DATASRCAPI void ds_cleardown_container_with_prefix(ds_data_t *data, const char *prefix)
Remove a set of symbols from the container.
Definition: container.c:139
DATASRCAPI int ds_get_gmt_offset(time_t t)
Calculate offset between local time and gmt.
Definition: event.c:1558
DATASRCAPI void ds_add_binary_uint64(ds_data_t *data, int32_t fieldnum, uint64_t value)
Add a value to a data object in the form of an unsigned 64 bit integer.
Definition: binary.c:485
DATASRCAPI int ds_and3_iszero(ds_set_t *p1, ds_set_t *p2, ds_set_t *p3)
Check if the bitwise and of 3 peer sets is 0.
Definition: peerset.c:133
DATASRCAPI int ds_del_read_event(ds_read_event_t *ev)
Remove a socket read event.
Definition: event.c:571
int32_t len
Definition: datasrc.h:2445
DATASRCAPI int ds_log_get_level(ds_log_t *log)
Get the current loglevel for the given logfile.
Definition: log.c:2007
DATASRCAPI void ds_or(ds_set_t *p1, ds_set_t *p2, ds_set_t *o)
Combine 2 peersets using bitwise or.
Definition: peerset.c:55
struct _ds_io_event ds_generic_event_t
Opaque type defining a generic read/write event.
Definition: datasrc.h:1027
void ds_log(ds_log_t *log, int level, const char *fmt,...)
Write a formatted string prefixed with log level and timestamp to the log object. ...
Definition: log.c:1778
recv_nodata_t recv_nodata
Definition: datasrc.h:378
DATASRCAPI int ds_init(ds_init_t *init, int argc, char **argv)
Parse the configuration files and initialise the DataSource library.
Definition: datasrc.c:414
DATASRCAPI int ds_peer_details(int peer, char **name)
Gets the ID and name of a peer.
Definition: peer.c:924
char * ipaddress
Definition: datasrc.h:1480
DATASRCAPI int32_t ds_add_record_float(ds_data_t *data, const char *field, double value)
Add a floating point value to a record object.
Definition: record.c:160
void ds_printf_time(ds_log_t *log, const char *fmt,...)
Write a formatted string prefixed with a timestamp string to a log object.
Definition: log.c:945
DATASRCAPI void ds_send_nodata_to_peer(int peer, const char *subject, unsigned short flags)
Send a "no data" message to a specific DataSource pper.
Definition: api.c:728
DATASRCAPI void ds_discard_objects(int count, char **obs)
Discard a number of objects.
Definition: advmap.c:3961
DATASRCAPI int ds_del_write_event(ds_write_event_t *ev)
Remove a socket write event.
Definition: event.c:631
DATASRCAPI void ds_timed_event_set_callback(ds_timed_event_t *ev, ds_timed_event_cb cb, int val, void *data)
Change the callback and callback values for a timed eent.
Definition: event.c:1294
DATASRCAPI int ds_get_service_by_index(int index, char **name_ptr)
Return the name/state of a service by index.
Definition: advmap.c:4165
DATASRCAPI void ds_replay_by_field_from_log(int fieldnum, char *value, recv_replay_t callback, ds_log_t *log)
Replays all data in the log object that arrived after an update with the specified value for the spec...
Definition: replay.c:621
struct _ds_delay ds_delay_t
The delay channel object type.
Definition: datasrc.h:175
DATASRCAPI ds_monitor_t * ds_monitor_new_ushort(const char *templatename, const char *key, const char *propertyname, uint16_t value)
Create a new ds_monitor_t object from an input unsigned short.
Definition: monitor.c:1422
DATASRCAPI void ds_config_add_bounded_option(char sopt, const char *longopt, const char *help, int type, void *value, void *min, void *max)
Add a bounded configuration option to the current configuration context.
Definition: config.c:426
DATASRCAPI void ds_add_container_symbol_at_position(ds_data_t *data, int position, const char *symbol)
Insert an object within a container at a particular position.
Definition: container.c:119
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:2485
DATASRCAPI time_t ds_get_time()
Gets the current time in seconds.
Definition: event.c:860
void ds_syslog(ds_log_t *log, int level, const char *fmt,...)
Write a formatted string to a log object and to syslog.
Definition: log.c:1013
DATASRCAPI void ds_add_latency_chain2(ds_data_t *dsdata, char suffix, int64_t millis, char suffix2, int64_t millis2)
function used to add two measurement points to latency chain data
Definition: lty_chain.c:310
DATASRCAPI int ds_del_except_event_free_data(ds_except_event_t *ev, void(*free_data)(int, void *))
Remove a socket except event.
Definition: event.c:725
int(* match)(ds5_namespace_t *nspace, const char *subject)
Tests a subject to see if it falls within this namespace.
Definition: datasrc.h:460
DATASRCAPI void ds_add_binary_float64(ds_data_t *data, int32_t fieldnum, double value)
Add a value to a data object in the form of a floating point number.
Definition: binary.c:255
DATASRCAPI ds5_publisher_t * ds5_create_active_publisher(ds5_namespace_t *nspace, ds5_dataprovider_t *provider, void *context)
Creates a data publisher that for a given subject sends multiple subscription requests and a single s...
Definition: dsv5_publisher.c:122
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)
Create a new delay channel.
Definition: delay.c:238
DATASRCAPI ds_data_t * ds_init_page(const char *subject, int rows, int cols, const char *type, unsigned short flags)
Initialise a data object as a page.
Definition: page.c:72
DATASRCAPI void ds_add_page_field(ds_data_t *data, int32_t fieldnum, const char *value)
Add an arbitrary field to a page.
Definition: page.c:136
int datatype
Definition: datasrc.h:1411
DATASRCAPI void ds_monitor_update_timestamp(const char *templatename, const char *key, const char *propertyname, int64_t value)
Post an update to the monitoring system for a timestamp value.
Definition: monitor.c:1354
recv_discard_t recv_discard
Definition: datasrc.h:376
DATASRCAPI void ds_add_page_row(ds_data_t *data, int row, int col, const char *str)
Add a row of data to a page data object.
Definition: page.c:110
DATASRCAPI sock_t ds_multicast_listen_socket(const char *p_interface, const char *addr, int port)
Creates a multicast listen socket.
Definition: net.c:472
DATASRCAPI int ds_get_num_services()
Return the number of services.
Definition: advmap.c:4148
DATASRCAPI ds_monitor_t * ds_monitor_new_ulong(const char *templatename, const char *key, const char *propertyname, uint32_t value)
Create a new ds_monitor_t object from an input unsigned long.
Definition: monitor.c:1488
DATASRCAPI int ds_del_read_event_free_data(ds_read_event_t *ev, void(*free_data)(int, void *))
Remove a socket read event.
Definition: event.c:606
DATASRCAPI int ds_fields_numbyindex(int index)
Return the field number of this index.
Definition: fields.c:560
DATASRCAPI void ds_free_log(ds_log_t *log)
Destroy a log object.
Definition: log.c:783
DATASRCAPI void ds_monitor_update_ushort(const char *templatename, const char *key, const char *propertyname, uint16_t)
Post an update to the monitoring system for an unsigned short value.
Definition: monitor.c:1218
DATASRCAPI struct tm * ds_localtime()
Get the current time in the local timezone.
Definition: event.c:886
DATASRCAPI void ds_set_object_data(const char *name, void *data)
Set an objects user data.
Definition: advmap.c:4450
DATASRCAPI int ds_peer_id(int peer)
Gets the ID of a peer.
Definition: peer.c:963
DATASRCAPI void ds_add_data(ds_data_t *data, int32_t fieldnum, const char *value)
Adds a string value to a data object.
Definition: api.c:108

Generated on Wed Jan 24 2018 12:22:46 for DataSource for C SDK