File: syncstream.h

package info (click to toggle)
agsync 0.2-pre-6
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 2,016 kB
  • ctags: 1,182
  • sloc: ansic: 9,979; sh: 8,120; makefile: 86
file content (142 lines) | stat: -rw-r--r-- 4,394 bytes parent folder | download | duplicates (3)
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
/*****************************************************************************
 * Avantgo CE Stream Protocol Commands
 * This file describes the basic operations performed over the stream
 * to the Avantgo libraries. The actual I/O is handled by the reader,
 * which should be specified in syncmain.c.
 */


/* ***** BEGIN LICENSE BLOCK *****
 * Version: MPL 1.1
 *
 * The contents of this file are subject to the Mozilla Public License Version
 * 1.1 (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 * for the specific language governing rights and limitations under the
 * License.
 *
 * The Original Code is "agsync"
 *
 * The Initial Developer of the Original Code is
 * Michael Jarrett
 * Portions created by the Initial Developer are Copyright (C) 2003
 * the Initial Developer. All Rights Reserved.
 *
 * Contributor(s):
 *
 * ***** END LICENSE BLOCK ***** */


#ifndef SYNCSTREAM_H
#define SYNCSTREAM_H

/* Set to the Avantgo-returned error in error conditions.
   A result code will always be 0 for Ok, 1 for Ok but there's more stuff,
   2 for error, or -1 for a socket problem. In case of result 2, the
   error code will be stored in asErrno
*/
extern int asErrno;

struct AGUserConfig;
struct AGDBConfig;
struct AGDeviceInfo;
struct AGRecord;
struct AGReader;
struct AGWriter;

/**
 * Writes an "End Session" command to the stream.
 * This does NOT read off the end-of-stream stuff from the RAPI
 * protocol.
 * @return The result code.
 */
extern int asEndSession(AGReader *r, AGWriter *w);

/**
 * Retrieve a user config from the device.
 * @return The user configuration read, or NULL on error.
 *         If NULL, the state of the passed configuration structure
 *         is undefined, and asErrno may or may not be set.
 */
extern AGUserConfig *asGetUserConfig(AGReader *r, AGWriter *w,
				     AGUserConfig *uc);


/**
 * Write a user config to the device.
 * @return Result code of operation.
 */ 
extern int asPutUserConfig(AGReader *r, AGWriter *w, AGUserConfig *uc);


/**
 * Begin server.
 * This specifies that we are now processing for a specific server UID.
 * @return Result code. If 2, error code should be in asErrno.
 *         I've seen 0x00 in asErrno mean the uid can't be found.
 */
extern int asStartServer(AGReader *r, AGWriter *w, int uid);


/**
 * End server.
 * End of block specified by asStartServer. Does it even exist?
 * @return Result code. Practically always 0.
 */
extern int asEndServer(AGReader *r, AGWriter *w);


/**
 * Read device info from the device.
 * @return The device info read, or NULL if failed.
 *         If NULL returned, state of devInfo undefined, and
 *         asErrno may or may not be set.
 */
extern AGDeviceInfo *asGetDeviceInfo(AGReader *r, AGWriter *w,
				     AGDeviceInfo *devInfo);



/**
 * Read record from the device.
 * Unfortunately, since we need information from the record ahead of time,
 * we have to allocate it. It's up to the receiver to free it (or not).
 * @return Result code.
 *         If 0, no more records available, agrPtr= NULL.
 *         If 1, one record read. agrPtr= ptr to new record.
 *         If 2, asErrno is set. agrPtr= NULL.
 */
extern int asGetNextRecord(AGReader *r, AGWriter *w, AGRecord **agrPtr);

/**
 * Read next MODIFIED record from the device.
 * Unfortunately, since we need information from the record ahead of time,
 * we have to allocate it. It's up to the receiver to free it (or not).
 * @return Result code.
 *         If 0, no more records available, agrPtr= NULL.
 *         If 1, one record read. agrPtr= ptr to new record.
 *         If 2, asErrno is set. agrPtr= NULL.
 */
extern int asGetNextModifiedRecord(AGReader *r, AGWriter *w,AGRecord **agrPtr);


/**
 * Open/Initialize a database.
 * Return Standard result code.
 */
extern int asOpenDatabase(AGReader *r, AGWriter *w, AGDBConfig *db);



/**
 * Perform a command on the device, as specified by AGProtocol.h.
 * @return Always AGCLIENT_CONTINUE. For some reason all commands
 *         implicity request more commands.
 */
extern int asPerformCommand(AGReader *r, AGWriter *w, int cmd,
			    unsigned char *cmdData, int len);
#endif