From f4651ea9cab69977883da1adf7ce12688bc0ad51 Mon Sep 17 00:00:00 2001 From: Tuka Martin Date: Tue, 24 Apr 2012 02:31:17 +0200 Subject: [PATCH] fwp: Corrected receiver demo Removed receive() function (All in main() function) Marked TODO lines for unfinished tasks --- src/fwp/fwp/demo/receiver.c | 75 +++++++++++++++++++------------------ 1 file changed, 38 insertions(+), 37 deletions(-) diff --git a/src/fwp/fwp/demo/receiver.c b/src/fwp/fwp/demo/receiver.c index 3821efef..8a6a344a 100644 --- a/src/fwp/fwp/demo/receiver.c +++ b/src/fwp/fwp/demo/receiver.c @@ -14,51 +14,32 @@ #include #include #include - -char msg[MSGBUFFSIZE]; - -frsh_resource_id_t resource_id = TEST_RESOURCE_ID; -frsh_stream_id_t stream_id = TEST_STREAM_ID; -long int num_msg = TEST_NUM_MSG; -size_t msg_size = MSGBUFFSIZE; -int receiver() +#include "fwp_confdefs.h" +#include "fwp.h" + +int main(int argc, char* argv[]) { + int opt; + opterr = 0; + bool opt_daemon = false; + char *opt_pidfile = NULL; size_t len; frsh_receive_endpoint_t repoint; int count; - frsh_network_address_t from; frsh_receive_endpoint_protocol_info_t recv_pinfo; - frsh_endpoint_queueing_info_t qinfo; - - recv_pinfo.body = NULL; + //frsh_endpoint_queueing_info_t qinfo; + //frsh_resource_id_t resource_id = TEST_RESOURCE_ID; + frsh_stream_id_t stream_id = TEST_STREAM_ID; + long int num_msg = TEST_NUM_MSG; + size_t msg_size = MSGBUFFSIZE; + char msg[MSGBUFFSIZE]; - /* local_addr should be handled when creating socket */ - //TODO: Segmentation fault in wvtest.sh file after calling WVPASSNE - //WVPASSNE(frsh_receive_endpoint_create(resource_id, stream_id, qinfo, recv_pinfo, &repoint), 0); - if (frsh_receive_endpoint_create(resource_id, stream_id, qinfo, recv_pinfo, - &repoint) != 0){ - return 0; - } - count = 0; - while (count != num_msg){ - count++; - WVPASSEQ(frsh_receive_sync(repoint, msg, msg_size, &len, &from), msg_size); - } - - /* TODO: destroy vres and send enpoint */ - - return 1; -} - -int main(int argc, char* argv[]) -{ - int opt; - opterr = 0; + recv_pinfo.body = NULL; - bool opt_daemon = false; - char *opt_pidfile = NULL; + fwp_endpoint_attr_t attr; + fwp_endpoint_attr_init(&attr); while ((opt = getopt (argc, argv, "e:p:m:")) != -1) { @@ -83,7 +64,27 @@ int main(int argc, char* argv[]) forb_daemon_prepare(opt_pidfile); WVFRSH(frsh_init()); - WVPASSEQ(receiver(), 1); + + /* local_addr should be handled when creating socket */ + //TODO: Segmentation fault in wvtest.sh file after calling WVPASSNE + //WVPASSNE(frsh_receive_endpoint_create(resource_id, stream_id, qinfo, recv_pinfo, &repoint), 0); + //if (frsh_receive_endpoint_create(resource_id, stream_id, qinfo, recv_pinfo, + // &repoint) != 0){ + // printf("Receive endpoint not created\n"); + // return -1; + //} + //TODO: Change to FRSH_RECEIVE function + if (fwp_receive_endpoint_create(stream_id, &attr, &repoint) < 0){ + return -1; + } + printf("Receive endpoint created\n"); + + count = 0; + while (count != num_msg){ + count++; + //TODO: Check return value & add WVTEST macro + frsh_receive_sync(repoint, msg, msg_size, &len, &from); + } return 0; } -- 2.39.2