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 #ifndef _VFORMAT_H
00026 #define _VFORMAT_H
00027
00028 #include "dll.h"
00029 #include <glib.h>
00030 #include <time.h>
00031
00032 #ifdef __cplusplus
00033 extern "C" {
00034 #endif
00035
00036 typedef enum {
00037 VFORMAT_CARD_21,
00038 VFORMAT_CARD_30,
00039 VFORMAT_NOTE,
00040 VFORMAT_EVENT_10,
00041 VFORMAT_EVENT_20,
00042 VFORMAT_TODO_10,
00043 VFORMAT_TODO_20,
00044 VFORMAT_JOURNAL
00045 } b_VFormatType;
00046
00047 typedef struct b_VFormat {
00048
00049 GList *attributes;
00050 } b_VFormat;
00051
00052 #define CRLF "\r\n"
00053
00054 typedef enum {
00055 VF_ENCODING_RAW,
00056 VF_ENCODING_BASE64,
00057 VF_ENCODING_QP,
00058 VF_ENCODING_8BIT
00059 } b_VFormatEncoding;
00060
00061 typedef struct b_VFormatAttribute {
00062 char *block;
00063
00064 char *group;
00065 char *name;
00066 GList *params;
00067 GList *values;
00068 GList *decoded_values;
00069 b_VFormatEncoding encoding;
00070 gboolean encoding_set;
00071 } b_VFormatAttribute;
00072
00073 typedef struct b_VFormatParam {
00074 char *name;
00075 GList *values;
00076 } b_VFormatParam;
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097 b_VFormat *b_vformat_new(void);
00098 b_VFormat *b_vformat_new_from_string(const char *str);
00099 void b_vformat_dump_structure(b_VFormat *format);
00100 char *b_vformat_to_string(b_VFormat *evc, b_VFormatType type);
00101 time_t b_vformat_time_to_unix(const char *inptime);
00102 void b_vformat_free(b_VFormat *format);
00103
00104
00105 b_VFormatAttribute *b_vformat_attribute_new (const char *attr_group, const char *attr_name);
00106 void b_vformat_attribute_free (b_VFormatAttribute *attr);
00107 b_VFormatAttribute *b_vformat_attribute_copy (b_VFormatAttribute *attr);
00108 void b_vformat_remove_attributes (b_VFormat *vformat, const char *attr_group, const char *attr_name);
00109 void b_vformat_remove_attribute (b_VFormat *vformat, b_VFormatAttribute *attr);
00110 void b_vformat_add_attribute (b_VFormat *vformat, b_VFormatAttribute *attr);
00111 void b_vformat_add_attribute_with_value (b_VFormat *vformat, b_VFormatAttribute *attr, const char *value);
00112 void b_vformat_add_attribute_with_values (b_VFormat *vformat, b_VFormatAttribute *attr, ...);
00113 void b_vformat_attribute_add_value (b_VFormatAttribute *attr, const char *value);
00114 void b_vformat_attribute_set_value (b_VFormatAttribute *attr, int nth, const char *value);
00115 void b_vformat_attribute_add_value_decoded (b_VFormatAttribute *attr, const char *value, int len);
00116 void b_vformat_attribute_add_values (b_VFormatAttribute *attr, ...);
00117 void b_vformat_attribute_remove_values (b_VFormatAttribute *attr);
00118 void b_vformat_attribute_remove_params (b_VFormatAttribute *attr);
00119 b_VFormatAttribute *b_vformat_find_attribute (b_VFormat *evc, const char *name, int nth, const char *block);
00120
00121
00122 b_VFormatParam* b_vformat_attribute_param_new (const char *param_name);
00123 void b_vformat_attribute_param_free (b_VFormatParam *param);
00124 b_VFormatParam* b_vformat_attribute_param_copy (b_VFormatParam *param);
00125 void b_vformat_attribute_add_param (b_VFormatAttribute *attr, b_VFormatParam *param);
00126 b_VFormatParam *b_vformat_attribute_find_param(b_VFormatAttribute *attr, const char *name, int level);
00127 void b_vformat_attribute_add_param_with_value (b_VFormatAttribute *attr, const char *name, const char *value);
00128 void b_vformat_attribute_add_param_with_values (b_VFormatAttribute *attr,
00129 b_VFormatParam *param, ...);
00130
00131 void b_vformat_attribute_param_add_value (b_VFormatParam *param,
00132 const char *value);
00133 void b_vformat_attribute_param_add_values (b_VFormatParam *param,
00134 ...);
00135 void b_vformat_attribute_param_remove_values (b_VFormatParam *param);
00136 gboolean b_vformat_attribute_has_param(b_VFormatAttribute *attr, const char *name);
00137
00138
00139
00140 GList* b_vformat_get_attributes (b_VFormat *vformat);
00141 const char* b_vformat_attribute_get_group (b_VFormatAttribute *attr);
00142 const char* b_vformat_attribute_get_name (b_VFormatAttribute *attr);
00143 const char* b_vformat_attribute_get_block (b_VFormatAttribute *attr);
00144 GList* b_vformat_attribute_get_values (b_VFormatAttribute *attr);
00145 GList* b_vformat_attribute_get_values_decoded (b_VFormatAttribute *attr);
00146 const char *b_vformat_attribute_get_nth_value(b_VFormatAttribute *attr, int nth);
00147
00148
00149 gboolean b_vformat_attribute_is_single_valued (b_VFormatAttribute *attr);
00150 char* b_vformat_attribute_get_value (b_VFormatAttribute *attr);
00151 GString* b_vformat_attribute_get_value_decoded (b_VFormatAttribute *attr);
00152
00153 GList* b_vformat_attribute_get_params (b_VFormatAttribute *attr);
00154 const char* b_vformat_attribute_param_get_name (b_VFormatParam *param);
00155 GList* b_vformat_attribute_param_get_values (b_VFormatParam *param);
00156 const char *b_vformat_attribute_param_get_nth_value(b_VFormatParam *param, int nth);
00157
00158
00159 gboolean b_vformat_attribute_has_type (b_VFormatAttribute *attr, const char *typestr);
00160
00161
00162 char* b_vformat_escape_string (const char *str, b_VFormatType type);
00163 char* b_vformat_unescape_string (const char *str);
00164
00165 #ifdef __cplusplus
00166 }
00167 #endif
00168
00169 #endif