diff -ruN src.old/chmview.c src/chmview.c
--- src.old/chmview.c	2005-03-07 21:29:18.000000000 +0100
+++ chmview.c	2008-08-18 14:39:39.000000000 +0200
@@ -17,19 +17,33 @@
     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
 
+#ifndef UNIX
 #include <windows.h>
+#endif
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <limits.h>
+
+#ifdef UNIX
+#include <errno.h>
+#include <locale.h>
+#else
 #include <dir.h>
+#endif
 
 #include "chm_lib.h"
 #include "utf8.h"
 
+#ifdef UNIX
+#define _strnicmp strncasecmp
+#define MODE 0755
+#endif
+
 struct cb_data
 {
-  int extractwithoutpath;
+  long extractwithoutpath;
   char *path;
   int pathlen;
 };
@@ -44,6 +58,7 @@
   return p;
 }
 
+#ifndef UNIX
 int makedir(char *path)
 {
   char *end;
@@ -75,6 +90,39 @@
   }
   return 1;
 }
+#else
+static int makedir(char *path)
+{
+  char *slash;
+  int  was_error, done, err;
+
+  slash = path;
+  done = 0;
+  was_error = 0;
+
+  do {
+    slash = index(slash + 1, '/');
+    if (slash)
+    {
+      *slash = 0;
+      if (mkdir(path, MODE) == -1 && EEXIST != errno)
+		was_error = 1;
+      *slash = '/';
+    }
+    else
+       done = 1;
+  } while (! done && ! was_error);
+
+  if (was_error)
+  {
+    perror("mkdir");
+	exit(1);
+    /* return 0; */
+  }
+
+  return 1;
+}
+#endif
 
 const char ILLEGAL_SYMB[] = "<>:|?*\"";
 const char ILLEGAL_REPL[] = "()_!__'";
@@ -94,7 +142,7 @@
   }
 }
 
-static int savetofile(struct chmFile *c, struct chmUnitInfo *ui, int extractwithoutpath)
+static int savetofile(struct chmFile *c, struct chmUnitInfo *ui, long extractwithoutpath)
 {
   LONGINT64 length=0;
   char *outbuf=NULL;
@@ -103,6 +151,9 @@
   char fullpath[CHM_MAX_PATHLEN*2+1];
   char target[CHM_MAX_PATHLEN*2+1];
   wchar_t temp[CHM_MAX_PATHLEN+1];
+#ifdef UNIX
+  size_t pathlen;
+#endif
 
   if (ui->length)
   {
@@ -116,13 +167,32 @@
       return -1;
     }
   }
+#ifndef UNIX
   GetCurrentDirectory(sizeof(fullpath)-1,fullpath);
   while ((p = strstr(fullpath,"\\")) != NULL)
     *p = '/';
   if (fullpath[strlen(fullpath)-1] != '/')
     strcat(fullpath,"/");
+#else
+  getcwd(fullpath, sizeof(fullpath)-1);
+  pathlen = strlen(fullpath);
+  if (pathlen == 0)
+	return -1;	/* impossible but... defensive programming */
+  if (fullpath[pathlen - 1] != '/')
+  {
+    if (pathlen == PATH_MAX)
+		return -1;
+    else
+		fullpath[pathlen] = '/';
+	fullpath[pathlen+1] = 0;
+  }
+#endif
   decode_UTF8(temp,ui->path);
+#ifndef UNIX
   WideCharToMultiByte(CP_ACP,0,temp,-1,target,sizeof(target),NULL,NULL);
+#else
+  wcstombs(target, temp, sizeof(target));
+#endif
   ReplaceIllegalChars(target);
   strcat(fullpath,extractwithoutpath?pointtoname(target):(target[0]=='/'?target+1:target));
   if (!extractwithoutpath)
@@ -147,26 +217,30 @@
   return 0;
 }
 
-void extract(struct chmFile *c, struct chmUnitInfo *ui, int extractwithoutpath)
+void extract(struct chmFile *c, struct chmUnitInfo *ui, long extractwithoutpath)
 {
   char target[CHM_MAX_PATHLEN*2+1];
   wchar_t temp[CHM_MAX_PATHLEN+1];
 
   decode_UTF8(temp,ui->path);
+#ifndef UNIX
   WideCharToMultiByte(CP_OEMCP,0,temp,-1,target,sizeof(target),NULL,NULL);
+#else
+  wcstombs(target, temp, sizeof(target));
+#endif
   printf("Extracting %s ",target);
   if (savetofile(c, ui, extractwithoutpath))
   {
     printf("Error\n");
     error=1;
     //return CHM_ENUMERATOR_FAILURE;
-  }
+  } else
   printf("OK\n");
 }
 
 int _extract_callback_all(struct chmFile *c, struct chmUnitInfo *ui, void *context)
 {
-  extract(c,ui,(int)context);
+  extract(c,ui,(long)context);
   return CHM_ENUMERATOR_CONTINUE;
 }
 
@@ -180,7 +254,7 @@
   return CHM_ENUMERATOR_CONTINUE;
 }
 
-extractdir(struct chmFile *c, char *path, int extractwithoutpath)
+extractdir(struct chmFile *c, char *path, long extractwithoutpath)
 {
   struct cb_data data = {extractwithoutpath,path,strlen(path)};
   chm_enumerate(c,CHM_ENUMERATE_ALL,_extract_callback_dir,(void *)&data);
@@ -193,7 +267,11 @@
   wchar_t temp[CHM_MAX_PATHLEN+1];
 
   decode_UTF8(temp,ui->path);
+#ifndef UNIX
   WideCharToMultiByte(CP_OEMCP,0,temp,-1,target,sizeof(target),NULL,NULL);
+#else
+  wcstombs(target, temp, sizeof(target));
+#endif
 
   if ((target)[0] == '/')
   {
@@ -243,6 +321,9 @@
 
   infname = argv[2];
 
+#ifdef UNIX
+  setlocale(LC_ALL,"");
+#endif
   c = chm_open(infname);
   if (!c)
     exit(-1);
@@ -265,7 +346,7 @@
       char target[CHM_MAX_PATHLEN*2+1];
       wchar_t temp[CHM_MAX_PATHLEN+1];
       int status;
-      int extractwithoutpath = command[0]=='e'?1:0;
+      long extractwithoutpath = command[0]=='e'?1:0;
 
       if (argc == 4)
       {
@@ -305,7 +386,11 @@
             strcat(target,name+1);
           else
             strcat(target,name);
+#ifndef UNIX 
           MultiByteToWideChar(CP_ACP,0,target,-1,temp,sizeof(temp));
+#else
+		  mbstowcs(temp, target, sizeof(target));
+#endif
           encode_UTF8(target,temp);
           status = chm_resolve_object(c,target,&ui);
           if (status==CHM_RESOLVE_SUCCESS && ui.path[strlen(ui.path)-1]!='/')
