gwin32.h

Go to the documentation of this file.
00001 /* GLIB - Library of useful routines for C programming
00002  * Copyright (C) 1995-1997  Peter Mattis, Spencer Kimball and Josh MacDonald
00003  *
00004  * This library is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU Lesser General Public
00006  * License as published by the Free Software Foundation; either
00007  * version 2 of the License, or (at your option) any later version.
00008  *
00009  * This library is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * Lesser General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU Lesser General Public
00015  * License along with this library; if not, write to the
00016  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00017  * Boston, MA 02111-1307, USA.
00018  */
00019 
00020 /*
00021  * Modified by the GLib Team and others 1997-2000.  See the AUTHORS
00022  * file for a list of people on the GLib Team.  See the ChangeLog
00023  * files for a list of changes.  These files are distributed with
00024  * GLib at ftp://ftp.gtk.org/pub/gtk/. 
00025  */
00026 
00027 #ifndef __G_WIN32_H__
00028 #define __G_WIN32_H__
00029 
00030 #include <g_types.h>
00031 
00032 #ifdef G_OS_WIN32
00033 
00034 /* Windows emulation stubs for common Unix functions
00035  */
00036 
00037 G_BEGIN_DECLS
00038 
00039 #define MAXPATHLEN 1024
00040 
00041 #ifdef _MSC_VER
00042 typedef int pid_t;
00043 #endif
00044 
00045 /*
00046  * To get prototypes for the following POSIXish functions, you have to
00047  * include the indicated non-POSIX headers. The functions are defined
00048  * in OLDNAMES.LIB (MSVC) or -lmoldname-msvc (mingw32).
00049  *
00050  * getcwd: <direct.h> (MSVC), <io.h> (mingw32)
00051  * getpid: <process.h>
00052  * access: <io.h>
00053  * unlink: <stdio.h> or <io.h>
00054  * open, read, write, lseek, close: <io.h>
00055  * rmdir: <direct.h>
00056  * pipe: <direct.h>
00057  */
00058 
00059 /* pipe is not in OLDNAMES.LIB or -lmoldname-msvc. */
00060 #define pipe(phandles)  _pipe (phandles, 4096, _O_BINARY)
00061 
00062 /* For some POSIX functions that are not provided by the MS runtime,
00063  * we provide emulators in glib, which are prefixed with g_win32_.
00064  */
00065 #    define ftruncate(fd, size) g_win32_ftruncate (fd, size)
00066 
00067 /* -lmingw32 also has emulations for these, but we need our own
00068  * for MSVC anyhow, so we might aswell use them always.
00069  */
00070 #    define opendir             g_win32_opendir
00071 #    define readdir             g_win32_readdir
00072 #    define rewinddir           g_win32_rewinddir
00073 #    define closedir            g_win32_closedir
00074 #    define NAME_MAX 255
00075 
00076 struct dirent
00077 {
00078   gchar  d_name[NAME_MAX + 1];
00079 };
00080 
00081 struct DIR
00082 {
00083   gchar        *dir_name;
00084   gboolean      just_opened;
00085   guint         find_file_handle;
00086   gpointer      find_file_data;
00087   struct dirent readdir_result;
00088 };
00089 typedef struct DIR DIR;
00090 
00091 /* emulation functions */
00092 extern int      g_win32_ftruncate       (gint            f,
00093                                          guint           size);
00094 DIR*            g_win32_opendir         (const gchar    *dirname);
00095 struct dirent*  g_win32_readdir         (DIR            *dir);
00096 void            g_win32_rewinddir       (DIR            *dir);
00097 gint            g_win32_closedir        (DIR            *dir);
00098 
00099 /* The MS setlocale uses locale names of the form "English_United
00100  * States.1252" etc. We want the Unixish standard form "en", "zh_TW"
00101  * etc. This function gets the current thread locale from Windows and
00102  * returns it as a string of the above form for use in forming file
00103  * names etc. The returned string should be deallocated with g_free().
00104  */
00105 gchar *         g_win32_getlocale  (void);
00106 
00107 /* Translate a Win32 error code (as returned by GetLastError()) into
00108  * the corresponding message. The returned string should be deallocated
00109  * with g_free().
00110  */
00111 gchar *         g_win32_error_message (gint error);
00112 
00113 G_END_DECLS
00114 
00115 #endif   /* G_OS_WIN32 */
00116 
00117 #endif /* __G_WIN32_H__ */

Generated on Tue Jul 5 14:14:43 2011 for ROOT_528-00b_version by  doxygen 1.5.1