1 /*
2  * Copyright (C) 2007 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef _FILE_SYNC_SERVICE_H_
18 #define _FILE_SYNC_SERVICE_H_
19 
20 #include <string>
21 
22 #define htoll(x) (x)
23 #define ltohl(x) (x)
24 
25 #define MKID(a,b,c,d) ((a) | ((b) << 8) | ((c) << 16) | ((d) << 24))
26 
27 #define ID_STAT MKID('S','T','A','T')
28 #define ID_LIST MKID('L','I','S','T')
29 #define ID_ULNK MKID('U','L','N','K')
30 #define ID_SEND MKID('S','E','N','D')
31 #define ID_RECV MKID('R','E','C','V')
32 #define ID_DENT MKID('D','E','N','T')
33 #define ID_DONE MKID('D','O','N','E')
34 #define ID_DATA MKID('D','A','T','A')
35 #define ID_OKAY MKID('O','K','A','Y')
36 #define ID_FAIL MKID('F','A','I','L')
37 #define ID_QUIT MKID('Q','U','I','T')
38 
39 union syncmsg {
40     unsigned id;
41     struct {
42         unsigned id;
43         unsigned namelen;
44     } req;
45     struct {
46         unsigned id;
47         unsigned mode;
48         unsigned size;
49         unsigned time;
50     } stat;
51     struct {
52         unsigned id;
53         unsigned mode;
54         unsigned size;
55         unsigned time;
56         unsigned namelen;
57     } dent;
58     struct {
59         unsigned id;
60         unsigned size;
61     } data;
62     struct {
63         unsigned id;
64         unsigned msglen;
65     } status;
66 } ;
67 
68 
69 void file_sync_service(int fd, void *cookie);
70 int do_sync_ls(const char *path);
71 int do_sync_push(const char *lpath, const char *rpath, int show_progress);
72 int do_sync_sync(const std::string& lpath, const std::string& rpath, bool list_only);
73 int do_sync_pull(const char *rpath, const char *lpath, int show_progress, int pullTime);
74 
75 #define SYNC_DATA_MAX (64*1024)
76 
77 #endif
78