include/alp/pdi.h

Go to the documentation of this file.
00001 /******************************************************************************
00002 
00003  * Copyright (c) 1999-2008 ACCESS CO., LTD. All rights reserved.
00004  * Copyright (c) 2006 PalmSource, Inc (an ACCESS company). All rights reserved.
00005 
00006  *****************************************************************************/
00013 #ifndef ALP_PDI_H_
00014 #define ALP_PDI_H_
00015 
00025 
00026  
00027 #include <alp/config.h>
00028 #include <alp/types.h>
00029 #include <alp/sysclass.h>
00030 #include <alp/uda.h>
00031 #include <alp/pdi_const.h>
00032 
00033 /*******************************************************************
00034 
00035  * Pdi Library result codes
00036 
00037  *******************************************************************/
00038 #define ALP_PDI_STATUS_READ                             (ALP_CLASS_PDIUDA | 0x00010000)         
00039 #define ALP_PDI_STATUS_WRITE                            (ALP_CLASS_PDIUDA | 0x00020000)         
00040 #define ALP_PDI_STATUS_NO_PROPERTY_VALUE        (ALP_CLASS_PDIUDA | 0x00040000)         
00041 #define ALP_PDI_STATUS_MORE_CHARS                       (ALP_CLASS_PDIUDA | 0x00050000)         
00042 #define ALP_PDI_STATUS_NO_MORE_FIELDS           (ALP_CLASS_PDIUDA | 0x00060000)         
00043 
00044 /*******************************************************************
00045  * Pdi library constants
00046  *******************************************************************/
00047 
00048 #define ALP_PDI_ASCII_ENCODING          0                                                                               
00049 #define ALP_PDI_QP_ENCODING             ALP_PDI_PAV_ENCODING_QUOTED_PRINTABLE   
00050 #define ALP_PDI_B64_ENCODING            ALP_PDI_PAV_ENCODING_BASE64                     
00051 #define ALP_PDI_B_ENCODING                      ALP_PDI_PAV_ENCODING_B                                  
00052 #define ALP_PDI_ESCAPE_ENCODING         ((uint16_t) (0x8000))                                   
00053 #define ALP_PDI_NO_ENCODING                     ((uint16_t) (0x8001))                                   
00054 
00055 // Constants for structured property values
00056 
00057 #define ALP_PDI_NO_FIELDS                       ((uint16_t) 0)  
00058 #define ALP_PDI_COMMA_FIELDS            ((uint16_t) 1)  
00059 #define ALP_PDI_SEMICOLON_FIELDS        ((uint16_t) 2)  
00060 #define ALP_PDI_DEFAULT_FIELDS          ((uint16_t) 4)  
00061 #define ALP_PDI_CONVERT_COMMA           ((uint16_t) 8)  
00062 #define ALP_PDI_CONVERT_SEMICOLON       ((uint16_t) 16) 
00063 
00064 // Constants to manage parser/generator behavior
00065 
00066 // Generator behavior
00067 #define ALP_PDI_ENABLE_FOLDING                          ((uint16_t) 1)  
00068 #define ALP_PDI_ENABLE_QUOTED_PRINTABLE         ((uint16_t) 2)  
00069 #define ALP_PDI_ESCAPE_MULTI_FIELD_VALUES       ((uint16_t) 4)  
00070 #define ALP_PDI_ENABLE_B                                        ((uint16_t) 8)  
00071 // Parser behavior, currently the open parser is OK
00072 // Maybe future evolution will declare new constants
00073 #define ALP_PDI_OPEN_PARSER                             ((uint16_t) 16)         
00074 #define ALP_PDI_PALM_COMPATIBILITY              (ALP_PDI_ESCAPE_MULTI_FIELD_VALUES | ALP_PDI_ENABLE_QUOTED_PRINTABLE | ALP_PDI_BYPASS_LOCALE_CHAR_ENCODING)     
00075 
00076 // parser/generator behavior
00077 #define ALP_PDI_BYPASS_LOCALE_CHAR_ENCODING     ((uint16_t) 32) 
00078 // Constants to manage writting of values
00079 #define ALP_PDI_WRITE_DATA                      ((uint16_t) 0)  
00080 #define ALP_PDI_WRITE_TEXT                      ((uint16_t) 8)  
00081 #define ALP_PDI_WRITE_MULTILINE         ((uint16_t) 16) 
00082 
00083 // Constant to manage growing buffers
00084 #define ALP_PDI_RESIZABLE_BUFFER                        ((uint16_t) 0xFFFF)     
00085 #define ALP_PDI_DEFAULT_BUFFER_MAX_SIZE         ((uint32_t) 0x21000)
00086 #define ALP_PDI_DEFAULT_BUFFER_DELTA_SIZE       ((uint16_t) 0x0100)     
00087 // event mask of automata
00088 
00089 #define ALP_PDI_EOF_EVENT_MASK                                  ((uint16_t) 1)          
00090 #define ALP_PDI_GROUP_NAME_EVENT_MASK                   ((uint16_t) 2)          
00091 #define ALP_PDI_PROPERTY_NAME_EVENT_MASK                ((uint16_t) 4)          
00092 #define ALP_PDI_PARAMETER_NAME_EVENT_MASK               ((uint16_t) 8)          
00093 #define ALP_PDI_PARAMETER_VALUE_EVENT_MASK              ((uint16_t) 16)         
00094 #define ALP_PDI_PROPERTY_DEFINED_EVENT_MASK             ((uint16_t) 32)         
00095 #define ALP_PDI_PROPERTY_VALUE_EVENT_MASK               ((uint16_t) 64)         
00096 #define ALP_PDI_PROPERTY_VALUE_FIELD_EVENT_MASK ((uint16_t) 128)        
00097 #define ALP_PDI_PROPERTY_VALUE_ITEM_EVENT_MASK  ((uint16_t) 256)        
00098 #define ALP_PDI_PROPERTY_VALUE_MORE_CHARS_EVENT_MASK    ((uint16_t) 512)        
00099 #define ALP_PDI_BEGIN_OBJECT_EVENT_MASK                 ((uint16_t) 1024)       
00100 #define ALP_PDI_END_OBJECT_EVENT_MASK                   ((uint16_t) 2048)       
00101 #define ALP_PDI_PROPERTY_VALUE_CRLF_EVENT_MASK  ((uint16_t) 4096)       
00102 #define ALP_PDI_PROPERTY_TXT_ENCODING_UTF16             ((uint16_t) 1)          
00103 
00104 
00105 /*******************************************************************
00106  * Public Data structures.
00107  *******************************************************************/
00108 
00110 typedef uint8_t AlpPdiDictionary;
00111 
00113 typedef uint16_t AlpErr16;
00114 
00116 typedef struct _AlpPdiReader {
00117 #if defined(WIN32)
00118         uint32_t srcCharSet;
00119         uint32_t destinationCharset;
00120 #endif
00121         AlpErr16 errorLowWord;          
00122         uint16_t encoding;                      
00123         uint8_t fieldNum;                       
00124         uint8_t padding1;                       
00125         uint32_t charset;                       
00126         uint32_t written;                       
00127         uint16_t property;                      
00128         uint16_t propertyValueType;     
00129         uint16_t parameter;                     
00130         uint32_t parameterPairs[8];     
00131         uint16_t customFieldNumber;     
00132         uint16_t padding2;                      
00133         void *appData;                          
00134         uint16_t pdiRefNum;                     
00135         uint16_t events;                        
00136         char *groupName;                        
00137         char *propertyName;                     
00138         char *parameterName;            
00139         char *parameterValue;           
00140         char *propertyValue;            
00141 } AlpPdiReader;
00142 
00144 typedef struct _AlpPdiWriter {
00145 #if defined(WIN32)
00146         uint32_t srcCharSet;
00147         uint32_t destinationCharset;
00148 #endif
00149         AlpErr16 errorLowWord;          
00150         uint16_t encoding;                      
00151         uint32_t charset;                       
00152         uint8_t padding1[2];            
00153         uint32_t reserved;                      
00154         void *appData;                          
00155         uint16_t pdiRefNum;                     
00156         uint16_t padding2;                      
00157 } AlpPdiWriter;
00158 
00159 #ifdef __cplusplus
00160 
00161 extern "C" {
00162 #endif
00163 
00164 /*******************************************************************
00165  * Reader / Writer initialization & finalization functions
00166  *******************************************************************/
00178 extern AlpPdiReader *alp_pdi_reader_new(AlpUDAReader * input, uint16_t version);
00179 
00195 extern void alp_pdi_reader_delete(AlpPdiReader ** ioReader);
00196 
00208 extern AlpPdiWriter *alp_pdi_writer_new(AlpUDAWriter * output, uint16_t version);
00209 
00216  extern void alp_pdi_writer_delete(AlpPdiWriter ** ioWriter);
00217 
00218 /*******************************************************************
00219  * Read functions group. 
00220  *******************************************************************/
00236 extern alp_status_t alp_pdi_read_property(AlpPdiReader * ioReader);
00237 
00257 extern alp_status_t alp_pdi_read_property_field(AlpPdiReader * ioReader, char **bufferPP, uint32_t bufferSize,
00258                                                                         uint16_t readMode);
00259 
00271 extern alp_status_t alp_pdi_read_property_name(AlpPdiReader * ioReader);
00272 
00284 extern alp_status_t alp_pdi_read_parameter(AlpPdiReader * ioReader);
00285 
00300 extern alp_status_t alp_pdi_define_resizing(AlpPdiReader * ioReader, uint16_t deltaSize, uint32_t maxSize);
00301 
00302 #define ALP_PDI_PARAMETER_PAIR_TEST(reader, pair)       ((reader->parameterPairs[(pair) & 7] & ((uint32_t) (1) << ((uint8_t) (pair) >> 3))) != 0)
00303 
00304 /*******************************************************************
00305  * Recursive objects functions group.
00306  *******************************************************************/
00307 
00319 extern alp_status_t alp_pdi_enter_object(AlpPdiReader * ioReader);
00320 
00321 /*******************************************************************
00322  * Write functions group. 
00323  *******************************************************************/
00324 
00334  extern alp_status_t alp_pdi_write_begin_object(AlpPdiWriter * ioWriter, uint16_t objectNameID);
00335 
00336 #define alp_pdi_write_end_object alp_pdi_write_begin_object
00337 
00348 extern alp_status_t alp_pdi_write_property(AlpPdiWriter * ioWriter, uint16_t propertyNameID);
00349 
00363 extern alp_status_t alp_pdi_write_parameter(AlpPdiWriter * ioWriter, uint16_t parameter, int parameterName);
00364 
00373 extern alp_status_t alp_pdi_write_property_value(AlpPdiWriter * ioWriter, char *buffer, uint16_t options);
00374 
00383 extern alp_status_t alp_pdi_write_property_fields(AlpPdiWriter * ioWriter, char *fields[], uint16_t fieldNumber,
00384                                                                                                   uint16_t options);
00393  extern alp_status_t alp_pdi_write_property_binary_value(AlpPdiWriter * ioWriter, const char *buffer, uint16_t size,
00394                                                                                                                 uint16_t options);
00404 extern alp_status_t alp_pdi_set_encoding(AlpPdiWriter * ioWriter, uint16_t encoding);
00405 
00415 extern alp_status_t alp_pdi_set_charset(AlpPdiWriter * ioWriter, uint32_t charset);
00416 
00417 #if defined(WIN32)
00418 
00427 extern alp_status_t alp_pdi_set_property_encoding(AlpPdiWriter * ioWriter, uint16_t encoding);
00428 
00438 extern alp_status_t alp_pdi_set_writer_src_charset(AlpPdiWriter * ioWriter, uint32_t charset);
00439 
00449 extern alp_status_t alp_pdi_set_writer_destination_charset(AlpPdiWriter * ioWriter, uint32_t charset);
00450 
00460 extern alp_status_t alp_pdi_set_reader_src_charset(AlpPdiReader * ioReader, uint32_t charset);
00461 
00471 extern alp_status_t alp_pdi_set_reader_destination_charset(AlpPdiReader * ioReader, uint32_t charset);
00472 
00473 #endif
00474 
00484 extern alp_status_t alp_pdi_write_property_str(AlpPdiWriter * ioWriter, const char *propertyName, uint8_t writeMode,
00485                                                                                            uint8_t requiredFields);
00492 extern alp_status_t alp_pdi_write_parameter_str(AlpPdiWriter * ioWriter, const char *parameterName,
00493                                                                                                 const char *parameterValue);
00499 extern alp_status_t alp_pdi_get_object_length( AlpPdiWriter * ioWriter, uint32_t *objectLength);
00500 
00501 /*******************************************************************
00502  * Customisation functions group
00503  *******************************************************************/
00504 
00505  
00513 extern AlpPdiDictionary *alp_pdi_define_reader_dictionary(AlpPdiReader * ioReader, AlpPdiDictionary * dictionary,
00514                                                                                                                   int disableMainDictionary);
00522 extern AlpPdiDictionary *alp_pdi_define_writer_dictionary(AlpPdiWriter * ioWriter, AlpPdiDictionary * dictionary,
00523                                                                                                                   int disableMainDictionary);
00524 #ifdef __cplusplus
00525 }
00526 #endif
00527 
00530 #endif 
00531 

Generated on Wed Jul 30 07:06:39 2008 by Doxygen 1.4.6 for ALP SDK + Hiker Documentation

Copyright © 1999-2008 ACCESS CO., LTD. All rights reserved.