Various small fix ups needed for mingw-w64 build.
authorAndrej Kacian <ticho@claws-mail.org>
Thu, 18 Jun 2015 21:58:51 +0000 (23:58 +0200)
committerAndrej Kacian <ticho@claws-mail.org>
Thu, 18 Jun 2015 21:58:51 +0000 (23:58 +0200)
src/common/Makefile.am
src/common/w32_dirent.c [deleted file]
src/common/w32_stdio.c
src/common/w32_stdlib.c
src/common/w32_string.c
src/common/w32_time.c
src/common/w32lib.h
src/ldaputil.h

index 796fae30aba5cf4d609e3f316d168acc08584c65..161922652c62eec11ecbc316c9f2c3315469e7a9 100644 (file)
@@ -10,7 +10,7 @@ noinst_LTLIBRARIES = libclawscommon.la
 
 if OS_WIN32
 arch_sources = fnmatch.c \
 
 if OS_WIN32
 arch_sources = fnmatch.c \
-               w32_dirent.c w32_reg.c w32_signal.c w32_stat.c \
+               w32_reg.c w32_signal.c w32_stat.c \
                w32_stdio.c w32_stdlib.c w32_string.c w32_time.c \
                w32_unistd.c w32_wait.c w32_account.c
 arch_headers = fnmatch.h w32lib.h
                w32_stdio.c w32_stdlib.c w32_string.c w32_time.c \
                w32_unistd.c w32_wait.c w32_account.c
 arch_headers = fnmatch.h w32lib.h
diff --git a/src/common/w32_dirent.c b/src/common/w32_dirent.c
deleted file mode 100644 (file)
index 91539dc..0000000
+++ /dev/null
@@ -1,100 +0,0 @@
-/* w32_dirent.c  - Posix emulation layer for Sylpheed (Claws)
- *
- * This file is part of w32lib.
- *
- * w32lib is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * w32lib is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- * For more information and a list of changes, see w32lib.h
- */
-
-
-#include <stdlib.h>
-#include <string.h>
-#include <windows.h>
-#include <dirent.h>
-
-#include "w32lib.h"
-
-
-
-DIR *
-opendir ( const char *name )
-{
-  DIR *dir;
-  
-  dir = calloc (1, sizeof *dir + strlen (name));
-  if (!dir)
-    return NULL;
-  strcpy (dir->dd_name, name);
-  return dir;
-}
-
-int 
-closedir (DIR *dir)
-{
-  FindClose( (HANDLE)dir->dd_handle );
-  free( dir );
-  return 0;
-}
-
-struct dirent *
-readdir( DIR *dir )
-{
-  WIN32_FIND_DATA fInfo;
-  struct dirent *xdirent;
-  int ret;
-  
-  if ( !dir->dd_handle )
-    {
-      char *dirname;
-      
-      if (*dir->dd_name) 
-        {
-          size_t n = strlen (dir->dd_name);
-          dirname = malloc (n + 4 + 1);
-          if (dirname) {
-            strcpy (dirname, dir->dd_name);
-            strcpy (dirname + n, "\\*.*");
-          }
-        }
-      else
-        dirname = strdup( "\\*.*" );
-      if (!dirname)
-        return NULL; /* Error. */
-
-      dir->dd_handle = (long)FindFirstFile( dirname, &fInfo );
-      free( dirname );
-      if ( !dir->dd_handle )
-        ret = 0;
-      else
-        ret = 1;
-    } 
-  else if ( dir->dd_handle != -1l )
-    {
-        ret = FindNextFile ((HANDLE)dir->dd_handle, &fInfo);
-    }
-  else
-    ret = 0;
-  if ( !ret ) 
-    return NULL;
-
-  xdirent = calloc ( 1, sizeof *xdirent);
-  if (xdirent)
-    {
-      strncpy (xdirent->d_name, fInfo.cFileName, FILENAME_MAX -1 );
-      xdirent->d_name[FILENAME_MAX-1] = 0;
-      xdirent->d_namlen = strlen( xdirent->d_name );
-    }
-  return xdirent;
-}
index 50b51c0f72219fd16bf9ba3c58ae00b8db67ae4f..af6a3ed2cb914656f02de92a84a4d69c4154d0f6 100644 (file)
 
 #include "w32lib.h"
 
 
 #include "w32lib.h"
 
