1 /* $Id$ 2 * Provides compiler-independent functions like DOS findfirst() and findnext() 3 * 4 * HUSKYLIB: common defines, types and functions for HUSKY 5 * 6 * This is part of The HUSKY Fidonet Software project: 7 * see http://husky.sourceforge.net for details 8 * 9 * 10 * HUSKYLIB is free software; you can redistribute it and/or 11 * modify it under the terms of the GNU Lesser General Public 12 * License as published by the Free Software Foundation; either 13 * version 2 of the License, or (at your option) any later version. 14 * 15 * HUSKYLIB is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 * General Public License for more details. 19 * 20 * You should have received a copy of the GNU Lesser General Public 21 * License along with this library; see file COPYING. If not, write to the 22 * Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 23 * 24 * See also http://www.gnu.org, license may be found here. 25 */ 26 27 #ifndef HUSKY_FFIND_H__ 28 #define HUSKY_FFIND_H__ 29 30 #include <stdio.h> 31 32 #include "compiler.h" /* compiler see directory of this (ffind.h) file */ 33 #include "huskyext.h" 34 35 36 #ifdef HAS_DOS_H 37 # include <dos.h> 38 #endif 39 #if defined(HAS_UNISTD_H) 40 # include <unistd.h> 41 #endif 42 #if defined(HAS_DIRENT_H) 43 # include <dirent.h> 44 #endif 45 #if defined(HAS_DIR_H) 46 #include <dir.h> 47 #endif 48 49 50 #if defined(__RSXNT__) || defined(__MINGW32__) || defined(__MSVC__) 51 # define WIN32_LEAN_AND_MEAN 52 # define NOGDI 53 # define NOUSER 54 # define NOMSG 55 56 # ifdef __RSXNT__ 57 /* The RSXNT winsock.h conflicts with EMX 58 io.h. As we do not need sockets anyway, we 59 just prevent their inclusion. */ 60 # define _WINSOCK_H 61 # endif 62 # if defined(__MINGW32__) 63 /* For HTick compatibility */ 64 # define _WINUSER_H 65 # endif 66 # include <windows.h> 67 #endif 68 69 70 struct ffind 71 { 72 /* this is the public area of the struct */ 73 char ff_attrib; 74 unsigned short ff_ftime; 75 unsigned short ff_fdate; 76 long ff_fsize; 77 char ff_name[256]; 78 79 /* now comes the privat area where search handles or similiar are stored */ 80 81 #if defined(__TURBOC__) || defined(__DJGPP__) 82 struct ffblk ffbuf; 83 84 #elif defined(__WATCOMC__) || defined(__MSC__) 85 struct find_t ffbuf; 86 unsigned long hdir; /* directory handle from DosFindFirst */ 87 88 #elif defined(__OS2__) || defined(__EMX__) 89 #if defined(__386__) || defined(__FLAT__) 90 unsigned long hdir; /* directory handle from DosFindFirst */ 91 #else 92 unsigned short hdir; /* directory handle from DosFindFirst */ 93 #endif 94 95 #elif defined(SASC) 96 struct FileInfoBlock info; 97 char newfile[FILENAME_MAX]; 98 char prefix[FILENAME_MAX]; 99 100 #elif defined(__UNIX__) 101 DIR *dir; 102 char firstbit[FILENAME_MAX]; 103 char lastbit[FILENAME_MAX]; 104 105 #elif defined(__RSXNT__) || defined(__MINGW32__) || defined(__MSVC__) 106 #ifndef _A_HIDDEN 107 # define _A_HIDDEN 0x02 108 #endif 109 WIN32_FIND_DATA InfoBuf; 110 HANDLE hDirA; 111 char attrib_srch; 112 113 #else 114 #error Unable to determine compiler and target operating system! 115 #endif 116 }; 117 118 typedef struct ffind FFIND; 119 120 /* 121 * I prefixed the functions below with an additional F in order to 122 * prevent name clashes with the Win32 API 123 */ 124 125 HUSKYEXT FFIND *_fast FFindOpen(const char *filespec, unsigned short attribute); 126 HUSKYEXT FFIND *_fast FFindInfo(const char *filespec); 127 HUSKYEXT int _fast FFindNext(FFIND * ff); 128 HUSKYEXT void _fast FFindClose(FFIND * ff); 129 130 #define MSDOS_READONLY 0x01 131 #define MSDOS_HIDDEN 0x02 132 #define MSDOS_SYSTEM 0x04 133 #define MSDOS_VOLUME 0x08 134 #define MSDOS_SUBDIR 0x10 135 #define MSDOS_ARCHIVE 0x20 136 #define MSDOS_RSVD1 0x40 137 #define MSDOS_RSVD2 0x80 138 139 #endif 140