s3-includes: only include system/filesys.h when needed.
[nivanova/samba-autobuild/.git] / source3 / torture / smbiconv.c
index c4d30164e47ab3ab5cdc755c9f6f064e4fe015ba..88ad6fef60976f69d5a317d515670d4cf5e15932 100644 (file)
@@ -21,6 +21,8 @@
 */
 
 #include "includes.h"
+#include "system/filesys.h"
+#include "popt_common.h"
 #undef realloc
 
 static int
@@ -86,7 +88,7 @@ incomplete character or shift sequence at end of buffer"));
 
 
 static int
-process_fd (iconv_t cd, int fd, FILE *output)
+process_fd (smb_iconv_t cd, int fd, FILE *output)
 {
   /* we have a problem with reading from a descriptor since we must not
      provide the iconv() function an incomplete character or shift
@@ -168,8 +170,8 @@ process_fd (iconv_t cd, int fd, FILE *output)
 int main(int argc, char *argv[])
 {
        const char *file = NULL;
-       char *from = "";
-       char *to = "";
+       const char *from = "";
+       const char *to = "";
        char *output = NULL;
        const char *preload_modules[] = {NULL, NULL};
        FILE *out = stdout;
@@ -200,7 +202,7 @@ int main(int argc, char *argv[])
 
        /* the following functions are part of the Samba debugging
           facilities.  See lib/debug.c */
-       setup_logging("smbiconv", True);
+       setup_logging("smbiconv", DEBUG_STDOUT);
 
        if (preload_modules[0]) smb_load_modules(preload_modules);
 
@@ -214,8 +216,9 @@ int main(int argc, char *argv[])
        }
 
        cd = smb_iconv_open(to, from);
-       if((int)cd == -1) {
+       if (cd == (smb_iconv_t)-1) {
                DEBUG(0,("unable to find from or to encoding, exiting...\n"));
+               if (out != stdout) fclose(out);
                return 1;
        }