+#if MINGW64_VERSION < 200
 FILE *popen( const char *command, const char *type ){
   return NULL;
 }
 FILE *popen( const char *command, const char *type ){
   return NULL;
 }
+#endif
 
 int pclose( FILE *stream ){
   return -1;
 
 int pclose( FILE *stream ){
   return -1;
index 3aba8f91094b78cd25374a25ccd81db0aa20e165..a55a17efe6a74c65b802806676680face08e1196 100644 (file)
@@ -31,6 +31,8 @@ void srandom( unsigned int seed ){
   srand( seed );
 }
 
   srand( seed );
 }
 
+#if MINGW64_VERSION < 200
 int truncate( const char *path, off_t length ){
   return -1;
 }
 int truncate( const char *path, off_t length ){
   return -1;
 }
+#endif
index 8bc0a1d82ab31da40c47d05e229b773146b9badd..6c238e3b92d6b8fa186b1256bd4369bb01dcd6b1 100644 (file)
@@ -24,6 +24,7 @@
 
 #include "w32lib.h"
 
 
 #include "w32lib.h"
 
+#if MINGW64_VERSION < 200
 int strcasecmp( const char *s1, const char *s2 ){
   size_t len1, len2, len;
 
 int strcasecmp( const char *s1, const char *s2 ){
   size_t len1, len2, len;
 
@@ -49,4 +50,4 @@ int strncasecmp( const char *s1, const char *s2, size_t n ){
 
    return 0;
 }
 
    return 0;
 }
-
+#endif /* MINGW64_VERSION < 200 */
index c7bb43ff7a52ea55f67f0facbaca7c89992ddb0f..ef7df8f9c2fb6073890674aae96d527245ad27fe 100644 (file)
@@ -25,6 +25,7 @@
 #include "w32lib.h"
 
 #if ! defined (__MINGW32__) || MINGW32_VERSION < 312
 #include "w32lib.h"
 
 #if ! defined (__MINGW32__) || MINGW32_VERSION < 312
+# if MINGW64_VERSION < 200
 int gettimeofday( struct timeval *tv, struct timezone *tz ){
   struct _timeb tstruct;
   _ftime( &tstruct );
 int gettimeofday( struct timeval *tv, struct timezone *tz ){
   struct _timeb tstruct;
   _ftime( &tstruct );
@@ -32,4 +33,5 @@ int gettimeofday( struct timeval *tv, struct timezone *tz ){
   tv->tv_usec = tstruct.millitm;
   return 1;
 }
   tv->tv_usec = tstruct.millitm;
   return 1;
 }
+# endif
 #endif
 #endif
index fb7b9239eb642060aaeb45cdcd3a6ce609a521de..cfa8e533929f9a1177d0722c89e9d2b9ebbdbd3c 100644 (file)
 #include <stdio.h>
 
 #ifdef __MINGW32__
 #include <stdio.h>
 
 #ifdef __MINGW32__
-#include <_mingw.h>
-#define MINGW32_VERSION (__MINGW32_MAJOR_VERSION * 100 \
+# include <_mingw.h>
+# define MINGW32_VERSION (__MINGW32_MAJOR_VERSION * 100 \
                         + __MINGW32_MINOR_VERSION)
                         + __MINGW32_MINOR_VERSION)
-#include <wchar.h>
-#include <dirent.h>
-#include <sys/time.h>
-#endif
+# define MINGW64_VERSION (__MINGW64_VERSION_MAJOR * 100 \
+                        + __MINGW64_VERSION_MINOR)
+# include <wchar.h>
+# include <dirent.h>
+# include <sys/time.h>
+# if MINGW64_VERSION >= 200
+#  include <sys/types.h>
+# endif
+#endif /* __MINGW32__ */
 
 #include <glib/gstdio.h>
 
 
 #include <glib/gstdio.h>
 
