Merge "Add missing #include <memory> for std::unique_ptr on Windows."
diff --git a/file_sync_client.cpp b/file_sync_client.cpp
index b928659..ab11619 100644
--- a/file_sync_client.cpp
+++ b/file_sync_client.cpp
@@ -81,7 +81,7 @@
     char buf[sizeof(SyncRequest) + path_length] __attribute__((aligned(8)));
     SyncRequest* req = reinterpret_cast<SyncRequest*>(buf);
     req->id = id;
-    req->path_length = htoll(path_length);
+    req->path_length = path_length;
     char* data = reinterpret_cast<char*>(req + 1);
     memcpy(data, path, path_length);
 
@@ -145,14 +145,14 @@
         if (msg.dent.id == ID_DONE) return true;
         if (msg.dent.id != ID_DENT) return false;
 
-        size_t len = ltohl(msg.dent.namelen);
+        size_t len = msg.dent.namelen;
         if (len > 256) return false; // TODO: resize buffer? continue?
 
         char buf[257];
         if (!ReadFdExactly(fd, buf, len)) return false;
         buf[len] = 0;
 
-        func(ltohl(msg.dent.mode), ltohl(msg.dent.size), ltohl(msg.dent.time), buf, cookie);
+        func(msg.dent.mode, msg.dent.size, msg.dent.time, buf, cookie);
     }
 }
 
@@ -167,9 +167,9 @@
         return false;
     }
 
-    if (timestamp) *timestamp = ltohl(msg.stat.time);
-    if (mode) *mode = ltohl(msg.stat.mode);
-    if (size) *size = ltohl(msg.stat.size);
+    if (timestamp) *timestamp = msg.stat.time;
+    if (mode) *mode = msg.stat.mode;
+    if (size) *size = msg.stat.size;
 
     return true;
 }
@@ -213,7 +213,7 @@
             break;
         }
 
-        sbuf->size = htoll(ret);
+        sbuf->size = ret;
         if (!WriteFdExactly(sc.fd, sbuf, sizeof(unsigned) * 2 + ret)) {
             err = -1;
             break;
@@ -240,7 +240,7 @@
     }
     sbuf->data[len] = '\0';
 
-    sbuf->size = htoll(len + 1);
+    sbuf->size = len + 1;
     sbuf->id = ID_DATA;
 
     if (!WriteFdExactly(sc.fd, sbuf, sizeof(unsigned) * 2 + len + 1)) {
@@ -271,14 +271,14 @@
 
     syncmsg msg;
     msg.data.id = ID_DONE;
-    msg.data.size = htoll(mtime);
+    msg.data.size = mtime;
     if (!WriteFdExactly(sc.fd, &msg.data, sizeof(msg.data))) goto fail;
 
     if (!ReadFdExactly(sc.fd, &msg.status, sizeof(msg.status))) goto fail;
 
     if (msg.status.id != ID_OKAY) {
         if (msg.status.id == ID_FAIL) {
-            size_t len = ltohl(msg.status.msglen);
+            size_t len = msg.status.msglen;
             if (len > 256) len = 256;
             if (!ReadFdExactly(sc.fd, sbuf->data, len)) goto fail;
             sbuf->data[len] = 0;
@@ -335,7 +335,7 @@
         id = msg.data.id;
 
     handle_data:
-        len = ltohl(msg.data.size);
+        len = msg.data.size;
         if (id == ID_DONE) break;
         if (id != ID_DATA) goto remote_error;
         if (len > sc.max) {
@@ -370,7 +370,7 @@
     adb_unlink(lpath);
 
     if(id == ID_FAIL) {
-        len = ltohl(msg.data.size);
+        len = msg.data.size;
         if(len > 256) len = 256;
         if(!ReadFdExactly(sc.fd, buffer, len)) {
             return -1;
diff --git a/file_sync_service.cpp b/file_sync_service.cpp
index 1323d83..3e46447 100644
--- a/file_sync_service.cpp
+++ b/file_sync_service.cpp
@@ -85,9 +85,9 @@
     memset(&st, 0, sizeof(st));
     // TODO: add a way to report that the stat failed!
     lstat(path, &st);
-    msg.stat.mode = htoll(st.st_mode);
-    msg.stat.size = htoll(st.st_size);
-    msg.stat.time = htoll(st.st_mtime);
+    msg.stat.mode = st.st_mode;
+    msg.stat.size = st.st_size;
+    msg.stat.time = st.st_mtime;
 
     return WriteFdExactly(s, &msg.stat, sizeof(msg.stat));
 }
@@ -107,10 +107,10 @@
         struct stat st;
         if (lstat(filename.c_str(), &st) == 0) {
             size_t d_name_length = strlen(de->d_name);
-            msg.dent.mode = htoll(st.st_mode);
-            msg.dent.size = htoll(st.st_size);
-            msg.dent.time = htoll(st.st_mtime);
-            msg.dent.namelen = htoll(d_name_length);
+            msg.dent.mode = st.st_mode;
+            msg.dent.size = st.st_size;
+            msg.dent.time = st.st_mtime;
+            msg.dent.namelen = d_name_length;
 
             if (!WriteFdExactly(s, &msg.dent, sizeof(msg.dent)) ||
                     !WriteFdExactly(s, de->d_name, d_name_length)) {
@@ -133,7 +133,7 @@
 
     syncmsg msg;
     msg.data.id = ID_FAIL;
-    msg.data.size = htoll(reason.size());
+    msg.data.size = reason.size();
     return WriteFdExactly(s, &msg.data, sizeof(msg.data)) && WriteFdExactly(s, reason);
 }
 
@@ -185,13 +185,13 @@
 
         if(msg.data.id != ID_DATA) {
             if(msg.data.id == ID_DONE) {
-                timestamp = ltohl(msg.data.size);
+                timestamp = msg.data.size;
                 break;
             }
             fail_message(s, "invalid data message");
             goto fail;
         }
-        len = ltohl(msg.data.size);
+        len = msg.data.size;
         if (len > buffer.size()) { // TODO: resize buffer?
             fail_message(s, "oversize data message");
             goto fail;
@@ -245,7 +245,7 @@
         return false;
     }
 
-    len = ltohl(msg.data.size);
+    len = msg.data.size;
     if (len > buffer.size()) { // TODO: resize buffer?
         fail_message(s, "oversize data message");
         return false;
@@ -346,7 +346,7 @@
             adb_close(fd);
             return status;
         }
-        msg.data.size = htoll(r);
+        msg.data.size = r;
         if (!WriteFdExactly(s, &msg.data, sizeof(msg.data)) || !WriteFdExactly(s, &buffer[0], r)) {
             adb_close(fd);
             return false;
@@ -368,7 +368,7 @@
         fail_message(fd, "command read failure");
         return false;
     }
-    size_t path_length = ltohl(request.path_length);
+    size_t path_length = request.path_length;
     if (path_length > 1024) {
         fail_message(fd, "path too long");
         return false;
diff --git a/file_sync_service.h b/file_sync_service.h
index c0df075..67ed3fc 100644
--- a/file_sync_service.h
+++ b/file_sync_service.h
@@ -19,9 +19,6 @@
 
 #include <string>
 
-#define htoll(x) (x)
-#define ltohl(x) (x)
-
 #define MKID(a,b,c,d) ((a) | ((b) << 8) | ((c) << 16) | ((d) << 24))
 
 #define ID_STAT MKID('S','T','A','T')