updated change log to reflect reality
[barry.git] / src / cbarry.h
blob305dbf9b823cb6fa3c9e2188061a804d85af7069
1 /**
2 * \file cbarry.h
3 * Main header file for Barry C API - incomplete
4 */
6 /*
7 Copyright (C) 2007, Net Direct Inc. (http://www.netdirect.ca/)
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 See the GNU General Public License in the COPYING file at the
19 root directory of this project for more details.
22 #ifndef __BARRY_CBARRY_H__
23 #define __BARRY_CBARRY_H__
26 * Supporting C headers
28 #include <stdint.h>
29 #include <time.h>
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
36 * Barry C API
38 * All functions that can fail will either return a handle, which can
39 * be compared to NULL, or return int, which will == -1 on error.
41 * Functions that return a "count" can also fail, but rarely (such as
42 * if you pass in a bad handle).
45 /* Handle types */
46 typedef void* probe_handle_t;
47 typedef void* con_handle_t;
48 typedef void* state_table_handle_t;
49 typedef void* record_handle_t;
50 typedef void (*process_record_callback_t)(int record_type,
51 record_handle_t filled_record);
52 typedef void (*fill_record_callback_t)(int record_type,
53 record_handle_t empty_record);
55 /* Record type codes */
56 #define BARRY_RECORD_CONTACT 1
57 #define BARRY_RECORD_MESSAGE 2
58 #define BARRY_RECORD_CALENDAR 3
59 #define BARRY_RECORD_SERVICEBOOK 4
61 /* Record field type codes */
62 #define BARRY_FIELDTYPE_NUMBER 1 /* uint32_t */
63 #define BARRY_FIELDTYPE_STRING 2 /* null terminated or raw str */
64 #define BARRY_FIELDTYPE_TIME 3 /* time_t */
66 #define IS_NUMBER(fieldcode) (((fieldcode & 0xff0000) == 0x010000)
67 #define IS_STRING(fieldcode) (((fieldcode & 0xff0000) == 0x020000)
68 #define IS_TIME(fieldcode) (((fieldcode & 0xff0000) == 0x030000)
70 /* Contact record field codes */
71 #define BARRY_CONTACT_RECORDID 0x010101 /* uint32_t */
72 #define BARRY_CONTACT_EMAIL 0x020102 /* strings below... */
73 #define BARRY_CONTACT_PHONE 0x020103
74 #define BARRY_CONTACT_FAX 0x020104
75 #define BARRY_CONTACT_WORKPHONE 0x020105
76 #define BARRY_CONTACT_HOMEPHONE 0x020106
77 #define BARRY_CONTACT_MOBILEPHONE 0x020107
78 #define BARRY_CONTACT_PAGER 0x020108
79 #define BARRY_CONTACT_PIN 0x020109
80 #define BARRY_CONTACT_FIRSTNAME 0x02010a
81 #define BARRY_CONTACT_LASTNAME 0x02010b
82 #define BARRY_CONTACT_COMPANY 0x02010c
83 #define BARRY_CONTACT_DEFAULTCOMMMETHOD 0x02010d
84 #define BARRY_CONTACT_ADDRESS1 0x02010e
85 #define BARRY_CONTACT_ADDRESS2 0x02010f
86 #define BARRY_CONTACT_ADDRESS3 0x020110
87 #define BARRY_CONTACT_CITY 0x020111
88 #define BARRY_CONTACT_PROVINCE 0x020112
89 #define BARRY_CONTACT_POSTALCODE 0x020113
90 #define BARRY_CONTACT_COUNTRY 0x020114
91 #define BARRY_CONTACT_TITLE 0x020115
92 #define BARRY_CONTACT_PUBLICKEY 0x020116
93 #define BARRY_CONTACT_NOTES 0x020117
95 /* Message record field codes */
96 #define BARRY_MESSAGE_FROM_NAME 0x020201 /* all strings */
97 #define BARRY_MESSAGE_FROM_EMAIL 0x020202
98 #define BARRY_MESSAGE_TO_NAME 0x020203
99 #define BARRY_MESSAGE_TO_EMAIL 0x020204
100 #define BARRY_MESSAGE_CC_NAME 0x020205
101 #define BARRY_MESSAGE_CC_EMAIL 0x020206
102 #define BARRY_MESSAGE_SUBJECT 0x020207
103 #define BARRY_MESSAGE_BODY 0x020208 /* string or raw */
105 /* Calendar record field codes */
106 #define BARRY_CALENDAR_ALLDAYEVENT 0x010301 /* true/false number */
107 #define BARRY_CALENDAR_SUBJECT 0x020302 /* strings... */
108 #define BARRY_CALENDAR_NOTES 0x020303
109 #define BARRY_CALENDAR_LOCATION 0x020304
110 #define BARRY_CALENDAR_NOTIFICATIONTIME 0x030305 /* time_t... */
111 #define BARRY_CALENDAR_STARTTIME 0x030306
112 #define BARRY_CALENDAR_ENDTIME 0x030307
113 #define BARRY_CALENDAR_INTERVAL 0x010308 /* number */
114 #define BARRY_CALENDAR_RECURRINGENDTIME 0x030309 /* time_t */
115 #define BARRY_CALENDAR_PERPETUAL 0x01030a /* true/false number */
116 #define BARRY_CALENDAR_TIMEZONE 0x01030b /* numeric code */
118 /* Service Book record field codes */
119 #define BARRY_SERVICEBOOK_RECORDID 0x010401 /* number */
120 #define BARRY_SERVICEBOOK_NAME 0x020402 /* strings... */
121 #define BARRY_SERVICEBOOK_HIDDENNAME 0x020403
122 #define BARRY_SERVICEBOOK_DESCRIPTION 0x020404
123 #define BARRY_SERVICEBOOK_DSID 0x020405
124 #define BARRY_SERVICEBOOK_BESDOMAIN 0x020406
125 #define BARRY_SERVICEBOOK_UNIQUEID 0x020407
126 #define BARRY_SERVICEBOOK_CONTENTID 0x020408
127 #define BARRY_SERVICEBOOK_CONFIG_FORMAT 0x010409 /* number */
129 /* Initialization */
130 void barry_init(int data_dump_mode);
131 const char *barry_version(int *major, int *minor);
133 /* Error string retrieval */
134 const char *barry_get_last_error();
136 /* Probe API */
137 probe_handle_t barry_probe(void);
138 void barry_probe_close(probe_handle_t handle);
139 int barry_probe_count(probe_handle_t handle);
140 int barry_probe_find_active(probe_handle_t handle, uint32_t pin);
141 void barry_probe_result(probe_handle_t handle, int index,
142 struct ProbeResult *result);
144 /* Controller API */
145 con_handle_t barry_con_open(struct ProbeResult *result);
146 void barry_con_close(con_handle_t handle);
147 int barry_con_mode(con_handle_t handle, int mode);
148 int barry_con_get_dbid(con_handle_t handle, const char *dbname);
149 int barry_con_get_db_count(con_handle_t handle);
150 int barry_con_get_db_info(con_handle_t handle, int index,
151 unsigned int *number, unsigned int *record_count,
152 char *name, int name_buf_size);
153 int barry_con_add_record(con_handle_t handle, unsigned int dbid,
154 record_handle_t rec);
155 int barry_con_get_record(con_handle_t handle, unsigned int dbid,
156 unsigned int state_table_index, record_handle_t *rec);
157 int barry_con_set_record(con_handle_t handle, unsigned int dbid,
158 unsigned int state_table_index, record_handle_t rec);
159 int barry_con_clear_dirty(con_handle_t handle, unsigned int dbid,
160 unsigned int state_table_index);
161 int barry_con_delete_record(con_handle_t handle, unsigned int dbid,
162 unsigned int state_table_index);
163 int barry_con_load_database(con_handle_t handle, unsigned int dbid,
164 process_record_callback_t callback);
165 int barry_con_save_database(con_handle_t handle, unsigned int dbid,
166 fill_record_callback_t callback);
168 /* State table API */
169 state_table_handle_t barry_get_state_table(con_handle_t handle,
170 unsigned int dbid);
171 void barry_free_state_table(state_table_handle_t handle);
172 int barry_make_new_record_id(state_table_handle_t handle);
173 int barry_get_state_count(state_handle_t handle);
174 int barry_get_state(state_table_handle_t handle, unsigned int index,
175 uint32_t *record_id, int *dirty_flag);
176 /* note: not every index from 0 to "state_count" is guaranteed to
177 exist... check the return value */
178 int barry_get_state_by_record_id(state_table_handle_t handle, unsigned int rec,
179 unsigned int *index, int *dirty_flag);
181 /* Record API */
182 record_handle_t barry_create_record(int record_type);
183 void barry_free_record(record_handle_t handle);
184 uint32_t barry_rec_get_num(record_handle_t handle, int field_type);
185 int barry_rec_set_num(record_handle_t handle, int field_type, uint32_t val);
186 const char *barry_rec_get_str(record_handle_t handle, int field_type);
187 int barry_rec_set_str(record_handle_t handle, int field_type, const char *str);
188 const char *barry_rec_get_raw(record_handle_t handle, int field_type,
189 int *raw_size);
190 int barry_rec_set_raw(record_handle_t handle, int field_type,
191 const char *buf, int size);
192 time_t barry_rec_get_time(record_handle_t handle, int field_type);
193 int barry_rec_set_time(record_handle_t handle, int field_type, time_t t);
195 /* Calendar record special API */
196 int barry_calendar_set_daily(record_handle_t handle);
197 int barry_calendar_set_monthly_by_date(record_handle_t handle,
198 int day_of_month);
199 int barry_calendar_set_monthly_by_day(record_handle_t handle,
200 int day_of_week, int week_of_month);
201 int barry_calendar_set_yearly_by_date(record_handle_t handle,
202 int day_of_month, int month_of_year);
203 int barry_calendar_set_yearly_by_day(record_handle_t handle,
204 int day_of_week, int week_of_month, int month_of_year);
205 int barry_calendar_set_weekly(record_handle_t handle, int weekday_bits);
206 int barry_calendar_get_fixme_need_read_access_to_this
208 /* Time zone API */
209 const TimeZone* barry_get_time_zone_table();
210 const TimeZone* barry_get_time_zone(unsigned short code);
211 unsigned short barry_get_time_zone_code(signed short hour_offset,
212 signed short min_offset); /* returns TIME_ZONE_CODE_ERR on error*/
214 #ifdef __cplusplus
216 #endif
218 #endif