~ubuntu-branches/ubuntu/wily/basilisk2/wily-proposed

« back to all changes in this revision

Viewing changes to src/Windows/posix_emu.h

  • Committer: Bazaar Package Importer
  • Author(s): Jonas Smedegaard
  • Date: 2008-03-06 19:33:01 UTC
  • mfrom: (2.1.4 gutsy)
  • Revision ID: james.westby@ubuntu.com-20080306193301-cc2ofn705nfsq3y0
Tags: 0.9.20070407-4
* Update copyright-check cdbs snippet to parse licensecheck using perl:
  + No longer randomly drops newlines
  + More compact hint file (and ordered more like wiki-proposed new copyright
    syntax).
  + No longer ignore files without copyright.
* Update copyright_hints.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *  posix_emu.h
 
3
 *
 
4
 *  Basilisk II (C) 1997-1999 Christian Bauer
 
5
 *
 
6
 *  Windows platform specific code copyright (C) Lauri Pesonen
 
7
 *
 
8
 *  This program is free software; you can redistribute it and/or modify
 
9
 *  it under the terms of the GNU General Public License as published by
 
10
 *  the Free Software Foundation; either version 2 of the License, or
 
11
 *  (at your option) any later version.
 
12
 *
 
13
 *  This program is distributed in the hope that it will be useful,
 
14
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
16
 *  GNU General Public License for more details.
 
17
 *
 
18
 *  You should have received a copy of the GNU General Public License
 
19
 *  along with this program; if not, write to the Free Software
 
20
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
21
 */
 
22
 
 
23
#include <fcntl.h>
 
24
#include <errno.h>
 
25
#include <io.h>
 
26
#include <direct.h>
 
27
#include <sys/stat.h>
 
28
 
 
29
#include "extfs.h"
 
30
 
 
31
void init_posix_emu(void);
 
32
void final_posix_emu(void);
 
33
 
 
34
typedef struct dirent {
 
35
        char d_name[MAX_PATH_LENGTH];
 
36
} dirent;
 
37
 
 
38
typedef struct DIR {
 
39
        HANDLE h;
 
40
        WIN32_FIND_DATA FindFileData;
 
41
        dirent de;
 
42
        char *vname_list;
 
43
} DIR;
 
44
 
 
45
// emulated
 
46
DIR *opendir( const char *path );
 
47
void closedir( DIR *d );
 
48
struct dirent *readdir( DIR *d );
 
49
 
 
50
// access() mode: exists?
 
51
#ifndef F_OK
 
52
#define F_OK 0
 
53
#endif
 
54
// access() mode: can do r/w?
 
55
#ifndef W_OK
 
56
#define W_OK 6
 
57
#endif
 
58
 
 
59
// hook stat functions to create virtual desktop
 
60
// because of errno all used funcs must be hooked.
 
61
int my_stat( const char *, struct my_stat * );
 
62
int my_fstat( int, struct my_stat * );
 
63
int my_open( const char *, int, ... );
 
64
int my_rename( const char *, const char * );
 
65
int my_access( const char *, int );
 
66
int my_mkdir( const char *path, int mode );
 
67
int my_remove( const char * );
 
68
int my_creat( const char *path, int mode );
 
69
int my_creat( const char *path, int mode );
 
70
int my_close( int fd );
 
71
long my_lseek( int fd, long, int);
 
72
int my_read( int fd, void *, unsigned int);
 
73
int my_write( int fd, const void *, unsigned int);
 
74
int my_chsize( int fd, unsigned int size );
 
75
int my_locking( int fd, int mode, long nbytes );
 
76
 
 
77
extern int my_errno;
 
78
 
 
79
// must hook all other functions that manipulate file names
 
80
#ifndef NO_POSIX_API_HOOK
 
81
#define stat my_stat
 
82
#define fstat my_fstat
 
83
#define open my_open
 
84
#define rename my_rename
 
85
#define access my_access
 
86
#define mkdir my_mkdir
 
87
#define remove my_remove
 
88
#define creat my_creat
 
89
#define close my_close
 
90
#define lseek my_lseek
 
91
#define read my_read
 
92
#define write my_write
 
93
#define ftruncate my_chsize
 
94
#define locking my_locking
 
95
 
 
96
#undef errno
 
97
#define errno my_errno
 
98
#endif //!NO_POSIX_API_HOOK
 
99
 
 
100
#ifndef S_ISDIR
 
101
#define S_ISDIR(stat_mode) (((stat_mode) & _S_IFDIR) != 0)
 
102
#endif
 
103
 
 
104
// can't #define "stat" unless there's a replacement for "struct stat"
 
105
struct my_stat {
 
106
  _dev_t st_dev;
 
107
  _ino_t st_ino;
 
108
  unsigned short st_mode;
 
109
  short st_nlink;
 
110
  short st_uid;
 
111
  short st_gid;
 
112
  _dev_t st_rdev;
 
113
  _off_t st_size;
 
114
  time_t st_atime;
 
115
  time_t st_mtime;
 
116
  time_t st_ctime;
 
117
};
 
118
 
 
119
// Your compiler may have different "struct stat" -> edit "struct my_stat"
 
120
#define validate_stat_struct ( sizeof(struct my_stat) == sizeof(struct stat) )
 
121
 
 
122
#define st_crtime st_ctime