1/* 2 * fontconfig/src/fcwindows.h 3 * 4 * Copyright © 2013 Google, Inc. 5 * 6 * Permission to use, copy, modify, distribute, and sell this software and its 7 * documentation for any purpose is hereby granted without fee, provided that 8 * the above copyright notice appear in all copies and that both that 9 * copyright notice and this permission notice appear in supporting 10 * documentation, and that the name of the author(s) not be used in 11 * advertising or publicity pertaining to distribution of the software without 12 * specific, written prior permission. The authors make no 13 * representations about the suitability of this software for any purpose. It 14 * is provided "as is" without express or implied warranty. 15 * 16 * THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 17 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO 18 * EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY SPECIAL, INDIRECT OR 19 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 20 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 21 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 22 * PERFORMANCE OF THIS SOFTWARE. 23 * 24 * Google Author(s): Behdad Esfahbod 25 */ 26 27#ifndef _FCWINDOWS_H_ 28#define _FCWINDOWS_H_ 29 30#ifdef HAVE_CONFIG_H 31#include <config.h> 32#endif 33 34#ifdef _WIN32 35 /* Request Windows Vista for building. This is required to 36 * get MemoryBarrier on mingw32... */ 37# if defined(_WIN32_WINNT) && _WIN32_WINNT < 0x0600 38# undef _WIN32_WINNT 39# endif 40# ifndef _WIN32_WINNT 41# define _WIN32_WINNT 0x0600 42# endif 43# define WIN32_LEAN_AND_MEAN 44# define WIN32_EXTRA_LEAN 45# define STRICT 46# include <windows.h> 47# include <io.h> 48 49#if defined(_MSC_VER) 50#include <BaseTsd.h> 51typedef SSIZE_T ssize_t; 52#endif 53 54#define FC_UINT64_FORMAT "I64u" 55 56#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) 57 58#ifndef S_ISDIR 59#define S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR) 60#endif 61 62#ifndef F_OK 63#define F_OK 0 64#endif 65#ifndef X_OK 66#define X_OK 0 /* no execute bit on windows */ 67#endif 68#ifndef W_OK 69#define W_OK 2 70#endif 71#ifndef R_OK 72#define R_OK 4 73#endif 74 75/* MingW provides dirent.h / openddir(), but MSVC does not */ 76#ifndef HAVE_DIRENT_H 77 78#define HAVE_STRUCT_DIRENT_D_TYPE 1 79 80typedef struct DIR DIR; 81 82typedef enum { 83 DT_UNKNOWN = 0, 84 DT_DIR, 85 DT_REG, 86} DIR_TYPE; 87 88typedef struct dirent { 89 const char *d_name; 90 DIR_TYPE d_type; 91} dirent; 92 93#define opendir(dirname) FcCompatOpendirWin32(dirname) 94#define closedir(d) FcCompatClosedirWin32(d) 95#define readdir(d) FcCompatReaddirWin32(d) 96 97DIR * FcCompatOpendirWin32 (const char *dirname); 98 99struct dirent * FcCompatReaddirWin32 (DIR *dir); 100 101int FcCompatClosedirWin32 (DIR *dir); 102 103#endif /* HAVE_DIRENT_H */ 104 105#endif /* _WIN32 */ 106 107#endif /* _FCWINDOWS_H_ */ 108