libopkg: make MD5 support optional
[oweals/opkg-lede.git] / libopkg / file_util.c
index cf5f7740e2bed43896575bde18d91fe15ccbb688..c54903c30b66907d126cd6ebb5ed0b58759e0f34 100644 (file)
@@ -26,7 +26,9 @@
 
 #include "sprintf_alloc.h"
 #include "file_util.h"
 
 #include "sprintf_alloc.h"
 #include "file_util.h"
+#ifdef HAVE_MD5
 #include "md5.h"
 #include "md5.h"
+#endif
 #include "libbb/libbb.h"
 
 #if defined HAVE_SHA256
 #include "libbb/libbb.h"
 
 #if defined HAVE_SHA256
@@ -135,6 +137,7 @@ file_mkdir_hier(const char *path, long mode)
        return make_directory(path, mode, FILEUTILS_RECUR);
 }
 
        return make_directory(path, mode, FILEUTILS_RECUR);
 }
 
+#ifdef HAVE_MD5
 char *file_md5sum_alloc(const char *file_name)
 {
     static const int md5sum_bin_len = 16;
 char *file_md5sum_alloc(const char *file_name)
 {
     static const int md5sum_bin_len = 16;
@@ -180,6 +183,7 @@ char *file_md5sum_alloc(const char *file_name)
 
     return md5sum_hex;
 }
 
     return md5sum_hex;
 }
+#endif
 
 #ifdef HAVE_SHA256
 char *file_sha256sum_alloc(const char *file_name)
 
 #ifdef HAVE_SHA256
 char *file_sha256sum_alloc(const char *file_name)
@@ -238,6 +242,11 @@ rm_r(const char *path)
        DIR *dir;
        struct dirent *dent;
 
        DIR *dir;
        struct dirent *dent;
 
+       if (path == NULL) {
+               opkg_perror(ERROR, "Missing directory parameter");
+               return -1;
+       }
+
        dir = opendir(path);
        if (dir == NULL) {
                opkg_perror(ERROR, "Failed to open dir %s", path);
        dir = opendir(path);
        if (dir == NULL) {
                opkg_perror(ERROR, "Failed to open dir %s", path);