@@ -125,9 +130,10 @@ typedef unsigned int uid_t;
 
 /* functions */
 /*** str ***/
 
 /* functions */
 /*** str ***/
+#if MINGW64_VERSION < 200
 int strcasecmp( const char *s1, const char *s2 );
 int strcasecmp( const char *s1, const char *s2 );
-
 int strncasecmp( const char *s1, const char *s2, size_t n );
 int strncasecmp( const char *s1, const char *s2, size_t n );
+#endif
 
 /*** dir ***/
 #ifndef __MINGW32__
 
 /*** dir ***/
 #ifndef __MINGW32__
@@ -163,16 +169,13 @@ typedef struct
 
 #endif /* !__MINGW32__ */
 
 
 #endif /* !__MINGW32__ */
 
-
-DIR *opendir( const char *name );
-int closedir( DIR *dir );
-struct dirent *readdir( DIR *dir );
-
 #if defined (__MINGW32__) && MINGW32_VERSION < 312
 #if defined (__MINGW32__) && MINGW32_VERSION < 312
+# if MINGW64_VERSION < 200
 struct timezone {
   int tz_minuteswest;
   int tz_dsttime;
 };
 struct timezone {
   int tz_minuteswest;
   int tz_dsttime;
 };
+# endif
 #endif
 
 /*** stat ***/
 #endif
 
 /*** stat ***/
@@ -183,7 +186,9 @@ pid_t waitpid( pid_t pid, int *status, int options );
 
 /*** sys/time ***/
 #if ! defined (__MINGW32__) || MINGW32_VERSION < 312
 
 /*** sys/time ***/
 #if ! defined (__MINGW32__) || MINGW32_VERSION < 312
+# if MINGW64_VERSION < 200
 int gettimeofday( struct timeval *tv, struct timezone *tz );
 int gettimeofday( struct timeval *tv, struct timezone *tz );
+# endif
 #endif
 
 /*** unistd ***/
 #endif
 
 /*** unistd ***/
@@ -195,14 +200,18 @@ unsigned int sleep( unsigned int seconds );
 /*** stdlib ***/
 long int random( void );
 void srandom( unsigned int seed );
 /*** stdlib ***/
 long int random( void );
 void srandom( unsigned int seed );
+#if MINGW64_VERSION < 200
 int truncate( const char *path, off_t length );
 int truncate( const char *path, off_t length );
+#endif
 
 /*** signal ***/
 int kill( pid_t pid, int sig );
 
 /*** stdio ***/
 
 /*** signal ***/
 int kill( pid_t pid, int sig );
 
 /*** stdio ***/
+#if MINGW64_VERSION < 200
 FILE *popen( const char *command, const char *type );
 int pclose( FILE *stream );
 FILE *popen( const char *command, const char *type );
 int pclose( FILE *stream );
+#endif
 
 /*** w32_account.c ***/
 int w32_is_administrator (void);
 
 /*** w32_account.c ***/
 int w32_is_administrator (void);
index b9eded57ed7b8127204217dbc9fbae69cd03f90e..0c711ca650ac03af8dda10e2ff718667f7db55df 100644 (file)
@@ -37,6 +37,9 @@
 #define ldap_unbind_ext(ld,x,y) ldap_unbind_s(ld)
 #define LDAP_ADMINLIMIT_EXCEEDED LDAP_ADMIN_LIMIT_EXCEEDED
 #define timeval l_timeval
 #define ldap_unbind_ext(ld,x,y) ldap_unbind_s(ld)
 #define LDAP_ADMINLIMIT_EXCEEDED LDAP_ADMIN_LIMIT_EXCEEDED
 #define timeval l_timeval
+#ifndef LDAP_OPT_SUCCESS
+# define LDAP_OPT_SUCCESS 0
+#endif
 #endif
 /* Function Prototypes */
 GList *ldaputil_read_basedn    ( const gchar *host, const gint port,
 #endif
 /* Function Prototypes */
 GList *ldaputil_read_basedn    ( const gchar *host, const gint port,