gutils.inc 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. {*
  2. * gutils.inc
  3. *
  4. * depends on gtypes.inc
  5. *}
  6. {$ifdef WIN32}
  7. { On native Win32, directory separator is the backslash, and search path
  8. separator is the semicolon.
  9. }
  10. const
  11. G_DIR_SEPERATOR = '\';
  12. G_DIR_SEPARATOR_S = '\';
  13. G_SEARCHPATH_SEPARATOR = ';';
  14. G_SEARCHPATH_SEPARATOR_S = ';';
  15. {$else}
  16. { !WIN32 }
  17. { Unix }
  18. const
  19. G_DIR_SEPARATOR = '/';
  20. G_DIR_SEPARATOR_S = '/';
  21. G_SEARCHPATH_SEPARATOR = ':';
  22. G_SEARCHPATH_SEPARATOR_S = ':';
  23. {$endif}
  24. function g_get_user_name:Pgchar;cdecl;external gliblib name 'g_get_user_name';
  25. function g_get_real_name:Pgchar;cdecl;external gliblib name 'g_get_real_name';
  26. function g_get_home_dir:Pgchar;cdecl;external gliblib name 'g_get_home_dir';
  27. function g_get_tmp_dir:Pgchar;cdecl;external gliblib name 'g_get_tmp_dir';
  28. function g_get_prgname:Pgchar;cdecl;external gliblib name 'g_get_prgname';
  29. procedure g_set_prgname(prgname:Pgchar);cdecl;external gliblib name 'g_set_prgname';
  30. type
  31. PGDebugKey = ^TGDebugKey;
  32. TGDebugKey = record
  33. key : Pgchar;
  34. value : guint;
  35. end;
  36. { Miscellaneous utility functions
  37. }
  38. function g_parse_debug_string(_string:Pgchar; keys:PGDebugKey; nkeys:guint):guint;cdecl;external gliblib name 'g_parse_debug_string';
  39. {$IFNDEF KYLIX}
  40. function g_snprintf(_string:Pgchar; n:gulong; format:Pgchar; args:array of const):gint;cdecl;overload;external gliblib name 'g_snprintf';
  41. function g_snprintf(_string:Pgchar; n:gulong; format:Pgchar):gint;cdecl;overload;external gliblib name 'g_snprintf';
  42. function g_vsnprintf(_string:Pgchar; n:gulong; format:Pgchar; args:array of const):gint;cdecl;external gliblib name 'g_vsnprintf';
  43. {$ELSE}
  44. function g_snprintf(_string:Pgchar; n:gulong; format:Pgchar):gint;varargs;cdecl;external gliblib name 'g_snprintf';
  45. function g_vsnprintf(_string:Pgchar; n:gulong; format:Pgchar):gint;varargs;cdecl;external gliblib name 'g_vsnprintf';
  46. {$ENDIF}
  47. { Check if a file name is an absolute path }
  48. function g_path_is_absolute(file_name:Pgchar):gboolean;cdecl;external gliblib name 'g_path_is_absolute';
  49. { In case of absolute paths, skip the root part }
  50. function g_path_skip_root(file_name:Pgchar):Pgchar;cdecl;external gliblib name 'g_path_skip_root';
  51. {DEPRECATED}
  52. { These two functions are deprecated and will be removed in the next
  53. major release of GLib. Use g_path_get_dirname/g_path_get_basename
  54. instead. Whatch out! The string returned by g_path_get_basename
  55. must be g_freed, while the string returned by g_basename must not. }
  56. function g_basename(file_name:Pgchar):Pgchar;cdecl;external gliblib name 'g_basename';
  57. function g_dirname(file_name:Pgchar):Pgchar;cdecl;external gliblib name 'g_path_get_dirname';
  58. { The returned strings are newly allocated with g_malloc() }
  59. function g_get_current_dir:Pgchar;cdecl;external gliblib name 'g_get_current_dir';
  60. function g_path_get_basename(file_name:Pgchar):Pgchar;cdecl;external gliblib name 'g_path_get_basename';
  61. function g_path_get_dirname(file_name:Pgchar):Pgchar;cdecl;external gliblib name 'g_path_get_dirname';
  62. { Set the pointer at the specified location to NULL }
  63. procedure g_nullify_pointer(nullify_location:Pgpointer);cdecl;external gliblib name 'g_nullify_pointer';
  64. { Get the codeset for the current locale }
  65. { gchar g_get_codeset (void); }
  66. { return the environment string for the variable. The returned memory
  67. must not be freed. }
  68. function g_getenv(variable:Pgchar):Pgchar;cdecl;external gliblib name 'g_getenv';
  69. { we try to provide a usefull equivalent for ATEXIT if it is
  70. not defined, but use is actually abandoned. people should
  71. use g_atexit() instead.
  72. }
  73. type
  74. TGVoidFunc = procedure;cdecl;
  75. { we use a GLib function as a replacement for ATEXIT, so
  76. the programmer is not required to check the return value
  77. (if there is any in the implementation) and doesn't encounter
  78. missing include files.
  79. }
  80. procedure g_atexit(func:TGVoidFunc);cdecl;external gliblib name 'g_atexit';
  81. { Look for an executable in PATH, following execvp() rules }
  82. function g_find_program_in_path(_program:Pgchar):Pgchar;cdecl;external gliblib name 'g_find_program_in_path';
  83. { Bit tests
  84. }
  85. function g_bit_nth_lsf(mask:gulong; nth_bit:gint):gint;cdecl;external gliblib name 'g_bit_nth_lsf';
  86. function g_bit_nth_msf(mask:gulong; nth_bit:gint):gint;cdecl;external gliblib name 'g_bit_nth_msf';
  87. function g_bit_storage(number:gulong):guint;cdecl;external gliblib name 'g_bit_storage';
  88. { Trash Stacks
  89. elements need to be >= sizeof (gpointer)
  90. }
  91. type
  92. PPGTrashStack = ^PGTrashStack;
  93. PGTrashStack = ^TGTrashStack;
  94. TGTrashStack = record
  95. next : PGTrashStack;
  96. end;
  97. procedure g_trash_stack_push(stack_p:PPGTrashStack; data_p:gpointer);cdecl;external gliblib name 'g_trash_stack_push';
  98. function g_trash_stack_pop(stack_p:PPGTrashStack):gpointer;cdecl;external gliblib name 'g_trash_stack_pop';
  99. function g_trash_stack_peek(stack_p:PPGTrashStack):gpointer;cdecl;external gliblib name 'g_trash_stack_peek';
  100. function g_trash_stack_height(stack_p:PPGTrashStack):guint;cdecl;external gliblib name 'g_trash_stack_height';
  101. {$IFNDEF KYLIX}
  102. { Glib version.
  103. we prefix variable declarations so they can
  104. properly get exported in windows dlls.
  105. }
  106. var
  107. glib_major_version : guint;external gliblib name 'glib_major_version';
  108. glib_minor_version : guint;external gliblib name 'glib_minor_version';
  109. glib_micro_version : guint;external gliblib name 'glib_micro_version';
  110. glib_interface_age : guint;external gliblib name 'glib_interface_age';
  111. glib_binary_age : guint;external gliblib name 'glib_binary_age';
  112. function GLIB_CHECK_VERSION (major, minor, micro: guint):boolean;
  113. {$ENDIF}