1 /*************************************************************************/ 2 /* module: Encoder header file */ 3 /* file: xltenc.h */ 4 /* target system: All */ 5 /* target OS: All */ 6 /*************************************************************************/ 7 8 /* 9 * Copyright Notice 10 * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication 11 * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc., 12 * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001). 13 * All Rights Reserved. 14 * Implementation of all or part of any Specification may require 15 * licenses under third party intellectual property rights, 16 * including without limitation, patent rights (such a third party 17 * may or may not be a Supporter). The Sponsors of the Specification 18 * are not responsible and shall not be held responsible in any 19 * manner for identifying or failing to identify any or all such 20 * third party intellectual property rights. 21 * 22 * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED 23 * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM, 24 * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA, 25 * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML 26 * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING 27 * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION 28 * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF 29 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT 30 * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO., 31 * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY 32 * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF 33 * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF 34 * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL, 35 * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH 36 * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED 37 * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE. 38 * 39 * The above notice and this paragraph must be included on all copies 40 * of this document that are made. 41 * 42 */ 43 44 /*************************************************************************/ 45 /* Definitions */ 46 /*************************************************************************/ 47 48 #ifndef _XLT_ENC_H 49 #define _XLT_ENC_H 50 51 52 #include <smlerr.h> 53 #include <xltenccom.h> 54 #include <smldef.h> 55 #include <smldtd.h> 56 #include <xlttags.h> 57 58 #ifdef _cplusplus 59 extern "C" { 60 #endif 61 62 //Type for storing encoder information 63 typedef struct XltEncoder_s 64 { 65 SmlEncoding_t enc; 66 SmlVersion_t vers; // %%% luz 2003-07-31: added SyncML version here 67 SmlPcdataExtension_t cur_ext; 68 SmlPcdataExtension_t last_ext; 69 Boolean_t final; 70 XltSpaceEvaluationPtr_t space_evaluation; 71 MemSize_t end_tag_size; 72 } XltEncoder_t, *XltEncoderPtr_t; 73 74 75 /** 76 * FUNCTION: smlXltEncInit 77 * 78 * Initializes an XML buffer; Creates XML code for the SyncHdr 79 * and appends it to the buffer. 80 * Returns 0 if operation was successful. 81 * 82 * PRE-Condition: no memory should be allocated for ppEncoder (should be NULL) 83 * pHeader has to contain a valid SyncHdr structure 84 * pBufEnd must point to the end of the (WB)XML buffer 85 * ppBufPos has to be initialized to the start point of the 86 * (WB)XML buffer. 87 * 88 * 89 * POST-Condition: After the function call ppBufPos points to the 90 * first free byte in the buffer behind the (WB)XML document 91 * 92 * IN: enc, the encoding constant (SML_WBXML or SML_XML) 93 * pHeader, the SyncML header structure 94 * pBufEnd, pointer to the end of the buffer to write on 95 * %%% luz:2003-07-31: vers must be the SyncML version (for namespaces and FPI's) 96 * 97 * IN/OUT: ppBufPos, current position of the bufferpointer 98 * ppEncoder, the encoder object 99 * 100 * RETURN: shows error codes of function, 101 * 0, if OK 102 * Possible Error Codes: 103 * SML_ERR_XLT_MISSING_CONT 104 * SML_ERR_XLT_BUF_ERR 105 * SML_ERR_XLT_INVAL_ELEM_TYPE 106 * SML_ERR_XLT_INVAL_LIST_TYPE 107 * SML_ERR_XLT_INVAL_TAG_TYPE 108 * SML_ERR_XLT_CONTENT_SIZE_LENGTH 109 * SML_ERR_XLT_ENC_UNK 110 * SML_ERR_XLT_INVAL_PROTO_ELEM 111 */ 112 Ret_t xltEncInit(SmlEncoding_t enc, const SmlSyncHdrPtr_t pHeader, const MemPtr_t pBufEnd, MemPtr_t *ppBufPos, XltEncoderPtr_t *ppEncoder, SmlVersion_t vers); 113 114 /** 115 * FUNCTION: smlXltEncAppend 116 * 117 * Generates XML code and appends it to the XML buffer. 118 * 119 * PRE-Condition: pEncoder holds the initialized encoder structure. 120 * the initialization takes place in the xltEncAppend function 121 * pContent has to contain a valid content structure structure 122 * pBufEnd must point to the end of the (WB)XML buffer 123 * ppBufPos has to be initialized to the start point of the 124 * (WB)XML buffer. 125 * 126 * 127 * POST-Condition: After the function call ppBufPos points to the 128 * first free byte in the buffer behind the (WB)XML document 129 * 130 * IN: pEncoder, the encoder object 131 * pe, the protocol element (PE_ADD, ...) 132 * pBufEnd, pointer to the end of the buffer to write on 133 * pContent, the content to append to the SyncML document 134 * 135 * IN/OUT: ppBufPos, current position of the bufferpointer 136 * 137 * RETURN: shows error codes of function, 138 * 0, if OK 139 * Possible Error Codes: 140 * SML_ERR_XLT_MISSING_CONT 141 * SML_ERR_XLT_BUF_ERR 142 * SML_ERR_XLT_INVAL_ELEM_TYPE 143 * SML_ERR_XLT_INVAL_LIST_TYPE 144 * SML_ERR_XLT_INVAL_TAG_TYPE 145 * SML_ERR_XLT_CONTENT_SIZE_LENGTH 146 * SML_ERR_XLT_ENC_UNK 147 * SML_ERR_XLT_INVAL_PROTO_ELEM 148 */ 149 150 Ret_t xltEncAppend(const XltEncoderPtr_t pEncoder, 151 SmlProtoElement_t pe, 152 const MemPtr_t pBufEnd, 153 const VoidPtr_t pContent, 154 MemPtr_t *ppBufPos); 155 /** 156 * FUNCTION: smlXltEncTerminate_t pBufEnd, const VoidPtr_t pContent, MemPtr_t *ppBufPos, 157 * 158 * Finalizes the (WB)XML document and returns the size of written bytes to 159 * the workspace module 160 * 161 * PRE-Condition: pEncoder holds the initialized encoder structure. 162 * the initialization takes place in the xltEncAppend function 163 * pBufEnd must point to the end of the (WB)XML buffer 164 * ppBufPos has to be initialized to the start point of the 165 * (WB)XML buffer. 166 * 167 * POST-Condition: After the function call ppBufPos points to the 168 * first free byte in the buffer behind the (WB)XML document 169 * 170 * IN: pEncoder, the encoder object 171 * pBufEnd, pointer to the end of the buffer to write on 172 * 173 * IN/OUT: ppBufPos, current position of the bufferpointer 174 * 175 * RETURN: shows error codes of function, 176 * 0, if OK 177 * Possible Error Codes: 178 * SML_ERR_XLT_MISSING_CONT 179 * SML_ERR_XLT_BUF_ERR 180 * SML_ERR_XLT_INVAL_ELEM_TYPE 181 * SML_ERR_XLT_INVAL_LIST_TYPE 182 * SML_ERR_XLT_INVAL_TAG_TYPE 183 * SML_ERR_XLT_CONTENT_SIZE_LENGTH 184 * SML_ERR_XLT_ENC_UNK 185 * SML_ERR_XLT_INVAL_PROTO_ELEM 186 */ 187 Ret_t xltEncTerminate(const XltEncoderPtr_t pEncoder, const MemPtr_t pBufEnd, MemPtr_t *ppBufPos); 188 Ret_t xltEncReset(XltEncoderPtr_t pEncoder); 189 Ret_t xltGenerateTag(XltTagID_t, XltTagType_t, SmlEncoding_t, BufferMgmtPtr_t, SmlPcdataExtension_t); 190 Ret_t xltStartEvaluation(XltEncoderPtr_t pEncoder); 191 Ret_t xltEndEvaluation(InstanceID_t id, XltEncoderPtr_t pEncoder, MemSize_t *freemem); 192 Ret_t xltEncBlock(XltTagID_t tagId, XltRO_t reqOptFlag, const VoidPtr_t pContent, SmlEncoding_t enc, BufferMgmtPtr_t pBufMgr, SmlPcdataExtension_t attFlag); 193 Ret_t xltBuildExtention(SmlPcdataExtension_t extId, XltRO_t reqOptFlag, VoidPtr_t pContent, SmlEncoding_t enc, BufferMgmtPtr_t pBufMgr); 194 Ret_t xltEncPcdata(XltTagID_t tagId, XltRO_t reqOptFlag, const VoidPtr_t pContent, SmlEncoding_t enc, BufferMgmtPtr_t pBufMgr, SmlPcdataExtension_t attFlag); 195 Ret_t subdtdEncWBXML(XltTagID_t tagId, XltRO_t reqOptFlag, const VoidPtr_t pContent, SmlEncoding_t enc, BufferMgmtPtr_t pBufMgr, SmlPcdataExtension_t attFlag); 196 197 #ifdef _cplusplus 198 } 199 #endif 200 201 #endif 202