00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #include <biosphere_module.h>
00036
00037 #include <stdio.h>
00038 #include <string.h>
00039 #include <stdlib.h>
00040 #include <sys/time.h>
00041 #include <unistd.h>
00042
00049 bs_module bsmod_symtable;
00050
00051
00055 static bs_status bsmod_dummy_init(void)
00056 {
00057 printf("dummy module initializing!\n");
00058 return BS_OK;
00059 }
00060
00061
00065 static bs_status bsmod_dummy_cleanup(void)
00066 {
00067 printf("shutting bsmod_dummy down!\n");
00068 return BS_OK;
00069 }
00070
00071
00072 static bs_service_response *create_response(const bs_service_request *request)
00073 {
00074 bs_service_response *resp;
00075 bs_message_instance *output;
00076 bs_part_instance *part;
00077 bs_data_type *type;
00078 unsigned i;
00079 char *string;
00080
00081 string = request->input->parts[0]->data;
00082
00083 resp = (bs_service_response *) calloc(1, sizeof(bs_service_response));
00084 for (i = 0; i < 16; i++)
00085 resp->uuid[i] = request->uuid[i];
00086 resp->service = (char *) malloc(strlen(request->service) + 1);
00087 resp->port = (char *) malloc(strlen(request->port) + 1);
00088 resp->operation = (char *) malloc(strlen(request->operation) + 1);
00089 strcpy(resp->service, request->service);
00090 strcpy(resp->port, request->port);
00091 strcpy(resp->operation, request->operation);
00092
00093 output = (bs_message_instance *) calloc(1, sizeof(bs_service_response));
00094 output->name = (char *) malloc(strlen("EchoResponse") + 1);
00095 strcpy(output->name, "EchoResponse");
00096 output->num_parts = 1;
00097 output->parts = (bs_part_instance **) calloc(1, sizeof(bs_part_instance *));
00098 resp->output = output;
00099
00100 part = (bs_part_instance *) calloc(1, sizeof(bs_part_instance));
00101 part->name = (char *) malloc(strlen("") + 1);
00102 strcpy(part->name, "return");
00103 part->data = (char *) calloc(1, strlen(string) + 1);
00104 strcpy(part->data, string);
00105 part->size = strlen(string);
00106 output->parts[0] = part;
00107
00108 type = (bs_data_type *) calloc(1, sizeof(bs_data_type));
00109 type->name = (char *) malloc(strlen("bs_string") + 1);
00110 strcpy(type->name, "bs_string");
00111 type->builtin = TRUE;
00112 type->from_mp = FALSE;
00113 part->type = type;
00114
00115 return resp;
00116 }
00117
00118
00122 static bs_status bsmod_dummy_handle_service(
00123 const bs_service_request *request,
00124 bs_service_response **response, void *extra)
00125 {
00126 struct timeval t;
00127
00128 gettimeofday(&t, 0);
00129 printf("%ld.%06ld,", t.tv_sec, t.tv_usec);
00130
00131 *response = create_response(request);
00132
00133 gettimeofday(&t, 0);
00134 printf("%ld.%06ld,", t.tv_sec, t.tv_usec);
00135 return BS_OK;
00136 }
00137
00138
00139
00140
00141
00142 bs_module bsmod_symtable = {
00143
00144 0,
00145 0,
00146
00147
00148 0,
00149 1,
00150
00151
00152 "dummy module",
00153 "M.A.Hartman",
00154 "jan 25, 2007",
00155 "(c) 2007, M.A.Hartman. See distributed LICENSE file for more information.",
00156 "A dummy module to illustrate the basic workings of a Bio-SPHERE module. "
00157 "It has basically no functionality and contains just the bare minimum "
00158 "required in a module.",
00159
00160
00161 bsmod_dummy_init,
00162 bsmod_dummy_cleanup,
00163
00164
00165 bsmod_dummy_handle_service,
00166 NULL,
00167 "bsmod_dummy.wsdl"
00168 };
00169