aboutsummaryrefslogtreecommitdiffstats
path: root/echld
diff options
context:
space:
mode:
authorLuis Ontanon <luis.ontanon@gmail.com>2013-06-25 03:33:02 +0000
committerLuis Ontanon <luis.ontanon@gmail.com>2013-06-25 03:33:02 +0000
commitdb09d8d0f0341f3ac09c5a59098467c5bd8f69ae (patch)
tree8d817b9552360201558f3d79da25a3522a9eb326 /echld
parente591c9f21e5d57be7a9cad4e9c5d62647bde38eb (diff)
another iteration, prepared for automake.
svn path=/trunk/; revision=50136
Diffstat (limited to 'echld')
-rw-r--r--echld/Makefile.am55
-rw-r--r--echld/Makefile.common4
-rw-r--r--echld/echld-int.h22
-rw-r--r--echld/echld-util.c2
-rw-r--r--echld/echld-util.h18
-rw-r--r--echld/echld.h66
-rw-r--r--echld/echld_child.c7
-rw-r--r--echld/echld_common.c6
-rw-r--r--echld/echld_parent.c66
-rw-r--r--echld/echld_test.c100
10 files changed, 112 insertions, 234 deletions
diff --git a/echld/Makefile.am b/echld/Makefile.am
index 6dfb03d0b8..8323be84c1 100644
--- a/echld/Makefile.am
+++ b/echld/Makefile.am
@@ -20,15 +20,22 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+include ../Makefile.am.inc
+
ACLOCAL_AMFLAGS = `../aclocal-flags`
+include Makefile.common
+
# Optional objects that I know how to build. These will be
# linked into libechld.
-echld_optional_objects =
+echld_optional_objects = $(LIBECHLD_SRC)
+
+
+lib_LTLIBRARIES = libechld.la
+
+libechld_la_LDFLAGS = -version-info 0:0:0 @LDFLAGS_SHAREDLIB@
-include ../Makefile.am.inc
-include Makefile.common
AM_CFLAGS =-DWS_BUILD_DLL
@@ -36,22 +43,17 @@ if HAVE_WARNINGS_AS_ERRORS
AM_CFLAGS += -Werror
endif
-
-lib_LTLIBRARIES = libechld.la
-# http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
-libechld_la_LDFLAGS = -version-info 0:0:0 @LDFLAGS_SHAREDLIB@
-
AM_CPPFLAGS = -I$(srcdir)/..
-libechld_la_SOURCES = \
+libechld_la_SOURCES = \
$(LIBECHLD_SRC) \
$(LIBECHLD_INCLUDES)
-EXTRA_libechld_la_SOURCES=
-
-libechld_la_DEPENDENCIES=
+libechld_la_DEPENDENCIES=
libechld_la_LIBADD = \
+ ../epan/libwireshark.la \
+ ../wsutil/libwsutil.la \
@GLIB_LIBS@
EXTRA_DIST = \
@@ -67,32 +69,3 @@ CLEANFILES = \
MAINTAINERCLEANFILES = \
Makefile.in
-bin_PROGRAMS =
- @echld_test_bin@
-
-EXTRA_PROGRAMS = echld_test
-
-echld_test_LDADD = \
- echld/libechld.la \
- @GLIB_LIBS@
-
-echld_test_CFLAGS = $(AM_CLEAN_CFLAGS)
-
-# ABI compliance checker can be obtained from
-# http://ispras.linux-foundation.org/index.php/ABI_compliance_checker
-# Checked using version 1.21.12
-#dumpabi-libechld: all abi-descriptor.xml
-# rm -rf abi-check-headers abi_dumps .libs/*.abi.tar.gz
-# mkdir abi-check-headers
-# cp ../config.h ../ws_symbol_export.h *.h abi-check-headers/
-# abi-compliance-checker -l libechld -v1 `readlink .libs/libechld.so | sed 's/.*\.so\.//'` \
-# -relpath $(abs_srcdir) -dump-abi abi-descriptor.xml || \
-# cat logs/libechld/[0-9]*/log.txt
-# cp -f abi_dumps/libechld/libechld_* .libs/
-# cd .libs && ln -sf libechld_*.abi.tar.gz libechld.abi.tar.gz
-#
-#checkapi:
-# $(PERL) ../tools/checkAPIs.pl -g abort -g termoutput \
-# $(PERL) ../tools/checkAPIs.pl -g termoutput -build \
-# $(LIBWSUTIL_SRC)
-# file_util.c unicode-utils.c
diff --git a/echld/Makefile.common b/echld/Makefile.common
index aefe6a9a46..f8004280e3 100644
--- a/echld/Makefile.common
+++ b/echld/Makefile.common
@@ -40,7 +40,3 @@ LIBECHLD_INCLUDES = \
echld-int.h \
echld-util.h \
echld.h
-
-# echld_test specifics
-echld_test_SOURCES = \
- echld_test.c
diff --git a/echld/echld-int.h b/echld/echld-int.h
index 6bd2122fb5..e21b69c154 100644
--- a/echld/echld-int.h
+++ b/echld/echld-int.h
@@ -122,8 +122,8 @@ typedef struct _echld_reader {
#define READER_FD_ISSET(R,fdset_p) READER_FD_ISSET(R.fd,&(fdset_p))
#define READER_FD_CLEAR(R,fdset_p) READER_FD_CLEAR(R.fd,&(fdset_p))
-void echld_init_reader(echld_reader_t* r, int fd, size_t initial);
-void echld_reset_reader(echld_reader_t* r, int fd, size_t initial);
+extern void echld_init_reader(echld_reader_t* r, int fd, size_t initial);
+extern void echld_reset_reader(echld_reader_t* r, int fd, size_t initial);
typedef struct _param {
const char* name;
@@ -174,23 +174,25 @@ typedef struct _parent_in {
echld_bool_t (*packet_list) (enc_msg_t*, char**, char**, char**); // name, filter, range
} parent_decoder_t;
-void echld_get_all_codecs(child_encoder_t**, child_decoder_t**, echld_parent_encoder_t**, parent_decoder_t**);
+extern void echld_get_all_codecs(child_encoder_t**, child_decoder_t**, echld_parent_encoder_t**, parent_decoder_t**);
-void echld_init_reader(echld_reader_t* r, int fd, size_t initial);
-void free_reader(echld_reader_t* r);
+extern void echld_init_reader(echld_reader_t* r, int fd, size_t initial);
+extern void free_reader(echld_reader_t* r);
-long echld_read_frame(echld_reader_t* r, read_cb_t cb, void* cb_data);
-long echld_write_frame(int fd, GByteArray* ba, guint16 chld_id, echld_msg_type_t type, guint16 reqh_id, void* data);
+extern long echld_read_frame(echld_reader_t* r, read_cb_t cb, void* cb_data);
+extern long echld_write_frame(int fd, GByteArray* ba, guint16 chld_id, echld_msg_type_t type, guint16 reqh_id, void* data);
-void echld_child_initialize(int pipe_from_parent, int pipe_to_parent, int reqh_id);
-int echld_child_loop(void);
+extern void echld_child_initialize(int pipe_from_parent, int pipe_to_parent, int reqh_id);
+extern int echld_child_loop(void);
/* never returns*/
-void echld_dispatcher_start(int* in_pipe_fds, int* out_pipe_fds);
+extern void echld_dispatcher_start(int* in_pipe_fds, int* out_pipe_fds);
extern void dummy_switch(echld_msg_type_t type);
+extern void echld_unused(void);
+
#define DEBUG_CHILD 5
#define DEBUG_DISPATCHER 5
diff --git a/echld/echld-util.c b/echld/echld-util.c
index bc29ac3b6b..6519e81c90 100644
--- a/echld/echld-util.c
+++ b/echld/echld-util.c
@@ -61,7 +61,7 @@ static gboolean pong(echld_msg_type_t type, GByteArray* ba _U_, void* data) {
}
-echld_state_t echld_ping(int chld_id, echld_ping_cb_t pcb, void* cb_data) {
+extern echld_state_t echld_ping(int chld_id, echld_ping_cb_t pcb, void* cb_data) {
struct _ping* p = g_new0(struct _ping,1);
p->cb = pcb;
diff --git a/echld/echld-util.h b/echld/echld-util.h
index 3afebe60f2..d7be39a78d 100644
--- a/echld/echld-util.h
+++ b/echld/echld-util.h
@@ -23,22 +23,26 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
+#ifndef __ECHLD_UTIL
+#define __ECHLD_UTIL
+
typedef void (*echld_ping_cb_t)(long usec, void* data);
-echld_state_t echld_ping(int child_id, echld_ping_cb_t pcb, void* cb_data);
+WS_DLL_PUBLIC echld_state_t echld_ping(int child_id, echld_ping_cb_t pcb, void* cb_data);
typedef void (*echld_list_interface_cb_t)(char* intf_name, char* params, void* cb_data);
-echld_state_t echld_list_interfaces(int child_id, echld_list_interface_cb_t, void* cb_data);
+WS_DLL_PUBLIC echld_state_t echld_list_interfaces(int child_id, echld_list_interface_cb_t, void* cb_data);
typedef void (*echild_get_packet_summary_cb_t)(char* summary, void* data);
-echld_state_t echld_open_file(int child_id, const char* filename,echild_get_packet_summary_cb_t,void*);
+WS_DLL_PUBLIC echld_state_t echld_open_file(int child_id, const char* filename,echild_get_packet_summary_cb_t,void*);
-echld_state_t echld_open_interface(int child_id, const char* intf_name, const char* params);
-echld_state_t echld_start_capture(int child_id, echild_get_packet_summary_cb_t);
-echld_state_t echld_stop_capture(int child_id);
+WS_DLL_PUBLIC echld_state_t echld_open_interface(int child_id, const char* intf_name, const char* params);
+WS_DLL_PUBLIC echld_state_t echld_start_capture(int child_id, echild_get_packet_summary_cb_t);
+WS_DLL_PUBLIC echld_state_t echld_stop_capture(int child_id);
typedef void (*echild_get_packets_cb)(char* tree_text,void* data);
typedef void (*echild_get_buffer_cb)(char* buffer_text, void* data);
-echld_state_t echld_get_packets_range(int child_id, const char* range, echild_get_packets_cb, echild_get_buffer_cb, void* data);
+WS_DLL_PUBLIC echld_state_t echld_get_packets_range(int child_id, const char* range, echild_get_packets_cb, echild_get_buffer_cb, void* data);
+#endif
diff --git a/echld/echld.h b/echld/echld.h
index b35f2b58ac..77738213b6 100644
--- a/echld/echld.h
+++ b/echld/echld.h
@@ -27,6 +27,8 @@
#ifndef __ECHLD_H
#define __ECHLD_H
+#include "ws_symbol_export.h"
+
#define ECHLD_VERSION "0.0"
#define ECHLD_MAJOR_VERSION 0 /* increases when existing things change */
/* if this changes an old client may or may not work */
@@ -72,10 +74,10 @@ typedef int echld_bool_t;
typedef struct timeval tv_t;
/* will initialize epan registering protocols and taps */
-void echld_initialize(echld_encoding_t);
+WS_DLL_PUBLIC void echld_initialize(echld_encoding_t);
/* cleans up (?) echld and kills the server process(es) */
-echld_state_t echld_terminate(void);
+WS_DLL_PUBLIC echld_state_t echld_terminate(void);
/*
* returning ECHLD_NO_ERROR means there has being no error
@@ -86,23 +88,23 @@ echld_state_t echld_terminate(void);
* for managing asyncronous errors use a msgh for ECHLD_ERROR
* the response cb of reqh might be a ECHLD_ERROR message
*/
-echld_error_t echld_get_error(const char** errstr_ptr);
+WS_DLL_PUBLIC echld_error_t echld_get_error(const char** errstr_ptr);
/*
* Children Management Operations
*/
/* create a new worker process */
-echld_chld_id_t echld_new(void* child_data);
+WS_DLL_PUBLIC echld_chld_id_t echld_new(void* child_data);
/* will return NULL on error, if NULL is also ok for you use echld_get_error() */
-void* echld_get_data(echld_chld_id_t);
+WS_DLL_PUBLIC void* echld_get_data(echld_chld_id_t);
-echld_state_t echld_set_data(echld_chld_id_t id, void* child_data);
+WS_DLL_PUBLIC echld_state_t echld_set_data(echld_chld_id_t id, void* child_data);
/* for each child call cb(id,child_data,cb_data) */
typedef echld_bool_t (*echld_iter_cb_t)(echld_chld_id_t, void* child_data, void* cb_data);
-void echld_foreach_child(echld_iter_cb_t cb, void* cb_data);
+WS_DLL_PUBLIC void echld_foreach_child(echld_iter_cb_t cb, void* cb_data);
/* enc_msg_t is an obscure object for an encoded message */
typedef struct _GByteArray enc_msg_t;
@@ -145,14 +147,14 @@ typedef struct _parent_out {
enc_msg_t* (*save_file)(const char* filename, const char* params);
} echld_parent_encoder_t;
-echld_parent_encoder_t* echld_get_encoder(void);
+WS_DLL_PUBLIC echld_parent_encoder_t* echld_get_encoder(void);
/*
* decoder
* it returns an allocated string with the decoded response of the message, you free it.
* it destroys the enc_msg_t as well.
*/
-char* echld_decode(echld_msg_type_t, enc_msg_t*);
+WS_DLL_PUBLIC char* echld_decode(echld_msg_type_t, enc_msg_t*);
/*
* Request Handlers
@@ -165,28 +167,28 @@ char* echld_decode(echld_msg_type_t, enc_msg_t*);
* resp_cb is the callback and cb_data the data it is going to be passed if executed
*
* returns the reqh id */
-echld_reqh_id_t echld_reqh(echld_chld_id_t, echld_msg_type_t, int usecs_timeout, enc_msg_t*, echld_msg_cb_t, void*);
+WS_DLL_PUBLIC echld_reqh_id_t echld_reqh(echld_chld_id_t, echld_msg_type_t, int usecs_timeout, enc_msg_t*, echld_msg_cb_t, void*);
/* get callback data for a live request */
-void* echld_reqh_get_data(echld_chld_id_t, echld_reqh_id_t);
+WS_DLL_PUBLIC void* echld_reqh_get_data(echld_chld_id_t, echld_reqh_id_t);
/* get the total timeout time for a live request, -1 is err */
-int echld_reqh_get_to(echld_chld_id_t, echld_reqh_id_t);
+WS_DLL_PUBLIC int echld_reqh_get_to(echld_chld_id_t, echld_reqh_id_t);
/* get the remaining timeout time for a live request, -1 is err */
-int echld_reqh_get_remaining_to(echld_chld_id_t, echld_reqh_id_t);
+WS_DLL_PUBLIC int echld_reqh_get_remaining_to(echld_chld_id_t, echld_reqh_id_t);
/* get the callback for a live request */
-echld_msg_cb_t echld_reqh_get_cb(echld_chld_id_t, echld_reqh_id_t);
+WS_DLL_PUBLIC echld_msg_cb_t echld_reqh_get_cb(echld_chld_id_t, echld_reqh_id_t);
/* set callback data for a live request */
-echld_state_t echld_reqh_set_data(echld_chld_id_t, echld_reqh_id_t, void* );
+WS_DLL_PUBLIC echld_state_t echld_reqh_set_data(echld_chld_id_t, echld_reqh_id_t, void* );
/* get the callback for a live request */
-echld_state_t echld_reqh_set_cb(echld_chld_id_t, echld_reqh_id_t, echld_msg_cb_t);
+WS_DLL_PUBLIC echld_state_t echld_reqh_set_cb(echld_chld_id_t, echld_reqh_id_t, echld_msg_cb_t);
/* stop receiving a live request */
-echld_state_t echld_reqh_detach(echld_chld_id_t, echld_reqh_id_t);
+WS_DLL_PUBLIC echld_state_t echld_reqh_detach(echld_chld_id_t, echld_reqh_id_t);
/*
@@ -195,34 +197,34 @@ echld_state_t echld_reqh_detach(echld_chld_id_t, echld_reqh_id_t);
*/
/* start a message handler */
-echld_msgh_id_t echld_msgh(echld_chld_id_t, echld_msg_type_t, echld_msg_cb_t resp_cb, void* msg_data);
+WS_DLL_PUBLIC echld_msgh_id_t echld_msgh(echld_chld_id_t, echld_msg_type_t, echld_msg_cb_t resp_cb, void* msg_data);
/* stop it */
-echld_state_t echld_msgh_detach(echld_chld_id_t, echld_msgh_id_t);
+WS_DLL_PUBLIC echld_state_t echld_msgh_detach(echld_chld_id_t, echld_msgh_id_t);
/* get a msgh's data */
-void* echld_msgh_get_data(echld_chld_id_t, echld_msgh_id_t);
+WS_DLL_PUBLIC void* echld_msgh_get_data(echld_chld_id_t, echld_msgh_id_t);
/* get a msgh's cb */
-echld_msg_cb_t echld_msgh_get_cb(echld_chld_id_t, echld_msgh_id_t);
+WS_DLL_PUBLIC echld_msg_cb_t echld_msgh_get_cb(echld_chld_id_t, echld_msgh_id_t);
/* get a msgh's type */
-echld_msg_type_t echld_msgh_get_type(echld_chld_id_t, echld_msgh_id_t);
+WS_DLL_PUBLIC echld_msg_type_t echld_msgh_get_type(echld_chld_id_t, echld_msgh_id_t);
/* get it all from a msgh */
-echld_state_t echld_msgh_get_all(echld_chld_id_t, int msgh_id, echld_msg_type_t*, echld_msg_cb_t*, void**);
+WS_DLL_PUBLIC echld_state_t echld_msgh_get_all(echld_chld_id_t, int msgh_id, echld_msg_type_t*, echld_msg_cb_t*, void**);
/* set a msgh's data */
-echld_state_t echld_msgh_set_data(echld_chld_id_t, int msgh_id, void* );
+WS_DLL_PUBLIC echld_state_t echld_msgh_set_data(echld_chld_id_t, int msgh_id, void* );
/* set a msgh's cb */
-echld_state_t echld_msgh_set_cb(echld_chld_id_t, int msgh_id, echld_msg_cb_t);
+WS_DLL_PUBLIC echld_state_t echld_msgh_set_cb(echld_chld_id_t, int msgh_id, echld_msg_cb_t);
/* set a msgh's type */
-echld_state_t echld_msgh_set_type(echld_chld_id_t, int msgh_id, echld_msg_type_t);
+WS_DLL_PUBLIC echld_state_t echld_msgh_set_type(echld_chld_id_t, int msgh_id, echld_msg_type_t);
/* set all elements of a msgh */
-echld_state_t echld_msgh_set_all(echld_chld_id_t, int msgh_id, echld_msg_type_t, echld_msg_cb_t, void*);
+WS_DLL_PUBLIC echld_state_t echld_msgh_set_all(echld_chld_id_t, int msgh_id, echld_msg_type_t, echld_msg_cb_t, void*);
@@ -236,7 +238,7 @@ echld_state_t echld_msgh_set_all(echld_chld_id_t, int msgh_id, echld_msg_type_t,
*
* returns ECHLD_TIMEOUT or ECHLD_OK if something was done
*/
-echld_state_t echld_wait(tv_t* timeout);
+WS_DLL_PUBLIC echld_state_t echld_wait(tv_t* timeout);
#define ECHLD_WAIT() do { struct timeval tv; int rfds, efds; \
echld_select(echld_fdset(&rfds, &efds),&rfds, NULL, &efds, NULL) \
@@ -246,16 +248,16 @@ echld_state_t echld_wait(tv_t* timeout);
to be used in place of select() in the main loop of the parent code
it will serve the children pipes and return as if select() was called.
*/
-int echld_select(int nfds, fd_set* rfds, fd_set* wfds, fd_set* efds, tv_t* timeout);
+WS_DLL_PUBLIC int echld_select(int nfds, fd_set* rfds, fd_set* wfds, fd_set* efds, tv_t* timeout);
/* or fit these two in your select loop */
/* returns nfds set */
-int echld_fdset(fd_set* rfds, fd_set* efds);
+WS_DLL_PUBLIC int echld_fdset(fd_set* rfds, fd_set* efds);
-int echld_fd_read(fd_set* rfds, fd_set* efds);
+WS_DLL_PUBLIC int echld_fd_read(fd_set* rfds, fd_set* efds);
-void echld_set_parent_dbg_level(int lvl);
+WS_DLL_PUBLIC void echld_set_parent_dbg_level(int lvl);
#define ECHLD_MAX_CHILDREN 32
diff --git a/echld/echld_child.c b/echld/echld_child.c
index 121284af8b..b603d3464a 100644
--- a/echld/echld_child.c
+++ b/echld/echld_child.c
@@ -534,3 +534,10 @@ int echld_child_loop(void) {
}
+extern void echld_unused(void) {
+ intflist2json(NULL);
+ child_start_interface_listing();
+ child_open_file(0, 0, NULL, NULL, 0);
+ child_open_interface(0, 0, NULL, NULL, NULL, 0);
+}
+
diff --git a/echld/echld_common.c b/echld/echld_common.c
index 74846baf9c..c078af5fd7 100644
--- a/echld/echld_common.c
+++ b/echld/echld_common.c
@@ -722,3 +722,9 @@ extern void dummy_switch(echld_msg_type_t type) {
case EC_ACTUAL_ERROR: break;
}
}
+
+static void* unused = int_deca;
+
+extern void unused_things(void) {
+ unused = NULL;
+}
diff --git a/echld/echld_parent.c b/echld/echld_parent.c
index be2cb99d92..466120f46a 100644
--- a/echld/echld_parent.c
+++ b/echld/echld_parent.c
@@ -95,7 +95,7 @@ static void parent_dbg(int level, const char* fmt, ...) {
#define PARENT_DBG(attrs)
#endif
-void echld_set_parent_dbg_level(int lvl) {
+extern void echld_set_parent_dbg_level(int lvl) {
PARENT_DBG((0,"Debug Level Set: %d",(dbg_level = lvl)));
}
@@ -238,7 +238,7 @@ void echld_initialize(echld_encoding_t enc) {
}
-echld_state_t echld_terminate(void) {
+extern echld_state_t echld_terminate(void) {
echld_cleanup();
return TRUE;
}
@@ -295,7 +295,7 @@ static echld_state_t reqh_snd(echld_t* c, echld_msg_type_t t, GByteArray* ba, ec
}
-echld_reqh_id_t echld_reqh(
+extern echld_reqh_id_t echld_reqh(
echld_chld_id_t child_id,
echld_msg_type_t t,
int usecs_timeout,
@@ -307,7 +307,7 @@ echld_reqh_id_t echld_reqh(
}
/* get callback data for a live request */
-void* echld_reqh_get_data(int child_id, int reqh_id) {
+extern void* echld_reqh_get_data(int child_id, int reqh_id) {
echld_t* c = get_child(child_id);
int idx;
@@ -322,7 +322,7 @@ void* echld_reqh_get_data(int child_id, int reqh_id) {
}
/* get the callback for a live request */
-echld_msg_cb_t echld_reqh_get_cb(int child_id, int reqh_id) {
+extern echld_msg_cb_t echld_reqh_get_cb(int child_id, int reqh_id) {
echld_t* c = get_child(child_id);
int idx;
@@ -337,7 +337,7 @@ echld_msg_cb_t echld_reqh_get_cb(int child_id, int reqh_id) {
}
/* set callback data for a live request */
-gboolean echld_reqh_set_data(int child_id, int reqh_id, void* cb_data) {
+extern gboolean echld_reqh_set_data(int child_id, int reqh_id, void* cb_data) {
echld_t* c = get_child(child_id);
int idx;
@@ -353,7 +353,7 @@ gboolean echld_reqh_set_data(int child_id, int reqh_id, void* cb_data) {
}
/* get the callback for a live request */
-gboolean echld_reqh_set_cb(int child_id, int reqh_id, echld_msg_cb_t cb){
+extern gboolean echld_reqh_set_cb(int child_id, int reqh_id, echld_msg_cb_t cb){
echld_t* c = get_child(child_id);
int idx;
@@ -369,7 +369,7 @@ gboolean echld_reqh_set_cb(int child_id, int reqh_id, echld_msg_cb_t cb){
/* stop receiving a live request */
-gboolean echld_reqh_detach(int child_id, int reqh_id) {
+extern gboolean echld_reqh_detach(int child_id, int reqh_id) {
echld_t* c = get_child(child_id);
int idx;
@@ -428,7 +428,7 @@ int chld_cmp(const void *a, const void *b) {
static int msgh_attach(echld_t* c, echld_msg_type_t t, echld_msg_cb_t resp_cb, void* cb_data);
-int echld_new(void* child_data) {
+extern int echld_new(void* child_data) {
int next_chld_id = 1;
echld_t* c = get_child(-1);
@@ -454,12 +454,12 @@ int echld_new(void* child_data) {
/* XXX these fail silently */
-void* echld_get_data(int child_id) {
+extern void* echld_get_data(int child_id) {
echld_t* c = get_child(child_id);
return c ? c->data : NULL;
}
-echld_state_t echld_set_data(echld_chld_id_t chld_id, void* data) {
+extern echld_state_t echld_set_data(echld_chld_id_t chld_id, void* data) {
echld_t* c = get_child(chld_id);
if (c) {
c->data = data;
@@ -494,7 +494,7 @@ static int msgh_attach(echld_t* c, echld_msg_type_t t, echld_msg_cb_t resp_cb, v
return 0;
}
-int echld_msgh(int child_id, echld_msg_type_t t, echld_msg_cb_t resp_cb, void* cb_data) {
+extern int echld_msgh(int child_id, echld_msg_type_t t, echld_msg_cb_t resp_cb, void* cb_data) {
echld_t* c = get_child(child_id);
if (c) return msgh_attach(c,t,resp_cb,cb_data);
@@ -513,7 +513,7 @@ static echld_state_t msgh_detach(echld_t* c, int msgh_id) {
return 1;
}
-echld_state_t echld_msgh_detach(int child_id, int msgh_id) {
+extern echld_state_t echld_msgh_detach(int child_id, int msgh_id) {
echld_t* c = get_child(child_id);
return msgh_detach(c,msgh_id);
}
@@ -528,7 +528,7 @@ static void* msgh_get_data(echld_t* c, int msgh_id) {
return ((hdlr_t*)(c->handlers->data))[idx].cb_data;
}
-void* echld_msgh_get_data(int child_id, int msgh_id) {
+extern void* echld_msgh_get_data(int child_id, int msgh_id) {
echld_t* c = get_child(child_id);
return msgh_get_data(c,msgh_id);
}
@@ -542,7 +542,7 @@ static echld_msg_cb_t msgh_get_cb(echld_t* c, int msgh_id) {
return ((hdlr_t*)(c->handlers->data))[idx].cb;
}
-echld_msg_cb_t echld_msgh_get_cb(int child_id, int msgh_id) {
+extern echld_msg_cb_t echld_msgh_get_cb(int child_id, int msgh_id) {
echld_t* c = get_child(child_id);
return msgh_get_cb(c,msgh_id);
}
@@ -556,7 +556,7 @@ static echld_msg_type_t msgh_get_type(echld_t* c, int msgh_id) {
return ((hdlr_t*)(c->handlers->data))[idx].type;
}
-echld_msg_type_t echld_msgh_get_type(int child_id, int msgh_id) {
+extern echld_msg_type_t echld_msgh_get_type(int child_id, int msgh_id) {
echld_t* c = get_child(child_id);
return c ? msgh_get_type(c,msgh_id) : EC_ACTUAL_ERROR;
}
@@ -577,7 +577,7 @@ static echld_state_t msgh_get_all(echld_t* c, int msgh_id, echld_msg_type_t* t,
return 0;
}
-gboolean echld_msgh_get_all(int child_id, int msgh_id, echld_msg_type_t* t, echld_msg_cb_t* cb, void** data) {
+extern gboolean echld_msgh_get_all(int child_id, int msgh_id, echld_msg_type_t* t, echld_msg_cb_t* cb, void** data) {
echld_t* c = get_child(child_id);
return c && msgh_get_all(c,msgh_id,t,cb,data);
}
@@ -597,7 +597,7 @@ static echld_state_t msgh_set_all(echld_t* c, int msgh_id, echld_msg_type_t t, e
return 0;
}
-gboolean echld_msgh_set_all(int child_id, int msgh_id, echld_msg_type_t t, echld_msg_cb_t cb, void* data) {
+extern gboolean echld_msgh_set_all(int child_id, int msgh_id, echld_msg_type_t t, echld_msg_cb_t cb, void* data) {
echld_t* c = get_child(child_id);
return c ? msgh_set_all(c,msgh_id,t,cb,data) : FALSE;
}
@@ -614,13 +614,13 @@ static gboolean msgh_set_data(echld_t* c, int msgh_id, void* data) {
}
-gboolean echld_msgh_set_data(int child_id, int msgh_id, void* data){
+extern gboolean echld_msgh_set_data(int child_id, int msgh_id, void* data){
echld_t* c = get_child(child_id);
return c ? msgh_set_data(c,msgh_id,data) : FALSE;
}
/* set a msgh's cb */
-gboolean msgh_set_cb(echld_t* c, int msgh_id, echld_msg_cb_t cb) {
+extern gboolean msgh_set_cb(echld_t* c, int msgh_id, echld_msg_cb_t cb) {
int idx = msgh_idx(c,msgh_id);
if (idx < 0) return FALSE;
@@ -630,7 +630,7 @@ gboolean msgh_set_cb(echld_t* c, int msgh_id, echld_msg_cb_t cb) {
return TRUE;
}
-gboolean echld_msgh_set_cb(int child_id, int msgh_id, echld_msg_cb_t cb) {
+extern gboolean echld_msgh_set_cb(int child_id, int msgh_id, echld_msg_cb_t cb) {
echld_t* c = get_child(child_id);
return c ? msgh_set_cb(c,msgh_id,cb) : FALSE;
}
@@ -647,14 +647,14 @@ static gboolean msgh_set_type(echld_t* c, int msgh_id, echld_msg_type_t t) {
return TRUE;
}
-gboolean echld_msgh_set_type(int child_id, int msgh_id, echld_msg_type_t t) {
+extern gboolean echld_msgh_set_type(int child_id, int msgh_id, echld_msg_type_t t) {
echld_t* c = get_child(child_id);
return c ? msgh_set_type(c,msgh_id,t) : FALSE;
}
/* call cb(id,child_data,cb_data) for each child*/
-void echld_foreach_child(echld_iter_cb_t cb, void* cb_data) {
+extern void echld_foreach_child(echld_iter_cb_t cb, void* cb_data) {
int i;
for(i=0;i<ECHLD_MAX_CHILDREN;i++) {
echld_t* c = &(parent.children[i]);
@@ -707,14 +707,14 @@ static long parent_read_frame(guint8* b, size_t len, echld_chld_id_t chld_id, ec
return 1;
}
-int echld_fdset(fd_set* rfds, fd_set* efds) {
+extern int echld_fdset(fd_set* rfds, fd_set* efds) {
FD_SET(parent.reader.fd, rfds);
FD_SET(parent.reader.fd, efds);
FD_SET(parent.dispatcher_fd, efds);
return 2;
}
-int echld_fd_read(fd_set* rfds, fd_set* efds) {
+extern int echld_fd_read(fd_set* rfds, fd_set* efds) {
int r_nfds=0;
if (FD_ISSET(parent.reader.fd,efds) || FD_ISSET(parent.dispatcher_fd,efds) ) {
/* Handle errored dispatcher */
@@ -730,7 +730,7 @@ int echld_fd_read(fd_set* rfds, fd_set* efds) {
return r_nfds;
}
-int echld_select(int nfds, fd_set* rfds, fd_set* wfds, fd_set* efds, struct timeval* timeout) {
+extern int echld_select(int nfds, fd_set* rfds, fd_set* wfds, fd_set* efds, struct timeval* timeout) {
fd_set my_rfds, my_wfds, my_efds;
int r_nfds;
@@ -747,22 +747,10 @@ int echld_select(int nfds, fd_set* rfds, fd_set* wfds, fd_set* efds, struct time
return r_nfds ;
}
-echld_state_t echld_wait(struct timeval* timeout) {
+extern echld_state_t echld_wait(struct timeval* timeout) {
if ( echld_select(0, NULL, NULL, NULL, timeout) < 0) {
return -1;
} else {
return ECHLD_OK;
}
}
-
-
-
-
-
-/* Ping the child */
-
-
-
-
-
-
diff --git a/echld/echld_test.c b/echld/echld_test.c
deleted file mode 100644
index 525c95a001..0000000000
--- a/echld/echld_test.c
+++ /dev/null
@@ -1,100 +0,0 @@
-/* echld-test.c
- * basic test framework for echld
- *
- * $Id$
- *
- * Wireshark - Network traffic analyzer
- * By Gerald Combs <gerald@wireshark.org>
- * Copyright 1998 Gerald Combs
- *
- * Copyright (c) 2013 by Luis Ontanon <luis@ontanon.org>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include "config.h"
-
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
-
-#ifdef HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-
-#include <sys/time.h>
-#include <sys/uio.h>
-
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
-#include "echld.h"
-#include "echld-util.h"
-
-#include <signal.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-
-int pings = 0;
-int errors = 0;
-
-void ping_cb(long usec, void* data _U_) {
- if (usec > 0) {
- fprintf(stderr, "ping=%d usec=%d\n", pings ,(int)usec );
- pings++;
- } else {
- errors++;
- }
-}
-
-
-int main(int argc, char** argv) {
- struct timeval tv;
- int tot_cycles = 0;
- int npings;
-
- tv.tv_sec = 0;
- tv.tv_usec = 250000;
-
-
- switch(argc) {
- case 1:
- npings = 10;
- break;
- case 2:
- npings = (int)atoi(argv[1]);
- break;
- default:
- fprintf(stderr, "usage: %s [num pings, default=10]\n",argv[0]);
- return 1;
- }
-
- echld_initialize(ECHLD_ENCODING_JSON);
-
-
- do {
- if (tot_cycles < npings) echld_ping(0,ping_cb,NULL);
- tot_cycles++;
- } while( pings < 10 && tot_cycles < 25 && echld_wait(&tv));
-
- fprintf(stderr, "Done: pings=%d errors=%d tot_cycles=%d\n", pings, errors ,tot_cycles );
-
- echld_terminate();
- return 0;
-}
-
-