Edinburgh Speech Tools
2.4-release
Loading...
Searching...
No Matches
system_specific_win32.c
1
/*************************************************************************/
2
/* */
3
/* Centre for Speech Technology Research */
4
/* University of Edinburgh, UK */
5
/* Copyright (c) 1994,1995,1996 */
6
/* All Rights Reserved. */
7
/* */
8
/* Permission is hereby granted, free of charge, to use and distribute */
9
/* this software and its documentation without restriction, including */
10
/* without limitation the rights to use, copy, modify, merge, publish, */
11
/* distribute, sublicense, and/or sell copies of this work, and to */
12
/* permit persons to whom this work is furnished to do so, subject to */
13
/* the following conditions: */
14
/* 1. The code must retain the above copyright notice, this list of */
15
/* conditions and the following disclaimer. */
16
/* 2. Any modifications must be clearly marked as such. */
17
/* 3. Original authors' names are not deleted. */
18
/* 4. The authors' names are not used to endorse or promote products */
19
/* derived from this software without specific prior written */
20
/* permission. */
21
/* */
22
/* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */
23
/* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */
24
/* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */
25
/* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */
26
/* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */
27
/* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */
28
/* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */
29
/* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */
30
/* THIS SOFTWARE. */
31
/* */
32
/*************************************************************************/
33
/* functions which mimic unix system calls */
34
35
#include <stdlib.h>
36
#include <stdio.h>
37
#include "EST_unix.h"
38
#include "EST_socket.h"
39
40
int
unix_access(
const
char
*
file
,
int
mode
)
41
{
42
DWORD
flags =
GetFileAttributes
(
file
);
43
44
if
(flags == 0xffffffff)
45
{
46
if
(
ERROR_FILE_NOT_FOUND
==
GetLastError
())
47
return
-1;
48
else
return
1;
49
}
50
51
if
(
mode
==F_OK)
52
return
0;
53
54
if
(
mode
==R_OK)
55
return
0;
56
57
if
(
mode
==W_OK)
58
{
59
/* When referring to a directory, FILE_ATTRIBUTE_READONLY means the directory can't be
60
deleted. It does not mean a file can't be written to the directory.
61
*/
62
if
(flags|
FILE_ATTRIBUTE_DIRECTORY
)
63
return
0;
64
else
65
return
(flags|
FILE_ATTRIBUTE_READONLY
) != 0;
66
}
67
68
return
1;
69
}
70
71
72
int
unix_read(
HANDLE
fd,
char
*buffer,
int
n)
73
{
74
int
howmany
;
75
76
if
(
ReadFile
(fd, buffer, n, &
howmany
, NULL))
77
return
howmany
;
78
79
return
-1;
80
}
81
82
char
*unix_getcwd(
char
*buffer,
int
maxlength
)
83
{
84
static
char
lbuffer
[1024];
85
86
if
(buffer==NULL)
87
{
88
buffer =
lbuffer
;
89
maxlength
=1023;
90
}
91
92
if
(
GetCurrentDirectory
(
maxlength
, buffer) >=0)
93
return
buffer;
94
return
NULL;
95
}
96
97
int
unix_waitpid(
int
pid
,
int
*
statusp
,
int
flags)
98
{
99
fprintf
(
stderr
,
"waitpid not yet implemented\n"
);
100
return
0;
101
}
102
103
int
unix_fork(
void
)
104
{
105
fprintf
(
stderr
,
" FORK NOT YET IMPLEMENTED\n"
);
106
return
-1;
107
}
108
109
static
int
sockets_initialised =0;
110
111
int
socket_initialise(
void
)
112
{
113
WORD
wVersionRequested
;
114
WSADATA
wsaData
;
115
int
err;
116
117
if
(sockets_initialised)
118
return
1;
119
120
wVersionRequested
=
MAKEWORD
( 2, 0 );
121
122
err =
WSAStartup
(
wVersionRequested
, &
wsaData
);
123
if
( err != 0 )
124
{
125
printf
(
"Socket Initialisation failed\n"
);
126
return
0;
127
}
128
129
sockets_initialised=1;
130
return
1;
131
}
EST_Hash_Pair
Definition
EST_THash.h:75
utils
system_specific_win32.c
Generated on Wed Jan 29 2025 14:56:50 for Edinburgh Speech Tools by
1.9.8