Main Page | Data Structures | File List | Data Fields | Globals

win32lacks.h

00001 /*
00002  * Copyright (C) 1999-2003 Alex Scott
00003  *
00004  * This library is free software; you can redistribute it and/or modify it
00005  * under the terms of the GNU Library General Public License as published by
00006  * the Free Software Foundation; either version 2 of the License, or (at
00007  * your option) any later version.
00008  *
00009  * This library is distributed in the hope that it will be useful, but
00010  * WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library
00012  * General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU Library General Public License
00015  * along with this library; if not, write to the Free Software Foundation,
00016  * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00017  */
00018 
00019 /* Emulations of functions missing from the WIN32 platform */
00020 
00021 #ifdef WIN32  // no need to use this if your not on a win32 platform
00022 
00023 # include <stdio.h>
00024 # include <errno.h>
00025 
00026 # include <windows.h>
00027 # include <direct.h>
00028 # include <io.h>
00029 
00030 # include "cuf-global.h"
00031 
00032 # ifndef _WIN32LACKS_H_
00033 #  define _WIN32LACKS_H_
00034 
00035 // emulation of the stat macros
00036 #  define S_ISDIR(m) ((m) & S_IFDIR)
00037 // More to be added when i need them or their requested
00038 
00039 #  ifndef strcasecmp
00040 #   define strcasecmp win32_strcasecmp
00041 #  endif
00042 #  ifndef strncasecmp
00043 #   define strncasecmp win32_strncasecmp
00044 #  endif
00045 #  ifndef snprintf
00046 #   define snprintf win32_snprintf
00047 #  endif
00048 
00049 /* WIN32 emulations of POSIX/BSD dir functions */
00050 #  ifndef opendir
00051 #   define opendir win32_opendir
00052 #  endif
00053 #  ifndef readdir
00054 #   define readdir win32_readdir
00055 #  endif
00056 #  ifndef rewinddir
00057 #   define rewinddir win32_rewinddir
00058 #  endif
00059 #  ifndef closedir
00060 #   define closedir win32_closedir
00061 #  endif
00062 
00063 #  define NAME_MAX 255
00064 
00065 // Use to keep the main function the same as were use to in unix.
00066 #  include <stdlib.h> /* needed for __argc and __argv */
00067 #  define WIN32MAIN \
00068 struct HINSTANCE__; \
00069 int _stdcall WinMain (struct HINSTANCE__ *hInstance, \
00070                       struct HINSTANCE__ *hPrevInstance, \
00071                       char *lpszCmdLine, int nCmdShow) { \
00072     return main (__argc, __argv); \
00073 }
00074 
00075 
00076 struct dirent {
00077         long d_ino;                     // not set in my WIN32 wrapper
00078         off_t d_off;                    // not set in my WIN32 wrapper
00079         unsigned short d_reclen;
00080         char d_name[NAME_MAX + 1];
00081 };
00082 
00083 typedef struct _DIR {
00084         char *dir_name;
00085         int just_opened;
00086         HANDLE find_file_handle;
00087         void *find_file_data;
00088         struct dirent readdir_result;
00089 } DIR;
00090 
00091 typedef unsigned int mode_t;
00092 
00093 char *win32_basename (char *file);
00094 
00095 int win32_strcasecmp (const char *sa, const char *sb);
00096 int win32_strncasecmp (const char *sa, const char *sb, size_t n);
00097 int win32_snprintf (char *str, size_t n, const char *format, ...);
00098 
00099 DIR *win32_opendir (const char *dirname);
00100 struct dirent *win32_readdir (DIR *dir);
00101 void win32_rewinddir (DIR *dir);
00102 int win32_closedir (DIR *dir);
00103 
00104 # endif /* _WIN32LACKS_H_ */
00105 
00106 #else
00107 
00108 // If not win32, it dosent do anything.
00109 # define WIN32MAIN
00110 
00111 #endif /* WIN32 */
00112 

Generated on Fri Jun 4 18:35:18 2004 for cuf by doxygen 1.3.6