/src/wrappers/glib/library/utilities/glib_windows_compatibility_functions.e

http://github.com/tybor/Liberty · Specman e · 240 lines · 2 code · 77 blank · 161 comment · 0 complexity · b9d8427d13f89c6fae0298f35e3bfaa5 MD5 · raw file

  1. deferred class GLIB_WINDOWS_COMPATIBILITY_FUNCTIONS
  2. -- Windows Compatibility Functions
  3. -- Windows Compatibility Functions -- UNIX emulation on Windows.
  4. -- Synopsis
  5. -- #include <glib.h>
  6. -- #define MAXPATHLEN
  7. -- #define pipe (phandles)
  8. -- gchar* g_win32_error_message (gint error);
  9. -- gchar* g_win32_getlocale (void);
  10. -- gchar* g_win32_get_package_installation_directory
  11. -- (gchar *package,
  12. -- gchar *dll_name);
  13. -- gchar* g_win32_get_package_installation_subdirectory
  14. -- (gchar *package,
  15. -- gchar *dll_name,
  16. -- gchar *subdir);
  17. -- guint g_win32_get_windows_version (void);
  18. -- gchar* g_win32_locale_filename_from_utf8
  19. -- (const gchar *utf8filename);
  20. -- #define G_WIN32_DLLMAIN_FOR_DLL_NAME (static, dll_name)
  21. -- #define G_WIN32_HAVE_WIDECHAR_API ()
  22. -- #define G_WIN32_IS_NT_BASED ()
  23. -- Description
  24. -- These functions provide some level of UNIX emulation on the Windows platform. If
  25. -- your application really needs the POSIX APIs, we suggest you try the Cygwin
  26. -- project.
  27. -- Details
  28. -- MAXPATHLEN
  29. -- #define MAXPATHLEN 1024
  30. -- Provided for UNIX emulation on Windows; equivalent to UNIX macro MAXPATHLEN,
  31. -- which is the maximum length of a filename (including full path).
  32. -- ---------------------------------------------------------------------------------
  33. -- pipe()
  34. -- #define pipe(phandles) _pipe (phandles, 4096, _O_BINARY)
  35. -- Provided for UNIX emulation on Windows; see documentation for pipe() in any UNIX
  36. -- manual.
  37. -- phandles : file descriptors, the first one for reading, the second one for
  38. -- writing.
  39. -- ---------------------------------------------------------------------------------
  40. -- g_win32_error_message ()
  41. -- gchar* g_win32_error_message (gint error);
  42. -- Translate a Win32 error code (as returned by GetLastError()) into the
  43. -- corresponding message. The message is either language neutral, or in the thread's
  44. -- language, or the user's language, the system's language, or US English (see docs
  45. -- for FormatMessage()). The returned string is in UTF-8. It should be deallocated
  46. -- with g_free().
  47. -- error : error code.
  48. -- Returns : newly-allocated error message
  49. -- ---------------------------------------------------------------------------------
  50. -- g_win32_getlocale ()
  51. -- gchar* g_win32_getlocale (void);
  52. -- The setlocale() function in the Microsoft C library uses locale names of the form
  53. -- "English_United States.1252" etc. We want the UNIXish standard form "en_US",
  54. -- "zh_TW" etc. This function gets the current thread locale from Windows - without
  55. -- any encoding info - and returns it as a string of the above form for use in
  56. -- forming file names etc. The returned string should be deallocated with g_free().
  57. -- Returns : newly-allocated locale name.
  58. -- ---------------------------------------------------------------------------------
  59. -- g_win32_get_package_installation_directory ()
  60. -- gchar* g_win32_get_package_installation_directory
  61. -- (gchar *package,
  62. -- gchar *dll_name);
  63. -- Try to determine the installation directory for a software package. Typically
  64. -- used by GNU software packages.
  65. -- package should be a short identifier for the package. Typically it is the same
  66. -- identifier as used for GETTEXT_PACKAGE in software configured according to GNU
  67. -- standards. The function first looks in the Windows Registry for the value
  68. -- #InstallationDirectory in the key #HKLM\Software\package, and if that value
  69. -- exists and is a string, returns that.
  70. -- If package is NULL, or the above value isn't found in the Registry, but dll_name
  71. -- is non-NULL, it should name a DLL loaded into the current process. Typically that
  72. -- would be the name of the DLL calling this function, looking for its installation
  73. -- directory. The function then asks Windows what directory that DLL was loaded
  74. -- from. If that directory's last component is "bin" or "lib", the parent directory
  75. -- is returned, otherwise the directory itself. If that DLL isn't loaded, the
  76. -- function proceeds as if dll_name was NULL.
  77. -- If both package and dll_name are NULL, the directory from where the main
  78. -- executable of the process was loaded is used instead in the same way as above.
  79. -- package : An identifier for a software package, or NULL, in UTF-8
  80. -- dll_name : The name of a DLL that a package provides, or NULL, in UTF-8
  81. -- Returns : a string containing the installation directory for package. The string
  82. -- is in the GLib file name encoding, i.e. UTF-8 on Windows. The return
  83. -- value should be freed with g_free() when not needed any longer.
  84. -- ---------------------------------------------------------------------------------
  85. -- g_win32_get_package_installation_subdirectory ()
  86. -- gchar* g_win32_get_package_installation_subdirectory
  87. -- (gchar *package,
  88. -- gchar *dll_name,
  89. -- gchar *subdir);
  90. -- Returns a newly-allocated string containing the path of the subdirectory subdir
  91. -- in the return value from calling g_win32_get_package_installation_directory()
  92. -- with the package and dll_name parameters.
  93. -- package : An identifier for a software package, in UTF-8, or NULL
  94. -- dll_name : The name of a DLL that a package provides, in UTF-8, or NULL
  95. -- subdir : A subdirectory of the package installation directory, also in UTF-8
  96. -- Returns : a string containing the complete path to subdir inside the
  97. -- installation directory of package. The returned string is in the GLib
  98. -- file name encoding, i.e. UTF-8 on Windows. The return value should be
  99. -- freed with g_free() when no longer needed.
  100. -- ---------------------------------------------------------------------------------
  101. -- g_win32_get_windows_version ()
  102. -- guint g_win32_get_windows_version (void);
  103. -- Returns version information for the Windows operating system the code is running
  104. -- on. See MSDN documentation for the GetVersion() function. To summarize, the most
  105. -- significant bit is one on Win9x, and zero on NT-based systems. The least
  106. -- significant byte is 4 on Windows NT 4, 5 on Windows XP. Software that needs
  107. -- really detailled version and feature information should use Win32 API like
  108. -- GetVersionEx() and VerifyVersionInfo().
  109. -- If there is an environment variable G_WIN32_PRETEND_WIN9X defined (with any
  110. -- value), this function always returns a version code for Windows 9x. This is
  111. -- mainly an internal debugging aid for GTK+ and GLib developers, to be able to
  112. -- check the code paths for Windows 9x.
  113. -- Returns : The version information.
  114. -- Since 2.6
  115. -- ---------------------------------------------------------------------------------
  116. -- g_win32_locale_filename_from_utf8 ()
  117. -- gchar* g_win32_locale_filename_from_utf8
  118. -- (const gchar *utf8filename);
  119. -- Converts a filename from UTF-8 to the system codepage.
  120. -- On NT-based Windows, on NTFS file systems, file names are in Unicode. It is quite
  121. -- possible that Unicode file names contain characters not representable in the
  122. -- system codepage. (For instance, Greek or Cyrillic characters on Western European
  123. -- or US Windows installations, or various less common CJK characters on CJK Windows
  124. -- installations.)
  125. -- In such a case, and if the filename refers to an existing file, and the file
  126. -- system stores alternate short (8.3) names for directory entries, the short form
  127. -- of the filename is returned. Note that the "short" name might in fact be longer
  128. -- than the Unicode name if the Unicode name has very short pathname components
  129. -- containing non-ASCII characters. If no system codepage name for the file is
  130. -- possible, NULL is returned.
  131. -- The return value is dynamically allocated and should be freed with g_free() when
  132. -- no longer needed.
  133. -- utf8filename : a UTF-8 encoded filename.
  134. -- Returns : The converted filename, or NULL on conversion failure and lack of
  135. -- short names.
  136. -- Since 2.8
  137. -- ---------------------------------------------------------------------------------
  138. -- G_WIN32_DLLMAIN_FOR_DLL_NAME()
  139. -- #define G_WIN32_DLLMAIN_FOR_DLL_NAME(static, dll_name)
  140. -- On Windows, this macro defines a DllMain() function that stores the actual DLL
  141. -- name that the code being compiled will be included in.
  142. -- On non-Windows platforms, expands to nothing.
  143. -- static : empty or "static".
  144. -- dll_name : the name of the (pointer to the) char array where the DLL name will be
  145. -- stored. If this is used, you must also include windows.h. If you need
  146. -- a more complex DLL entry point function, you cannot use this.
  147. -- ---------------------------------------------------------------------------------
  148. -- G_WIN32_HAVE_WIDECHAR_API()
  149. -- #define G_WIN32_HAVE_WIDECHAR_API() (G_WIN32_IS_NT_BASED ())
  150. -- On Windows, this macro defines an expression which evaluates to TRUE if the code
  151. -- is running on a version of Windows where the wide character versions of the Win32
  152. -- API functions, and the wide chaacter versions of the C library functions work.
  153. -- (They are always present in the DLLs, but don't work on Windows 9x and Me.)
  154. -- On non-Windows platforms, it is not defined.
  155. -- Since 2.6
  156. -- ---------------------------------------------------------------------------------
  157. -- G_WIN32_IS_NT_BASED()
  158. -- #define G_WIN32_IS_NT_BASED() (g_win32_get_windows_version () < 0x80000000)
  159. -- On Windows, this macro defines an expression which evaluates to TRUE if the code
  160. -- is running on an NT-based Windows operating system.
  161. -- On non-Windows platforms, it is not defined.
  162. -- Since 2.6
  163. end -- class GLIB_WINDOWS_COMPATIBILITY_FUNCTIONS