file_sync_service.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. #ifndef _FILE_SYNC_SERVICE_H_
  17. #define _FILE_SYNC_SERVICE_H_
  18. #ifdef HAVE_BIG_ENDIAN
  19. static inline unsigned __swap_uint32(unsigned x)
  20. {
  21. return (((x) & 0xFF000000) >> 24)
  22. | (((x) & 0x00FF0000) >> 8)
  23. | (((x) & 0x0000FF00) << 8)
  24. | (((x) & 0x000000FF) << 24);
  25. }
  26. #define htoll(x) __swap_uint32(x)
  27. #define ltohl(x) __swap_uint32(x)
  28. #define MKID(a,b,c,d) ((d) | ((c) << 8) | ((b) << 16) | ((a) << 24))
  29. #else
  30. #define htoll(x) (x)
  31. #define ltohl(x) (x)
  32. #define MKID(a,b,c,d) ((a) | ((b) << 8) | ((c) << 16) | ((d) << 24))
  33. #endif
  34. #define ID_STAT MKID('S','T','A','T')
  35. #define ID_LIST MKID('L','I','S','T')
  36. #define ID_ULNK MKID('U','L','N','K')
  37. #define ID_SEND MKID('S','E','N','D')
  38. #define ID_RECV MKID('R','E','C','V')
  39. #define ID_DENT MKID('D','E','N','T')
  40. #define ID_DONE MKID('D','O','N','E')
  41. #define ID_DATA MKID('D','A','T','A')
  42. #define ID_OKAY MKID('O','K','A','Y')
  43. #define ID_FAIL MKID('F','A','I','L')
  44. #define ID_QUIT MKID('Q','U','I','T')
  45. typedef union {
  46. unsigned id;
  47. struct {
  48. unsigned id;
  49. unsigned namelen;
  50. } req;
  51. struct {
  52. unsigned id;
  53. unsigned mode;
  54. unsigned size;
  55. unsigned time;
  56. } stat;
  57. struct {
  58. unsigned id;
  59. unsigned mode;
  60. unsigned size;
  61. unsigned time;
  62. unsigned namelen;
  63. } dent;
  64. struct {
  65. unsigned id;
  66. unsigned size;
  67. } data;
  68. struct {
  69. unsigned id;
  70. unsigned msglen;
  71. } status;
  72. } syncmsg;
  73. void file_sync_service(int fd, void *cookie);
  74. int do_sync_ls(const char *path);
  75. int do_sync_push(const char *lpath, const char *rpath, int verifyApk);
  76. int do_sync_sync(const char *lpath, const char *rpath, int listonly);
  77. int do_sync_pull(const char *rpath, const char *lpath);
  78. #define SYNC_DATA_MAX (64*1024)
  79. #endif