1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
|
/* This file is part of the KDE project
Copyright (C) 2003-2004 Jaroslaw Staniek <[email protected]>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#define _WINSOCKAPI_ /* skip winsock */
#include <windows.h>
#include <unistd.h>
#include <sys/stat.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>
#include <fcntl.h>
#include "win32_utils.h"
KDEWIN32_EXPORT int getgroups(int size, gid_t list[])
{
/* TODO */
return 0;
}
KDEWIN32_EXPORT int readlink(const char *__path, char *__buf, int __buflen)
{
if (!__path) {
errno = EINVAL;
return -1;
}
if ( (__buflen < 0) || ((int)strlen(__path)>(__buflen-1)) )
{
errno = ENAMETOOLONG;
return -1;
}
if (access(__path, R_OK) == 0) {
/* ok, copy to buf */
strncpy(__buf,__path,__buflen);
errno = 0;
return 0;
}
errno = ENOENT;
return -1;
}
KDEWIN32_EXPORT int symlink(const char *__name1, const char *__name2)
{
return fcopy(__name1, __name2);
}
KDEWIN32_EXPORT int link(const char *__name1, const char *__name2)
{
return fcopy(__name1, __name2);
}
KDEWIN32_EXPORT int chown(const char *__path, uid_t __owner, gid_t __group)
{
return 0;
}
KDEWIN32_EXPORT int fchown(int __fd, uid_t __owner, gid_t __group )
{
return 0;
}
KDEWIN32_EXPORT int lstat(const char *path, struct stat *sb)
{
return _stat(path,(struct _stat*)sb);
}
KDEWIN32_EXPORT int fchmod(int __fd, mode_t __mode)
{
return 0;
}
/* Get the real user ID of the calling process. */
KDEWIN32_EXPORT uid_t getuid()
{
return 1; /* NOT A ROOT! */
}
/* Get the effective user ID of the calling process. */
KDEWIN32_EXPORT uid_t geteuid (void)
{
return 1; /* NOT A ROOT! */
}
/* Get the real group ID of the calling process. */
KDEWIN32_EXPORT gid_t getgid (void)
{
return 1; /* NOT A ROOT GR! */
}
/* Get the effective group ID of the calling process. */
KDEWIN32_EXPORT gid_t getegid (void)
{
return 1; /* NOT A ROOT GR! */
}
KDEWIN32_EXPORT int pipe(int *fd)
{
/** @todo */
return _pipe( fd, 256, O_BINARY ); /* OK? */
}
KDEWIN32_EXPORT pid_t fork(void)
{
/** @todo */
return -1;
}
KDEWIN32_EXPORT pid_t setsid(void)
{
/** @todo */
return -1;
}
typedef unsigned int size_t;
/*#define INCL_WINSOCK_API_PROTOTYPES 0
#include <winsock2.h>*/
KDEWIN32_EXPORT int kde_gethostname(char *__name, size_t __len)
{
size_t len = __len;
if (0==GetComputerNameA(__name, &len))
return -1;
return 0;
}
#define getlogin_buf_size 255
char getlogin_buf[getlogin_buf_size+1];
KDEWIN32_EXPORT char* getlogin()
{
/*! @todo make this reentrant!*/
size_t size = sizeof(getlogin_buf);
*getlogin_buf = 0;
if (!GetUserNameA(getlogin_buf, (LPDWORD)&size))
return 0;
return getlogin_buf;
}
KDEWIN32_EXPORT void usleep(unsigned int usec)
{
Sleep(usec/1000);
}
KDEWIN32_EXPORT void sleep(unsigned int sec)
{
Sleep(sec*1000);
}
KDEWIN32_EXPORT long int random()
{
return rand();
}
KDEWIN32_EXPORT int setreuid(uid_t ruid, uid_t euid)
{
/*! @todo */
return 0;
}
|