tools: tplink-safeloader: fix whitespace issues
[project/firmware-utils.git] / src / mkhilinkfw.c
index fe6a200678c81f1ecc6c4edfd7b96e4488f75ba2..55908e5caa7f447c214ec5b30749ef61618424a0 100644 (file)
@@ -22,6 +22,7 @@
  *   gcc -lcrypto hlkcrypt.c -o hlkcrypt
  */
  
+#include <arpa/inet.h>
 #include <errno.h>
 #include <fcntl.h>
 #include <getopt.h>
@@ -31,6 +32,8 @@
 #include <stdlib.h>
 #include <string.h>
 #include <sys/mman.h>
+#include <sys/types.h>
+#include <sys/stat.h>
 #include <unistd.h>
  
 #define DES_KEY "H@L9K*(3"
@@ -65,8 +68,8 @@ static DES_key_schedule schedule;
 static void show_usage(const char *arg0);
 static void exit_cleanup(void);
 static void copy_file(int src, int dst);
-static void encrypt(void *p, off_t len);
-static void decrypt(void *p, off_t len);
+static void do_encrypt(void *p, off_t len);
+static void do_decrypt(void *p, off_t len);
  
  
 int main(int argc, char **argv)
@@ -208,7 +211,7 @@ int main(int argc, char **argv)
                        munmap(p, file_len);
                        exit(EXIT_FAILURE);
                }
-               encrypt(p, len);
+               do_encrypt(p, len);
                munmap(p, file_len);
                if (len != file_len) {
                        if (ftruncate(temp_fd, len) < 0) {
@@ -221,7 +224,7 @@ int main(int argc, char **argv)
        if (decrypt_opt) {
                off_t header_len = min(file_len, sizeof(image_header_t) + 3);
                memcpy(buf, p, header_len);
-               decrypt(buf, header_len);
+               do_decrypt(buf, header_len);
                header = (image_header_t *)buf;
                if (ntohl(header->ih_magic) != IH_MAGIC) {
                        fprintf(stderr, "Header magic incorrect: "
@@ -229,7 +232,7 @@ int main(int argc, char **argv)
                                IH_MAGIC, ntohl(header->ih_magic));
                        exit(EXIT_FAILURE);
                }
-               decrypt(p, file_len);
+               do_decrypt(p, file_len);
                munmap(p, file_len);
        }
  
@@ -279,7 +282,7 @@ static void copy_file(int src, int dst)
     }
 }
  
-static void encrypt(void *p, off_t len)
+static void do_encrypt(void *p, off_t len)
 {
        DES_cblock *pblock;
        int num_blocks;
@@ -299,7 +302,7 @@ static void encrypt(void *p, off_t len)
        }
 }
  
-static void decrypt(void *p, off_t len)
+static void do_decrypt(void *p, off_t len)
 {
        DES_cblock *pblock;
        int num_blocks;