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

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

Generated on Fri May 16 14:49:54 2008 for Mobile-C by  doxygen 1.5.4