aboutsummaryrefslogtreecommitdiffstats
path: root/datalink.h
blob: ab6f2d755f9a18c4e19bcb9d2b26e1ae574d865a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
/* 
 * Copyright 1996-2002 - Karl R. Hakimian and David Fries
 *
 * This file is part of datalink.
 *
 * Datalink is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * Datalink is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with datalink (see COPYING); if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 */

#ifndef __DATALINK_H__
#define __DATALINK_H__

typedef struct time_s
{
	unsigned char tz_num;
	unsigned char hours;
	unsigned char minutes;
	unsigned char seconds;
	unsigned char month;
	unsigned char day;
	unsigned char year;
	unsigned char dow;	/* Day Of the Week */
	unsigned char hour_fmt;
	unsigned char date_fmt;
	unsigned char download;
	int offset;
	char *label;
} Time, *TimePtr;

typedef struct alarm_s
{
	unsigned char alarm_num;
	unsigned char hours;
	unsigned char minutes;
	unsigned char month;
	unsigned char day;
	char *label;
	unsigned char audible;
} Alarm, *AlarmPtr;

typedef struct chron_s
{
	unsigned char chron_laps;
	int memused;
	char *label;
} Chron, *ChronPtr;

typedef struct timer_s
{
	unsigned char timer_num;
	unsigned char hours;
	unsigned char minutes;
	unsigned char second;
	unsigned char repeat;
	unsigned char chron;
	char *label;
} Timer, *TimerPtr;

typedef struct system_s
{
	unsigned char chime;
	unsigned char beep;
} System, *SystemPtr;

typedef struct appointment_s
{
	unsigned char month;
	unsigned char day;
	unsigned char time;
	char *label;
} Appointment, *AppointmentPtr;

typedef struct phone_s
{
	char *number;
	char *label;
} Phone, *PhonePtr;

typedef struct todo_s
{
	unsigned char priority;
	char *label;
} ToDo, *ToDoPtr;

typedef struct anniversary_s
{
	unsigned char month;
	unsigned char day;
	char *label;
} Anniversary, *AnniversaryPtr;

typedef struct wristapp_s
{
	int len;
	unsigned char *data;
} WristApp, *WristAppPtr;

typedef struct melody_s
{
	int len;
	unsigned char *data;
} Melody, *MelodyPtr;

typedef struct item_s
{
	struct item_s *next;
	int type;
	union
	{
		Time time;
		Alarm alarm;
		Chron chron;
		Timer timer;
		System sys;
		Appointment app;
		Phone phone;
		ToDo todo;
		Anniversary anniv;
		System system;
		WristApp wristapp;
		Melody melody;
	}
	data;
}
Item, *ItemPtr;

typedef struct list_s
{
	ItemPtr first;
	ItemPtr last;
	int download;
	int count;
} List, *ListPtr;

typedef struct watch_info_s
{
	int dl_device;		/* Device to download to. */
	int max_tz;
	int max_alarms;
	int max_apps;
	int max_chrons;
	int max_phones;
	int max_timers;
	int max_todos;
	int max_annivs;
	int max_system;
	int max_wristapp;
	int max_melody;
	int max_tzlen;
	int max_mem;		/* Memory available. */
	int mem_size;		/* Memory used. */
	int max_str;		/* Max string length for this device. */
	int max_alarm_str;	/* Max string length for an alarm on this device. */
	int max_chron_str;	/* Max string length for the cron on this device. */
	int max_phone_str;	/* Max string length for a phone on this device. */
	int max_timer_str;	/* Max string length for the timer on this device. */
	int max_wristapp_len;
	int max_mel_len;
	int pre_notification_time;
	int time_adjust;
	List times;
	List alarms;
	List chron;
	List timers;
	List system;
	List apps;
	List phones;
	List todos;
	List annivs;
	List wristapp;
	List melody;
} WatchInfo, *WatchInfoPtr;

/* defines */

#ifndef NULL
#define NULL 0l
#endif

/* Item types */
#define DL_NO_TYPE			0
#define DL_TIME_TYPE		1
#define DL_ALARM_TYPE		2
#define DL_APP_TYPE			3
#define DL_PHONE_TYPE		4
#define DL_TODO_TYPE		5
#define DL_ANNIV_TYPE		6
#define DL_SYSTEM_TYPE		7
#define DL_WRISTAPP_TYPE	8
#define DL_MELODY_TYPE		9
#define DL_TIMER_TYPE		10
#define DL_CHRON_TYPE		11
#define DL_MAX_TYPE			12

/* Output types */
#define NO_OUTPUT 0
#define SVGA_BLINK 1
#define SER_BLINK 2
#define BLINK_FILE 3

/* Watch types */
#define NO_WATCH 0
#define DATALINK_70 1
#define DATALINK_150 2
#define DATALINK_150S 3
#define DATALINK_IRONMAN 4

#define DEF_LPTRANSINFO 1

extern int (*dl_error_proc) (char *);
extern int (*dl_warn_proc) (char *);

/* Function definitions. */

void dl_add_to_list(ListPtr, ItemPtr);
int dl_anniv_by_date(ItemPtr, ItemPtr);
int dl_anniv_by_label(ItemPtr, ItemPtr);
int dl_app_by_datetime(ItemPtr, ItemPtr);
int dl_app_by_label(ItemPtr, ItemPtr);
unsigned short int dl_docrc(unsigned char *);
void dl_fill_pack_ascii(unsigned char *, unsigned char *, int, char);
void dl_free_download(void);
int dl_init_download(WatchInfoPtr, ListPtr, ListPtr, ListPtr, ListPtr,
		     ListPtr, ListPtr, ListPtr, ListPtr, ListPtr, ListPtr,
		     ListPtr);
WatchInfoPtr dl_init_watch(int);
int dl_item_ok(WatchInfoPtr, ItemPtr);
ItemPtr dl_new_item(WatchInfoPtr, int);
ListPtr dl_new_list(void);
int dl_pack_ascii(unsigned char *, unsigned char *);
int dl_pack_char(char);
int dl_pack_digit(char);
void dl_pack_phone(unsigned char *, unsigned char *, int);
int dl_pack_size(char *);
int dl_phone_by_label(ItemPtr, ItemPtr);
WatchInfoPtr dl_read_save(char *, int, ListPtr *, ListPtr *, ListPtr *,
			  ListPtr *, ListPtr *, ListPtr *, ListPtr *,
			  ListPtr *, ListPtr *, ListPtr *, ListPtr *);
int dl_send_data(WatchInfoPtr, int);
void dl_set_error(int (*)());
void dl_set_warn(int (*)());
int dl_sizeof_item(WatchInfoPtr, ItemPtr);
int dl_sizeof_list(WatchInfoPtr, ListPtr);
int dl_sort(ListPtr, int (*)());
int dl_string_ok(char *, int);
int dl_todo_by_label(ItemPtr, ItemPtr);
int dl_todo_by_prio(ItemPtr, ItemPtr);
int dl_write_save(char *, char *, char *);

int open_vt();
void close_vt(int oldvt);
int send_data(int type, unsigned char **packets, int npckts);

#endif				/* __DATALINK_H__ */