/home/dko/projects/mobilec/trunk/src/include/fipa_acl.h

Go to the documentation of this file.
00001 /* SVN FILE INFO
00002  * $Revision: 174 $ : Last Committed Revision
00003  * $Date: 2008-06-24 10:50:29 -0700 (Tue, 24 Jun 2008) $ : Last Committed Date */
00004 /*[
00005  * Copyright (c) 2007 Integration Engineering Laboratory
00006                       University of California, Davis
00007  *
00008  * Permission to use, copy, and distribute this software and its
00009  * documentation for any purpose with or without fee is hereby granted,
00010  * provided that the above copyright notice appear in all copies and
00011  * that both that copyright notice and this permission notice appear
00012  * in supporting documentation.
00013  *
00014  * Permission to modify the software is granted, but not the right to
00015  * distribute the complete modified source code.  Modifications are to
00016  * be distributed as patches to the released version.  Permission to
00017  * distribute binaries produced by compiling modified sources is granted,
00018  * provided you
00019  *   1. distribute the corresponding source modifications from the
00020  *    released version in the form of a patch file along with the binaries,
00021  *   2. add special version identification to distinguish your version
00022  *    in addition to the base release version number,
00023  *   3. provide your name and address as the primary contact for the
00024  *    support of your modified version, and
00025  *   4. retain our contact information in regard to use of the base
00026  *    software.
00027  * Permission to distribute the released version of the source code along
00028  * with corresponding source modifications in the form of a patch file is
00029  * granted with same provisions 2 through 4 for binary distributions.
00030  *
00031  * This software is provided "as is" without express or implied warranty
00032  * to the extent permitted by applicable law.
00033 ]*/
00034 
00035 #ifndef _FIPA_ACL_MESSAGE_H_
00036 #define _FIPA_ACL_MESSAGE_H_
00037 #include "dynstring.h"
00038 
00039 
00040 enum fipa_performative_e
00041 {
00042   FIPA_ERROR=-1,
00043   FIPA_ZERO,
00044   FIPA_ACCEPT_PROPOSAL,
00045   FIPA_AGREE,
00046   FIPA_CANCEL,
00047   FIPA_CALL_FOR_PROPOSAL,
00048   FIPA_CONFIRM,
00049   FIPA_DISCONFIRM,
00050   FIPA_FAILURE,
00051   FIPA_INFORM,
00052   FIPA_INFORM_IF,
00053   FIPA_INFORM_REF,
00054   FIPA_NOT_UNDERSTOOD,
00055   FIPA_PROPOGATE,
00056   FIPA_PROPOSE,
00057   FIPA_PROXY,
00058   FIPA_QUERY_IF,
00059   FIPA_QUERY_REF,
00060   FIPA_REFUSE,
00061   FIPA_REJECT_PROPOSAL,
00062   FIPA_REQUEST,
00063   FIPA_REQUEST_WHEN,
00064   FIPA_REQUEST_WHENEVER,
00065   FIPA_SUBSCRIBE
00066 };
00067 
00068 int fipa_performative_Compose(dynstring_t* msg, enum fipa_performative_e performative);
00069 
00070 typedef enum fipa_expression_type_e
00071 {
00072   FIPA_EXPR_ZERO,
00073   FIPA_EXPR_WORD,
00074   FIPA_EXPR_STRING,
00075   FIPA_EXPR_NUMBER,
00076   FIPA_EXPR_DATETIME,
00077   FIPA_EXPR_EXPRESSION
00078 } fipa_expression_type_t; 
00079 
00080 /* fipa_acl_message */
00081 typedef struct fipa_acl_message_s
00082 {
00083   enum fipa_performative_e performative;
00084 
00085   struct fipa_agent_identifier_s* sender;
00086 
00087   struct fipa_agent_identifier_set_s* receiver;
00088   int receiver_num;
00089 
00090   struct fipa_agent_identifier_set_s* reply_to;
00091 
00092   /*struct fipa_content_s* content; */
00093   struct fipa_string_s* content; /* We will write the parser for this later */
00094 
00095   struct fipa_expression_s* language;
00096 
00097   struct fipa_expression_s* encoding;
00098   
00099   struct fipa_expression_s* ontology;
00100 
00101   struct fipa_word_s* protocol;
00102 
00103   struct fipa_expression_s* conversation_id;
00104 
00105   struct fipa_expression_s* reply_with;
00106 
00107   struct fipa_expression_s* in_reply_to;
00108 
00109   struct fipa_DateTime_s* reply_by;
00110 } fipa_acl_message_t;
00111 typedef fipa_acl_message_t* fipa_acl_message_p;
00112 fipa_acl_message_t* fipa_acl_message_New(void);
00113 int fipa_acl_message_Destroy(fipa_acl_message_t* message);
00114 fipa_acl_message_t* fipa_acl_message_Copy(fipa_acl_message_t* src);
00115 int fipa_acl_Compose(dynstring_t** msg, fipa_acl_message_t* acl);
00116 
00117 /* fipa_message_string */
00118 typedef struct fipa_message_string_s
00119 {
00120   char* message;
00121   char* parse;    /* This pointer points to some part of "message" */
00122 } fipa_message_string_t;
00123 typedef fipa_message_string_t* fipa_message_string_p;
00124 fipa_message_string_t* fipa_message_string_New(void);
00125 int fipa_message_string_Destroy(fipa_message_string_t* message);
00126 fipa_message_string_t* fipa_message_string_Copy(fipa_message_string_t* src);
00127 
00128 /* fipa_url_sequence */
00129 typedef struct fipa_url_sequence_s
00130 {
00131   int num;
00132   struct fipa_url_s** urls;
00133 } fipa_url_sequence_t;
00134 typedef fipa_url_sequence_t* fipa_url_sequence_p;
00135 fipa_url_sequence_t* fipa_url_sequence_New(void);
00136 int fipa_url_sequence_Destroy(fipa_url_sequence_t* sequence);
00137 fipa_url_sequence_t* fipa_url_sequence_Copy(fipa_url_sequence_t* src);
00138 int fipa_url_sequence_Compose(dynstring_t* msg, fipa_url_sequence_t* urls);
00139 
00140 /* fipa_agent_identifier_set */
00141 typedef struct fipa_agent_identifier_set_s
00142 {
00143   int num;
00144   int retain_order;
00145   struct fipa_agent_identifier_s** fipa_agent_identifiers;
00146 } fipa_agent_identifier_set_t;
00147 typedef fipa_agent_identifier_set_t* fipa_agent_identifier_set_p;
00148 fipa_agent_identifier_set_t* fipa_agent_identifier_set_New(void);
00149 int fipa_agent_identifier_set_Destroy(fipa_agent_identifier_set_t* idset);
00150 fipa_agent_identifier_set_t* fipa_agent_identifier_set_Copy(
00151     fipa_agent_identifier_set_t* src);
00152 int fipa_agent_identifier_set_Compose(dynstring_t* msg, fipa_agent_identifier_set_t* ids);
00153 
00154 /* fipa_agent_identifier */
00155 typedef struct fipa_agent_identifier_s
00156 {
00157   char* name;
00158   struct fipa_url_sequence_s* addresses;
00159   struct fipa_agent_identifier_set_s* resolvers;
00160 } fipa_agent_identifier_t;
00161 typedef fipa_agent_identifier_t* fipa_agent_identifier_p;
00162 fipa_agent_identifier_t* fipa_agent_identifier_New(void);
00163 int fipa_agent_identifier_Destroy(fipa_agent_identifier_t* id);
00164 fipa_agent_identifier_t* fipa_agent_identifier_Copy(fipa_agent_identifier_t* src);
00165 int fipa_agent_identifier_Compose(dynstring_t* msg, fipa_agent_identifier_t* id);
00166 
00167 /* fipa_expression */
00168 typedef struct fipa_expression_s
00169 {
00170   enum fipa_expression_type_e type;
00171   union content_u
00172   {
00173     struct fipa_word_s* word;
00174     struct fipa_string_s* string;
00175     struct fipa_number_s* number;
00176     struct fipa_DateTime_s* datetime;
00177     struct fipa_expression_s** expression;
00178   } content;
00179 } fipa_expression_t;
00180 typedef fipa_expression_t* fipa_expression_p;
00181 fipa_expression_t* fipa_expression_New(void);
00182 int fipa_expression_Destroy(fipa_expression_t* expr);
00183 fipa_expression_t* fipa_expression_Copy(fipa_expression_t* src);
00184 int fipa_expression_Compose(dynstring_t* msg, fipa_expression_t* expr);
00185 
00186 /* fipa_word */
00187 typedef struct fipa_word_s
00188 {
00189   char* content;
00190 } fipa_word_t;
00191 typedef fipa_word_t* fipa_word_p;
00192 fipa_word_t* fipa_word_New(void);
00193 int fipa_word_Destroy(fipa_word_t* word);
00194 fipa_word_t* fipa_word_Copy(fipa_word_t* src);
00195 int fipa_word_Compose(dynstring_t* msg, fipa_word_t* word);
00196 
00197 /* fipa_string */
00198 typedef struct fipa_string_s
00199 {
00200   char* content;
00201 } fipa_string_t;
00202 typedef fipa_string_t* fipa_string_p;
00203 fipa_string_t* fipa_string_New(void);
00204 int fipa_string_Destroy(fipa_string_t* str);
00205 fipa_string_t* fipa_string_Copy(fipa_string_t* src);
00206 int fipa_string_Compose(dynstring_t* msg, fipa_string_t* string);
00207 
00208 /* fipa_DateTime */
00209 typedef struct fipa_DateTime_s
00210 {
00211   int year;
00212   int month;
00213   int day;
00214   int hour;
00215   int minute;
00216   int second;
00217   int millisecond;
00218   char sign; /* May be '+', '-', or '\0' */
00219   int is_utc; /* May be 1 (yes) or 0 (no) */
00220 } fipa_DateTime_t;
00221 typedef fipa_DateTime_t* fipa_DateTime_p;
00222 fipa_DateTime_t* fipa_DateTime_New(void);
00223 int fipa_DateTime_Destroy(fipa_DateTime_t* dt);
00224 fipa_DateTime_t* fipa_DateTime_Copy(fipa_DateTime_t* src);
00225 int fipa_DateTime_Compose(dynstring_t* msg, fipa_DateTime_t* date);
00226 
00227 /* fipa_url */
00228 typedef struct fipa_url_s
00229 {
00230   char *str;
00231 } fipa_url_t;
00232 typedef fipa_url_t* fipa_url_p;
00233 fipa_url_t* fipa_url_New(void);
00234 int fipa_url_Destroy(fipa_url_t* url);
00235 fipa_url_t* fipa_url_Copy(fipa_url_t* src);
00236 int fipa_url_Compose(dynstring_t* msg, fipa_url_t* url);
00237 
00238 /* fipa_Number */
00239 typedef struct fipa_number_s
00240 {
00241   char *str;
00242 } fipa_number_t;
00243 typedef fipa_number_t* fipa_number_p;
00244 fipa_number_t* fipa_number_New(void);
00245 int fipa_number_Destroy(fipa_number_t* number);
00246 fipa_number_t* fipa_number_Copy(fipa_number_t* src);
00247 int fipa_number_Compose(dynstring_t* msg, fipa_number_t* number);
00248 
00249 
00250 /* Parsing Functions */
00251 int fipa_acl_Parse(struct fipa_acl_message_s* acl, fipa_message_string_p message);
00252 int fipa_message_parameter_Parse(struct fipa_acl_message_s* acl, fipa_message_string_p message);
00253 int fipa_message_type_Parse(
00254     enum fipa_performative_e* performative, 
00255     fipa_message_string_p message
00256     );
00257 int fipa_GetAtom(
00258     fipa_message_string_p message,
00259     char expected_atom
00260     );
00261 int fipa_word_Parse(fipa_word_t** word, fipa_message_string_p message);
00262 int fipa_word_Destroy(fipa_word_t* word);
00263 int fipa_CheckNextToken(const fipa_message_string_p message, const char* token);
00264 int fipa_expression_Parse(fipa_expression_t** expression, fipa_message_string_p message);
00265 int fipa_GetNextWord(char** word, const fipa_message_string_p message);
00266 int fipa_GetWholeToken(char** word, const fipa_message_string_p message);
00267 int fipa_datetime_Parse(fipa_DateTime_p* datetime, fipa_message_string_p message);
00268 int fipa_string_Parse( fipa_string_p* fipa_string, fipa_message_string_p message);
00269 int fipa_agent_identifier_Parse(fipa_agent_identifier_p* aid, fipa_message_string_p message);
00270 int fipa_agent_identifier_set_Parse(fipa_agent_identifier_set_p* agent_ids, fipa_message_string_p message);
00271 int fipa_url_sequence_Parse(fipa_url_sequence_p* urls, fipa_message_string_p message);
00272 int fipa_url_Parse(fipa_url_p* url, fipa_message_string_p message);
00273 
00274 struct fipa_acl_message_s* fipa_Reply(
00275     struct fipa_acl_message_s* acl);
00276 
00277 #endif

Generated on Tue Jul 1 15:29:57 2008 for Mobile-C by  doxygen 1.5.4