00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef _SML_PARSE_H_
00023 #define _SML_PARSE_H_
00024
00025 typedef enum {
00026 SML_PARSER_RESULT_ERROR = 0,
00027 SML_PARSER_RESULT_OPEN = 1,
00028 SML_PARSER_RESULT_CLOSE = 2,
00029 SML_PARSER_RESULT_NORMAL = 3,
00030 SML_PARSER_RESULT_STATUS = 4,
00031 SML_PARSER_RESULT_OTHER = 5
00032 } SmlParserResult;
00033
00034 typedef void (* SmlParserFreeFunction) (void *userdata);
00035 typedef SmlBool (* SmlParserStartFunction) (void *userdata, const char *data, unsigned int size, SmlError **error);
00036 typedef SmlBool (* SmlParserEndFunction) (void *userdata, SmlBool *final, SmlBool *end, SmlError **error);
00037 typedef SmlBool (* SmlParserHeaderFunction) (void *userdata, SmlHeader **header, SmlCred **cred, SmlError **error);
00038 typedef SmlBool (* SmlParserStatusFunction) (void *userdata, SmlStatus **status, SmlError **error);
00039 typedef SmlParserResult (* SmlParserCommandFunction) (void *userdata, SmlCommand **cmd, SmlError **error);
00040
00041 typedef struct SmlParserFunctions {
00042 SmlParserFreeFunction free;
00043 SmlParserStartFunction start;
00044 SmlParserEndFunction end;
00045 SmlParserHeaderFunction get_header;
00046 SmlParserStatusFunction get_status;
00047 SmlParserCommandFunction get_cmd;
00048 } SmlParserFunctions;
00049
00050 typedef void (* SmlAssemblerFreeFunction) (void *userdata);
00051 typedef SmlBool (* SmlAssemblerStartFunction) (void *userdata, SmlSession *session, SmlError **error);
00052 typedef SmlBool (* SmlAssemblerEndFunction) (void *userdata, SmlError **error);
00053 typedef SmlBool (* SmlAssemblerRunFunction) (void *userdata, char **data, unsigned int *size, SmlBool *end, SmlBool final, unsigned int maxsize, SmlError **error);
00054 typedef unsigned int (* SmlAssemblerFlushFunction) (void *userdata);
00055 typedef SmlBool (* SmlAssemblerStatusFunction) (void *userdata, SmlStatus *status, SmlError **error);
00056 typedef SmlBool (* SmlAssemblerRemStatusFunction) (void *userdata, SmlError **error);
00057 typedef SmlBool (* SmlAssemblerReserveStatusFunction) (void *userdata, unsigned int cmdRef, unsigned int msgRef, unsigned int cmdID, SmlError **error);
00058 typedef SmlBool (* SmlAssemblerStatusMissingFunction) (void *userdata);
00059 typedef SmlBool (* SmlAssemblerStartCommandFunction) (void *userdata, unsigned int parentID, SmlCommand *cmd, SmlError **error);
00060 typedef SmlBool (* SmlAssemblerEndCommandFunction) (void *userdata, unsigned int parentID, SmlError **error);
00061 typedef SmlBool (* SmlAssemblerRemCommandFunction) (void *userdata, unsigned int parentID, SmlError **error);
00062 typedef SmlBool (* SmlAssemblerHeaderFunction) (void *userdata, SmlSession *session, SmlError **error);
00063 typedef unsigned int (* SmlAssemblerCheckFunction) (void *userdata, SmlBool headeronly, SmlError **error);
00064 typedef SmlBool (* SmlAssemblerNextCmdRefFunction) (void *userdata, unsigned int *cmdRef, unsigned int *msgRef);
00065 typedef void (* SmlAssemblerRestoreCommandsFunction) (void *userdata);
00066
00067 typedef struct SmlAssemblerFunctions {
00068 SmlAssemblerFreeFunction free;
00069 SmlAssemblerStartFunction start;
00070 SmlAssemblerEndFunction end;
00071 SmlAssemblerRunFunction run;
00072 SmlAssemblerFlushFunction flush;
00073 SmlAssemblerStatusFunction add_status;
00074 SmlAssemblerRemStatusFunction rem_status;
00075 SmlAssemblerReserveStatusFunction reserve_status;
00076 SmlAssemblerStatusMissingFunction missing_status;
00077 SmlAssemblerStartCommandFunction start_cmd;
00078 SmlAssemblerEndCommandFunction end_cmd;
00079 SmlAssemblerRemCommandFunction rem_cmd;
00080 SmlAssemblerHeaderFunction add_header;
00081 SmlAssemblerCheckFunction check_size;
00082 SmlAssemblerNextCmdRefFunction next_cmdref;
00083 SmlAssemblerRestoreCommandsFunction restore_cmds;
00084 } SmlAssemblerFunctions;
00085
00086 typedef enum {
00087 SML_ASSEMBLER_RESULT_ERROR = 0,
00088 SML_ASSEMBLER_RESULT_OK = 1,
00089 SML_ASSEMBLER_RESULT_MISMATCH =2
00090 } SmlAssemblerResult;
00091
00092 SmlParser *smlParserNew(SmlMimeType type, unsigned int limit, SmlError **error);
00093 void smlParserFree(SmlParser *parser);
00094 SmlBool smlParserStart(SmlParser *parser, const char *data, unsigned int size, SmlError **error);
00095 SmlBool smlParserGetHeader(SmlParser *parser, SmlHeader **header, SmlCred **cred, SmlError **error);
00096 SmlParserResult smlParserGetCommand(SmlParser *parser, SmlCommand **cmd, SmlError **error);
00097 SmlBool smlParserGetStatus(SmlParser *parser, SmlStatus **status, SmlError **error);
00098 SmlBool smlParserEnd(SmlParser *parser, SmlBool *final, SmlBool *end, SmlError **error);
00099
00100 SmlAssembler *smlAssemblerNew(SmlMimeType type, unsigned int limit, SmlError **error);
00101 void smlAssemblerFree(SmlAssembler *assm);
00102 SmlBool smlAssemblerStart(SmlAssembler *assm, SmlSession *session, SmlError **error);
00103 unsigned int smlAssemblerFlush(SmlAssembler *assm);
00104 void smlAssemblerRestoreCommands(SmlAssembler *assm);
00105 SmlBool smlAssemblerRun(SmlAssembler *assm, char **data, unsigned int *size, SmlBool *end, SmlBool final, SmlError **error);
00106 SmlAssemblerResult smlAssemblerAddStatus(SmlAssembler *assm, SmlStatus *status, SmlError **error);
00107 SmlAssemblerResult smlAssemblerAddStatusFull(SmlAssembler *assm, SmlStatus *status, SmlBool force, SmlError **error);
00108 SmlAssemblerResult smlAssemblerReserveStatus(SmlAssembler *assm, unsigned int cmdRef, unsigned int msgRef, unsigned int cmdID, SmlError **error);
00109 SmlBool smlAssemblerAddHeader(SmlAssembler *assm, SmlSession *session, SmlError **error);
00110 SmlAssemblerResult smlAssemblerStartCommand(SmlAssembler *assm, SmlCommand *parent, SmlCommand *cmd, SmlError **error);
00111 SmlBool smlAssemblerEndCommand(SmlAssembler *assm, SmlCommand *parent, SmlError **error);
00112 unsigned int smlAssemblerCheckSize(SmlAssembler *assm, SmlBool headeronly, SmlError **error);
00113 void smlAssemblerSetOption(SmlAssembler *assm, const char *optionname, const char *value);
00114 const char *smlAssemblerGetOption(SmlAssembler *assm, const char *optionname);
00115
00116 unsigned int smlAssemblerSetRemoteMaxMsgSize(SmlAssembler *assm, unsigned int limit);
00117 unsigned int smlAssemblerGetRemoteMaxMsgSize(SmlAssembler *assm);
00118 SmlBool smlAssemblerGetSpace(SmlAssembler *assm, int *space, SmlCommand *parent, SmlCommand *cmd, SmlError **error);
00119
00120 unsigned int smlAssemblerGetRemoteMaxObjSize(SmlAssembler *assm);
00121 unsigned int smlAssemblerSetRemoteMaxObjSize(SmlAssembler *assm, unsigned int limit);
00122
00123 SmlBool smlAssemblerIsEmpty(SmlAssembler *assm);
00124 SmlBool smlAssemblerIsStatusMissing(SmlAssembler *assm);
00125 SmlBool smlAssemblerGetNextCmdRef(SmlAssembler *assm, unsigned int *cmdRef, unsigned int *msgRef);
00126
00127
00128 void smlAssemblerSetRequestedLimit(SmlAssembler *assm, unsigned int limit) LIBSYNCML_DEPRECATED;
00129 void smlAssemblerSetLimit(SmlAssembler *assm, unsigned int limit) LIBSYNCML_DEPRECATED;
00130 unsigned int smlAssemblerGetLimit(SmlAssembler *assm) LIBSYNCML_DEPRECATED;
00131 void smlAssemblerSetRequestedMaxObjSize(SmlAssembler *assm, int limit) LIBSYNCML_DEPRECATED;
00132 void smlAssemblerSetSendingMaxObjSize(SmlAssembler *assm, int limit) LIBSYNCML_DEPRECATED;
00133 int smlAssemblerGetSendingMaxObjSize(SmlAssembler *assm) LIBSYNCML_DEPRECATED;
00134 int smlAssemblerGetRequestedMaxObjSize(SmlAssembler *assm) LIBSYNCML_DEPRECATED;
00135
00136
00137 void smlParserSetManager(SmlParser *parser, SmlManager *manager);
00138
00139 #endif //_SML_PARSE_H_