1 | diff -ruN -x configure -x ltmain.sh -x aclocal.m4 -x config.guess -x config.sub -x Makefile.in glib-2.6.5/buildos2.sh glib-2.6.5.os2/buildos2.sh |
---|
2 | --- glib-2.6.5/buildos2.sh Thu Jan 1 00:00:00 1970 |
---|
3 | +++ glib-2.6.5.os2/buildos2.sh Thu Jul 28 20:34:02 2005 |
---|
4 | @@ -0,0 +1,13 @@ |
---|
5 | +#!bash.exe |
---|
6 | +export ac_executable_extensions=".exe" |
---|
7 | +export LANG=C |
---|
8 | +export CFLAGS="-O2 -Zmtd -Zsysv-signals -Zbin-files -D__ST_MT_ERRNO__" |
---|
9 | +export LDFLAGS="-O2 -Zmtd -Zsysv-signals -Zbin-files -D__ST_MT_ERRNO__" |
---|
10 | +export EMXSHELL=bash.exe |
---|
11 | +#libtoolize --force; aclocal --force; autoconf --force; automake --force |
---|
12 | +#./configure --prefix=/usr --sysconfdir=/etc --disable-libtool-locking --with-threads=none --disable-largefile SHELL=bash.exe LIBS="-liconv_s -lshm -lemxfix -lgcc" |
---|
13 | +#/usr/bin/make.exe MAKE=/usr/bin/make.exe SHELL=bash.exe 2>&1 |tee make.log |
---|
14 | +#/usr/bin/make.exe MAKE=/usr/bin/make.exe SHELL=bash.exe check 2>&1 |tee check.log |
---|
15 | +#/usr/bin/make.exe MAKE=/usr/bin/make.exe SHELL=bash.exe install 2>&1 |tee inst.log |
---|
16 | +/usr/bin/make.exe MAKE=/usr/bin/make.exe SHELL=bash.exe DESTDIR=/x11install/glib2 install 2>&1 |tee inst.log |
---|
17 | +#/usr/bin/make.exe MAKE=/usr/bin/make.exe SHELL=bash.exe distclean 2>&1 |tee make.log |
---|
18 | diff -ruN -x configure -x ltmain.sh -x aclocal.m4 -x config.guess -x config.sub -x Makefile.in glib-2.6.5/configure.in glib-2.6.5.os2/configure.in |
---|
19 | --- glib-2.6.5/configure.in Wed May 18 06:12:32 2005 |
---|
20 | +++ glib-2.6.5.os2/configure.in Sun Jul 31 17:14:26 2005 |
---|
21 | @@ -147,17 +147,32 @@ |
---|
22 | glib_pid_type=int |
---|
23 | ;; |
---|
24 | esac |
---|
25 | + |
---|
26 | +AC_MSG_CHECKING([for Linux]) |
---|
27 | case $host in |
---|
28 | *-*-linux*) |
---|
29 | glib_os_linux=yes |
---|
30 | ;; |
---|
31 | + *) |
---|
32 | + glib_os_linux=no |
---|
33 | + ;; |
---|
34 | esac |
---|
35 | |
---|
36 | +AC_MSG_CHECKING([for OS/2]) |
---|
37 | +case $host in |
---|
38 | + *-*-os2*) |
---|
39 | + glib_os_os2=yes |
---|
40 | + ;; |
---|
41 | + *) |
---|
42 | + glib_os_os2=no |
---|
43 | + ;; |
---|
44 | +esac |
---|
45 | |
---|
46 | AC_MSG_RESULT([$glib_native_win32]) |
---|
47 | AM_CONDITIONAL(OS_WIN32, [test "$glib_native_win32" = "yes"]) |
---|
48 | AM_CONDITIONAL(OS_UNIX, [test "$glib_native_win32" != "yes"]) |
---|
49 | AM_CONDITIONAL(OS_LINUX, [test "$glib_os_linux" = "yes"]) |
---|
50 | +AM_CONDITIONAL(OS_OS2, [test "$glib_os_os2" = "yes"]) |
---|
51 | AC_SUBST(G_LIB_WIN32_RESOURCE) |
---|
52 | AC_SUBST(G_MODULE_WIN32_RESOURCE) |
---|
53 | AC_SUBST(G_OBJECT_WIN32_RESOURCE) |
---|
54 | @@ -1235,7 +1250,7 @@ |
---|
55 | hpux9* | hpux10* | hpux11*) # taken from ltconfig |
---|
56 | glib_gmodule_suffix='sl' |
---|
57 | ;; |
---|
58 | - cygwin* | mingw*) |
---|
59 | + cygwin* | mingw* | os2*) |
---|
60 | glib_gmodule_suffix='dll' |
---|
61 | ;; |
---|
62 | aix*) |
---|
63 | @@ -1267,6 +1282,9 @@ |
---|
64 | *-*-mingw*) |
---|
65 | GSPAWN=gspawn-win32.lo |
---|
66 | ;; |
---|
67 | + *-*-os2*) |
---|
68 | + GSPAWN=gspawn-os2.lo |
---|
69 | + ;; |
---|
70 | *) |
---|
71 | GSPAWN=gspawn.lo |
---|
72 | ;; |
---|
73 | @@ -1308,7 +1326,7 @@ |
---|
74 | |
---|
75 | AC_MSG_CHECKING([whether to compile timeloop]) |
---|
76 | case "$host" in |
---|
77 | - *-*-cygwin*|*-*-mingw*) |
---|
78 | + *-*-cygwin* | *-*-mingw* | *-*-os2*) |
---|
79 | enable_timeloop=no |
---|
80 | ;; |
---|
81 | *) |
---|
82 | diff -ruN -x configure -x ltmain.sh -x aclocal.m4 -x config.guess -x config.sub -x Makefile.in glib-2.6.5/glib/gconvert.c glib-2.6.5.os2/glib/gconvert.c |
---|
83 | --- glib-2.6.5/glib/gconvert.c Wed Apr 27 09:08:00 2005 |
---|
84 | +++ glib-2.6.5.os2/glib/gconvert.c Sun Jul 31 17:14:58 2005 |
---|
85 | @@ -1412,7 +1412,7 @@ |
---|
86 | char *escaped_path; |
---|
87 | char *res; |
---|
88 | |
---|
89 | -#ifdef G_OS_WIN32 |
---|
90 | +#if defined G_OS_WIN32 || defined __EMX__ |
---|
91 | char *p, *backslash; |
---|
92 | |
---|
93 | /* Turn backslashes into forward slashes. That's what Netscape |
---|
94 | @@ -1442,7 +1442,7 @@ |
---|
95 | escaped_path, |
---|
96 | NULL); |
---|
97 | |
---|
98 | -#ifdef G_OS_WIN32 |
---|
99 | +#if defined G_OS_WIN32 || defined __EMX__ |
---|
100 | g_free ((char *) pathname); |
---|
101 | #endif |
---|
102 | |
---|
103 | @@ -1675,7 +1675,7 @@ |
---|
104 | } |
---|
105 | |
---|
106 | offs = 0; |
---|
107 | -#ifdef G_OS_WIN32 |
---|
108 | +#if defined G_OS_WIN32 || defined __EMX__ |
---|
109 | /* Drop localhost */ |
---|
110 | if (hostname && *hostname != NULL && |
---|
111 | g_ascii_strcasecmp (*hostname, "localhost") == 0) |
---|
112 | @@ -1684,6 +1684,7 @@ |
---|
113 | *hostname = NULL; |
---|
114 | } |
---|
115 | |
---|
116 | +#ifndef __EMX__ |
---|
117 | /* Turn slashes into backslashes, because that's the canonical spelling */ |
---|
118 | p = filename; |
---|
119 | while ((slash = strchr (p, '/')) != NULL) |
---|
120 | @@ -1691,6 +1692,7 @@ |
---|
121 | *slash = '\\'; |
---|
122 | p = slash + 1; |
---|
123 | } |
---|
124 | +#endif |
---|
125 | |
---|
126 | /* Windows URIs with a drive letter can be like "file://host/c:/foo" |
---|
127 | * or "file://host/c|/foo" (some Netscape versions). In those cases, start |
---|
128 | @@ -1777,7 +1779,7 @@ |
---|
129 | return NULL; |
---|
130 | } |
---|
131 | |
---|
132 | -#ifdef G_OS_WIN32 |
---|
133 | +#if defined G_OS_WIN32 || defined __EMX__ |
---|
134 | /* Don't use localhost unnecessarily */ |
---|
135 | if (hostname && g_ascii_strcasecmp (hostname, "localhost") == 0) |
---|
136 | hostname = NULL; |
---|
137 | diff -ruN -x configure -x ltmain.sh -x aclocal.m4 -x config.guess -x config.sub -x Makefile.in glib-2.6.5/glib/gfileutils.c glib-2.6.5.os2/glib/gfileutils.c |
---|
138 | --- glib-2.6.5/glib/gfileutils.c Mon Mar 14 05:02:06 2005 |
---|
139 | +++ glib-2.6.5.os2/glib/gfileutils.c Sun Jul 31 17:14:58 2005 |
---|
140 | @@ -224,6 +224,9 @@ |
---|
141 | { |
---|
142 | struct stat s; |
---|
143 | |
---|
144 | +#ifdef __EMX__ |
---|
145 | +#define lstat stat |
---|
146 | +#endif |
---|
147 | if ((lstat (filename, &s) == 0) && S_ISLNK (s.st_mode)) |
---|
148 | return TRUE; |
---|
149 | } |
---|
150 | diff -ruN -x configure -x ltmain.sh -x aclocal.m4 -x config.guess -x config.sub -x Makefile.in glib-2.6.5/glib/giounix.c glib-2.6.5.os2/glib/giounix.c |
---|
151 | --- glib-2.6.5/glib/giounix.c Mon Mar 14 05:02:06 2005 |
---|
152 | +++ glib-2.6.5.os2/glib/giounix.c Sun Jul 31 17:14:58 2005 |
---|
153 | @@ -42,6 +42,10 @@ |
---|
154 | #include <errno.h> |
---|
155 | #include <string.h> |
---|
156 | #include <fcntl.h> |
---|
157 | +#ifdef __EMX__ |
---|
158 | +#define INCL_DOSFILEMGR |
---|
159 | +#include <os2.h> |
---|
160 | +#endif |
---|
161 | |
---|
162 | #include "glib.h" |
---|
163 | #include "galias.h" |
---|
164 | @@ -391,6 +395,10 @@ |
---|
165 | GIOFlags flags = 0; |
---|
166 | glong fcntl_flags; |
---|
167 | GIOUnixChannel *unix_channel = (GIOUnixChannel *) channel; |
---|
168 | +#ifdef __EMX__ |
---|
169 | + int rc; |
---|
170 | + ULONG mode; |
---|
171 | +#endif |
---|
172 | |
---|
173 | fcntl_flags = fcntl (unix_channel->fd, F_GETFL); |
---|
174 | |
---|
175 | @@ -410,6 +418,7 @@ |
---|
176 | #endif |
---|
177 | flags |= G_IO_FLAG_NONBLOCK; |
---|
178 | |
---|
179 | +#ifndef __EMX__ |
---|
180 | switch (fcntl_flags & (O_RDONLY | O_WRONLY | O_RDWR)) |
---|
181 | { |
---|
182 | case O_RDONLY: |
---|
183 | @@ -427,6 +436,27 @@ |
---|
184 | default: |
---|
185 | g_assert_not_reached (); |
---|
186 | } |
---|
187 | +#else /* __EMX__ */ |
---|
188 | + /* F_GETFL doesn't return access modes in EMX */ |
---|
189 | + rc = DosQueryFHState(unix_channel->fd, &mode); |
---|
190 | + switch (mode & (OPEN_ACCESS_READONLY | OPEN_ACCESS_WRITEONLY | OPEN_ACCESS_READWRITE)) |
---|
191 | + { |
---|
192 | + case OPEN_ACCESS_READONLY: |
---|
193 | + channel->is_readable = TRUE; |
---|
194 | + channel->is_writeable = FALSE; |
---|
195 | + break; |
---|
196 | + case OPEN_ACCESS_WRITEONLY: |
---|
197 | + channel->is_readable = FALSE; |
---|
198 | + channel->is_writeable = TRUE; |
---|
199 | + break; |
---|
200 | + case OPEN_ACCESS_READWRITE: |
---|
201 | + channel->is_readable = TRUE; |
---|
202 | + channel->is_writeable = TRUE; |
---|
203 | + break; |
---|
204 | + default: |
---|
205 | + g_assert_not_reached (); |
---|
206 | + } |
---|
207 | +#endif /* __EMX__ */ |
---|
208 | |
---|
209 | return flags; |
---|
210 | } |
---|
211 | @@ -528,6 +558,10 @@ |
---|
212 | } |
---|
213 | |
---|
214 | channel = (GIOChannel *) g_new (GIOUnixChannel, 1); |
---|
215 | + |
---|
216 | +#ifdef __EMX__ |
---|
217 | +#define S_ISBLK(dummy) 0 |
---|
218 | +#endif |
---|
219 | |
---|
220 | channel->is_seekable = S_ISREG (buffer.st_mode) || S_ISCHR (buffer.st_mode) |
---|
221 | || S_ISBLK (buffer.st_mode); |
---|
222 | diff -ruN -x configure -x ltmain.sh -x aclocal.m4 -x config.guess -x config.sub -x Makefile.in glib-2.6.5/glib/glib-2.0.os2name glib-2.6.5.os2/glib/glib-2.0.os2name |
---|
223 | --- glib-2.6.5/glib/glib-2.0.os2name Thu Jan 1 00:00:00 1970 |
---|
224 | +++ glib-2.6.5.os2/glib/glib-2.0.os2name Sun Jul 31 17:14:58 2005 |
---|
225 | @@ -0,0 +1 @@ |
---|
226 | +glib2 |
---|
227 | diff -ruN -x configure -x ltmain.sh -x aclocal.m4 -x config.guess -x config.sub -x Makefile.in glib-2.6.5/glib/gmain.c glib-2.6.5.os2/glib/gmain.c |
---|
228 | --- glib-2.6.5/glib/gmain.c Fri Apr 1 23:41:12 2005 |
---|
229 | +++ glib-2.6.5.os2/glib/gmain.c Sun Jul 31 17:14:58 2005 |
---|
230 | @@ -3552,6 +3552,11 @@ |
---|
231 | */ |
---|
232 | } |
---|
233 | } |
---|
234 | + |
---|
235 | +#ifdef __EMX__ |
---|
236 | +/* doesn't have a meaning in EMX */ |
---|
237 | +#define SA_RESTART 0x10000000 |
---|
238 | +#endif |
---|
239 | |
---|
240 | static void |
---|
241 | g_child_watch_source_init_single (void) |
---|
242 | diff -ruN -x configure -x ltmain.sh -x aclocal.m4 -x config.guess -x config.sub -x Makefile.in glib-2.6.5/glib/gspawn-os2.c glib-2.6.5.os2/glib/gspawn-os2.c |
---|
243 | --- glib-2.6.5/glib/gspawn-os2.c Thu Jan 1 00:00:00 1970 |
---|
244 | +++ glib-2.6.5.os2/glib/gspawn-os2.c Sun Jul 31 17:14:58 2005 |
---|
245 | @@ -0,0 +1,1230 @@ |
---|
246 | +/* Copied and modified from: |
---|
247 | + * |
---|
248 | + * gspawn.c - Process launching |
---|
249 | + * |
---|
250 | + * Copyright 2000 Red Hat, Inc. |
---|
251 | + * g_execvpe implementation based on GNU libc execvp: |
---|
252 | + * Copyright 1991, 92, 95, 96, 97, 98, 99 Free Software Foundation, Inc. |
---|
253 | + * |
---|
254 | + * GLib is free software; you can redistribute it and/or |
---|
255 | + * modify it under the terms of the GNU Lesser General Public License as |
---|
256 | + * published by the Free Software Foundation; either version 2 of the |
---|
257 | + * License, or (at your option) any later version. |
---|
258 | + * |
---|
259 | + * GLib is distributed in the hope that it will be useful, |
---|
260 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
261 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
262 | + * Lesser General Public License for more details. |
---|
263 | + * |
---|
264 | + * You should have received a copy of the GNU Lesser General Public |
---|
265 | + * License along with GLib; see the file COPYING.LIB. If not, write |
---|
266 | + * to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
---|
267 | + * Boston, MA 02111-1307, USA. |
---|
268 | + */ |
---|
269 | + |
---|
270 | +#include "config.h" |
---|
271 | + |
---|
272 | +#include <sys/time.h> |
---|
273 | +#include <sys/types.h> |
---|
274 | +#include <sys/wait.h> |
---|
275 | +#include <unistd.h> |
---|
276 | +#include <errno.h> |
---|
277 | +#include <fcntl.h> |
---|
278 | +#include <signal.h> |
---|
279 | +#include <string.h> |
---|
280 | + |
---|
281 | +#ifdef HAVE_SYS_SELECT_H |
---|
282 | +#include <sys/select.h> |
---|
283 | +#endif /* HAVE_SYS_SELECT_H */ |
---|
284 | + |
---|
285 | +#include <stdlib.h> |
---|
286 | +#include <process.h> |
---|
287 | + |
---|
288 | +#include "glib.h" |
---|
289 | +#include "galias.h" |
---|
290 | + |
---|
291 | +#include "glibintl.h" |
---|
292 | + |
---|
293 | +static gint g_execute (const gchar *file, |
---|
294 | + gchar **argv, |
---|
295 | + gchar **envp, |
---|
296 | + gboolean search_path); |
---|
297 | + |
---|
298 | +static gboolean make_pipe (gint p[2], |
---|
299 | + GError **error); |
---|
300 | +static gboolean fork_exec_with_pipes (gboolean intermediate_child, |
---|
301 | + const gchar *working_directory, |
---|
302 | + gchar **argv, |
---|
303 | + gchar **envp, |
---|
304 | + gboolean close_descriptors, |
---|
305 | + gboolean search_path, |
---|
306 | + gboolean stdout_to_null, |
---|
307 | + gboolean stderr_to_null, |
---|
308 | + gboolean child_inherits_stdin, |
---|
309 | + gboolean file_and_argv_zero, |
---|
310 | + GSpawnChildSetupFunc child_setup, |
---|
311 | + gpointer user_data, |
---|
312 | + GPid *child_pid, |
---|
313 | + gint *standard_input, |
---|
314 | + gint *standard_output, |
---|
315 | + gint *standard_error, |
---|
316 | + GError **error); |
---|
317 | + |
---|
318 | +GQuark |
---|
319 | +g_spawn_error_quark (void) |
---|
320 | +{ |
---|
321 | + static GQuark quark = 0; |
---|
322 | + if (quark == 0) |
---|
323 | + quark = g_quark_from_static_string ("g-exec-error-quark"); |
---|
324 | + return quark; |
---|
325 | +} |
---|
326 | + |
---|
327 | +/** |
---|
328 | + * g_spawn_async: |
---|
329 | + * @working_directory: child's current working directory, or %NULL to inherit parent's |
---|
330 | + * @argv: child's argument vector |
---|
331 | + * @envp: child's environment, or %NULL to inherit parent's |
---|
332 | + * @flags: flags from #GSpawnFlags |
---|
333 | + * @child_setup: function to run in the child just before exec() |
---|
334 | + * @user_data: user data for @child_setup |
---|
335 | + * @child_pid: return location for child process ID, or %NULL |
---|
336 | + * @error: return location for error |
---|
337 | + * |
---|
338 | + * See g_spawn_async_with_pipes() for a full description; this function |
---|
339 | + * simply calls the g_spawn_async_with_pipes() without any pipes. |
---|
340 | + * |
---|
341 | + * Return value: %TRUE on success, %FALSE if error is set |
---|
342 | + **/ |
---|
343 | +gboolean |
---|
344 | +g_spawn_async (const gchar *working_directory, |
---|
345 | + gchar **argv, |
---|
346 | + gchar **envp, |
---|
347 | + GSpawnFlags flags, |
---|
348 | + GSpawnChildSetupFunc child_setup, |
---|
349 | + gpointer user_data, |
---|
350 | + GPid *child_pid, |
---|
351 | + GError **error) |
---|
352 | +{ |
---|
353 | + g_return_val_if_fail (argv != NULL, FALSE); |
---|
354 | + |
---|
355 | + return g_spawn_async_with_pipes (working_directory, |
---|
356 | + argv, envp, |
---|
357 | + flags, |
---|
358 | + child_setup, |
---|
359 | + user_data, |
---|
360 | + child_pid, |
---|
361 | + NULL, NULL, NULL, |
---|
362 | + error); |
---|
363 | +} |
---|
364 | + |
---|
365 | +/* Avoids a danger in threaded situations (calling close() |
---|
366 | + * on a file descriptor twice, and another thread has |
---|
367 | + * re-opened it since the first close) |
---|
368 | + */ |
---|
369 | +static gint |
---|
370 | +close_and_invalidate (gint *fd) |
---|
371 | +{ |
---|
372 | + gint ret; |
---|
373 | + |
---|
374 | + if (*fd < 0) |
---|
375 | + return -1; |
---|
376 | + else |
---|
377 | + { |
---|
378 | + ret = close (*fd); |
---|
379 | + *fd = -1; |
---|
380 | + } |
---|
381 | + |
---|
382 | + return ret; |
---|
383 | +} |
---|
384 | + |
---|
385 | +typedef enum |
---|
386 | +{ |
---|
387 | + READ_FAILED = 0, /* FALSE */ |
---|
388 | + READ_OK, |
---|
389 | + READ_EOF |
---|
390 | +} ReadResult; |
---|
391 | + |
---|
392 | +static ReadResult |
---|
393 | +read_data (GString *str, |
---|
394 | + gint fd, |
---|
395 | + GError **error) |
---|
396 | +{ |
---|
397 | + gssize bytes; |
---|
398 | + gchar buf[4096]; |
---|
399 | + |
---|
400 | + again: |
---|
401 | + |
---|
402 | + bytes = read (fd, buf, 4096); |
---|
403 | + |
---|
404 | + if (bytes == 0) |
---|
405 | + return READ_EOF; |
---|
406 | + else if (bytes > 0) |
---|
407 | + { |
---|
408 | + g_string_append_len (str, buf, bytes); |
---|
409 | + return READ_OK; |
---|
410 | + } |
---|
411 | + else if (bytes < 0 && errno == EINTR) |
---|
412 | + goto again; |
---|
413 | + else if (bytes < 0) |
---|
414 | + { |
---|
415 | + g_set_error (error, |
---|
416 | + G_SPAWN_ERROR, |
---|
417 | + G_SPAWN_ERROR_READ, |
---|
418 | + _("Failed to read data from child process (%s)"), |
---|
419 | + g_strerror (errno)); |
---|
420 | + |
---|
421 | + return READ_FAILED; |
---|
422 | + } |
---|
423 | + else |
---|
424 | + return READ_OK; |
---|
425 | +} |
---|
426 | + |
---|
427 | +/** |
---|
428 | + * g_spawn_sync: |
---|
429 | + * @working_directory: child's current working directory, or %NULL to inherit parent's |
---|
430 | + * @argv: child's argument vector |
---|
431 | + * @envp: child's environment, or %NULL to inherit parent's |
---|
432 | + * @flags: flags from #GSpawnFlags |
---|
433 | + * @child_setup: function to run in the child just before exec() |
---|
434 | + * @user_data: user data for @child_setup |
---|
435 | + * @standard_output: return location for child output |
---|
436 | + * @standard_error: return location for child error messages |
---|
437 | + * @exit_status: child exit status, as returned by waitpid() |
---|
438 | + * @error: return location for error |
---|
439 | + * |
---|
440 | + * Executes a child synchronously (waits for the child to exit before returning). |
---|
441 | + * All output from the child is stored in @standard_output and @standard_error, |
---|
442 | + * if those parameters are non-%NULL. If @exit_status is non-%NULL, the exit |
---|
443 | + * status of the child is stored there as it would be returned by |
---|
444 | + * waitpid(); standard UNIX macros such as WIFEXITED() and WEXITSTATUS() |
---|
445 | + * must be used to evaluate the exit status. If an error occurs, no data is |
---|
446 | + * returned in @standard_output, @standard_error, or @exit_status. |
---|
447 | + * |
---|
448 | + * This function calls g_spawn_async_with_pipes() internally; see that function |
---|
449 | + * for full details on the other parameters. |
---|
450 | + * |
---|
451 | + * Return value: %TRUE on success, %FALSE if an error was set. |
---|
452 | + **/ |
---|
453 | +gboolean |
---|
454 | +g_spawn_sync (const gchar *working_directory, |
---|
455 | + gchar **argv, |
---|
456 | + gchar **envp, |
---|
457 | + GSpawnFlags flags, |
---|
458 | + GSpawnChildSetupFunc child_setup, |
---|
459 | + gpointer user_data, |
---|
460 | + gchar **standard_output, |
---|
461 | + gchar **standard_error, |
---|
462 | + gint *exit_status, |
---|
463 | + GError **error) |
---|
464 | +{ |
---|
465 | + gint outpipe = -1; |
---|
466 | + gint errpipe = -1; |
---|
467 | + GPid pid; |
---|
468 | + fd_set fds; |
---|
469 | + gint ret; |
---|
470 | + GString *outstr = NULL; |
---|
471 | + GString *errstr = NULL; |
---|
472 | + gboolean failed; |
---|
473 | + gint status; |
---|
474 | + |
---|
475 | + g_return_val_if_fail (argv != NULL, FALSE); |
---|
476 | + g_return_val_if_fail (!(flags & G_SPAWN_DO_NOT_REAP_CHILD), FALSE); |
---|
477 | + g_return_val_if_fail (standard_output == NULL || |
---|
478 | + !(flags & G_SPAWN_STDOUT_TO_DEV_NULL), FALSE); |
---|
479 | + g_return_val_if_fail (standard_error == NULL || |
---|
480 | + !(flags & G_SPAWN_STDERR_TO_DEV_NULL), FALSE); |
---|
481 | + |
---|
482 | + /* Just to ensure segfaults if callers try to use |
---|
483 | + * these when an error is reported. |
---|
484 | + */ |
---|
485 | + if (standard_output) |
---|
486 | + *standard_output = NULL; |
---|
487 | + |
---|
488 | + if (standard_error) |
---|
489 | + *standard_error = NULL; |
---|
490 | + |
---|
491 | + if (!fork_exec_with_pipes (FALSE, |
---|
492 | + working_directory, |
---|
493 | + argv, |
---|
494 | + envp, |
---|
495 | + !(flags & G_SPAWN_LEAVE_DESCRIPTORS_OPEN), |
---|
496 | + (flags & G_SPAWN_SEARCH_PATH) != 0, |
---|
497 | + (flags & G_SPAWN_STDOUT_TO_DEV_NULL) != 0, |
---|
498 | + (flags & G_SPAWN_STDERR_TO_DEV_NULL) != 0, |
---|
499 | + (flags & G_SPAWN_CHILD_INHERITS_STDIN) != 0, |
---|
500 | + (flags & G_SPAWN_FILE_AND_ARGV_ZERO) != 0, |
---|
501 | + child_setup, |
---|
502 | + user_data, |
---|
503 | + &pid, |
---|
504 | + NULL, |
---|
505 | + standard_output ? &outpipe : NULL, |
---|
506 | + standard_error ? &errpipe : NULL, |
---|
507 | + error)) |
---|
508 | + return FALSE; |
---|
509 | + |
---|
510 | + /* Read data from child. */ |
---|
511 | + |
---|
512 | + failed = FALSE; |
---|
513 | + |
---|
514 | + if (outpipe >= 0) |
---|
515 | + { |
---|
516 | + outstr = g_string_new (NULL); |
---|
517 | + } |
---|
518 | + |
---|
519 | + if (errpipe >= 0) |
---|
520 | + { |
---|
521 | + errstr = g_string_new (NULL); |
---|
522 | + } |
---|
523 | + |
---|
524 | + /* Read data until we get EOF on both pipes. */ |
---|
525 | + while (!failed && |
---|
526 | + (outpipe >= 0 || |
---|
527 | + errpipe >= 0)) |
---|
528 | + { |
---|
529 | + ret = 0; |
---|
530 | + |
---|
531 | + FD_ZERO (&fds); |
---|
532 | + if (outpipe >= 0) |
---|
533 | + FD_SET (outpipe, &fds); |
---|
534 | + if (errpipe >= 0) |
---|
535 | + FD_SET (errpipe, &fds); |
---|
536 | + |
---|
537 | + ret = select (MAX (outpipe, errpipe) + 1, |
---|
538 | + &fds, |
---|
539 | + NULL, NULL, |
---|
540 | + NULL /* no timeout */); |
---|
541 | + |
---|
542 | + if (ret < 0 && errno != EINTR) |
---|
543 | + { |
---|
544 | + failed = TRUE; |
---|
545 | + |
---|
546 | + g_set_error (error, |
---|
547 | + G_SPAWN_ERROR, |
---|
548 | + G_SPAWN_ERROR_READ, |
---|
549 | + _("Unexpected error in select() reading data from a child process (%s)"), |
---|
550 | + g_strerror (errno)); |
---|
551 | + |
---|
552 | + break; |
---|
553 | + } |
---|
554 | + |
---|
555 | + if (outpipe >= 0 && FD_ISSET (outpipe, &fds)) |
---|
556 | + { |
---|
557 | + switch (read_data (outstr, outpipe, error)) |
---|
558 | + { |
---|
559 | + case READ_FAILED: |
---|
560 | + failed = TRUE; |
---|
561 | + break; |
---|
562 | + case READ_EOF: |
---|
563 | + close_and_invalidate (&outpipe); |
---|
564 | + outpipe = -1; |
---|
565 | + break; |
---|
566 | + default: |
---|
567 | + break; |
---|
568 | + } |
---|
569 | + |
---|
570 | + if (failed) |
---|
571 | + break; |
---|
572 | + } |
---|
573 | + |
---|
574 | + if (errpipe >= 0 && FD_ISSET (errpipe, &fds)) |
---|
575 | + { |
---|
576 | + switch (read_data (errstr, errpipe, error)) |
---|
577 | + { |
---|
578 | + case READ_FAILED: |
---|
579 | + failed = TRUE; |
---|
580 | + break; |
---|
581 | + case READ_EOF: |
---|
582 | + close_and_invalidate (&errpipe); |
---|
583 | + errpipe = -1; |
---|
584 | + break; |
---|
585 | + default: |
---|
586 | + break; |
---|
587 | + } |
---|
588 | + |
---|
589 | + if (failed) |
---|
590 | + break; |
---|
591 | + } |
---|
592 | + } |
---|
593 | + |
---|
594 | + /* These should only be open still if we had an error. */ |
---|
595 | + |
---|
596 | + if (outpipe >= 0) |
---|
597 | + close_and_invalidate (&outpipe); |
---|
598 | + if (errpipe >= 0) |
---|
599 | + close_and_invalidate (&errpipe); |
---|
600 | + |
---|
601 | + /* Wait for child to exit, even if we have |
---|
602 | + * an error pending. |
---|
603 | + */ |
---|
604 | + again: |
---|
605 | + |
---|
606 | + ret = waitpid (pid, &status, 0); |
---|
607 | + |
---|
608 | + if (ret < 0) |
---|
609 | + { |
---|
610 | + if (errno == EINTR) |
---|
611 | + goto again; |
---|
612 | + else if (errno == ECHILD) |
---|
613 | + { |
---|
614 | + if (exit_status) |
---|
615 | + { |
---|
616 | + g_warning ("In call to g_spawn_sync(), exit status of a child process was requested but SIGCHLD action was set to SIG_IGN and ECHILD was received by waitpid(), so exit status can't be returned. This is a bug in the program calling g_spawn_sync(); either don't request the exit status, or don't set the SIGCHLD action."); |
---|
617 | + } |
---|
618 | + else |
---|
619 | + { |
---|
620 | + /* We don't need the exit status. */ |
---|
621 | + } |
---|
622 | + } |
---|
623 | + else |
---|
624 | + { |
---|
625 | + if (!failed) /* avoid error pileups */ |
---|
626 | + { |
---|
627 | + failed = TRUE; |
---|
628 | + |
---|
629 | + g_set_error (error, |
---|
630 | + G_SPAWN_ERROR, |
---|
631 | + G_SPAWN_ERROR_READ, |
---|
632 | + _("Unexpected error in waitpid() (%s)"), |
---|
633 | + g_strerror (errno)); |
---|
634 | + } |
---|
635 | + } |
---|
636 | + } |
---|
637 | + |
---|
638 | + if (failed) |
---|
639 | + { |
---|
640 | + if (outstr) |
---|
641 | + g_string_free (outstr, TRUE); |
---|
642 | + if (errstr) |
---|
643 | + g_string_free (errstr, TRUE); |
---|
644 | + |
---|
645 | + return FALSE; |
---|
646 | + } |
---|
647 | + else |
---|
648 | + { |
---|
649 | + if (exit_status) |
---|
650 | + *exit_status = status; |
---|
651 | + |
---|
652 | + if (standard_output) |
---|
653 | + *standard_output = g_string_free (outstr, FALSE); |
---|
654 | + |
---|
655 | + if (standard_error) |
---|
656 | + *standard_error = g_string_free (errstr, FALSE); |
---|
657 | + |
---|
658 | + return TRUE; |
---|
659 | + } |
---|
660 | +} |
---|
661 | + |
---|
662 | +/** |
---|
663 | + * g_spawn_async_with_pipes: |
---|
664 | + * @working_directory: child's current working directory, or %NULL to inherit parent's |
---|
665 | + * @argv: child's argument vector |
---|
666 | + * @envp: child's environment, or %NULL to inherit parent's |
---|
667 | + * @flags: flags from #GSpawnFlags |
---|
668 | + * @child_setup: function to run in the child just before exec() |
---|
669 | + * @user_data: user data for @child_setup |
---|
670 | + * @child_pid: return location for child process ID, or %NULL |
---|
671 | + * @standard_input: return location for file descriptor to write to child's stdin, or %NULL |
---|
672 | + * @standard_output: return location for file descriptor to read child's stdout, or %NULL |
---|
673 | + * @standard_error: return location for file descriptor to read child's stderr, or %NULL |
---|
674 | + * @error: return location for error |
---|
675 | + * |
---|
676 | + * Executes a child program asynchronously (your program will not |
---|
677 | + * block waiting for the child to exit). The child program is |
---|
678 | + * specified by the only argument that must be provided, @argv. @argv |
---|
679 | + * should be a %NULL-terminated array of strings, to be passed as the |
---|
680 | + * argument vector for the child. The first string in @argv is of |
---|
681 | + * course the name of the program to execute. By default, the name of |
---|
682 | + * the program must be a full path; the <envar>PATH</envar> shell variable |
---|
683 | + * will only be searched if you pass the %G_SPAWN_SEARCH_PATH flag. |
---|
684 | + * |
---|
685 | + * On Windows, the low-level child process creation API |
---|
686 | + * (CreateProcess())doesn't use argument vectors, |
---|
687 | + * but a command line. The C runtime library's |
---|
688 | + * <function>spawn*()</function> family of functions (which |
---|
689 | + * g_spawn_async_with_pipes() eventually calls) paste the argument |
---|
690 | + * vector elements into a command line, and the C runtime startup code |
---|
691 | + * does a corresponding reconstruction of an argument vector from the |
---|
692 | + * command line, to be passed to main(). Complications arise when you have |
---|
693 | + * argument vector elements that contain spaces of double quotes. The |
---|
694 | + * <function>spawn*()</function> functions don't do any quoting or |
---|
695 | + * escaping, but on the other hand the startup code does do unquoting |
---|
696 | + * and unescaping in order to enable receiving arguments with embedded |
---|
697 | + * spaces or double quotes. To work around this asymmetry, |
---|
698 | + * g_spawn_async_with_pipes() will do quoting and escaping on argument |
---|
699 | + * vector elements that need it before calling the C runtime |
---|
700 | + * spawn() function. |
---|
701 | + * |
---|
702 | + * @envp is a %NULL-terminated array of strings, where each string |
---|
703 | + * has the form <literal>KEY=VALUE</literal>. This will become |
---|
704 | + * the child's environment. If @envp is %NULL, the child inherits its |
---|
705 | + * parent's environment. |
---|
706 | + * |
---|
707 | + * @flags should be the bitwise OR of any flags you want to affect the |
---|
708 | + * function's behaviour. The %G_SPAWN_DO_NOT_REAP_CHILD means that |
---|
709 | + * the child will not automatically be reaped; you must use a |
---|
710 | + * #GChildWatch source to be notified about the death of the child |
---|
711 | + * process. Eventually you must call g_spawn_close_pid() on the |
---|
712 | + * @child_pid, in order to free resources which may be associated |
---|
713 | + * with the child process. (On Unix, using a #GChildWatch source is |
---|
714 | + * equivalent to calling waitpid() or handling the %SIGCHLD signal |
---|
715 | + * manually. On Windows, calling g_spawn_close_pid() is equivalent |
---|
716 | + * to calling CloseHandle() on the process handle returned in |
---|
717 | + * @child_pid). |
---|
718 | + * |
---|
719 | + * %G_SPAWN_LEAVE_DESCRIPTORS_OPEN means that the parent's open file |
---|
720 | + * descriptors will be inherited by the child; otherwise all |
---|
721 | + * descriptors except stdin/stdout/stderr will be closed before |
---|
722 | + * calling exec() in the child. %G_SPAWN_SEARCH_PATH |
---|
723 | + * means that <literal>argv[0]</literal> need not be an absolute path, it |
---|
724 | + * will be looked for in the user's <envar>PATH</envar>. |
---|
725 | + * %G_SPAWN_STDOUT_TO_DEV_NULL means that the child's standard output will |
---|
726 | + * be discarded, instead of going to the same location as the parent's |
---|
727 | + * standard output. If you use this flag, @standard_output must be %NULL. |
---|
728 | + * %G_SPAWN_STDERR_TO_DEV_NULL means that the child's standard error |
---|
729 | + * will be discarded, instead of going to the same location as the parent's |
---|
730 | + * standard error. If you use this flag, @standard_error must be %NULL. |
---|
731 | + * %G_SPAWN_CHILD_INHERITS_STDIN means that the child will inherit the parent's |
---|
732 | + * standard input (by default, the child's standard input is attached to |
---|
733 | + * /dev/null). If you use this flag, @standard_input must be %NULL. |
---|
734 | + * %G_SPAWN_FILE_AND_ARGV_ZERO means that the first element of @argv is |
---|
735 | + * the file to execute, while the remaining elements are the |
---|
736 | + * actual argument vector to pass to the file. Normally |
---|
737 | + * g_spawn_async_with_pipes() uses @argv[0] as the file to execute, and |
---|
738 | + * passes all of @argv to the child. |
---|
739 | + * |
---|
740 | + * @child_setup and @user_data are a function and user data. On POSIX |
---|
741 | + * platforms, the function is called in the child after GLib has |
---|
742 | + * performed all the setup it plans to perform (including creating |
---|
743 | + * pipes, closing file descriptors, etc.) but before calling |
---|
744 | + * exec(). That is, @child_setup is called just |
---|
745 | + * before calling exec() in the child. Obviously |
---|
746 | + * actions taken in this function will only affect the child, not the |
---|
747 | + * parent. On Windows, there is no separate fork() and exec() |
---|
748 | + * functionality. Child processes are created and run right away with |
---|
749 | + * one API call, CreateProcess(). @child_setup is |
---|
750 | + * called in the parent process just before creating the child |
---|
751 | + * process. You should carefully consider what you do in @child_setup |
---|
752 | + * if you intend your software to be portable to Windows. |
---|
753 | + * |
---|
754 | + * If non-%NULL, @child_pid will on Unix be filled with the child's |
---|
755 | + * process ID. You can use the process ID to send signals to the |
---|
756 | + * child, or to waitpid() if you specified the |
---|
757 | + * %G_SPAWN_DO_NOT_REAP_CHILD flag. On Windows, @child_pid will be |
---|
758 | + * filled with a handle to the child process only if you specified the |
---|
759 | + * %G_SPAWN_DO_NOT_REAP_CHILD flag. You can then access the child |
---|
760 | + * process using the Win32 API, for example wait for its termination |
---|
761 | + * with the <function>WaitFor*()</function> functions, or examine its |
---|
762 | + * exit code with GetExitCodeProcess(). You should close the handle |
---|
763 | + * with CloseHandle() when you no longer need it. |
---|
764 | + * |
---|
765 | + * If non-%NULL, the @standard_input, @standard_output, @standard_error |
---|
766 | + * locations will be filled with file descriptors for writing to the child's |
---|
767 | + * standard input or reading from its standard output or standard error. |
---|
768 | + * The caller of g_spawn_async_with_pipes() must close these file descriptors |
---|
769 | + * when they are no longer in use. If these parameters are %NULL, the corresponding |
---|
770 | + * pipe won't be created. |
---|
771 | + * |
---|
772 | + * If @standard_input is NULL, the child's standard input is attached to /dev/null |
---|
773 | + * unless %G_SPAWN_CHILD_INHERITS_STDIN is set. |
---|
774 | + * |
---|
775 | + * If @standard_error is NULL, the child's standard error goes to the same location |
---|
776 | + * as the parent's standard error unless %G_SPAWN_STDERR_TO_DEV_NULL is set. |
---|
777 | + * |
---|
778 | + * If @standard_output is NULL, the child's standard output goes to the same location |
---|
779 | + * as the parent's standard output unless %G_SPAWN_STDOUT_TO_DEV_NULL is set. |
---|
780 | + * |
---|
781 | + * @error can be %NULL to ignore errors, or non-%NULL to report errors. |
---|
782 | + * If an error is set, the function returns %FALSE. Errors |
---|
783 | + * are reported even if they occur in the child (for example if the |
---|
784 | + * executable in <literal>argv[0]</literal> is not found). Typically |
---|
785 | + * the <literal>message</literal> field of returned errors should be displayed |
---|
786 | + * to users. Possible errors are those from the #G_SPAWN_ERROR domain. |
---|
787 | + * |
---|
788 | + * If an error occurs, @child_pid, @standard_input, @standard_output, |
---|
789 | + * and @standard_error will not be filled with valid values. |
---|
790 | + * |
---|
791 | + * If @child_pid is not %NULL and an error does not occur then the returned |
---|
792 | + * pid must be closed using g_spawn_close_pid(). |
---|
793 | + * |
---|
794 | + * Return value: %TRUE on success, %FALSE if an error was set |
---|
795 | + **/ |
---|
796 | + |
---|
797 | +static void |
---|
798 | +Waitpid (GPid *pid) |
---|
799 | +{ |
---|
800 | + int stat_loc; |
---|
801 | + |
---|
802 | + waitpid (*pid, &stat_loc, 0); |
---|
803 | + /* Discard everything |
---|
804 | + */ |
---|
805 | +} |
---|
806 | + |
---|
807 | +gboolean |
---|
808 | +g_spawn_async_with_pipes (const gchar *working_directory, |
---|
809 | + gchar **argv, |
---|
810 | + gchar **envp, |
---|
811 | + GSpawnFlags flags, |
---|
812 | + GSpawnChildSetupFunc child_setup, |
---|
813 | + gpointer user_data, |
---|
814 | + GPid *child_pid, |
---|
815 | + gint *standard_input, |
---|
816 | + gint *standard_output, |
---|
817 | + gint *standard_error, |
---|
818 | + GError **error) |
---|
819 | +{ |
---|
820 | + gboolean result; |
---|
821 | + int tid; |
---|
822 | + |
---|
823 | + g_return_val_if_fail (argv != NULL, FALSE); |
---|
824 | + g_return_val_if_fail (standard_output == NULL || |
---|
825 | + !(flags & G_SPAWN_STDOUT_TO_DEV_NULL), FALSE); |
---|
826 | + g_return_val_if_fail (standard_error == NULL || |
---|
827 | + !(flags & G_SPAWN_STDERR_TO_DEV_NULL), FALSE); |
---|
828 | + /* can't inherit stdin if we have an input pipe. */ |
---|
829 | + g_return_val_if_fail (standard_input == NULL || |
---|
830 | + !(flags & G_SPAWN_CHILD_INHERITS_STDIN), FALSE); |
---|
831 | + |
---|
832 | + result = fork_exec_with_pipes (!(flags & G_SPAWN_DO_NOT_REAP_CHILD), |
---|
833 | + working_directory, |
---|
834 | + argv, |
---|
835 | + envp, |
---|
836 | + !(flags & G_SPAWN_LEAVE_DESCRIPTORS_OPEN), |
---|
837 | + (flags & G_SPAWN_SEARCH_PATH) != 0, |
---|
838 | + (flags & G_SPAWN_STDOUT_TO_DEV_NULL) != 0, |
---|
839 | + (flags & G_SPAWN_STDERR_TO_DEV_NULL) != 0, |
---|
840 | + (flags & G_SPAWN_CHILD_INHERITS_STDIN) != 0, |
---|
841 | + (flags & G_SPAWN_FILE_AND_ARGV_ZERO) != 0, |
---|
842 | + child_setup, |
---|
843 | + user_data, |
---|
844 | + child_pid, |
---|
845 | + standard_input, |
---|
846 | + standard_output, |
---|
847 | + standard_error, |
---|
848 | + error); |
---|
849 | + /* start a thread with waitpid() so the return code does not fill up memory |
---|
850 | + */ |
---|
851 | + tid = _beginthread (Waitpid, NULL, 0x2000, (void *) child_pid); |
---|
852 | + |
---|
853 | + return result; |
---|
854 | +} |
---|
855 | + |
---|
856 | +/** |
---|
857 | + * g_spawn_command_line_sync: |
---|
858 | + * @command_line: a command line |
---|
859 | + * @standard_output: return location for child output |
---|
860 | + * @standard_error: return location for child errors |
---|
861 | + * @exit_status: return location for child exit status |
---|
862 | + * @error: return location for errors |
---|
863 | + * |
---|
864 | + * A simple version of g_spawn_sync() with little-used parameters |
---|
865 | + * removed, taking a command line instead of an argument vector. See |
---|
866 | + * g_spawn_sync() for full details. @command_line will be parsed by |
---|
867 | + * g_shell_parse_argv(). Unlike g_spawn_sync(), the %G_SPAWN_SEARCH_PATH flag |
---|
868 | + * is enabled. Note that %G_SPAWN_SEARCH_PATH can have security |
---|
869 | + * implications, so consider using g_spawn_sync() directly if |
---|
870 | + * appropriate. Possible errors are those from g_spawn_sync() and those |
---|
871 | + * from g_shell_parse_argv(). |
---|
872 | + * |
---|
873 | + * On Windows, please note the implications of g_shell_parse_argv() |
---|
874 | + * parsing @command_line. Space is a separator, and backslashes are |
---|
875 | + * special. Thus you cannot simply pass a @command_line containing |
---|
876 | + * canonical Windows paths, like "c:\\program files\\app\\app.exe", as |
---|
877 | + * the backslashes will be eaten, and the space will act as a |
---|
878 | + * separator. You need to enclose such paths with single quotes, like |
---|
879 | + * "'c:\\program files\\app\\app.exe' 'e:\\folder\\argument.txt'". |
---|
880 | + * |
---|
881 | + * Return value: %TRUE on success, %FALSE if an error was set |
---|
882 | + **/ |
---|
883 | +gboolean |
---|
884 | +g_spawn_command_line_sync (const gchar *command_line, |
---|
885 | + gchar **standard_output, |
---|
886 | + gchar **standard_error, |
---|
887 | + gint *exit_status, |
---|
888 | + GError **error) |
---|
889 | +{ |
---|
890 | + gboolean retval; |
---|
891 | + gchar **argv = NULL; |
---|
892 | + |
---|
893 | + g_return_val_if_fail (command_line != NULL, FALSE); |
---|
894 | + |
---|
895 | + if (!g_shell_parse_argv (command_line, |
---|
896 | + NULL, &argv, |
---|
897 | + error)) |
---|
898 | + return FALSE; |
---|
899 | + |
---|
900 | + retval = g_spawn_sync (NULL, |
---|
901 | + argv, |
---|
902 | + NULL, |
---|
903 | + G_SPAWN_SEARCH_PATH, |
---|
904 | + NULL, |
---|
905 | + NULL, |
---|
906 | + standard_output, |
---|
907 | + standard_error, |
---|
908 | + exit_status, |
---|
909 | + error); |
---|
910 | + g_strfreev (argv); |
---|
911 | + |
---|
912 | + return retval; |
---|
913 | +} |
---|
914 | + |
---|
915 | +/** |
---|
916 | + * g_spawn_command_line_async: |
---|
917 | + * @command_line: a command line |
---|
918 | + * @error: return location for errors |
---|
919 | + * |
---|
920 | + * A simple version of g_spawn_async() that parses a command line with |
---|
921 | + * g_shell_parse_argv() and passes it to g_spawn_async(). Runs a |
---|
922 | + * command line in the background. Unlike g_spawn_async(), the |
---|
923 | + * %G_SPAWN_SEARCH_PATH flag is enabled, other flags are not. Note |
---|
924 | + * that %G_SPAWN_SEARCH_PATH can have security implications, so |
---|
925 | + * consider using g_spawn_async() directly if appropriate. Possible |
---|
926 | + * errors are those from g_shell_parse_argv() and g_spawn_async(). |
---|
927 | + * |
---|
928 | + * The same concerns on Windows apply as for g_spawn_command_line_sync(). |
---|
929 | + * |
---|
930 | + * Return value: %TRUE on success, %FALSE if error is set. |
---|
931 | + **/ |
---|
932 | +gboolean |
---|
933 | +g_spawn_command_line_async (const gchar *command_line, |
---|
934 | + GError **error) |
---|
935 | +{ |
---|
936 | + gboolean retval; |
---|
937 | + gchar **argv = NULL; |
---|
938 | + |
---|
939 | + g_return_val_if_fail (command_line != NULL, FALSE); |
---|
940 | + |
---|
941 | + if (!g_shell_parse_argv (command_line, |
---|
942 | + NULL, &argv, |
---|
943 | + error)) |
---|
944 | + return FALSE; |
---|
945 | + |
---|
946 | + retval = g_spawn_async (NULL, |
---|
947 | + argv, |
---|
948 | + NULL, |
---|
949 | + G_SPAWN_SEARCH_PATH, |
---|
950 | + NULL, |
---|
951 | + NULL, |
---|
952 | + NULL, |
---|
953 | + error); |
---|
954 | + g_strfreev (argv); |
---|
955 | + |
---|
956 | + return retval; |
---|
957 | +} |
---|
958 | + |
---|
959 | +static gint |
---|
960 | +exec_err_to_g_error (gint en) |
---|
961 | +{ |
---|
962 | + switch (en) |
---|
963 | + { |
---|
964 | +#ifdef EACCES |
---|
965 | + case EACCES: |
---|
966 | + return G_SPAWN_ERROR_ACCES; |
---|
967 | + break; |
---|
968 | +#endif |
---|
969 | + |
---|
970 | +#ifdef EPERM |
---|
971 | + case EPERM: |
---|
972 | + return G_SPAWN_ERROR_PERM; |
---|
973 | + break; |
---|
974 | +#endif |
---|
975 | + |
---|
976 | +#ifdef E2BIG |
---|
977 | + case E2BIG: |
---|
978 | + return G_SPAWN_ERROR_2BIG; |
---|
979 | + break; |
---|
980 | +#endif |
---|
981 | + |
---|
982 | +#ifdef ENOEXEC |
---|
983 | + case ENOEXEC: |
---|
984 | + return G_SPAWN_ERROR_NOEXEC; |
---|
985 | + break; |
---|
986 | +#endif |
---|
987 | + |
---|
988 | +#ifdef ENAMETOOLONG |
---|
989 | + case ENAMETOOLONG: |
---|
990 | + return G_SPAWN_ERROR_NAMETOOLONG; |
---|
991 | + break; |
---|
992 | +#endif |
---|
993 | + |
---|
994 | +#ifdef ENOENT |
---|
995 | + case ENOENT: |
---|
996 | + return G_SPAWN_ERROR_NOENT; |
---|
997 | + break; |
---|
998 | +#endif |
---|
999 | + |
---|
1000 | +#ifdef ENOMEM |
---|
1001 | + case ENOMEM: |
---|
1002 | + return G_SPAWN_ERROR_NOMEM; |
---|
1003 | + break; |
---|
1004 | +#endif |
---|
1005 | + |
---|
1006 | +#ifdef ENOTDIR |
---|
1007 | + case ENOTDIR: |
---|
1008 | + return G_SPAWN_ERROR_NOTDIR; |
---|
1009 | + break; |
---|
1010 | +#endif |
---|
1011 | + |
---|
1012 | +#ifdef ELOOP |
---|
1013 | + case ELOOP: |
---|
1014 | + return G_SPAWN_ERROR_LOOP; |
---|
1015 | + break; |
---|
1016 | +#endif |
---|
1017 | + |
---|
1018 | +#ifdef ETXTBUSY |
---|
1019 | + case ETXTBUSY: |
---|
1020 | + return G_SPAWN_ERROR_TXTBUSY; |
---|
1021 | + break; |
---|
1022 | +#endif |
---|
1023 | + |
---|
1024 | +#ifdef EIO |
---|
1025 | + case EIO: |
---|
1026 | + return G_SPAWN_ERROR_IO; |
---|
1027 | + break; |
---|
1028 | +#endif |
---|
1029 | + |
---|
1030 | +#ifdef ENFILE |
---|
1031 | + case ENFILE: |
---|
1032 | + return G_SPAWN_ERROR_NFILE; |
---|
1033 | + break; |
---|
1034 | +#endif |
---|
1035 | + |
---|
1036 | +#ifdef EMFILE |
---|
1037 | + case EMFILE: |
---|
1038 | + return G_SPAWN_ERROR_MFILE; |
---|
1039 | + break; |
---|
1040 | +#endif |
---|
1041 | + |
---|
1042 | +#ifdef EINVAL |
---|
1043 | + case EINVAL: |
---|
1044 | + return G_SPAWN_ERROR_INVAL; |
---|
1045 | + break; |
---|
1046 | +#endif |
---|
1047 | + |
---|
1048 | +#ifdef EISDIR |
---|
1049 | + case EISDIR: |
---|
1050 | + return G_SPAWN_ERROR_ISDIR; |
---|
1051 | + break; |
---|
1052 | +#endif |
---|
1053 | + |
---|
1054 | +#ifdef ELIBBAD |
---|
1055 | + case ELIBBAD: |
---|
1056 | + return G_SPAWN_ERROR_LIBBAD; |
---|
1057 | + break; |
---|
1058 | +#endif |
---|
1059 | + |
---|
1060 | + default: |
---|
1061 | + return G_SPAWN_ERROR_FAILED; |
---|
1062 | + break; |
---|
1063 | + } |
---|
1064 | +} |
---|
1065 | + |
---|
1066 | +static void |
---|
1067 | +set_cloexec (gint fd) |
---|
1068 | +{ |
---|
1069 | + fcntl (fd, F_SETFD, FD_CLOEXEC); |
---|
1070 | +} |
---|
1071 | + |
---|
1072 | +static gint |
---|
1073 | +sane_dup2 (gint fd1, gint fd2) |
---|
1074 | +{ |
---|
1075 | + gint ret; |
---|
1076 | + |
---|
1077 | + retry: |
---|
1078 | + ret = dup2 (fd1, fd2); |
---|
1079 | + if (ret < 0 && errno == EINTR) |
---|
1080 | + goto retry; |
---|
1081 | + |
---|
1082 | + return ret; |
---|
1083 | +} |
---|
1084 | + |
---|
1085 | +enum |
---|
1086 | +{ |
---|
1087 | + CHILD_CHDIR_FAILED, |
---|
1088 | + CHILD_EXEC_FAILED, |
---|
1089 | + CHILD_DUP2_FAILED, |
---|
1090 | + CHILD_FORK_FAILED |
---|
1091 | +}; |
---|
1092 | + |
---|
1093 | +static gint |
---|
1094 | +do_exec (gint stdin_fd, |
---|
1095 | + gint stdout_fd, |
---|
1096 | + gint stderr_fd, |
---|
1097 | + const gchar *working_directory, |
---|
1098 | + gchar **argv, |
---|
1099 | + gchar **envp, |
---|
1100 | + gboolean close_descriptors, |
---|
1101 | + gboolean search_path, |
---|
1102 | + gboolean stdout_to_null, |
---|
1103 | + gboolean stderr_to_null, |
---|
1104 | + gboolean child_inherits_stdin, |
---|
1105 | + gboolean file_and_argv_zero, |
---|
1106 | + GSpawnChildSetupFunc child_setup, |
---|
1107 | + gpointer user_data, |
---|
1108 | + GError **error) |
---|
1109 | +{ |
---|
1110 | + gint stdin_sav = -1; |
---|
1111 | + gint stdout_sav = -1; |
---|
1112 | + gint stderr_sav = -1; |
---|
1113 | + gint pid = -1; |
---|
1114 | + char wd[1024]; |
---|
1115 | + |
---|
1116 | + /* Save current working directory |
---|
1117 | + */ |
---|
1118 | + if (working_directory && *working_directory) |
---|
1119 | + _getcwd2 (wd,sizeof(wd)); |
---|
1120 | + |
---|
1121 | + if (working_directory && *working_directory && _chdir2 (working_directory) < 0) |
---|
1122 | + g_set_error (error, |
---|
1123 | + G_SPAWN_ERROR, |
---|
1124 | + G_SPAWN_ERROR_CHDIR, |
---|
1125 | + _("Failed to change to directory '%s' (%s)"), |
---|
1126 | + working_directory, |
---|
1127 | + g_strerror (errno)); |
---|
1128 | + |
---|
1129 | + |
---|
1130 | + /* Close all file descriptors but stdin stdout and stderr as |
---|
1131 | + * soon as we exec. Note that this includes |
---|
1132 | + * child_err_report_fd, which keeps the parent from blocking |
---|
1133 | + * forever on the other end of that pipe. |
---|
1134 | + */ |
---|
1135 | + |
---|
1136 | + if (close_descriptors) |
---|
1137 | + { |
---|
1138 | + gint open_max; |
---|
1139 | + gint i; |
---|
1140 | + |
---|
1141 | + open_max = /*sysconf (_SC_OPEN_MAX)*/256; |
---|
1142 | + for (i = 3; i < open_max; i++) |
---|
1143 | + set_cloexec (i); |
---|
1144 | + } |
---|
1145 | + |
---|
1146 | + /* Redirect pipes as required |
---|
1147 | + * Save the handles before closing them!!!! |
---|
1148 | + */ |
---|
1149 | + |
---|
1150 | + if (stdin_fd >= 0) |
---|
1151 | + { |
---|
1152 | + stdin_sav = dup (0); |
---|
1153 | + /* dup2 can't actually fail here I don't think */ |
---|
1154 | + |
---|
1155 | + if (sane_dup2 (stdin_fd, 0) < 0) |
---|
1156 | + g_set_error (error, |
---|
1157 | + G_SPAWN_ERROR, |
---|
1158 | + G_SPAWN_ERROR_FAILED, |
---|
1159 | + _("Failed to redirect input or output of child process (%s)"), |
---|
1160 | + g_strerror (errno)); |
---|
1161 | + |
---|
1162 | + /* ignore this if it doesn't work */ |
---|
1163 | + close_and_invalidate (&stdin_fd); |
---|
1164 | + } |
---|
1165 | + else if (!child_inherits_stdin) |
---|
1166 | + { |
---|
1167 | + /* Keep process from blocking on a read of stdin */ |
---|
1168 | + gint read_null = open ("NUL", O_RDONLY); |
---|
1169 | + stdin_sav = dup (0); |
---|
1170 | + sane_dup2 (read_null, 0); |
---|
1171 | + close_and_invalidate (&read_null); |
---|
1172 | + } |
---|
1173 | + |
---|
1174 | + if (stdout_fd >= 0) |
---|
1175 | + { |
---|
1176 | + stdout_sav = dup (1); |
---|
1177 | + /* dup2 can't actually fail here I don't think */ |
---|
1178 | + |
---|
1179 | + if (sane_dup2 (stdout_fd, 1) < 0) |
---|
1180 | + g_set_error (error, |
---|
1181 | + G_SPAWN_ERROR, |
---|
1182 | + G_SPAWN_ERROR_FAILED, |
---|
1183 | + _("Failed to redirect input or ouput of child process (%s)"), |
---|
1184 | + g_strerror (errno)); |
---|
1185 | + |
---|
1186 | + /* ignore this if it doesn't work */ |
---|
1187 | + close_and_invalidate (&stdout_fd); |
---|
1188 | + } |
---|
1189 | + else if (stdout_to_null) |
---|
1190 | + { |
---|
1191 | + gint write_null = open ("NUL", O_WRONLY); |
---|
1192 | + stdout_sav = dup (1); |
---|
1193 | + sane_dup2 (write_null, 1); |
---|
1194 | + close_and_invalidate (&write_null); |
---|
1195 | + } |
---|
1196 | + |
---|
1197 | + if (stderr_fd >= 0) |
---|
1198 | + { |
---|
1199 | + stderr_sav = dup (2); |
---|
1200 | + /* dup2 can't actually fail here I don't think */ |
---|
1201 | + |
---|
1202 | + if (sane_dup2 (stderr_fd, 2) < 0) |
---|
1203 | + g_set_error (error, |
---|
1204 | + G_SPAWN_ERROR, |
---|
1205 | + G_SPAWN_ERROR_FAILED, |
---|
1206 | + _("Failed to redirect input or ouput of child process (%s)"), |
---|
1207 | + g_strerror (errno)); |
---|
1208 | + |
---|
1209 | + /* ignore this if it doesn't work */ |
---|
1210 | + close_and_invalidate (&stderr_fd); |
---|
1211 | + } |
---|
1212 | + else if (stderr_to_null) |
---|
1213 | + { |
---|
1214 | + gint write_null = open ("NUL", O_WRONLY); |
---|
1215 | + stderr_sav = dup (2); |
---|
1216 | + sane_dup2 (write_null, 2); |
---|
1217 | + close_and_invalidate (&write_null); |
---|
1218 | + } |
---|
1219 | + |
---|
1220 | + /* Call user function just before we exec */ |
---|
1221 | + if (child_setup) |
---|
1222 | + { |
---|
1223 | + (* child_setup) (user_data); |
---|
1224 | + } |
---|
1225 | + |
---|
1226 | + pid = g_execute (argv[0], |
---|
1227 | + file_and_argv_zero ? argv + 1 : argv, |
---|
1228 | + envp, search_path); |
---|
1229 | + |
---|
1230 | + /* Restore working directory |
---|
1231 | + */ |
---|
1232 | + if (working_directory && *working_directory) |
---|
1233 | + _chdir2 (wd); |
---|
1234 | + |
---|
1235 | + /* Restore the saved handles |
---|
1236 | + */ |
---|
1237 | + if (stdin_sav > -1) |
---|
1238 | + { |
---|
1239 | + sane_dup2 (stdin_sav, 0); |
---|
1240 | + close (stdin_sav); |
---|
1241 | + } |
---|
1242 | + |
---|
1243 | + if (stdout_sav > -1) |
---|
1244 | + { |
---|
1245 | + sane_dup2 (stdout_sav, 1); |
---|
1246 | + close (stdout_sav); |
---|
1247 | + } |
---|
1248 | + |
---|
1249 | + if (stderr_sav > -1) |
---|
1250 | + { |
---|
1251 | + sane_dup2 (stderr_sav, 2); |
---|
1252 | + close (stderr_sav); |
---|
1253 | + } |
---|
1254 | + |
---|
1255 | + return pid; |
---|
1256 | + |
---|
1257 | +} |
---|
1258 | + |
---|
1259 | +static gboolean |
---|
1260 | +fork_exec_with_pipes (gboolean intermediate_child, |
---|
1261 | + const gchar *working_directory, |
---|
1262 | + gchar **argv, |
---|
1263 | + gchar **envp, |
---|
1264 | + gboolean close_descriptors, |
---|
1265 | + gboolean search_path, |
---|
1266 | + gboolean stdout_to_null, |
---|
1267 | + gboolean stderr_to_null, |
---|
1268 | + gboolean child_inherits_stdin, |
---|
1269 | + gboolean file_and_argv_zero, |
---|
1270 | + GSpawnChildSetupFunc child_setup, |
---|
1271 | + gpointer user_data, |
---|
1272 | + GPid *child_pid, |
---|
1273 | + gint *standard_input, |
---|
1274 | + gint *standard_output, |
---|
1275 | + gint *standard_error, |
---|
1276 | + GError **error) |
---|
1277 | +{ |
---|
1278 | + GPid pid = -1; |
---|
1279 | + gint stdin_pipe[2] = { -1, -1 }; |
---|
1280 | + gint stdout_pipe[2] = { -1, -1 }; |
---|
1281 | + gint stderr_pipe[2] = { -1, -1 }; |
---|
1282 | + |
---|
1283 | + if (standard_input && !make_pipe (stdin_pipe, error)) |
---|
1284 | + goto cleanup_and_fail; |
---|
1285 | + |
---|
1286 | + if (standard_output && !make_pipe (stdout_pipe, error)) |
---|
1287 | + goto cleanup_and_fail; |
---|
1288 | + |
---|
1289 | + if (standard_error && !make_pipe (stderr_pipe, error)) |
---|
1290 | + goto cleanup_and_fail; |
---|
1291 | + |
---|
1292 | + /* Be sure we crash if the parent exits |
---|
1293 | + * and we write to the err_report_pipe |
---|
1294 | + */ |
---|
1295 | + signal (SIGPIPE, SIG_DFL); |
---|
1296 | + |
---|
1297 | + /* Close the parent's end of the pipes; |
---|
1298 | + * not needed in the close_descriptors case, |
---|
1299 | + * though |
---|
1300 | + */ |
---|
1301 | + set_cloexec (stdin_pipe[1]); |
---|
1302 | + set_cloexec (stdout_pipe[0]); |
---|
1303 | + set_cloexec (stderr_pipe[0]); |
---|
1304 | + |
---|
1305 | + /* Spawn the child |
---|
1306 | + */ |
---|
1307 | + pid = do_exec (stdin_pipe[0], |
---|
1308 | + stdout_pipe[1], |
---|
1309 | + stderr_pipe[1], |
---|
1310 | + working_directory, |
---|
1311 | + argv, |
---|
1312 | + envp, |
---|
1313 | + close_descriptors, |
---|
1314 | + search_path, |
---|
1315 | + stdout_to_null, |
---|
1316 | + stderr_to_null, |
---|
1317 | + child_inherits_stdin, |
---|
1318 | + file_and_argv_zero, |
---|
1319 | + child_setup, |
---|
1320 | + user_data, |
---|
1321 | + error); |
---|
1322 | + |
---|
1323 | + { |
---|
1324 | + |
---|
1325 | + /* Close the uncared-about ends of the pipes */ |
---|
1326 | + close_and_invalidate (&stdin_pipe[0]); |
---|
1327 | + close_and_invalidate (&stdout_pipe[1]); |
---|
1328 | + close_and_invalidate (&stderr_pipe[1]); |
---|
1329 | + |
---|
1330 | + /* Success against all odds! return the information */ |
---|
1331 | + |
---|
1332 | + if (child_pid) |
---|
1333 | + *child_pid = pid; |
---|
1334 | + |
---|
1335 | + if (standard_input) |
---|
1336 | + *standard_input = stdin_pipe[1]; |
---|
1337 | + if (standard_output) |
---|
1338 | + *standard_output = stdout_pipe[0]; |
---|
1339 | + if (standard_error) |
---|
1340 | + *standard_error = stderr_pipe[0]; |
---|
1341 | + |
---|
1342 | + return TRUE; |
---|
1343 | + } |
---|
1344 | + |
---|
1345 | + cleanup_and_fail: |
---|
1346 | + |
---|
1347 | + /* There was an error from the Child, reap the child to avoid it being |
---|
1348 | + a zombie. |
---|
1349 | + */ |
---|
1350 | + |
---|
1351 | + if (pid > 0) |
---|
1352 | + { |
---|
1353 | + wait_failed: |
---|
1354 | + if (waitpid (pid, NULL, 0) < 0) |
---|
1355 | + { |
---|
1356 | + if (errno == EINTR) |
---|
1357 | + goto wait_failed; |
---|
1358 | + else if (errno == ECHILD) |
---|
1359 | + ; /* do nothing, child already reaped */ |
---|
1360 | + else |
---|
1361 | + g_warning ("waitpid() should not fail in " |
---|
1362 | + "'fork_exec_with_pipes'"); |
---|
1363 | + } |
---|
1364 | + } |
---|
1365 | + |
---|
1366 | + close_and_invalidate (&stdin_pipe[0]); |
---|
1367 | + close_and_invalidate (&stdin_pipe[1]); |
---|
1368 | + close_and_invalidate (&stdout_pipe[0]); |
---|
1369 | + close_and_invalidate (&stdout_pipe[1]); |
---|
1370 | + close_and_invalidate (&stderr_pipe[0]); |
---|
1371 | + close_and_invalidate (&stderr_pipe[1]); |
---|
1372 | + |
---|
1373 | + return FALSE; |
---|
1374 | +} |
---|
1375 | + |
---|
1376 | +static gboolean |
---|
1377 | +make_pipe (gint p[2], |
---|
1378 | + GError **error) |
---|
1379 | +{ |
---|
1380 | + if (pipe (p) < 0) |
---|
1381 | + { |
---|
1382 | + g_set_error (error, |
---|
1383 | + G_SPAWN_ERROR, |
---|
1384 | + G_SPAWN_ERROR_FAILED, |
---|
1385 | + _("Failed to create pipe for communicating with child process (%s)"), |
---|
1386 | + g_strerror (errno)); |
---|
1387 | + return FALSE; |
---|
1388 | + } |
---|
1389 | + else |
---|
1390 | + return TRUE; |
---|
1391 | +} |
---|
1392 | + |
---|
1393 | +/* Based on execvp from GNU C Library */ |
---|
1394 | + |
---|
1395 | +static gint |
---|
1396 | +script_execute (const gchar *file, |
---|
1397 | + gchar **argv, |
---|
1398 | + gchar **envp, |
---|
1399 | + gboolean search_path) |
---|
1400 | +{ |
---|
1401 | + /* Count the arguments. */ |
---|
1402 | + int argc = 0; |
---|
1403 | + gint pid = -1; |
---|
1404 | + |
---|
1405 | + while (argv[argc]) |
---|
1406 | + ++argc; |
---|
1407 | + |
---|
1408 | + /* Construct an argument list for the shell. */ |
---|
1409 | + { |
---|
1410 | + gchar **new_argv; |
---|
1411 | + |
---|
1412 | + new_argv = g_new0 (gchar*, argc + 2); /* /bin/sh and NULL */ |
---|
1413 | + |
---|
1414 | + new_argv[0] = (char *) "sh.exe"; |
---|
1415 | + new_argv[1] = (char *) file; |
---|
1416 | + while (argc > 0) |
---|
1417 | + { |
---|
1418 | + new_argv[argc + 1] = argv[argc]; |
---|
1419 | + --argc; |
---|
1420 | + } |
---|
1421 | + |
---|
1422 | + /* Execute the shell. */ |
---|
1423 | + if (envp) |
---|
1424 | + pid = spawnve (P_NOWAIT, new_argv[0], new_argv, envp); |
---|
1425 | + else |
---|
1426 | + pid = spawnv (P_NOWAIT, new_argv[0], new_argv); |
---|
1427 | + |
---|
1428 | + g_free (new_argv); |
---|
1429 | + |
---|
1430 | + return pid; |
---|
1431 | + } |
---|
1432 | +} |
---|
1433 | + |
---|
1434 | +static gint |
---|
1435 | +g_execute (const gchar *file, |
---|
1436 | + gchar **argv, |
---|
1437 | + gchar **envp, |
---|
1438 | + gboolean search_path) |
---|
1439 | +{ |
---|
1440 | + gint pid; |
---|
1441 | + |
---|
1442 | + if (*file == '\0') |
---|
1443 | + { |
---|
1444 | + /* We check the simple case first. */ |
---|
1445 | + errno = ENOENT; |
---|
1446 | + return -1; |
---|
1447 | + } |
---|
1448 | + |
---|
1449 | + if (envp) |
---|
1450 | + pid = spawnve (P_NOWAIT, file, argv, envp); |
---|
1451 | + else |
---|
1452 | + pid = spawnv (P_NOWAIT, file, argv); |
---|
1453 | + |
---|
1454 | + if (pid == -1) |
---|
1455 | + pid = script_execute (file, argv, envp, FALSE); |
---|
1456 | + |
---|
1457 | + return pid; |
---|
1458 | +} |
---|
1459 | + |
---|
1460 | +/** |
---|
1461 | + * g_spawn_close_pid: |
---|
1462 | + * @pid: The process identifier to close |
---|
1463 | + * |
---|
1464 | + * On some platforms, notably WIN32, the #GPid type represents a resource |
---|
1465 | + * which must be closed to prevent resource leaking. g_spawn_close_pid() |
---|
1466 | + * is provided for this purpose. It should be used on all platforms, even |
---|
1467 | + * though it doesn't do anything under UNIX. |
---|
1468 | + **/ |
---|
1469 | +void |
---|
1470 | +g_spawn_close_pid (GPid pid) |
---|
1471 | +{ |
---|
1472 | +} |
---|
1473 | + |
---|
1474 | +#define __G_SPAWN_C__ |
---|
1475 | +#include "galiasdef.c" |
---|
1476 | diff -ruN -x configure -x ltmain.sh -x aclocal.m4 -x config.guess -x config.sub -x Makefile.in glib-2.6.5/glib/gutils.c glib-2.6.5.os2/glib/gutils.c |
---|
1477 | --- glib-2.6.5/glib/gutils.c Wed Jun 8 21:57:14 2005 |
---|
1478 | +++ glib-2.6.5.os2/glib/gutils.c Sun Jul 31 17:14:58 2005 |
---|
1479 | @@ -634,7 +634,7 @@ |
---|
1480 | if (G_IS_DIR_SEPARATOR (file_name[0])) |
---|
1481 | return TRUE; |
---|
1482 | |
---|
1483 | -#ifdef G_OS_WIN32 |
---|
1484 | +#if defined G_OS_WIN32 || defined __EMX__ |
---|
1485 | /* Recognize drive letter on native Windows */ |
---|
1486 | if (g_ascii_isalpha (file_name[0]) && file_name[1] == ':' && G_IS_DIR_SEPARATOR (file_name[2])) |
---|
1487 | return TRUE; |
---|
1488 | @@ -648,7 +648,7 @@ |
---|
1489 | { |
---|
1490 | g_return_val_if_fail (file_name != NULL, NULL); |
---|
1491 | |
---|
1492 | -#ifdef G_PLATFORM_WIN32 |
---|
1493 | +#if defined G_PLATFORM_WIN32 || defined __EMX__ |
---|
1494 | /* Skip \\server\share or //server/share */ |
---|
1495 | if (G_IS_DIR_SEPARATOR (file_name[0]) && |
---|
1496 | G_IS_DIR_SEPARATOR (file_name[1]) && |
---|
1497 | @@ -665,6 +665,13 @@ |
---|
1498 | p = q; |
---|
1499 | } |
---|
1500 | #endif |
---|
1501 | +#ifdef __EMX__ |
---|
1502 | + { |
---|
1503 | + gchar *q = strchr (file_name + 2, '\\'); |
---|
1504 | + if (p == NULL || (q != NULL && q < p)) |
---|
1505 | + p = q; |
---|
1506 | + } |
---|
1507 | +#endif |
---|
1508 | if (p && |
---|
1509 | p > file_name + 2 && |
---|
1510 | p[1]) |
---|
1511 | @@ -691,7 +698,7 @@ |
---|
1512 | return (gchar *)file_name; |
---|
1513 | } |
---|
1514 | |
---|
1515 | -#ifdef G_OS_WIN32 |
---|
1516 | +#if defined G_OS_WIN32 || defined __EMX__ |
---|
1517 | /* Skip X:\ */ |
---|
1518 | if (g_ascii_isalpha (file_name[0]) && file_name[1] == ':' && G_IS_DIR_SEPARATOR (file_name[2])) |
---|
1519 | return (gchar *)file_name + 3; |
---|
1520 | @@ -716,9 +723,16 @@ |
---|
1521 | base = q; |
---|
1522 | } |
---|
1523 | #endif |
---|
1524 | +#ifdef __EMX__ |
---|
1525 | + { |
---|
1526 | + gchar *q = strrchr (file_name, '\\'); |
---|
1527 | + if (base == NULL || (q != NULL && q > base)) |
---|
1528 | + base = q; |
---|
1529 | + } |
---|
1530 | +#endif |
---|
1531 | if (!base) |
---|
1532 | { |
---|
1533 | -#ifdef G_OS_WIN32 |
---|
1534 | +#if defined G_OS_WIN32 || defined __EMX__ |
---|
1535 | if (g_ascii_isalpha (file_name[0]) && file_name[1] == ':') |
---|
1536 | { |
---|
1537 | gchar drive_colon_dot[4]; |
---|
1538 | @@ -737,7 +751,7 @@ |
---|
1539 | while (base > file_name && G_IS_DIR_SEPARATOR (*base)) |
---|
1540 | base--; |
---|
1541 | |
---|
1542 | -#ifdef G_OS_WIN32 |
---|
1543 | +#if defined G_OS_WIN32 || defined __EMX__ |
---|
1544 | /* base points to the char before the last slash. |
---|
1545 | * |
---|
1546 | * In case file_name is the root of a drive (X:\) or a child of the |
---|
1547 | @@ -835,6 +849,9 @@ |
---|
1548 | gchar *dir = NULL; |
---|
1549 | static gulong max_len = 0; |
---|
1550 | |
---|
1551 | +#ifdef __EMX__ |
---|
1552 | +#define getcwd(a,b) _getcwd2(a,b) |
---|
1553 | +#endif |
---|
1554 | if (max_len == 0) |
---|
1555 | max_len = (G_PATH_LENGTH == -1) ? 2048 : G_PATH_LENGTH; |
---|
1556 | |
---|
1557 | @@ -2514,6 +2531,10 @@ |
---|
1558 | |
---|
1559 | #endif /* G_OS_WIN32 */ |
---|
1560 | |
---|
1561 | +#ifdef __EMX__ |
---|
1562 | +extern char *__XOS2RedirRoot (char *fname); |
---|
1563 | +#endif |
---|
1564 | + |
---|
1565 | G_CONST_RETURN gchar * |
---|
1566 | _glib_gettext (const gchar *str) |
---|
1567 | { |
---|
1568 | @@ -2521,7 +2542,11 @@ |
---|
1569 | |
---|
1570 | if (!_glib_gettext_initialized) |
---|
1571 | { |
---|
1572 | +#ifndef __EMX__ |
---|
1573 | bindtextdomain(GETTEXT_PACKAGE, GLIB_LOCALE_DIR); |
---|
1574 | +#else |
---|
1575 | + bindtextdomain(GETTEXT_PACKAGE, __XOS2RedirRoot (GLIB_LOCALE_DIR)); |
---|
1576 | +#endif |
---|
1577 | # ifdef HAVE_BIND_TEXTDOMAIN_CODESET |
---|
1578 | bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); |
---|
1579 | # endif |
---|
1580 | diff -ruN -x configure -x ltmain.sh -x aclocal.m4 -x config.guess -x config.sub -x Makefile.in glib-2.6.5/glib/gutils.h glib-2.6.5.os2/glib/gutils.h |
---|
1581 | --- glib-2.6.5/glib/gutils.h Tue Apr 19 10:06:04 2005 |
---|
1582 | +++ glib-2.6.5.os2/glib/gutils.h Sun Jul 31 17:14:58 2005 |
---|
1583 | @@ -44,8 +44,15 @@ |
---|
1584 | #define G_SEARCHPATH_SEPARATOR ';' |
---|
1585 | #define G_SEARCHPATH_SEPARATOR_S ";" |
---|
1586 | |
---|
1587 | -#else /* !G_OS_WIN32 */ |
---|
1588 | +#elif defined(__EMX__) /* !G_OS_WIN32 */ |
---|
1589 | |
---|
1590 | +#define G_DIR_SEPARATOR '/' |
---|
1591 | +#define G_DIR_SEPARATOR_S "/" |
---|
1592 | +#define G_IS_DIR_SEPARATOR(c) ((c) == G_DIR_SEPARATOR || (c) == '\\') |
---|
1593 | +#define G_SEARCHPATH_SEPARATOR ';' |
---|
1594 | +#define G_SEARCHPATH_SEPARATOR_S ";" |
---|
1595 | + |
---|
1596 | +#else |
---|
1597 | /* Unix */ |
---|
1598 | |
---|
1599 | #define G_DIR_SEPARATOR '/' |
---|
1600 | diff -ruN -x configure -x ltmain.sh -x aclocal.m4 -x config.guess -x config.sub -x Makefile.in glib-2.6.5/glib/libcharset/localcharset.c glib-2.6.5.os2/glib/libcharset/localcharset.c |
---|
1601 | --- glib-2.6.5/glib/libcharset/localcharset.c Sun Oct 24 03:37:42 2004 |
---|
1602 | +++ glib-2.6.5.os2/glib/libcharset/localcharset.c Thu Jul 21 19:51:50 2005 |
---|
1603 | @@ -248,7 +248,7 @@ |
---|
1604 | const char * |
---|
1605 | _g_locale_charset_raw (void) |
---|
1606 | { |
---|
1607 | - const char *codeset; |
---|
1608 | + const char *codeset = NULL; |
---|
1609 | |
---|
1610 | #if !(defined WIN32 || defined OS2) |
---|
1611 | |
---|
1612 | @@ -331,21 +331,21 @@ |
---|
1613 | buf [modifier - dot] = '\0'; |
---|
1614 | return buf; |
---|
1615 | } |
---|
1616 | - } |
---|
1617 | |
---|
1618 | - /* Resolve through the charset.alias file. */ |
---|
1619 | - codeset = locale; |
---|
1620 | - } |
---|
1621 | - else |
---|
1622 | - { |
---|
1623 | - /* OS/2 has a function returning the locale's codepage as a number. */ |
---|
1624 | - if (DosQueryCp (sizeof (cp), cp, &cplen)) |
---|
1625 | - codeset = ""; |
---|
1626 | - else |
---|
1627 | - { |
---|
1628 | - sprintf (buf, "CP%u", cp[0]); |
---|
1629 | - codeset = buf; |
---|
1630 | + /* Resolve through the charset.alias file. */ |
---|
1631 | + codeset = locale; |
---|
1632 | } |
---|
1633 | + else |
---|
1634 | + { |
---|
1635 | + /* OS/2 has a function returning the locale's codepage as a number. */ |
---|
1636 | + if (DosQueryCp (sizeof (cp), cp, &cplen)) |
---|
1637 | + codeset = ""; |
---|
1638 | + else |
---|
1639 | + { |
---|
1640 | + sprintf (buf, "CP%u", cp[0]); |
---|
1641 | + codeset = buf; |
---|
1642 | + } |
---|
1643 | + } |
---|
1644 | } |
---|
1645 | |
---|
1646 | #endif |
---|
1647 | diff -ruN -x configure -x ltmain.sh -x aclocal.m4 -x config.guess -x config.sub -x Makefile.in glib-2.6.5/glib/Makefile.am glib-2.6.5.os2/glib/Makefile.am |
---|
1648 | --- glib-2.6.5/glib/Makefile.am Mon Mar 14 05:02:06 2005 |
---|
1649 | +++ glib-2.6.5.os2/glib/Makefile.am Sun Jul 31 17:14:58 2005 |
---|
1650 | @@ -123,6 +123,7 @@ |
---|
1651 | giowin32.c \ |
---|
1652 | gspawn.c \ |
---|
1653 | gspawn-win32.c \ |
---|
1654 | + gspawn-os2.c \ |
---|
1655 | gwin32.c |
---|
1656 | |
---|
1657 | glibincludedir=$(includedir)/glib-2.0 |
---|
1658 | @@ -225,9 +226,15 @@ |
---|
1659 | libglib_2_0_la_LIBADD = libcharset/libcharset.la $(printf_la) @GIO@ @GSPAWN@ @PLATFORMDEP@ @G_LIB_WIN32_RESOURCE@ @ICONV_LIBS@ @G_LIBS_EXTRA@ |
---|
1660 | libglib_2_0_la_DEPENDENCIES = libcharset/libcharset.la $(printf_la) @GIO@ @GSPAWN@ @PLATFORMDEP@ @G_LIB_WIN32_RESOURCE@ @GLIB_DEF@ |
---|
1661 | |
---|
1662 | +if !OS_OS2 |
---|
1663 | libglib_2_0_la_LDFLAGS = \ |
---|
1664 | -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \ |
---|
1665 | -export-dynamic $(no_undefined) $(export_symbols) |
---|
1666 | +else |
---|
1667 | +libglib_2_0_la_LDFLAGS = \ |
---|
1668 | + -version-info $(LT_CURRENT) $(LT_REVISION) $(LT_AGE) \ |
---|
1669 | + -export-dynamic $(no_undefined) $(export_symbols) |
---|
1670 | +endif |
---|
1671 | |
---|
1672 | if OS_WIN32 |
---|
1673 | bin_PROGRAMS = gspawn-win32-helper |
---|
1674 | diff -ruN -x configure -x ltmain.sh -x aclocal.m4 -x config.guess -x config.sub -x Makefile.in glib-2.6.5/gmodule/gmodule-2.0.os2name glib-2.6.5.os2/gmodule/gmodule-2.0.os2name |
---|
1675 | --- glib-2.6.5/gmodule/gmodule-2.0.os2name Thu Jan 1 00:00:00 1970 |
---|
1676 | +++ glib-2.6.5.os2/gmodule/gmodule-2.0.os2name Thu Jul 21 19:51:52 2005 |
---|
1677 | @@ -0,0 +1 @@ |
---|
1678 | +gmodule2 |
---|
1679 | diff -ruN -x configure -x ltmain.sh -x aclocal.m4 -x config.guess -x config.sub -x Makefile.in glib-2.6.5/gmodule/gmodule.c glib-2.6.5.os2/gmodule/gmodule.c |
---|
1680 | --- glib-2.6.5/gmodule/gmodule.c Sun Jan 2 17:03:56 2005 |
---|
1681 | +++ glib-2.6.5.os2/gmodule/gmodule.c Thu Jul 21 19:51:52 2005 |
---|
1682 | @@ -144,6 +144,9 @@ |
---|
1683 | |
---|
1684 | /* --- include platform specifc code --- */ |
---|
1685 | #define SUPPORT_OR_RETURN(rv) { g_module_set_error (NULL); } |
---|
1686 | +#ifdef __EMX__ |
---|
1687 | +#include "gmodule-os2.c" |
---|
1688 | +#else |
---|
1689 | #if (G_MODULE_IMPL == G_MODULE_IMPL_DL) |
---|
1690 | #include "gmodule-dl.c" |
---|
1691 | #elif (G_MODULE_IMPL == G_MODULE_IMPL_DLD) |
---|
1692 | @@ -188,6 +191,7 @@ |
---|
1693 | return NULL; |
---|
1694 | } |
---|
1695 | #endif /* no implementation */ |
---|
1696 | +#endif /* !__EMX__ */ |
---|
1697 | |
---|
1698 | /* --- functions --- */ |
---|
1699 | gboolean |
---|
1700 | diff -ruN -x configure -x ltmain.sh -x aclocal.m4 -x config.guess -x config.sub -x Makefile.in glib-2.6.5/gmodule/Makefile.am glib-2.6.5.os2/gmodule/Makefile.am |
---|
1701 | --- glib-2.6.5/gmodule/Makefile.am Wed Mar 9 03:23:10 2005 |
---|
1702 | +++ glib-2.6.5.os2/gmodule/Makefile.am Thu Jul 21 19:51:52 2005 |
---|
1703 | @@ -71,10 +71,17 @@ |
---|
1704 | endif |
---|
1705 | |
---|
1706 | libgmodule_2_0_la_SOURCES = gmodule.c |
---|
1707 | +if !OS_OS2 |
---|
1708 | libgmodule_2_0_la_LDFLAGS = \ |
---|
1709 | $(G_MODULE_LDFLAGS) \ |
---|
1710 | -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \ |
---|
1711 | -export-dynamic $(no_undefined) $(export_symbols) |
---|
1712 | +else |
---|
1713 | +libgmodule_2_0_la_LDFLAGS = \ |
---|
1714 | + $(G_MODULE_LDFLAGS) \ |
---|
1715 | + -version-info $(LT_CURRENT) $(LT_REVISION) $(LT_AGE) \ |
---|
1716 | + -export-dynamic $(no_undefined) $(export_symbols) |
---|
1717 | +endif |
---|
1718 | |
---|
1719 | libgmodule_2_0_la_LIBADD = $(G_MODULE_WIN32_RESOURCE) $(G_MODULE_LIBS_EXTRA) $(G_MODULE_LIBS) $(libglib) |
---|
1720 | |
---|
1721 | diff -ruN -x configure -x ltmain.sh -x aclocal.m4 -x config.guess -x config.sub -x Makefile.in glib-2.6.5/gobject/glib-genmarshal.c glib-2.6.5.os2/gobject/glib-genmarshal.c |
---|
1722 | --- glib-2.6.5/gobject/glib-genmarshal.c Wed Jul 21 19:59:16 2004 |
---|
1723 | +++ glib-2.6.5.os2/gobject/glib-genmarshal.c Thu Jul 21 19:51:52 2005 |
---|
1724 | @@ -613,7 +613,11 @@ |
---|
1725 | if (files) |
---|
1726 | files = g_slist_reverse (files); |
---|
1727 | else |
---|
1728 | +#ifndef __EMX__ |
---|
1729 | files = g_slist_prepend (files, "/dev/stdin"); |
---|
1730 | +#else |
---|
1731 | + files = g_slist_prepend (files, "con"); |
---|
1732 | +#endif |
---|
1733 | |
---|
1734 | /* setup auxillary structs */ |
---|
1735 | scanner = g_scanner_new (&scanner_config_template); |
---|
1736 | diff -ruN -x configure -x ltmain.sh -x aclocal.m4 -x config.guess -x config.sub -x Makefile.in glib-2.6.5/gobject/gobject-2.0.os2name glib-2.6.5.os2/gobject/gobject-2.0.os2name |
---|
1737 | --- glib-2.6.5/gobject/gobject-2.0.os2name Thu Jan 1 00:00:00 1970 |
---|
1738 | +++ glib-2.6.5.os2/gobject/gobject-2.0.os2name Thu Jul 21 19:51:52 2005 |
---|
1739 | @@ -0,0 +1 @@ |
---|
1740 | +gobject2 |
---|
1741 | diff -ruN -x configure -x ltmain.sh -x aclocal.m4 -x config.guess -x config.sub -x Makefile.in glib-2.6.5/gobject/Makefile.am glib-2.6.5.os2/gobject/Makefile.am |
---|
1742 | --- glib-2.6.5/gobject/Makefile.am Wed Apr 6 17:11:48 2005 |
---|
1743 | +++ glib-2.6.5.os2/gobject/Makefile.am Thu Jul 21 19:51:52 2005 |
---|
1744 | @@ -77,9 +77,15 @@ |
---|
1745 | |
---|
1746 | # libtool stuff: set version and export symbols for resolving |
---|
1747 | libgobjectincludedir = $(includedir)/glib-2.0/gobject |
---|
1748 | +if !OS_OS2 |
---|
1749 | libgobject_2_0_la_LDFLAGS = \ |
---|
1750 | -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \ |
---|
1751 | -export-dynamic $(no_undefined) $(export_symbols) |
---|
1752 | +else |
---|
1753 | +libgobject_2_0_la_LDFLAGS = \ |
---|
1754 | + -version-info $(LT_CURRENT) $(LT_REVISION) $(LT_AGE) \ |
---|
1755 | + -export-dynamic $(no_undefined) $(export_symbols) |
---|
1756 | +endif |
---|
1757 | |
---|
1758 | libgobject_2_0_la_LIBADD = $(G_OBJECT_WIN32_RESOURCE) $(libglib) |
---|
1759 | |
---|
1760 | diff -ruN -x configure -x ltmain.sh -x aclocal.m4 -x config.guess -x config.sub -x Makefile.in glib-2.6.5/gthread/gthread-2.0.os2name glib-2.6.5.os2/gthread/gthread-2.0.os2name |
---|
1761 | --- glib-2.6.5/gthread/gthread-2.0.os2name Thu Jan 1 00:00:00 1970 |
---|
1762 | +++ glib-2.6.5.os2/gthread/gthread-2.0.os2name Thu Jul 21 19:51:52 2005 |
---|
1763 | @@ -0,0 +1 @@ |
---|
1764 | +gthread2 |
---|
1765 | diff -ruN -x configure -x ltmain.sh -x aclocal.m4 -x config.guess -x config.sub -x Makefile.in glib-2.6.5/gthread/Makefile.am glib-2.6.5.os2/gthread/Makefile.am |
---|
1766 | --- glib-2.6.5/gthread/Makefile.am Sat Mar 6 08:37:44 2004 |
---|
1767 | +++ glib-2.6.5.os2/gthread/Makefile.am Thu Jul 21 19:51:52 2005 |
---|
1768 | @@ -55,9 +55,15 @@ |
---|
1769 | endif |
---|
1770 | |
---|
1771 | libgthread_2_0_la_SOURCES = gthread-impl.c |
---|
1772 | +if !OS_OS2 |
---|
1773 | libgthread_2_0_la_LDFLAGS = \ |
---|
1774 | -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \ |
---|
1775 | -export-dynamic $(no_undefined) $(export_symbols) |
---|
1776 | +else |
---|
1777 | +libgthread_2_0_la_LDFLAGS = \ |
---|
1778 | + -version-info $(LT_CURRENT) $(LT_REVISION) $(LT_AGE) \ |
---|
1779 | + -export-dynamic $(no_undefined) $(export_symbols) |
---|
1780 | +endif |
---|
1781 | |
---|
1782 | libgthread_2_0_la_LIBADD = $(G_THREAD_WIN32_RESOURCE) $(G_THREAD_LIBS_EXTRA) $(G_THREAD_LIBS_FOR_GTHREAD) $(libglib) |
---|
1783 | |
---|
1784 | diff -ruN -x configure -x ltmain.sh -x aclocal.m4 -x config.guess -x config.sub -x Makefile.in glib-2.6.5/m4macros/glib-gettext.m4 glib-2.6.5.os2/m4macros/glib-gettext.m4 |
---|
1785 | --- glib-2.6.5/m4macros/glib-gettext.m4 Fri Mar 11 19:01:04 2005 |
---|
1786 | +++ glib-2.6.5.os2/m4macros/glib-gettext.m4 Thu Jul 21 19:51:52 2005 |
---|
1787 | @@ -74,12 +74,14 @@ |
---|
1788 | IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" |
---|
1789 | for ac_dir in ifelse([$5], , $PATH, [$5]); do |
---|
1790 | test -z "$ac_dir" && ac_dir=. |
---|
1791 | - if test -f $ac_dir/$ac_word; then |
---|
1792 | - if [$3]; then |
---|
1793 | - ac_cv_path_$1="$ac_dir/$ac_word" |
---|
1794 | - break |
---|
1795 | + for ac_exec_ext in '' $ac_executable_extensions; do |
---|
1796 | + if test -f $ac_dir/$ac_word$ac_exec_ext; then |
---|
1797 | + if [$3]; then |
---|
1798 | + ac_cv_path_$1="$ac_dir/$ac_word$ac_exec_ext" |
---|
1799 | + break |
---|
1800 | + fi |
---|
1801 | fi |
---|
1802 | - fi |
---|
1803 | + done |
---|
1804 | done |
---|
1805 | IFS="$ac_save_ifs" |
---|
1806 | dnl If no 4th arg is given, leave the cache variable unset, |
---|
1807 | diff -ruN -x configure -x ltmain.sh -x aclocal.m4 -x config.guess -x config.sub -x Makefile.in glib-2.6.5/setenv.cmd glib-2.6.5.os2/setenv.cmd |
---|
1808 | --- glib-2.6.5/setenv.cmd Thu Jan 1 00:00:00 1970 |
---|
1809 | +++ glib-2.6.5.os2/setenv.cmd Thu Jul 21 20:37:12 2005 |
---|
1810 | @@ -0,0 +1,12 @@ |
---|
1811 | +setlocal |
---|
1812 | +call ..\setenv302.cmd |
---|
1813 | +path=e:\usr\bin;e:\perl\bin;e:\usr\X11R6\bin;%PATH% |
---|
1814 | +set PERLLIB_PREFIX=L:/Perl/lib;E:/Perl/lib |
---|
1815 | +set beginlibpath=e:\x11_latest\glib-2.6.5\glib\.libs;e:\x11_latest\glib-2.6.5\gmodule\.libs;e:\x11_latest\glib-2.6.5\gobject\.libs;e:\x11_latest\glib-2.6.5\gthread\.libs;%BEGINLIBPATH%e:\usr\X11R6\lib; |
---|
1816 | +set ETC= |
---|
1817 | +set C_INCLUDE_PATH=e:/usr/include;%C_INCLUDE_PATH% |
---|
1818 | +set LIBRARY_PATH=e:/usr/lib;%LIBRARY_PATH% |
---|
1819 | +set CONFIG_SHELL=bash.exe |
---|
1820 | +set EMXSHELL=bash.exe |
---|
1821 | +bash.exe |
---|
1822 | +endlocal |
---|
1823 | diff -ruN -x configure -x ltmain.sh -x aclocal.m4 -x config.guess -x config.sub -x Makefile.in glib-2.6.5/tests/dirname-test.c glib-2.6.5.os2/tests/dirname-test.c |
---|
1824 | --- glib-2.6.5/tests/dirname-test.c Sun Mar 21 22:43:12 2004 |
---|
1825 | +++ glib-2.6.5.os2/tests/dirname-test.c Thu Jul 21 19:51:52 2005 |
---|
1826 | @@ -73,7 +73,7 @@ |
---|
1827 | { "c///", "c" }, |
---|
1828 | { "/a/b", "/a" }, |
---|
1829 | { "/a/b/", "/a/b" }, |
---|
1830 | -#ifdef G_OS_WIN32 |
---|
1831 | +#if defined(G_OS_WIN32) || defined(__EMX__) |
---|
1832 | { "\\", "\\" }, |
---|
1833 | { ".\\\\\\\\", "." }, |
---|
1834 | { ".\\/\\/", "." }, |
---|
1835 | diff -ruN -x configure -x ltmain.sh -x aclocal.m4 -x config.guess -x config.sub -x Makefile.in glib-2.6.5/tests/iochannel-test.c glib-2.6.5.os2/tests/iochannel-test.c |
---|
1836 | --- glib-2.6.5/tests/iochannel-test.c Wed Oct 16 00:39:16 2002 |
---|
1837 | +++ glib-2.6.5.os2/tests/iochannel-test.c Thu Jul 21 19:51:52 2005 |
---|
1838 | @@ -22,7 +22,11 @@ |
---|
1839 | glong wlength = 0; |
---|
1840 | gsize length_out; |
---|
1841 | gboolean block; |
---|
1842 | +#ifndef __EMX__ |
---|
1843 | const gchar encoding[] = "EUC-JP"; |
---|
1844 | +#else |
---|
1845 | + const gchar encoding[] = "KOI8-R"; |
---|
1846 | +#endif |
---|
1847 | GIOStatus status; |
---|
1848 | GIOFlags flags; |
---|
1849 | |
---|
1850 | diff -ruN -x configure -x ltmain.sh -x aclocal.m4 -x config.guess -x config.sub -x Makefile.in glib-2.6.5/tests/libmoduletestplugin_a.c glib-2.6.5.os2/tests/libmoduletestplugin_a.c |
---|
1851 | --- glib-2.6.5/tests/libmoduletestplugin_a.c Thu Jul 4 17:19:30 2002 |
---|
1852 | +++ glib-2.6.5.os2/tests/libmoduletestplugin_a.c Thu Jul 21 19:51:52 2005 |
---|
1853 | @@ -30,7 +30,7 @@ |
---|
1854 | #include <gmodule.h> |
---|
1855 | #include <stdlib.h> |
---|
1856 | |
---|
1857 | -G_MODULE_EXPORT gchar* gplugin_a_state; |
---|
1858 | +G_MODULE_EXPORT gchar* gplugin_a_state = NULL; |
---|
1859 | |
---|
1860 | G_MODULE_EXPORT void |
---|
1861 | gplugin_a_func (void) |
---|
1862 | diff -ruN -x configure -x ltmain.sh -x aclocal.m4 -x config.guess -x config.sub -x Makefile.in glib-2.6.5/tests/libmoduletestplugin_b.c glib-2.6.5.os2/tests/libmoduletestplugin_b.c |
---|
1863 | --- glib-2.6.5/tests/libmoduletestplugin_b.c Thu Jul 4 17:19:30 2002 |
---|
1864 | +++ glib-2.6.5.os2/tests/libmoduletestplugin_b.c Thu Jul 21 19:51:52 2005 |
---|
1865 | @@ -29,7 +29,7 @@ |
---|
1866 | |
---|
1867 | #include <gmodule.h> |
---|
1868 | |
---|
1869 | -G_MODULE_EXPORT gchar* gplugin_b_state; |
---|
1870 | +G_MODULE_EXPORT gchar* gplugin_b_state = NULL; |
---|
1871 | |
---|
1872 | G_MODULE_EXPORT const gchar* |
---|
1873 | g_module_check_init (GModule *module) |
---|
1874 | diff -ruN -x configure -x ltmain.sh -x aclocal.m4 -x config.guess -x config.sub -x Makefile.in glib-2.6.5/tests/Makefile.am glib-2.6.5.os2/tests/Makefile.am |
---|
1875 | --- glib-2.6.5/tests/Makefile.am Tue Feb 8 16:15:16 2005 |
---|
1876 | +++ glib-2.6.5.os2/tests/Makefile.am Thu Jul 21 19:51:52 2005 |
---|
1877 | @@ -9,6 +9,11 @@ |
---|
1878 | libgmodule = $(top_builddir)/gmodule/libgmodule-2.0.la |
---|
1879 | libgobject = $(top_builddir)/gobject/libgobject-2.0.la |
---|
1880 | |
---|
1881 | +if OS_OS2 |
---|
1882 | +libadd_libgmodule = $(libgmodule) |
---|
1883 | +libadd_libglib = $(libglib) |
---|
1884 | +endif |
---|
1885 | + |
---|
1886 | if PLATFORM_WIN32 |
---|
1887 | libadd_libgmodule = $(libgmodule) |
---|
1888 | libadd_libglib = $(libglib) |
---|
1889 | diff -ruN -x configure -x ltmain.sh -x aclocal.m4 -x config.guess -x config.sub -x Makefile.in glib-2.6.5/tests/module-test.c glib-2.6.5.os2/tests/module-test.c |
---|
1890 | --- glib-2.6.5/tests/module-test.c Fri Jan 9 15:40:30 2004 |
---|
1891 | +++ glib-2.6.5.os2/tests/module-test.c Thu Jul 21 19:51:52 2005 |
---|
1892 | @@ -94,12 +94,14 @@ |
---|
1893 | |
---|
1894 | /* module handles */ |
---|
1895 | |
---|
1896 | +#ifndef __EMX__ |
---|
1897 | module_self = g_module_open (NULL, G_MODULE_BIND_LAZY); |
---|
1898 | if (!module_self) |
---|
1899 | g_error ("error: %s", g_module_error ()); |
---|
1900 | |
---|
1901 | if (!g_module_symbol (module_self, "g_module_close", (gpointer *) &f_self)) |
---|
1902 | g_error ("error: %s", g_module_error ()); |
---|
1903 | +#endif |
---|
1904 | |
---|
1905 | module_a = g_module_open (plugin_a, G_MODULE_BIND_LAZY); |
---|
1906 | if (!module_a) |
---|
1907 | @@ -139,9 +141,11 @@ |
---|
1908 | /* get and call globally clashing functions |
---|
1909 | */ |
---|
1910 | |
---|
1911 | +#ifndef __EMX__ |
---|
1912 | if (!g_module_symbol (module_self, "g_clash_func", (gpointer *) &f_self)) |
---|
1913 | g_error ("error: %s", g_module_error ()); |
---|
1914 | test_states (NULL, NULL, NULL); |
---|
1915 | +#endif |
---|
1916 | |
---|
1917 | if (!g_module_symbol (module_a, "g_clash_func", (gpointer *) &f_a)) |
---|
1918 | g_error ("error: %s", g_module_error ()); |
---|
1919 | @@ -151,8 +155,10 @@ |
---|
1920 | g_error ("error: %s", g_module_error ()); |
---|
1921 | test_states (NULL, NULL, NULL); |
---|
1922 | |
---|
1923 | +#ifndef __EMX__ |
---|
1924 | f_self (); |
---|
1925 | test_states ("global clash", NULL, NULL); |
---|
1926 | +#endif |
---|
1927 | |
---|
1928 | f_a (); |
---|
1929 | test_states (NULL, "global clash", NULL); |
---|
1930 | diff -ruN -x configure -x ltmain.sh -x aclocal.m4 -x config.guess -x config.sub -x Makefile.in glib-2.6.5/tests/moduletestplugin_a.os2name glib-2.6.5.os2/tests/moduletestplugin_a.os2name |
---|
1931 | --- glib-2.6.5/tests/moduletestplugin_a.os2name Thu Jan 1 00:00:00 1970 |
---|
1932 | +++ glib-2.6.5.os2/tests/moduletestplugin_a.os2name Thu Jul 21 19:51:52 2005 |
---|
1933 | @@ -0,0 +1 @@ |
---|
1934 | +mod_pl_a |
---|
1935 | diff -ruN -x configure -x ltmain.sh -x aclocal.m4 -x config.guess -x config.sub -x Makefile.in glib-2.6.5/tests/moduletestplugin_b.os2name glib-2.6.5.os2/tests/moduletestplugin_b.os2name |
---|
1936 | --- glib-2.6.5/tests/moduletestplugin_b.os2name Thu Jan 1 00:00:00 1970 |
---|
1937 | +++ glib-2.6.5.os2/tests/moduletestplugin_b.os2name Thu Jul 21 19:51:52 2005 |
---|
1938 | @@ -0,0 +1 @@ |
---|
1939 | +mod_pl_b |
---|
1940 | diff -ruN -x configure -x ltmain.sh -x aclocal.m4 -x config.guess -x config.sub -x Makefile.in glib-2.6.5/tests/run-markup-tests.sh glib-2.6.5.os2/tests/run-markup-tests.sh |
---|
1941 | --- glib-2.6.5/tests/run-markup-tests.sh Mon Jan 24 18:34:00 2005 |
---|
1942 | +++ glib-2.6.5.os2/tests/run-markup-tests.sh Thu Jul 21 19:51:52 2005 |
---|
1943 | @@ -16,7 +16,8 @@ |
---|
1944 | error_out=/dev/null |
---|
1945 | if [ "$1" = "-v" ]; then |
---|
1946 | verbose=1 |
---|
1947 | - error_out=/dev/stderr |
---|
1948 | +# error_out=/dev/stderr |
---|
1949 | + error_out=con |
---|
1950 | fi |
---|
1951 | for I in ${srcdir:-.}/markups/fail-*.gmarkup; do |
---|
1952 | echo_v "Parsing $I, should fail" |
---|
1953 | diff -ruN -x configure -x ltmain.sh -x aclocal.m4 -x config.guess -x config.sub -x Makefile.in glib-2.6.5/tests/spawn-test.c glib-2.6.5.os2/tests/spawn-test.c |
---|
1954 | --- glib-2.6.5/tests/spawn-test.c Sun Mar 20 21:06:48 2005 |
---|
1955 | +++ glib-2.6.5.os2/tests/spawn-test.c Thu Jul 21 20:47:50 2005 |
---|
1956 | @@ -83,8 +83,12 @@ |
---|
1957 | else |
---|
1958 | { |
---|
1959 | g_assert (output != NULL); |
---|
1960 | - |
---|
1961 | + |
---|
1962 | +#ifndef __EMX__ |
---|
1963 | if (strcmp (output, "hello\n") != 0) |
---|
1964 | +#else |
---|
1965 | + if (strcmp (output, "hello\r\n") != 0) |
---|
1966 | +#endif |
---|
1967 | { |
---|
1968 | printf ("output was '%s', should have been 'hello'\n", |
---|
1969 | output); |
---|
1970 | diff -ruN -x configure -x ltmain.sh -x aclocal.m4 -x config.guess -x config.sub -x Makefile.in glib-2.6.5/tests/unicode-encoding.c glib-2.6.5.os2/tests/unicode-encoding.c |
---|
1971 | --- glib-2.6.5/tests/unicode-encoding.c Wed Mar 31 04:19:10 2004 |
---|
1972 | +++ glib-2.6.5.os2/tests/unicode-encoding.c Thu Jul 21 19:51:52 2005 |
---|
1973 | @@ -195,7 +195,7 @@ |
---|
1974 | gint n_chars; |
---|
1975 | gchar *utf8_result; |
---|
1976 | |
---|
1977 | -#ifdef G_PLATFORM_WIN32 |
---|
1978 | +#if defined G_PLATFORM_WIN32 || defined __EMX__ |
---|
1979 | #define TARGET "UTF-16LE" |
---|
1980 | #else |
---|
1981 | #define TARGET "UTF-16" |
---|
1982 | diff -ruN -x configure -x ltmain.sh -x aclocal.m4 -x config.guess -x config.sub -x Makefile.in glib-2.6.5/tests/uri-test.c glib-2.6.5.os2/tests/uri-test.c |
---|
1983 | --- glib-2.6.5/tests/uri-test.c Fri Oct 22 21:51:28 2004 |
---|
1984 | +++ glib-2.6.5.os2/tests/uri-test.c Thu Jul 21 19:51:52 2005 |
---|
1985 | @@ -47,7 +47,7 @@ |
---|
1986 | { "/etc", NULL, "file:///etc"}, |
---|
1987 | { "/etc", "", "file:///etc"}, |
---|
1988 | { "/etc", "otherhost", "file://otherhost/etc"}, |
---|
1989 | -#ifdef G_OS_WIN32 |
---|
1990 | +#if defined G_OS_WIN32 || defined __EMX__ |
---|
1991 | { "/etc", "localhost", "file:///etc"}, |
---|
1992 | { "c:\\windows", NULL, "file:///c:/windows"}, |
---|
1993 | { "c:\\windows", "localhost", "file:///c:/windows"}, |
---|
1994 | @@ -76,7 +76,7 @@ |
---|
1995 | { "/ABCDEFGHIJKLMNOPQRSTUVWXYZ", NULL, "file:///ABCDEFGHIJKLMNOPQRSTUVWXYZ"}, |
---|
1996 | { "/abcdefghijklmnopqrstuvwxyz", NULL, "file:///abcdefghijklmnopqrstuvwxyz"}, |
---|
1997 | { "/-_.!~*'()", NULL, "file:///-_.!~*'()"}, |
---|
1998 | -#ifdef G_OS_WIN32 |
---|
1999 | +#if defined G_OS_WIN32 || defined __EMX__ |
---|
2000 | /* As '\\' is a path separator on Win32, it gets turned into '/' in the URI */ |
---|
2001 | { "/\"#%<>[\\]^`{|}\x7F", NULL, "file:///%22%23%25%3C%3E%5B/%5D%5E%60%7B%7C%7D%7F"}, |
---|
2002 | #else |
---|
2003 | @@ -114,7 +114,7 @@ |
---|
2004 | from_uri_tests[] = { |
---|
2005 | { "file:///etc", "/etc"}, |
---|
2006 | { "file:/etc", "/etc"}, |
---|
2007 | -#ifdef G_OS_WIN32 |
---|
2008 | +#if defined G_OS_WIN32 || defined __EMX__ |
---|
2009 | /* On Win32 we don't return "localhost" hostames, just in case |
---|
2010 | * it isn't recognized anyway. |
---|
2011 | */ |
---|
2012 | @@ -139,7 +139,7 @@ |
---|
2013 | { "http://www.yahoo.com/", NULL, NULL, G_CONVERT_ERROR_BAD_URI}, |
---|
2014 | { "file:////etc", "//etc"}, |
---|
2015 | { "file://///etc", "///etc"}, |
---|
2016 | -#ifdef G_OS_WIN32 |
---|
2017 | +#if defined G_OS_WIN32 || defined __EMX__ |
---|
2018 | /* URIs with backslashes come from some nonstandard application, but accept them anyhow */ |
---|
2019 | { "file:///c:\\foo", "c:\\foo"}, |
---|
2020 | { "file:///c:/foo\\bar", "c:\\foo\\bar"}, |
---|
2021 | @@ -269,7 +269,7 @@ |
---|
2022 | } |
---|
2023 | else |
---|
2024 | { |
---|
2025 | -#ifdef G_OS_WIN32 |
---|
2026 | +#if defined G_OS_WIN32 |
---|
2027 | gchar *slash, *p; |
---|
2028 | |
---|
2029 | p = from_uri_tests[i].expected_filename = g_strdup (from_uri_tests[i].expected_filename); |
---|
2030 | @@ -362,7 +362,7 @@ |
---|
2031 | { |
---|
2032 | g_print ("roundtrip test %d failed, hostname modified: " |
---|
2033 | " expected \"%s\", but got \"%s\"\n", |
---|
2034 | - i, to_uri_tests[i].hostname, hostname); |
---|
2035 | + i, to_uri_tests[i].hostname ? to_uri_tests[i].hostname : "", hostname ? hostname : ""); |
---|
2036 | any_failed = TRUE; |
---|
2037 | } |
---|
2038 | |
---|