Updated copyright dates for 2009
[barry/progweb.git] / src / cbarry.h
blobc3ea69107a93ff6ff69e68f4794dfe01b699e815
1 /**
2 * \file cbarry.h
3 * Main header file for Barry C API - incomplete
4 */
6 /*
7 Copyright (C) 2007-2009, 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 "dll.h"
29 #include <stdint.h>
30 #include <time.h>
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
37 * Barry C API
39 * All functions that can fail will either return a handle, which can
40 * be compared to NULL, or return int, which will == -1 on error.
42 * Functions that return a "count" can also fail, but rarely (such as
43 * if you pass in a bad handle).
46 /* Handle types */
47 typedef void* probe_handle_t;
48 typedef void* con_handle_t;
49 typedef void* state_table_handle_t;
50 typedef void* record_handle_t;
51 typedef void (*process_record_callback_t)(int record_type,
52 record_handle_t filled_record);
53 typedef void (*fill_record_callback_t)(int record_type,
54 record_handle_t empty_record);
56 /* Record type codes */
57 #define BARRY_RECORD_CONTACT 1
58 #define BARRY_RECORD_MESSAGE 2
59 #define BARRY_RECORD_CALENDAR 3
60 #define BARRY_RECORD_SERVICEBOOK 4
62 /* Record field type codes */
63 #define BARRY_FIELDTYPE_NUMBER 1 /* uint32_t */
64 #define BARRY_FIELDTYPE_STRING 2 /* null terminated or raw str */
65 #define BARRY_FIELDTYPE_TIME 3 /* time_t */
67 #define IS_NUMBER(fieldcode) (((fieldcode & 0xff0000) == 0x010000)
68 #define IS_STRING(fieldcode) (((fieldcode & 0xff0000) == 0x020000)
69 #define IS_TIME(fieldcode) (((fieldcode & 0xff0000) == 0x030000)
71 /* Contact record field codes */
72 #define BARRY_CONTACT_RECORDID 0x010101 /* uint32_t */
73 #define BARRY_CONTACT_EMAIL 0x020102 /* strings below... */
74 #define BARRY_CONTACT_PHONE 0x020103
75 #define BARRY_CONTACT_FAX 0x020104
76 #define BARRY_CONTACT_WORKPHONE 0x020105
77 #define BARRY_CONTACT_HOMEPHONE 0x020106
78 #define BARRY_CONTACT_MOBILEPHONE 0x020107
79 #define BARRY_CONTACT_PAGER 0x020108
80 #define BARRY_CONTACT_PIN 0x020109
81 #define BARRY_CONTACT_FIRSTNAME 0x02010a
82 #define BARRY_CONTACT_LASTNAME 0x02010b
83 #define BARRY_CONTACT_COMPANY 0x02010c
84 #define BARRY_CONTACT_DEFAULTCOMMMETHOD 0x02010d
85 #define BARRY_CONTACT_ADDRESS1 0x02010e
86 #define BARRY_CONTACT_ADDRESS2 0x02010f
87 #define BARRY_CONTACT_ADDRESS3 0x020110
88 #define BARRY_CONTACT_CITY 0x020111
89 #define BARRY_CONTACT_PROVINCE 0x020112
90 #define BARRY_CONTACT_POSTALCODE 0x020113
91 #define BARRY_CONTACT_COUNTRY 0x020114
92 #define BARRY_CONTACT_TITLE 0x020115
93 #define BARRY_CONTACT_PUBLICKEY 0x020116
94 #define BARRY_CONTACT_NOTES 0x020117
96 /* Message record field codes */
97 #define BARRY_MESSAGE_FROM_NAME 0x020201 /* all strings */
98 #define BARRY_MESSAGE_FROM_EMAIL 0x020202
99 #define BARRY_MESSAGE_TO_NAME 0x020203
100 #define BARRY_MESSAGE_TO_EMAIL 0x020204
101 #define BARRY_MESSAGE_CC_NAME 0x020205
102 #define BARRY_MESSAGE_CC_EMAIL 0x020206
103 #define BARRY_MESSAGE_SUBJECT 0x020207
104 #define BARRY_MESSAGE_BODY 0x020208 /* string or raw */
106 /* Calendar record field codes */
107 #define BARRY_CALENDAR_ALLDAYEVENT 0x010301 /* true/false number */
108 #define BARRY_CALENDAR_SUBJECT 0x020302 /* strings... */
109 #define BARRY_CALENDAR_NOTES 0x020303
110 #define BARRY_CALENDAR_LOCATION 0x020304
111 #define BARRY_CALENDAR_NOTIFICATIONTIME 0x030305 /* time_t... */
112 #define BARRY_CALENDAR_STARTTIME 0x030306
113 #define BARRY_CALENDAR_ENDTIME 0x030307
114 #define BARRY_CALENDAR_INTERVAL 0x010308 /* number */
115 #define BARRY_CALENDAR_RECURRINGENDTIME 0x030309 /* time_t */
116 #define BARRY_CALENDAR_PERPETUAL 0x01030a /* true/false number */
117 #define BARRY_CALENDAR_TIMEZONE 0x01030b /* numeric code */
119 /* Service Book record field codes */
120 #define BARRY_SERVICEBOOK_RECORDID 0x010401 /* number */
121 #define BARRY_SERVICEBOOK_NAME 0x020402 /* strings... */
122 #define BARRY_SERVICEBOOK_HIDDENNAME 0x020403
123 #define BARRY_SERVICEBOOK_DESCRIPTION 0x020404
124 #define BARRY_SERVICEBOOK_DSID 0x020405
125 #define BARRY_SERVICEBOOK_BESDOMAIN 0x020406
126 #define BARRY_SERVICEBOOK_UNIQUEID 0x020407
127 #define BARRY_SERVICEBOOK_CONTENTID 0x020408
128 #define BARRY_SERVICEBOOK_CONFIG_FORMAT 0x010409 /* number */
130 /* Initialization */
131 BXEXPORT void barry_init(int data_dump_mode);
132 BXEXPORT const char *barry_version(int *major, int *minor);
134 /* Error string retrieval */
135 BXEXPORT const char *barry_get_last_error();
137 /* Probe API */
138 BXEXPORT probe_handle_t barry_probe(void);
139 BXEXPORT void barry_probe_close(probe_handle_t handle);
140 BXEXPORT int barry_probe_count(probe_handle_t handle);
141 BXEXPORT int barry_probe_find_active(probe_handle_t handle, uint32_t pin);
142 BXEXPORT void barry_probe_result(probe_handle_t handle, int index,
143 struct ProbeResult *result);
145 /* Controller API */
146 BXEXPORT con_handle_t barry_con_open(struct ProbeResult *result);
147 BXEXPORT void barry_con_close(con_handle_t handle);
148 BXEXPORT int barry_con_mode(con_handle_t handle, int mode);
149 BXEXPORT int barry_con_get_dbid(con_handle_t handle, const char *dbname);
150 BXEXPORT int barry_con_get_db_count(con_handle_t handle);
151 BXEXPORT int barry_con_get_db_info(con_handle_t handle, int index,
152 unsigned int *number, unsigned int *record_count,
153 char *name, int name_buf_size);
154 BXEXPORT int barry_con_add_record(con_handle_t handle, unsigned int dbid,
155 record_handle_t rec);
156 BXEXPORT int barry_con_get_record(con_handle_t handle, unsigned int dbid,
157 unsigned int state_table_index, record_handle_t *rec);
158 BXEXPORT int barry_con_set_record(con_handle_t handle, unsigned int dbid,
159 unsigned int state_table_index, record_handle_t rec);
160 BXEXPORT int barry_con_clear_dirty(con_handle_t handle, unsigned int dbid,
161 unsigned int state_table_index);
162 BXEXPORT int barry_con_delete_record(con_handle_t handle, unsigned int dbid,
163 unsigned int state_table_index);
164 BXEXPORT int barry_con_load_database(con_handle_t handle, unsigned int dbid,
165 process_record_callback_t callback);
166 BXEXPORT int barry_con_save_database(con_handle_t handle, unsigned int dbid,
167 fill_record_callback_t callback);
169 /* State table API */
170 BXEXPORT state_table_handle_t barry_get_state_table(con_handle_t handle,
171 unsigned int dbid);
172 BXEXPORT void barry_free_state_table(state_table_handle_t handle);
173 BXEXPORT int barry_make_new_record_id(state_table_handle_t handle);
174 BXEXPORT int barry_get_state_count(state_handle_t handle);
175 BXEXPORT int barry_get_state(state_table_handle_t handle, unsigned int index,
176 uint32_t *record_id, int *dirty_flag);
177 /* note: not every index from 0 to "state_count" is guaranteed to
178 exist... check the return value */
179 BXEXPORT int barry_get_state_by_record_id(state_table_handle_t handle, unsigned int rec,
180 unsigned int *index, int *dirty_flag);
182 /* Record API */
183 BXEXPORT record_handle_t barry_create_record(int record_type);
184 BXEXPORT void barry_free_record(record_handle_t handle);
185 BXEXPORT uint32_t barry_rec_get_num(record_handle_t handle, int field_type);
186 BXEXPORT int barry_rec_set_num(record_handle_t handle, int field_type, uint32_t val);
187 BXEXPORT const char *barry_rec_get_str(record_handle_t handle, int field_type);
188 BXEXPORT int barry_rec_set_str(record_handle_t handle, int field_type, const char *str);
189 BXEXPORT const char *barry_rec_get_raw(record_handle_t handle, int field_type,
190 int *raw_size);
191 BXEXPORT int barry_rec_set_raw(record_handle_t handle, int field_type,
192 const char *buf, int size);
193 BXEXPORT time_t barry_rec_get_time(record_handle_t handle, int field_type);
194 BXEXPORT int barry_rec_set_time(record_handle_t handle, int field_type, time_t t);
196 /* Calendar record special API */
197 BXEXPORT int barry_calendar_set_daily(record_handle_t handle);
198 BXEXPORT int barry_calendar_set_monthly_by_date(record_handle_t handle,
199 int day_of_month);
200 BXEXPORT int barry_calendar_set_monthly_by_day(record_handle_t handle,
201 int day_of_week, int week_of_month);
202 BXEXPORT int barry_calendar_set_yearly_by_date(record_handle_t handle,
203 int day_of_month, int month_of_year);
204 BXEXPORT int barry_calendar_set_yearly_by_day(record_handle_t handle,
205 int day_of_week, int week_of_month, int month_of_year);
206 BXEXPORT int barry_calendar_set_weekly(record_handle_t handle, int weekday_bits);
207 BXEXPORT int barry_calendar_get_fixme_need_read_access_to_this
209 /* Time zone API */
210 BXEXPORT const TimeZone* barry_get_time_zone_table();
211 BXEXPORT const TimeZone* barry_get_time_zone(unsigned short code);
212 BXEXPORT unsigned short barry_get_time_zone_code(signed short hour_offset,
213 signed short min_offset); /* returns TIME_ZONE_CODE_ERR on error*/
215 #ifdef __cplusplus
217 #endif
219 #endif