File: rrac.h

package info (click to toggle)
librra 0.14-1.2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 2,156 kB
  • sloc: ansic: 12,769; sh: 10,454; makefile: 181
file content (186 lines) | stat: -rw-r--r-- 4,170 bytes parent folder | download | duplicates (2)
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
#ifndef __rrac_h__
#define __rrac_h__

#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <rapi.h>

#define OBJECT_ID_STOP 0xffffffff

struct _RRAC;
typedef struct _RRAC RRAC;

typedef bool (*Command69Callback)(
    uint32_t subcommand, 
    uint8_t* data, 
    size_t size, 
    void* cookie);

RRAC* rrac_new();

void rrac_destroy(RRAC* rrac);

bool rrac_set_command_69_callback(
    RRAC* rrac,
    Command69Callback callback, 
    void* cookie);

bool rrac_connect(RRAC* rrac, RapiConnection *connection);

void rrac_disconnect(RRAC* rrac);

bool rrac_is_connected(RRAC* rrac);

/** Get file descriptor for use with select() or poll() */
int rrac_get_event_descriptor(RRAC* self);

/** See if there is an event pending */
bool rrac_event_pending(RRAC* self);

/** Wait for an event */
bool rrac_event_wait(RRAC* self, int timeoutInSeconds, bool* gotEvent);


#include <synce.h>

typedef struct
{
	uint32_t offset_00;
	WCHAR name1[100];
	WCHAR name2[80];
	uint32_t id;
	uint32_t count;
	uint32_t total_size;
	FILETIME filetime;
} RawObjectType;

bool rrac_send_65(
		RRAC* rrac, 
		uint32_t type_id, 
		uint32_t object_id1, 
		uint32_t object_id2, 
		uint32_t flags);

bool rrac_recv_65(
		RRAC* rrac, 
		uint32_t* type_id, 
		uint32_t* object_id1, 
		uint32_t* object_id2,
		uint32_t* flags);

bool rrac_send_66(
		RRAC* rrac, 
		uint32_t type_id, 
		uint32_t object_id, 
		uint32_t flags);

bool rrac_send_67(RRAC* rrac, uint32_t type_id, uint32_t* ids, size_t count);

bool rrac_send_6f(RRAC* rrac, uint32_t subcommand);

bool rrac_recv_reply_6f_6(RRAC* rrac);
bool rrac_recv_reply_6f_10(RRAC* rrac);
bool rrac_recv_reply_6f_c1(
		RRAC* rrac,
		RawObjectType** object_type_array,
		uint32_t* object_type_count);

bool rrac_send_70_2(RRAC* rrac, uint32_t subsubcommand);

bool rrac_send_70_3(RRAC* rrac, uint32_t* ids, size_t count);

bool rrac_recv_reply_70(RRAC* rrac);

bool rrac_recv_69_2(RRAC* rrac);

bool rrac_recv_69_not_2(
		RRAC* rrac,
		uint32_t* subcommand,
		uint32_t* type_id,
		uint32_t* some_count,
		uint32_t** ids,
		uint32_t* id_count);

bool rrac_recv_data(
		RRAC* rrac,
		uint32_t* object_id,
		uint32_t* type_id,
		uint8_t** data, 
		size_t* size);

bool rrac_send_data(
		RRAC* rrac,
		uint32_t object_id,
		uint32_t type_id,
		uint32_t flags,
		uint8_t* data, 
		size_t size);

#define rrac_alloc(n) malloc(n)
#define rrac_free(p) if (p) free(p)

struct _SyncCommand;
typedef struct _SyncCommand SyncCommand;

#define SYNC_COMMAND_ERROR              0x006e
#define SYNC_COMMAND_NOTIFY             0x0069
#define SYNC_COMMAND_NEGOTIATION        0x0065

#define SYNC_COMMAND_NOTIFY_UPDATE      0x00000000
#define SYNC_COMMAND_NOTIFY_PARTNERS    0x02000000
#define SYNC_COMMAND_NOTIFY_IDS_4       0x04000000
#define SYNC_COMMAND_NOTIFY_IDS_6       0x06000000
#define SYNC_COMMAND_NOTIFY_INVALID     0xffffffff

/* Destroy SyncCommand object */
void sync_command_destroy(SyncCommand* self);

/* Get command code from SyncCommand object */
uint16_t sync_command_code(SyncCommand* self);

/* Get notify code from SyncCommand object if command code is SYNC_COMMAND_NOTIFY */
uint32_t sync_command_notify_code(SyncCommand* self);

typedef struct
{
	uint32_t  current;
	uint32_t  ids[2];
} SyncPartners;

/** Get SyncParners structure if notify code is SYNC_COMMAND_NOTIFY_PARTNERS */
bool sync_command_notify_partners(SyncCommand* self, SyncPartners* partners);

typedef struct
{
  uint32_t  notify_code;
  uint32_t  type;
  uint32_t  total;
  uint32_t  deleted;
  uint32_t  unchanged;
  uint32_t  changed;
} SyncNotifyHeader;

/** Get total and changed ID count if notify code is SYNC_COMMAND_NOTIFY_IDS_[46] */
bool sync_command_notify_header(SyncCommand* self, SyncNotifyHeader* header);

/** Get IDs if notify code is SYNC_COMMAND_NOTIFY_IDS_[46] */
bool sync_command_notify_ids(SyncCommand* self, uint32_t* ids);

typedef struct
{
	uint32_t    type_id;
	uint32_t    old_id;
	uint32_t    new_id;
	uint32_t    flags;
} SyncNegotiation;

/** Get SYNC_COMMAND_NEGOTIATION data */
bool sync_command_negotiation_get(
    SyncCommand* self, 
    SyncNegotiation* negotiation);

SyncCommand* rrac_recv_command(RRAC* self);

#endif