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 #ifndef _WIN32
00035 #include "config.h"
00036 #else
00037 #include "winconfig.h"
00038 #endif
00039
00040 #include <stdio.h>
00041 #include <stdlib.h>
00042 #include <string.h>
00043 #ifndef _WIN32
00044 #include <strings.h>
00045 #else
00046 #define strcasecmp(a, b) \
00047 _stricmp(a, b)
00048 #endif
00049 #include "include/fipa_acl.h"
00050 #include "include/mc_error.h"
00051 #include "include/macros.h"
00052
00053 #define FREEMEM(x) \
00054 if (x != NULL) free(x)
00055
00056
00057 fipa_acl_message_t* fipa_acl_message_New(void)
00058 {
00059 fipa_acl_message_t* acl;
00060 acl = (fipa_acl_message_t*)malloc(sizeof(fipa_acl_message_t));
00061 memset(acl, 0, sizeof(fipa_acl_message_t));
00062 return acl;
00063 }
00064
00065 int fipa_acl_message_Destroy(fipa_acl_message_t* message)
00066 {
00067
00068 if (message == NULL) return 0;
00069 fipa_agent_identifier_Destroy(message->sender);
00070 fipa_agent_identifier_set_Destroy(message->receiver);
00071 fipa_agent_identifier_set_Destroy(message->reply_to);
00072 fipa_string_Destroy(message->content);
00073 fipa_expression_Destroy(message->language);
00074 fipa_expression_Destroy(message->encoding);
00075 fipa_expression_Destroy(message->ontology);
00076 fipa_word_Destroy(message->protocol);
00077 fipa_expression_Destroy(message->conversation_id);
00078 fipa_expression_Destroy(message->reply_with);
00079 fipa_expression_Destroy(message->in_reply_to);
00080 fipa_DateTime_Destroy(message->reply_by);
00081
00082 free(message);
00083 return 0;
00084 }
00085
00086 fipa_acl_message_t* fipa_acl_message_Copy(fipa_acl_message_t* src)
00087 {
00088 fipa_acl_message_t* copy;
00089 if (src == NULL) return NULL;
00090 copy = fipa_acl_message_New();
00091 copy->performative = src->performative;
00092 copy->sender = fipa_agent_identifier_Copy(src->sender);
00093 copy->receiver = fipa_agent_identifier_set_Copy(src->receiver);
00094 copy->reply_to = fipa_agent_identifier_set_Copy(src->reply_to);
00095 copy->content = fipa_string_Copy(src->content);
00096 copy->language = fipa_expression_Copy(src->language);
00097 copy->encoding = fipa_expression_Copy(src->encoding);
00098 copy->ontology = fipa_expression_Copy(src->ontology);
00099 copy->protocol = fipa_word_Copy(src->protocol);
00100 copy->conversation_id = fipa_expression_Copy(src->conversation_id);
00101 copy->reply_with = fipa_expression_Copy(src->reply_with);
00102 copy->in_reply_to = fipa_expression_Copy(src->in_reply_to);
00103 copy->reply_by = fipa_DateTime_Copy(src->reply_by);
00104
00105 return copy;
00106 }
00107
00108
00109 fipa_message_string_t* fipa_message_string_New(void)
00110 {
00111 fipa_message_string_t* str;
00112 str = (fipa_message_string_t*)malloc(sizeof(fipa_message_string_t));
00113 memset(str, 0, sizeof(fipa_message_string_t));
00114 return str;
00115 }
00116
00117 int fipa_message_string_Destroy(fipa_message_string_t* message)
00118 {
00119 if (message == NULL) return 0;
00120 if (message->message != NULL) {
00121 free(message->message);
00122 }
00123 free(message);
00124 return 0;
00125 }
00126
00127 fipa_message_string_t* fipa_message_string_Copy(fipa_message_string_t* src)
00128 {
00129 fipa_message_string_t* copy;
00130 if (src == NULL) return NULL;
00131 copy->message = strdup(src->message);
00132 copy->parse = copy->message + (src->parse - src->message);
00133 return copy;
00134 }
00135
00136
00137 fipa_url_sequence_t* fipa_url_sequence_New(void)
00138 {
00139 fipa_url_sequence_t* sequence;
00140 sequence = (fipa_url_sequence_t*)malloc(sizeof(fipa_url_sequence_t));
00141 memset(sequence, 0, sizeof(fipa_url_sequence_t));
00142 return sequence;
00143 }
00144
00145 int fipa_url_sequence_Destroy(fipa_url_sequence_t* sequence)
00146 {
00147 int i;
00148 if (sequence == NULL) return 0;
00149 for (i = 0; i < sequence->num; i++) {
00150 fipa_url_Destroy(sequence->urls[i]);
00151 }
00152 free(sequence->urls);
00153 free(sequence);
00154 return 0;
00155 }
00156
00157 fipa_url_sequence_t* fipa_url_sequence_Copy(fipa_url_sequence_t* src)
00158 {
00159 int i;
00160 fipa_url_sequence_t* copy;
00161 if (src == NULL) return NULL;
00162 copy = fipa_url_sequence_New();
00163 copy->num = src->num;
00164 copy->urls = (fipa_url_t**)malloc(
00165 sizeof(fipa_url_t*) * src->num);
00166 for( i = 0; i < src->num; i++) {
00167 copy->urls[i] = fipa_url_Copy(src->urls[i]);
00168 }
00169 return copy;
00170 }
00171
00172
00173 fipa_agent_identifier_set_t* fipa_agent_identifier_set_New(void)
00174 {
00175 fipa_agent_identifier_set_t* set;
00176 set = (fipa_agent_identifier_set_t*)malloc(sizeof(fipa_agent_identifier_set_t));
00177 memset(set, 0, sizeof(fipa_agent_identifier_set_t));
00178 return set;
00179 }
00180
00181 int fipa_agent_identifier_set_Destroy(fipa_agent_identifier_set_t* idset)
00182 {
00183 int i;
00184 if (idset == NULL) return 0;
00185 for(i = 0; i < idset->num; i++) {
00186 fipa_agent_identifier_Destroy(idset->fipa_agent_identifiers[i]);
00187 }
00188 free(idset->fipa_agent_identifiers);
00189 free(idset);
00190 return 0;
00191 }
00192
00193 fipa_agent_identifier_set_t* fipa_agent_identifier_set_Copy(
00194 fipa_agent_identifier_set_t* src)
00195 {
00196 int i;
00197 fipa_agent_identifier_set_t* copy;
00198
00199 if (src == NULL) { return NULL; }
00200 copy = fipa_agent_identifier_set_New();
00201 copy->num = src->num;
00202 copy->retain_order = src->retain_order;
00203 copy->fipa_agent_identifiers = (fipa_agent_identifier_t**)malloc(
00204 sizeof(fipa_agent_identifier_t*) * src->num);
00205 for(i = 0; i < src->num; i++) {
00206 copy->fipa_agent_identifiers[i] = fipa_agent_identifier_Copy(
00207 src->fipa_agent_identifiers[i]);
00208 }
00209
00210 return copy;
00211 }
00212
00213
00214 fipa_agent_identifier_t* fipa_agent_identifier_New(void)
00215 {
00216 fipa_agent_identifier_t* id;
00217 id = (fipa_agent_identifier_t*)malloc(sizeof(fipa_agent_identifier_t));
00218 memset(id, 0, sizeof(fipa_agent_identifier_t));
00219 return id;
00220 }
00221
00222 int fipa_agent_identifier_Destroy(fipa_agent_identifier_t* id)
00223 {
00224 if (id == NULL) return 0;
00225 if (id->name != NULL) {
00226 free(id->name);
00227 }
00228 fipa_url_sequence_Destroy(id->addresses);
00229 fipa_agent_identifier_set_Destroy(id->resolvers);
00230 free(id);
00231 return 0;
00232 }
00233
00234 fipa_agent_identifier_t* fipa_agent_identifier_Copy(fipa_agent_identifier_t* src)
00235 {
00236 fipa_agent_identifier_t* copy;
00237 if (src == NULL) return NULL;
00238 copy = fipa_agent_identifier_New();
00239 copy->name = strdup(src->name);
00240 copy->addresses = fipa_url_sequence_Copy(src->addresses);
00241 copy->resolvers = fipa_agent_identifier_set_Copy(src->resolvers);
00242 return copy;
00243 }
00244
00245
00246 fipa_expression_t* fipa_expression_New(void)
00247 {
00248 fipa_expression_t* expr;
00249 expr = (fipa_expression_t*)malloc(sizeof(fipa_expression_t));
00250 memset(expr, 0, sizeof(fipa_expression_t));
00251 return expr;
00252 }
00253
00254 int fipa_expression_Destroy(fipa_expression_t* expr)
00255 {
00256 int i;
00257 if (expr == NULL) return 0;
00258 switch (expr->type) {
00259 case FIPA_EXPR_WORD:
00260 fipa_word_Destroy(expr->content.word);
00261 break;
00262 case FIPA_EXPR_STRING:
00263 fipa_string_Destroy(expr->content.string);
00264 break;
00265 case FIPA_EXPR_NUMBER:
00266 fipa_number_Destroy(expr->content.number);
00267 break;
00268 case FIPA_EXPR_DATETIME:
00269 fipa_DateTime_Destroy(expr->content.datetime);
00270 break;
00271 case FIPA_EXPR_EXPRESSION:
00272 if (expr->content.expression == NULL) break;
00273 for (i = 0; expr->content.expression[i] != NULL; i++) {
00274 fipa_expression_Destroy(expr->content.expression[i]);
00275 }
00276 FREEMEM(expr->content.expression);
00277 break;
00278 default:
00279 break;
00280 }
00281 free(expr);
00282 return 0;
00283 }
00284
00285 fipa_expression_t* fipa_expression_Copy(fipa_expression_t* src)
00286 {
00287 int i, num;
00288 fipa_expression_t* copy;
00289 if (src == NULL) return NULL;
00290 copy = fipa_expression_New();
00291 copy->type = src->type;
00292 switch(src->type) {
00293 case FIPA_EXPR_WORD:
00294 copy->content.word = fipa_word_Copy(src->content.word);
00295 break;
00296 case FIPA_EXPR_STRING:
00297 copy->content.string = fipa_string_Copy(src->content.string);
00298 break;
00299 case FIPA_EXPR_NUMBER:
00300 copy->content.number = fipa_number_Copy(src->content.number);
00301 break;
00302 case FIPA_EXPR_DATETIME:
00303 copy->content.datetime = fipa_DateTime_Copy(src->content.datetime);
00304 break;
00305 case FIPA_EXPR_EXPRESSION:
00306
00307 for(i = 0; src->content.expression[i] != NULL; i++);
00308
00309 num = i;
00310 copy->content.expression = (fipa_expression_t**)malloc(
00311 sizeof(fipa_expression_t*) * (num + 1));
00312 for(i = 0; i < num; i++) {
00313 copy->content.expression[i] = fipa_expression_Copy(
00314 src->content.expression[i] );
00315 }
00316 copy->content.expression[num] = NULL;
00317 break;
00318 default:
00319 fipa_expression_Destroy(copy);
00320 return NULL;
00321 }
00322 return copy;
00323 }
00324
00325
00326 fipa_word_t* fipa_word_New(void)
00327 {
00328 fipa_word_t* word;
00329 word = (fipa_word_t*)malloc(sizeof(fipa_word_t));
00330 memset(word, 0, sizeof(fipa_word_t));
00331 return word;
00332 }
00333
00334 int fipa_word_Destroy(fipa_word_t* word)
00335 {
00336 if (word == NULL) return 0;
00337 if (word->content != NULL) {
00338 free( word->content );
00339 }
00340 free(word);
00341 return 0;
00342 }
00343
00344 fipa_word_t* fipa_word_Copy(fipa_word_t* src)
00345 {
00346 fipa_word_t* copy;
00347 if (src == NULL) return NULL;
00348 copy = fipa_word_New();
00349 copy->content = strdup(src->content);
00350 return copy;
00351 }
00352
00353
00354 fipa_string_t* fipa_string_New(void)
00355 {
00356 fipa_string_t* str;
00357 str = (fipa_string_t*)malloc(sizeof(fipa_string_t));
00358 memset(str, 0, sizeof(fipa_string_t));
00359 return str;
00360 }
00361
00362 int fipa_string_Destroy(fipa_string_t* str)
00363 {
00364 if (str == NULL) return 0;
00365 if (str->content != NULL) {
00366 free(str->content);
00367 }
00368 free(str);
00369 return 0;
00370 }
00371
00372 fipa_string_t* fipa_string_Copy(fipa_string_t* src)
00373 {
00374 fipa_string_t* copy;
00375 if (src == NULL) return NULL;
00376 copy = fipa_string_New();
00377 copy->content = strdup(src->content);
00378 return copy;
00379 }
00380
00381
00382 fipa_DateTime_t* fipa_DateTime_New(void)
00383 {
00384 fipa_DateTime_t* dt;
00385 dt = (fipa_DateTime_t*)malloc(sizeof(fipa_DateTime_t));
00386 memset(dt, 0, sizeof(fipa_DateTime_t));
00387 return dt;
00388 }
00389
00390 int fipa_DateTime_Destroy(fipa_DateTime_t* dt)
00391 {
00392 if(dt == NULL) return 0;
00393 free(dt);
00394 return 0;
00395 }
00396
00397 fipa_DateTime_t* fipa_DateTime_Copy(fipa_DateTime_t* src)
00398 {
00399 fipa_DateTime_t* copy;
00400 if (src == NULL) return NULL;
00401 copy = fipa_DateTime_New();
00402 *copy = *src;
00403 return copy;
00404 }
00405
00406
00407 fipa_url_t* fipa_url_New(void)
00408 {
00409 fipa_url_t* url;
00410 url = (fipa_url_t*)malloc(sizeof(fipa_url_t));
00411 memset(url, 0, sizeof(fipa_url_t));
00412 return url;
00413 }
00414
00415 int fipa_url_Destroy(fipa_url_t* url)
00416 {
00417 if (url == NULL) return 0;
00418 if (url->str != NULL) {
00419 free(url->str);
00420 }
00421 free(url);
00422 return 0;
00423 }
00424
00425 fipa_url_t* fipa_url_Copy(fipa_url_t* src)
00426 {
00427 fipa_url_t* copy;
00428 if (src == NULL) return NULL;
00429 copy = fipa_url_New();
00430 copy->str = strdup(src->str);
00431 return copy;
00432 }
00433
00434
00435 fipa_number_t* fipa_number_New(void)
00436 {
00437 fipa_number_t* num;
00438 num = (fipa_number_t*)malloc(sizeof(fipa_number_t));
00439 memset(num, 0, sizeof(fipa_number_t));
00440 return num;
00441 }
00442
00443 int fipa_number_Destroy(fipa_number_t* number)
00444 {
00445 if (number == NULL) return 0;
00446 if (number->str != NULL){
00447 free(number->str);
00448 }
00449 free(number);
00450 return 0;
00451 }
00452
00453 fipa_number_t* fipa_number_Copy(fipa_number_t* src)
00454 {
00455 fipa_number_t* copy;
00456 if (src == NULL) return NULL;
00457 copy = fipa_number_New();
00458 copy->str = strdup(src->str);
00459 return copy;
00460 }
00461
00462
00463 int fipa_acl_Parse(fipa_acl_message_p acl, fipa_message_string_p message)
00464 {
00465 int err = 0;
00466 if (fipa_GetAtom(message,'(')) {
00467 err = MC_ERR_PARSE;
00468 goto exit;
00469 }
00470 if (fipa_message_type_Parse(&(acl->performative), message)) {
00471 err = MC_ERR_PARSE;
00472 goto exit;
00473 }
00474 while(fipa_GetAtom(message, ')')){
00475 err = fipa_message_parameter_Parse(acl, message);
00476 if (err) return err;
00477 }
00478
00479 exit:
00480 return err;
00481 }
00482
00483 int fipa_message_parameter_Parse(fipa_acl_message_p acl, fipa_message_string_p message)
00484 {
00485 int err;
00486 fipa_word_t* word = NULL;
00487 char* parameter;
00488 if((err = fipa_GetAtom(message, ':'))) return err;
00489 if((err = fipa_word_Parse(&word, message))) return err;
00490 parameter = word->content;
00491 if (!strcmp(parameter, "sender")) {
00492 err = fipa_agent_identifier_Parse(&(acl->sender), message);
00493 } else if (!strcmp(parameter, "receiver")) {
00494 err = fipa_agent_identifier_set_Parse(&(acl->receiver), message);
00495 } else if (!strcmp(parameter, "content")) {
00496 err = fipa_string_Parse(&(acl->content), message);
00497 } else if (!strcmp(parameter, "reply-with")) {
00498 err = fipa_expression_Parse(&(acl->reply_with), message);
00499 } else if (!strcmp(parameter, "reply-by")) {
00500 err = fipa_datetime_Parse(&(acl->reply_by), message);
00501 } else if (!strcmp(parameter, "in-reply-to")) {
00502 err = fipa_expression_Parse(&(acl->in_reply_to), message);
00503 } else if (!strcmp(parameter, "reply-to")) {
00504 err = fipa_agent_identifier_set_Parse(&(acl->reply_to), message);
00505 } else if (!strcmp(parameter, "language")) {
00506 err = fipa_expression_Parse(&(acl->language), message);
00507 } else if (!strcmp(parameter, "encoding")) {
00508 err = fipa_expression_Parse(&(acl->encoding), message);
00509 } else if (!strcmp(parameter, "ontology")) {
00510 err = fipa_expression_Parse(&(acl->ontology), message);
00511 } else if (!strcmp(parameter, "protocol")) {
00512 err = fipa_word_Parse(&(acl->protocol), message);
00513 } else if (!strcmp(parameter, "conversation-id")) {
00514 err = fipa_expression_Parse(&(acl->conversation_id), message);
00515 } else {
00516
00517 fprintf(stderr, "FIXME: No handling of user defined parameters. %s:%d\n",
00518 __FILE__, __LINE__);
00519 err = MC_ERR_PARSE;
00520 }
00521 fipa_word_Destroy(word);
00522 return err;
00523 }
00524
00525 int fipa_message_type_Parse(
00526 enum fipa_performative_e* performative,
00527 fipa_message_string_p message
00528 )
00529 {
00530 int err = 0;
00531 fipa_word_p word;
00532 err = fipa_word_Parse(&word, message);
00533 if (err) return err;
00534 if(!strcasecmp(word->content, "accept-proposal")) {
00535 *performative = FIPA_ACCEPT_PROPOSAL;
00536 } else if (!strcasecmp(word->content, "agree")) {
00537 *performative = FIPA_AGREE;
00538 } else if (!strcasecmp(word->content, "cancel")) {
00539 *performative = FIPA_CANCEL;
00540 } else if (!strcasecmp(word->content, "call-for-proposal")) {
00541 *performative = FIPA_CALL_FOR_PROPOSAL;
00542 } else if (!strcasecmp(word->content, "confirm")) {
00543 *performative = FIPA_CONFIRM;
00544 } else if (!strcasecmp(word->content, "disconfirm")) {
00545 *performative = FIPA_DISCONFIRM;
00546 } else if (!strcasecmp(word->content, "failure")) {
00547 *performative = FIPA_FAILURE;
00548 } else if (!strcasecmp(word->content, "inform")) {
00549 *performative = FIPA_INFORM;
00550 } else if (!strcasecmp(word->content, "inform-if")) {
00551 *performative = FIPA_INFORM_IF;
00552 } else if (!strcasecmp(word->content, "inform-ref")) {
00553 *performative = FIPA_INFORM_REF;
00554 } else if (!strcasecmp(word->content, "not-understood")) {
00555 *performative = FIPA_NOT_UNDERSTOOD;
00556 } else if (!strcasecmp(word->content, "propogate")) {
00557 *performative = FIPA_PROPOGATE;
00558 } else if (!strcasecmp(word->content, "propose")) {
00559 *performative = FIPA_PROPOSE;
00560 } else if (!strcasecmp(word->content, "proxy")) {
00561 *performative = FIPA_PROXY;
00562 } else if (!strcasecmp(word->content, "query-if")) {
00563 *performative = FIPA_QUERY_IF;
00564 } else if (!strcasecmp(word->content, "query-ref")) {
00565 *performative = FIPA_QUERY_REF;
00566 } else if (!strcasecmp(word->content, "refuse")) {
00567 *performative = FIPA_REFUSE;
00568 } else if (!strcasecmp(word->content, "reject-proposal")) {
00569 *performative = FIPA_REJECT_PROPOSAL;
00570 } else if (!strcasecmp(word->content, "request")) {
00571 *performative = FIPA_REQUEST;
00572 } else if (!strcasecmp(word->content, "request-when")) {
00573 *performative = FIPA_REQUEST_WHEN;
00574 } else if (!strcasecmp(word->content, "request-whenever")) {
00575 *performative = FIPA_REQUEST_WHENEVER;
00576 } else if (!strcasecmp(word->content, "subscribe")) {
00577 *performative = FIPA_SUBSCRIBE;
00578 } else {
00579 fprintf(stderr, "Unknown performative: '%s'. %s:%d\n",
00580 word->content, __FILE__, __LINE__);
00581 err = MC_ERR_PARSE;
00582 }
00583 fipa_word_Destroy(word);
00584 return err;
00585 }
00586
00587 int fipa_GetAtom(
00588 fipa_message_string_p message,
00589 char expected_atom
00590 )
00591 {
00592 while
00593 (
00594 (*(message->parse) >= 0x00) &&
00595 (*(message->parse) <= 0x20)
00596 )
00597 {
00598 if (*(message->parse) == 0x00)
00599 return MC_ERR_PARSE;
00600 message->parse++;
00601 }
00602 if( *(message->parse) == expected_atom) {
00603 message->parse++;
00604 return MC_SUCCESS;
00605 } else {
00606 return MC_ERR_PARSE;
00607 }
00608 }
00609
00610 int fipa_word_Parse(fipa_word_t** word, fipa_message_string_p message)
00611 {
00612 char* tmp;
00613 int i = 0;
00614
00615 while
00616 (
00617 (*(message->parse)>=0x00) &&
00618 (*(message->parse)<=0x20)
00619 )
00620 {
00621
00622 if (*(message->parse) == '\0') {
00623 return MC_ERR_PARSE;
00624 }
00625 message->parse++;
00626 }
00627
00628 tmp = message->parse;
00629 while (*tmp > 0x20) {
00630 tmp++;
00631 i++;
00632 }
00633 *word = (fipa_word_t*)malloc(sizeof(fipa_word_t));
00634 CHECK_NULL(*word, exit(0););
00635 (*word)->content = malloc
00636 (
00637 sizeof(char) * (i+1)
00638 );
00639 CHECK_NULL((*word)->content, exit(0););
00640
00641
00642 i = 0;
00643 while( *(message->parse) > 0x20 ) {
00644 ((*word)->content)[i] = *(message->parse);
00645 message->parse++;
00646 i++;
00647 }
00648 ((*word)->content)[i] = '\0';
00649 return MC_SUCCESS;
00650 }
00651
00652 int fipa_CheckNextToken(const fipa_message_string_p message, const char* token)
00653 {
00654 char* tmp = message->parse;
00655 while
00656 (
00657 (*tmp >= 0x00) &&
00658 (*tmp <= 0x20)
00659 )
00660 tmp++;
00661 while (*token != '\0') {
00662 if (*token != *tmp) {
00663 return 0;
00664 }
00665 token++;
00666 tmp++;
00667 }
00668 return 1;
00669 }
00670
00671 int fipa_expression_Parse(fipa_expression_t** expression, fipa_message_string_p message)
00672 {
00673 int i=0;
00674 *expression = (fipa_expression_t*)malloc(sizeof(fipa_expression_t));
00675
00676
00677
00678 if (fipa_CheckNextToken(message, "(")) {
00679 (*expression)->type = FIPA_EXPR_EXPRESSION;
00680 if(fipa_GetAtom(message, '(')) {
00681
00682 fprintf(stderr, "Fatal error. %s:%d\n", __FILE__, __LINE__);
00683 exit(0);
00684 }
00685 for
00686 (
00687 i = 0;
00688 !fipa_expression_Parse( &(((*expression)->content.expression)[i]), message);
00689 i++
00690 );
00691 if(fipa_GetAtom(message, ')')) {
00692 fprintf(stderr, "Parse error. %s:%d\n", __FILE__, __LINE__);
00693 return MC_ERR_PARSE;
00694 }
00695 } else if (
00696
00697 !fipa_datetime_Parse(&((*expression)->content.datetime), message)
00698 )
00699 {
00700 (*expression)->type = FIPA_EXPR_DATETIME;
00701 } else if (
00702
00703 !fipa_string_Parse(&((*expression)->content.string), message)
00704 )
00705 {
00706 (*expression)->type = FIPA_EXPR_STRING;
00707 } else if (
00708
00709 !fipa_word_Parse(&((*expression)->content.word), message)
00710 )
00711 {
00712 (*expression)->type=FIPA_EXPR_WORD;
00713 }
00714 else
00715 {
00716
00717 return MC_ERR_PARSE;
00718 }
00719 return MC_SUCCESS;
00720 }
00721
00722 int fipa_GetNextWord(char** word, const fipa_message_string_p message)
00723 {
00724 char *tmp;
00725 int i = 0;
00726 int j;
00727
00728 tmp = message->parse;
00729 while
00730 (
00731 (*tmp >= 0x00) &&
00732 (*tmp <= 0x20)
00733 )
00734 tmp++;
00735
00736
00737 if
00738 (
00739 ((*tmp >= 0x00) && (*tmp <= 0x20)) ||
00740 (*tmp == '(') ||
00741 (*tmp == ')') ||
00742 (*tmp == '#') ||
00743 ((*tmp >= 0x30) && (*tmp <= 0x39)) ||
00744 (*tmp == '-') ||
00745 (*tmp == '@')
00746 )
00747 return ERR;
00748 i++;
00749 tmp++;
00750
00751 while
00752 (
00753 ((*tmp < 0x00) || (*tmp > 0x20)) &&
00754 (*tmp != '(') &&
00755 (*tmp != ')')
00756 ) {
00757 i++;
00758 tmp++;
00759 }
00760
00761 *word = (char*)malloc(sizeof(char) * (i+1));
00762
00763 for (j = 0; j < i; j++) {
00764 *((*word) + j) = *(message->parse+j);
00765 }
00766 *((*word)+j) = '\0';
00767 return MC_SUCCESS;
00768 }
00769
00770 int fipa_GetWholeToken(char** word, fipa_message_string_p message)
00771 {
00772 char *tmp;
00773 int i = 0;
00774 int j;
00775
00776 tmp = message->parse;
00777 while
00778 (
00779 (*tmp >= 0x00) &&
00780 (*tmp <= 0x20)
00781 )
00782 {
00783 tmp++;
00784 message->parse++;
00785 }
00786
00787 i++;
00788 tmp++;
00789
00790 while
00791 (
00792 ((*tmp < 0x00) || (*tmp > 0x20))
00793 ) {
00794 i++;
00795 tmp++;
00796 }
00797
00798 *word = (char*)malloc(sizeof(char) * (i+1));
00799
00800 for (j = 0; j < i; j++) {
00801 *((*word) + j) = *(message->parse+j);
00802 }
00803 *((*word)+j) = '\0';
00804 return MC_SUCCESS;
00805 }
00806
00807 int fipa_datetime_Parse(fipa_DateTime_p* datetime, fipa_message_string_p message)
00808 {
00809 char *word;
00810 char *tmp;
00811 int i;
00812 char buf[5];
00813
00814 fipa_GetWholeToken(&word, message);
00815 tmp = word;
00816 if (
00817 (*tmp == '+') ||
00818 (*tmp == '-')
00819 )
00820 tmp++;
00821
00822 for(i = 0; i < 8; i++) {
00823 if (*tmp < 0x30 || *tmp > 0x39) {
00824 free(word);
00825 return MC_ERR_PARSE;
00826 }
00827 tmp++;
00828 }
00829
00830 if (*tmp == 'T') {
00831 tmp++;
00832 } else {
00833 free(word);
00834 return MC_ERR_PARSE;
00835 }
00836
00837 for(i = 0; i < 9; i++) {
00838 if(*tmp < 0x30 || *tmp > 0x39) {
00839 free(word);
00840 return MC_ERR_PARSE;
00841 }
00842 tmp++;
00843 }
00844
00845
00846 *datetime = (fipa_DateTime_p)malloc(sizeof(fipa_DateTime_t));
00847 tmp = word;
00848 switch(*tmp) {
00849 case '+':
00850 (*datetime)->sign = '+';
00851 tmp++;
00852 message->parse++;
00853 break;
00854 case '-':
00855 (*datetime)->sign = '-';
00856 tmp++;
00857 message->parse++;
00858 break;
00859 default:
00860 break;
00861 }
00862
00863
00864 for(i = 0; i < 4; i++) {
00865 buf[i] = *tmp;
00866 tmp++;
00867 message->parse++;
00868 }
00869 buf[i] = '\0';
00870 (*datetime)->year = atoi(buf);
00871
00872
00873 for(i = 0; i < 2; i++) {
00874 buf[i] = *tmp;
00875 tmp++;
00876 message->parse++;
00877 }
00878 buf[i] = '\0';
00879 (*datetime)->month = atoi(buf);
00880
00881
00882 for(i = 0; i < 2; i++) {
00883 buf[i] = *tmp;
00884 tmp++;
00885 message->parse++;
00886 }
00887 buf[i] = '\0';
00888 (*datetime)->month = atoi(buf);
00889
00890
00891 if (*tmp != 'T') {
00892
00893 fprintf(stderr, "Fatal Error. %s:%d\n", __FILE__, __LINE__);
00894 exit(0);
00895 }
00896 tmp++;
00897 message->parse++;
00898
00899
00900 for(i = 0; i < 2; i++) {
00901 buf[i] = *tmp;
00902 tmp++;
00903 message->parse++;
00904 }
00905 buf[i] = '\0';
00906 (*datetime)->hour = atoi(buf);
00907
00908
00909 for(i = 0; i < 2; i++) {
00910 buf[i] = *tmp;
00911 tmp++;
00912 message->parse++;
00913 }
00914 buf[i] = '\0';
00915 (*datetime)->minute = atoi(buf);
00916
00917
00918 for(i = 0; i < 2; i++) {
00919 buf[i] = *tmp;
00920 tmp++;
00921 message->parse++;
00922 }
00923 buf[i] = '\0';
00924 (*datetime)->second = atoi(buf);
00925
00926
00927 for(i = 0; i < 3; i++) {
00928 buf[i] = *tmp;
00929 tmp++;
00930 message->parse++;
00931 }
00932 buf[i] = '\0';
00933 (*datetime)->millisecond = atoi(buf);
00934
00935 if (*tmp == 'Z') {
00936 (*datetime)->is_utc = 1;
00937 message->parse++;
00938 }
00939 else
00940 (*datetime)->is_utc = 0;
00941 free(word);
00942 return MC_SUCCESS;
00943 }
00944
00945 int fipa_string_Parse( fipa_string_p* fipa_string, fipa_message_string_p message)
00946 {
00947 int len;
00948 char *tmp;
00949
00950 if(fipa_GetAtom(message, '\"')) {
00951 return MC_ERR_PARSE;
00952 }
00953
00954 tmp = message->parse;
00955 len = 0;
00956 while
00957 (
00958 (*tmp != '\0')
00959 )
00960 {
00961 if (*tmp == '\"') {
00962 break;
00963 }
00964 if (*tmp == '\\') {
00965 tmp++;
00966 len++;
00967 }
00968 tmp++;
00969 len++;
00970 }
00971 *fipa_string = (fipa_string_p)malloc(sizeof(fipa_string_t));
00972 (*fipa_string)->content = (char*)malloc
00973 (
00974 sizeof(char) * (len + 1)
00975 );
00976 len = 0;
00977 while (message->parse < tmp) {
00978 ((*fipa_string)->content)[len] = *(message->parse);
00979 len++;
00980 message->parse++;
00981 }
00982 ((*fipa_string)->content)[len] = '\0';
00983
00984 if(fipa_GetAtom(message, '\"')) {
00985 return MC_ERR_PARSE;
00986 }
00987 return MC_SUCCESS;
00988 }
00989
00990 int fipa_agent_identifier_Parse(fipa_agent_identifier_p* aid, fipa_message_string_p message)
00991 {
00992 int err = 0;
00993 fipa_word_t* word = NULL;
00994 char *rewind;
00995 if
00996 (
00997 (err = fipa_GetAtom(message, '(') )
00998 ) return err;
00999 if
01000 (
01001 (err = fipa_word_Parse(&word, message) )
01002 )
01003 {
01004 fipa_word_Destroy(word);
01005 return err;
01006 }
01007 if (strcmp(word->content, "agent-identifier")) {
01008 free(word->content);
01009 fipa_word_Destroy(word);
01010 return MC_ERR_PARSE;
01011 }
01012 fipa_word_Destroy(word);
01013 word = NULL;
01014 if
01015 (
01016 (err = fipa_GetAtom(message, ':') )
01017 ) return err;
01018 if
01019 (
01020 (err = fipa_word_Parse(&word, message))
01021 )
01022 {
01023 fipa_word_Destroy(word);
01024 return err;
01025 }
01026 if (strcmp(word->content, "name")) {
01027 return MC_ERR_PARSE;
01028 }
01029 fipa_word_Destroy(word);
01030 word = NULL;
01031
01032 *aid = (fipa_agent_identifier_p)malloc(sizeof(fipa_agent_identifier_t));
01033 memset(*aid, 0, sizeof(fipa_agent_identifier_t));
01034 if
01035 (
01036 (err = fipa_word_Parse(&word, message))
01037 )
01038 {
01039 fipa_word_Destroy(word);
01040 return err;
01041 }
01042 (*aid)->name = (char*)malloc
01043 (
01044 sizeof(char) *
01045 (strlen(word->content)+1)
01046 );
01047 CHECK_NULL((*aid)->name, exit(0););
01048 strcpy((*aid)->name, word->content);
01049
01050 fipa_word_Destroy(word);
01051
01052
01053
01054 rewind = message->parse;
01055 if
01056 (
01057 (!(err = fipa_GetAtom(message, ':')))
01058 )
01059 {
01060 if
01061 (
01062 (err = fipa_word_Parse(&word, message))
01063 ) {
01064 message->parse = rewind;
01065 fipa_word_Destroy(word);
01066 return MC_ERR_PARSE;
01067 }
01068
01069 if (!strcmp(word->content, "addresses"))
01070 {
01071 err = fipa_url_sequence_Parse(&((*aid)->addresses), message);
01072 if(err) {
01073 message->parse = rewind;
01074 fipa_word_Destroy(word);
01075 return err;
01076 }
01077 } else if (!strcmp(word->content, "resolvers"))
01078 {
01079 err = fipa_agent_identifier_set_Parse(&((*aid)->resolvers), message);
01080 if (err) {
01081 message->parse = rewind;
01082 fipa_word_Destroy(word);
01083 return err;
01084 }
01085 } else {
01086 message->parse = rewind;
01087 }
01088 }
01089
01090 err = fipa_GetAtom(message, ')');
01091 fipa_word_Destroy(word);
01092 if (err) {return MC_ERR_PARSE;}
01093 return MC_SUCCESS;
01094
01095 }
01096
01097 int fipa_url_sequence_Parse(fipa_url_sequence_p* urls, fipa_message_string_p message)
01098 {
01099 int err;
01100 fipa_word_p word;
01101 int i;
01102 if
01103 (
01104 (err = fipa_GetAtom(message, '(') )
01105 ) return err;
01106 if
01107 (
01108 (err = fipa_word_Parse(&word, message) )
01109 ) return err;
01110 if ( strcmp(word->content, "sequence")) {
01111 fipa_word_Destroy(word);
01112 return MC_ERR_PARSE;
01113 }
01114 fipa_word_Destroy(word);
01115 *urls = fipa_url_sequence_New();
01116
01117
01118 (*urls)->urls = (fipa_url_t**)malloc(sizeof(fipa_url_t*)*20);
01119 i = 0;
01120 (*urls)->num = 0;
01121 while( fipa_GetAtom(message, ')') ) {
01122 fipa_url_Parse(&(*urls)->urls[i], message);
01123 i++;
01124 (*urls)->num++;
01125 }
01126 return 0;
01127 }
01128
01129 int fipa_url_Parse(fipa_url_p* url, fipa_message_string_p message)
01130 {
01131 fipa_word_p word = NULL;
01132 int err;
01133 *url = (fipa_url_t*)malloc(sizeof(fipa_url_t));
01134 err = fipa_word_Parse(&word, message);
01135 if (err) {
01136 free(*url);
01137 if(word == NULL) fipa_word_Destroy(word);
01138 fprintf(stderr, "Error parsing. %s:%d\n", __FILE__, __LINE__);
01139 return err;
01140 }
01141 (*url)->str = strdup(word->content);
01142 fipa_word_Destroy(word);
01143 return 0;
01144 }
01145
01146
01147
01148
01149 int fipa_agent_identifier_set_Parse(fipa_agent_identifier_set_p* agent_ids, fipa_message_string_p message)
01150 {
01151 int err;
01152 fipa_word_p word;
01153 int i=0;
01154
01155 if
01156 (
01157 (err = fipa_GetAtom(message, '(') )
01158 ) return err;
01159 if
01160 (
01161 (err = fipa_word_Parse(&word, message) )
01162 ) return err;
01163 if (!strcmp(word->content, "set")) {
01164 *agent_ids = (fipa_agent_identifier_set_p)malloc(sizeof(struct fipa_agent_identifier_set_s));
01165 (*agent_ids)->retain_order = 0;
01166 } else if (!strcmp(word->content, "sequence")) {
01167 *agent_ids = (fipa_agent_identifier_set_p)malloc(sizeof(struct fipa_agent_identifier_set_s));
01168 (*agent_ids)->retain_order = 1;
01169 } else {
01170 free(word->content);
01171 free(word);
01172 return MC_ERR_PARSE;
01173 }
01174 free(word->content);
01175 free(word);
01176 (*agent_ids)->fipa_agent_identifiers =
01177 (fipa_agent_identifier_p*)malloc(20 * sizeof(fipa_agent_identifier_t*));
01178 while( fipa_GetAtom(message, ')') ) {
01179 err = fipa_agent_identifier_Parse
01180 (&(((*agent_ids)->fipa_agent_identifiers)[i]), message);
01181 if(err) return err;
01182 i++;
01183 }
01184 (*agent_ids)->num = i;
01185 return MC_SUCCESS;
01186 }
01187
01188
01189
01190 int fipa_acl_Compose(dynstring_t** msg, fipa_acl_message_t* acl)
01191 {
01192 *msg = dynstring_New();
01193 dynstring_Append(*msg, "(");
01194 fipa_performative_Compose(*msg, acl->performative);
01195 if (acl->sender != NULL) {
01196 dynstring_Append(*msg, ":sender ");
01197 fipa_agent_identifier_Compose(*msg, acl->sender);
01198 dynstring_Append(*msg, "\n");
01199 }
01200 if (acl->receiver != NULL) {
01201 dynstring_Append(*msg, ":receiver ");
01202 fipa_agent_identifier_set_Compose(*msg, acl->receiver);
01203 dynstring_Append(*msg, "\n");
01204 }
01205 if (acl->reply_to) {
01206 dynstring_Append(*msg, ":reply-to ");
01207 fipa_agent_identifier_set_Compose(*msg, acl->reply_to);
01208 dynstring_Append(*msg, "\n");
01209 }
01210 if (acl->content) {
01211 dynstring_Append(*msg, ":content ");
01212 fipa_string_Compose(*msg, acl->content);
01213 dynstring_Append(*msg, "\n");
01214 }
01215 if (acl->language) {
01216 dynstring_Append(*msg, ":language ");
01217 fipa_expression_Compose(*msg, acl->language);
01218 dynstring_Append(*msg, "\n");
01219 }
01220 if (acl->encoding) {
01221 dynstring_Append(*msg, ":encoding ");
01222 fipa_expression_Compose(*msg, acl->encoding);
01223 dynstring_Append(*msg, "\n");
01224 }
01225 if (acl->ontology) {
01226 dynstring_Append(*msg, ":ontology ");
01227 fipa_expression_Compose(*msg, acl->ontology);
01228 dynstring_Append(*msg, "\n");
01229 }
01230 if (acl->protocol) {
01231 dynstring_Append(*msg, ":protocol ");
01232 fipa_word_Compose(*msg, acl->protocol);
01233 dynstring_Append(*msg, "\n");
01234 }
01235 if (acl->conversation_id) {
01236 dynstring_Append(*msg, ":conversation-id ");
01237 fipa_expression_Compose(*msg, acl->conversation_id);
01238 dynstring_Append(*msg, "\n");
01239 }
01240 if (acl->reply_with) {
01241 dynstring_Append(*msg, ":reply-with ");
01242 fipa_expression_Compose(*msg, acl->reply_with);
01243 dynstring_Append(*msg, "\n");
01244 }
01245 if (acl->in_reply_to) {
01246 dynstring_Append(*msg, ":in-reply-to ");
01247 fipa_expression_Compose(*msg, acl->in_reply_to);
01248 dynstring_Append(*msg, "\n");
01249 }
01250 if (acl->reply_by) {
01251 dynstring_Append(*msg, ":reply-by ");
01252 fipa_DateTime_Compose(*msg, acl->reply_by);
01253 dynstring_Append(*msg, "\n");
01254 }
01255 dynstring_Append(*msg, ")");
01256 return 0;
01257 }
01258
01259 int fipa_performative_Compose(dynstring_t* msg, enum fipa_performative_e performative)
01260 {
01261 switch(performative) {
01262 case FIPA_ACCEPT_PROPOSAL:
01263 dynstring_Append(msg, "accept-proposal ");
01264 break;
01265 case FIPA_AGREE:
01266 dynstring_Append(msg, "agree ");
01267 break;
01268 case FIPA_CANCEL:
01269 dynstring_Append(msg, "cancel ");
01270 break;
01271 case FIPA_CALL_FOR_PROPOSAL:
01272 dynstring_Append(msg, "call-for-proposal ");
01273 break;
01274 case FIPA_CONFIRM:
01275 dynstring_Append(msg, "confirm ");
01276 break;
01277 case FIPA_DISCONFIRM:
01278 dynstring_Append(msg, "disconfirm ");
01279 break;
01280 case FIPA_FAILURE:
01281 dynstring_Append(msg, "failure ");
01282 break;
01283 case FIPA_INFORM:
01284 dynstring_Append(msg, "inform ");
01285 break;
01286 case FIPA_INFORM_IF:
01287 dynstring_Append(msg, "inform-if ");
01288 break;
01289 case FIPA_INFORM_REF:
01290 dynstring_Append(msg, "inform-ref ");
01291 break;
01292 case FIPA_NOT_UNDERSTOOD:
01293 dynstring_Append(msg, "not-understood ");
01294 break;
01295 case FIPA_PROPOGATE:
01296 dynstring_Append(msg, "propogate ");
01297 break;
01298 case FIPA_PROPOSE:
01299 dynstring_Append(msg, "propose ");
01300 break;
01301 case FIPA_PROXY:
01302 dynstring_Append(msg, "proxy ");
01303 break;
01304 case FIPA_QUERY_IF:
01305 dynstring_Append(msg, "query-if ");
01306 break;
01307 case FIPA_QUERY_REF:
01308 dynstring_Append(msg, "query-ref ");
01309 break;
01310 case FIPA_REFUSE:
01311 dynstring_Append(msg, "refuse ");
01312 break;
01313 case FIPA_REJECT_PROPOSAL:
01314 dynstring_Append(msg, "reject-proposal ");
01315 break;
01316 case FIPA_REQUEST:
01317 dynstring_Append(msg, "request ");
01318 break;
01319 case FIPA_REQUEST_WHEN:
01320 dynstring_Append(msg, "request-when ");
01321 break;
01322 case FIPA_REQUEST_WHENEVER:
01323 dynstring_Append(msg, "request-whenever ");
01324 break;
01325 case FIPA_SUBSCRIBE:
01326 dynstring_Append(msg, "subscribe ");
01327 break;
01328 default:
01329 return MC_ERR_PARSE;
01330 }
01331 return 0;
01332 }
01333
01334 int fipa_url_sequence_Compose(dynstring_t* msg, fipa_url_sequence_t* urls)
01335 {
01336 int i;
01337 if(urls == NULL) return 0;
01338 if(urls->num == 0) return 0;
01339 dynstring_Append(msg, "(sequence ");
01340 for(i = 0; i < urls->num; i++) {
01341 fipa_url_Compose(msg, urls->urls[i]);
01342 }
01343 dynstring_Append(msg, ") ");
01344 return 0;
01345 }
01346
01347 int fipa_agent_identifier_set_Compose(dynstring_t* msg, fipa_agent_identifier_set_t* ids)
01348 {
01349 int i;
01350 if(ids == NULL) return 0;
01351 if(ids->num == 0) return 0;
01352 dynstring_Append(msg, "(set ");
01353 for(i = 0; i < ids->num; i++) {
01354 fipa_agent_identifier_Compose(msg, ids->fipa_agent_identifiers[i]);
01355 }
01356 dynstring_Append(msg, ") ");
01357 return 0;
01358 }
01359
01360 int fipa_agent_identifier_Compose(dynstring_t* msg, fipa_agent_identifier_t* id)
01361 {
01362 if(id == NULL) return 0;
01363 dynstring_Append(msg, "(agent-identifier ");
01364 dynstring_Append(msg, ":name ");
01365 dynstring_Append(msg, id->name);
01366 dynstring_Append(msg, " ");
01367
01368 if (id->addresses != NULL) {
01369 if (id->addresses->num != 0) {
01370 dynstring_Append(msg, ":addresses ");
01371 fipa_url_sequence_Compose(msg, id->addresses);
01372 }
01373 }
01374
01375 if (id->resolvers != NULL) {
01376 if (id->resolvers->num != 0) {
01377 dynstring_Append(msg, ":resolvers ");
01378 fipa_agent_identifier_set_Compose(msg, id->resolvers);
01379 }
01380 }
01381
01382 dynstring_Append(msg, ") ");
01383 return 0;
01384 }
01385
01386 int fipa_expression_Compose(dynstring_t* msg, fipa_expression_t* expr)
01387 {
01388 fipa_expression_t* tmp_expr;
01389 if (expr == NULL) return 0;
01390 switch(expr->type) {
01391 case FIPA_EXPR_WORD:
01392 fipa_word_Compose(msg, expr->content.word);
01393 break;
01394 case FIPA_EXPR_STRING:
01395 fipa_string_Compose(msg, expr->content.string);
01396 break;
01397 case FIPA_EXPR_NUMBER:
01398 fipa_number_Compose(msg, expr->content.number);
01399 break;
01400 case FIPA_EXPR_DATETIME:
01401 fipa_DateTime_Compose(msg, expr->content.datetime);
01402 break;
01403 case FIPA_EXPR_EXPRESSION:
01404 tmp_expr = expr->content.expression[0];
01405 while(tmp_expr != NULL) {
01406 fipa_expression_Compose(msg, tmp_expr);
01407 tmp_expr++;
01408 }
01409 break;
01410 default:
01411 return MC_ERR_PARSE;
01412 }
01413 return 0;
01414 }
01415
01416 int fipa_word_Compose(dynstring_t* msg, fipa_word_t* word)
01417 {
01418 if (word == NULL) return 0;
01419 dynstring_Append(msg, word->content);
01420 dynstring_Append(msg, " ");
01421 return 0;
01422 }
01423
01424 int fipa_string_Compose(dynstring_t* msg, fipa_string_t* string)
01425 {
01426 if (string == NULL) return 0;
01427 dynstring_Append(msg, "\"");
01428 dynstring_Append(msg, string->content);
01429 dynstring_Append(msg, "\" ");
01430 return 0;
01431 }
01432
01433 int fipa_DateTime_Compose(dynstring_t* msg, fipa_DateTime_t* date)
01434 {
01435 char buf[40];
01436
01437 if(date == NULL) return 0;
01438 dynstring_Append(msg, &date->sign);
01439 sprintf(buf, "%04d%02d%02dT%02d%02d%02d%03d",
01440 date->year,
01441 date->month,
01442 date->day,
01443 date->hour,
01444 date->minute,
01445 date->second,
01446 date->millisecond
01447 );
01448 dynstring_Append(msg, buf);
01449 return 0;
01450 }
01451
01452
01453 int fipa_url_Compose(dynstring_t* msg, fipa_url_t* url)
01454 {
01455 if(url == NULL) return 0;
01456 dynstring_Append(msg, url->str);
01457 dynstring_Append(msg, " ");
01458 return 0;
01459 }
01460
01461 int fipa_number_Compose(dynstring_t* msg, fipa_number_t* number)
01462 {
01463 if (number == NULL) return 0;
01464 dynstring_Append(msg, number->str);
01465 dynstring_Append(msg, " ");
01466 return 0;
01467 }
01468
01469 struct fipa_acl_message_s* fipa_Reply(
01470 struct fipa_acl_message_s* acl)
01471 {
01472
01473 struct fipa_acl_message_s* acl_reply;
01474
01475 acl_reply = fipa_acl_message_New();
01476
01477
01478
01479 if (acl->reply_to != NULL && acl->reply_to->num != 0) {
01480 acl_reply->receiver = fipa_agent_identifier_set_Copy(acl->reply_to);
01481 } else {
01482 acl_reply->receiver = fipa_agent_identifier_set_New();
01483 acl_reply->receiver->num = 1;
01484 acl_reply->receiver->retain_order = 0;
01485
01486 acl_reply->receiver->fipa_agent_identifiers = (fipa_agent_identifier_t**)malloc(
01487 sizeof(fipa_agent_identifier_t*));
01488 acl_reply->receiver->fipa_agent_identifiers[0] = fipa_agent_identifier_Copy(
01489 acl->sender );
01490 }
01491
01492 return acl_reply;
01493 }
01494
01495 #undef FREEMEM