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 #ifndef _FIPA_ACL_MESSAGE_H_
00036 #define _FIPA_ACL_MESSAGE_H_
00037 #include "dynstring.h"
00038
00039 #ifndef _FIPA_PERFORMATIVE_E_
00040 #define _FIPA_PERFORMATIVE_E_
00041 enum fipa_performative_e
00042 {
00043 FIPA_ERROR=-1,
00044 FIPA_ZERO,
00045 FIPA_ACCEPT_PROPOSAL,
00046 FIPA_AGREE,
00047 FIPA_CANCEL,
00048 FIPA_CALL_FOR_PROPOSAL,
00049 FIPA_CONFIRM,
00050 FIPA_DISCONFIRM,
00051 FIPA_FAILURE,
00052 FIPA_INFORM,
00053 FIPA_INFORM_IF,
00054 FIPA_INFORM_REF,
00055 FIPA_NOT_UNDERSTOOD,
00056 FIPA_PROPOGATE,
00057 FIPA_PROPOSE,
00058 FIPA_PROXY,
00059 FIPA_QUERY_IF,
00060 FIPA_QUERY_REF,
00061 FIPA_REFUSE,
00062 FIPA_REJECT_PROPOSAL,
00063 FIPA_REQUEST,
00064 FIPA_REQUEST_WHEN,
00065 FIPA_REQUEST_WHENEVER,
00066 FIPA_SUBSCRIBE
00067 };
00068 #endif
00069
00070 #ifndef _FIPA_PROTOCOL_E_
00071 #define _FIPA_PROTOCOL_E_
00072 enum fipa_protocol_e
00073 {
00074 FIPA_PROTOCOL_ERROR=-1,
00075 FIPA_PROTOCOL_NONE,
00076 FIPA_PROTOCOL_REQUEST,
00077 FIPA_PROTOCOL_QUERY,
00078 FIPA_PROTOCOL_REQUEST_WHEN,
00079 FIPA_PROTOCOL_CONTRACT_NET,
00080 FIPA_PROTOCOL_ITERATED_CONTRACT_NET,
00081 FIPA_PROTOCOL_ENGLISH_AUCTION,
00082 FIPA_PROTOCOL_DUTCH_AUCTION,
00083 FIPA_PROTOCOL_BROKERING,
00084 FIPA_PROTOCOL_RECRUITING,
00085 FIPA_PROTOCOL_SUBSCRIBE,
00086 FIPA_PROTOCOL_PROPOSE,
00087 FIPA_PROTOCOL_END
00088 };
00089 #endif
00090
00091 int fipa_performative_Compose(dynstring_t* msg, enum fipa_performative_e performative);
00092 int fipa_protocol_Compose(dynstring_t* msg, enum fipa_protocol_e protocol);
00093
00094 typedef enum fipa_expression_type_e
00095 {
00096 FIPA_EXPR_ZERO,
00097 FIPA_EXPR_WORD,
00098 FIPA_EXPR_STRING,
00099 FIPA_EXPR_NUMBER,
00100 FIPA_EXPR_DATETIME,
00101 FIPA_EXPR_EXPRESSION
00102 } fipa_expression_type_t;
00103
00104
00105 typedef struct fipa_acl_message_s
00106 {
00107 enum fipa_performative_e performative;
00108
00109 struct fipa_agent_identifier_s* sender;
00110
00111 struct fipa_agent_identifier_set_s* receiver;
00112 int receiver_num;
00113
00114 struct fipa_agent_identifier_set_s* reply_to;
00115
00116
00117 struct fipa_string_s* content;
00118
00119 struct fipa_expression_s* language;
00120
00121 struct fipa_expression_s* encoding;
00122
00123 struct fipa_expression_s* ontology;
00124
00125
00126 enum fipa_protocol_e protocol;
00127
00128 struct fipa_expression_s* conversation_id;
00129
00130 struct fipa_expression_s* reply_with;
00131
00132 struct fipa_expression_s* in_reply_to;
00133
00134 struct fipa_DateTime_s* reply_by;
00135 } fipa_acl_message_t;
00136 typedef fipa_acl_message_t* fipa_acl_message_p;
00137 fipa_acl_message_t* fipa_acl_message_New(void);
00138 int fipa_acl_message_Destroy(fipa_acl_message_t* message);
00139 fipa_acl_message_t* fipa_acl_message_Copy(fipa_acl_message_t* src);
00140 int fipa_acl_Compose(dynstring_t** msg, fipa_acl_message_t* acl);
00141
00142
00143 typedef struct fipa_message_string_s
00144 {
00145 char* message;
00146 char* parse;
00147 } fipa_message_string_t;
00148 typedef fipa_message_string_t* fipa_message_string_p;
00149 fipa_message_string_t* fipa_message_string_New(void);
00150 int fipa_message_string_Destroy(fipa_message_string_t* message);
00151 fipa_message_string_t* fipa_message_string_Copy(fipa_message_string_t* src);
00152
00153
00154 typedef struct fipa_url_sequence_s
00155 {
00156 int num;
00157 struct fipa_url_s** urls;
00158 } fipa_url_sequence_t;
00159 typedef fipa_url_sequence_t* fipa_url_sequence_p;
00160 fipa_url_sequence_t* fipa_url_sequence_New(void);
00161 int fipa_url_sequence_Destroy(fipa_url_sequence_t* sequence);
00162 fipa_url_sequence_t* fipa_url_sequence_Copy(fipa_url_sequence_t* src);
00163 int fipa_url_sequence_Compose(dynstring_t* msg, fipa_url_sequence_t* urls);
00164
00165
00166 typedef struct fipa_agent_identifier_set_s
00167 {
00168 int num;
00169 int retain_order;
00170 struct fipa_agent_identifier_s** fipa_agent_identifiers;
00171 } fipa_agent_identifier_set_t;
00172 typedef fipa_agent_identifier_set_t* fipa_agent_identifier_set_p;
00173 fipa_agent_identifier_set_t* fipa_agent_identifier_set_New(void);
00174 int fipa_agent_identifier_set_Destroy(fipa_agent_identifier_set_t* idset);
00175 fipa_agent_identifier_set_t* fipa_agent_identifier_set_Copy(
00176 fipa_agent_identifier_set_t* src);
00177 int fipa_agent_identifier_set_Compose(dynstring_t* msg, fipa_agent_identifier_set_t* ids);
00178
00179
00180 typedef struct fipa_agent_identifier_s
00181 {
00182 char* name;
00183 struct fipa_url_sequence_s* addresses;
00184 struct fipa_agent_identifier_set_s* resolvers;
00185 } fipa_agent_identifier_t;
00186 typedef fipa_agent_identifier_t* fipa_agent_identifier_p;
00187 fipa_agent_identifier_t* fipa_agent_identifier_New(void);
00188 int fipa_agent_identifier_Destroy(fipa_agent_identifier_t* id);
00189 fipa_agent_identifier_t* fipa_agent_identifier_Copy(fipa_agent_identifier_t* src);
00190 int fipa_agent_identifier_Compose(dynstring_t* msg, fipa_agent_identifier_t* id);
00191
00192
00193 typedef struct fipa_expression_s
00194 {
00195 enum fipa_expression_type_e type;
00196 union content_u
00197 {
00198 struct fipa_word_s* word;
00199 struct fipa_string_s* string;
00200 struct fipa_number_s* number;
00201 struct fipa_DateTime_s* datetime;
00202 struct fipa_expression_s** expression;
00203 } content;
00204 } fipa_expression_t;
00205 typedef fipa_expression_t* fipa_expression_p;
00206 fipa_expression_t* fipa_expression_New(void);
00207 int fipa_expression_Destroy(fipa_expression_t* expr);
00208 fipa_expression_t* fipa_expression_Copy(fipa_expression_t* src);
00209 int fipa_expression_Compose(dynstring_t* msg, fipa_expression_t* expr);
00210
00211
00212 typedef struct fipa_word_s
00213 {
00214 char* content;
00215 } fipa_word_t;
00216 typedef fipa_word_t* fipa_word_p;
00217 fipa_word_t* fipa_word_New(void);
00218 int fipa_word_Destroy(fipa_word_t* word);
00219 fipa_word_t* fipa_word_Copy(fipa_word_t* src);
00220 int fipa_word_Compose(dynstring_t* msg, fipa_word_t* word);
00221
00222
00223 typedef struct fipa_string_s
00224 {
00225 char* content;
00226 } fipa_string_t;
00227 typedef fipa_string_t* fipa_string_p;
00228 fipa_string_t* fipa_string_New(void);
00229 int fipa_string_Destroy(fipa_string_t* str);
00230 fipa_string_t* fipa_string_Copy(fipa_string_t* src);
00231 int fipa_string_Compose(dynstring_t* msg, fipa_string_t* string);
00232
00233
00234 typedef struct fipa_DateTime_s
00235 {
00236 int year;
00237 int month;
00238 int day;
00239 int hour;
00240 int minute;
00241 int second;
00242 int millisecond;
00243 char sign;
00244 int is_utc;
00245 } fipa_DateTime_t;
00246 typedef fipa_DateTime_t* fipa_DateTime_p;
00247 fipa_DateTime_t* fipa_DateTime_New(void);
00248 int fipa_DateTime_Destroy(fipa_DateTime_t* dt);
00249 fipa_DateTime_t* fipa_DateTime_Copy(fipa_DateTime_t* src);
00250 int fipa_DateTime_Compose(dynstring_t* msg, fipa_DateTime_t* date);
00251
00252
00253 typedef struct fipa_url_s
00254 {
00255 char *str;
00256 } fipa_url_t;
00257 typedef fipa_url_t* fipa_url_p;
00258 fipa_url_t* fipa_url_New(void);
00259 int fipa_url_Destroy(fipa_url_t* url);
00260 fipa_url_t* fipa_url_Copy(fipa_url_t* src);
00261 int fipa_url_Compose(dynstring_t* msg, fipa_url_t* url);
00262
00263
00264 typedef struct fipa_number_s
00265 {
00266 char *str;
00267 } fipa_number_t;
00268 typedef fipa_number_t* fipa_number_p;
00269 fipa_number_t* fipa_number_New(void);
00270 int fipa_number_Destroy(fipa_number_t* number);
00271 fipa_number_t* fipa_number_Copy(fipa_number_t* src);
00272 int fipa_number_Compose(dynstring_t* msg, fipa_number_t* number);
00273
00274
00275
00276 int fipa_acl_Parse(struct fipa_acl_message_s* acl, fipa_message_string_p message);
00277 int fipa_message_parameter_Parse(struct fipa_acl_message_s* acl, fipa_message_string_p message);
00278 int fipa_protocol_type_Parse(enum fipa_protocol_e* protocol, fipa_message_string_p message);
00279 int fipa_message_type_Parse(enum fipa_performative_e* performative, fipa_message_string_p message);
00280 int fipa_GetAtom( fipa_message_string_p message, char expected_atom);
00281 int fipa_word_Parse(fipa_word_t** word, fipa_message_string_p message);
00282 int fipa_word_Destroy(fipa_word_t* word);
00283 int fipa_CheckNextToken(const fipa_message_string_p message, const char* token);
00284 int fipa_expression_Parse(fipa_expression_t** expression, fipa_message_string_p message);
00285 int fipa_GetNextWord(char** word, const fipa_message_string_p message);
00286 int fipa_GetWholeToken(char** word, const fipa_message_string_p message);
00287 int fipa_datetime_Parse(fipa_DateTime_p* datetime, fipa_message_string_p message);
00288 int fipa_string_Parse( fipa_string_p* fipa_string, fipa_message_string_p message);
00289 int fipa_agent_identifier_Parse(fipa_agent_identifier_p* aid, fipa_message_string_p message);
00290 int fipa_agent_identifier_set_Parse(fipa_agent_identifier_set_p* agent_ids, fipa_message_string_p message);
00291 int fipa_url_sequence_Parse(fipa_url_sequence_p* urls, fipa_message_string_p message);
00292 int fipa_url_Parse(fipa_url_p* url, fipa_message_string_p message);
00293
00294 struct fipa_acl_message_s* fipa_Reply(
00295 struct fipa_acl_message_s* acl);
00296
00297 #endif