S60 Open C
glib API Specification

glib API Specification

Table of Contents

API Description
API Categories
Arrays
Asynchronous Queues
Atomic Operations
Automatic String Completion
Balanced Binary Trees
Basic Types
Byte Arrays
Byte Order Macros
Caches
Character Set Conversion
Commandline option parser
Datasets
Date and Time Functions
Double-ended Queues
Doubly Linked lists
Dynamic Loading of Modules
Error Reporting
File Utilities
Glob-style pattern matching
Hash Tables
Hook Functions
Internationalization
IO Channels
Keyed Data Lists
Key-value file parser
Lexical Scanner
Limits of Basic Type
Memory Allocation
Memory Allocators
Memory Chunks
Memory Slices
Message Logging
Message Output and Debugging
Miscellaneous Macros
Miscellaneous Utility Functions
N-ary Trees
Numerical Definitions
Pointer Arrays
Quarks
Random Numbers
Relations and Tuples
Shell-related Utilities
Simple XML Subset Parser
Singly Linked Lists
Spawning Processes
Standard Macros
Strings
String Chunks
String Utility Functions
The Main Event Loop
Threads
Thread Pools
Timers
Trash Stacks
Type Conversion Macros
Unicode Manipulation
Version Information

 


API Description

The glib library is arranged into following categories:

 


API Categories

Following is the classification of the functions.

 


Arrays

This chapter lists arrays of arbitrary elements which grow automatically as elements are added.

Function

Description

GArray Contains the public fields of an Array.
g_array_new Creates a new GArray.
g_array_sized_new Creates a new GArray with reserved_size elements preallocated.
g_array_append_val Adds the value on to the end of the array.
g_array_append_vals Adds len elements onto the end of the array.
g_array_prepend_val Adds the value on to the start of the array.
g_array_prepend_vals Adds len elements onto the start of the array.
g_array_insert_val Inserts an element into an array at the given index.
g_array_insert_vals Inserts len elements into a GArray at the given index.
g_array_remove_index Removes the element at the given index from a GArray.
g_array_remove_index_fast Removes the element at the given index from a GArray.
g_array_remove_range Removes the given number of elements starting at the given index from a GArray.
g_array_sort Sorts a GArray using compare_func .
g_array_sort_with_data Sorts a GArray but the comparison function receives a user data argument.
g_array_index Returns the element of a GArray at the given index.
g_array_set_size Sets the size of the array.
g_array_free Frees the memory allocated for the GArray.

Give feedback of this article

 


Asynchronous Queues

Function

Description

GAsyncQueue The GAsyncQueue struct is an opaque data structure, which represents an asynchronous queue.
g_async_queue_new Creates a new asynchronous queue with the initial reference count of 1.
g_async_queue_ref Increases the reference count of the asynchronous queue by 1.
g_async_queue_unref Decreases the reference count of the asynchronous queue by 1.
g_async_queue_push Pushes the data into the queue. data must not be NULL.
g_async_queue_push_sorted Inserts data into queue using func to determine the new position.
g_async_queue_pop Pops data from the queue. This function blocks until data become available.
g_async_queue_try_pop Tries to pop data from the queue. If no data is available, NULL is returned.
g_async_queue_timed_pop Pops data from the queue. If no data is received before end_time, NULL is returned.
g_async_queue_length Returns the length of the queue.
g_async_queue_sort This function will lock queue before it sorts the queue and unlock it when it is finished.
g_async_queue_lock Acquires the queue's lock.
g_async_queue_unlock Releases the queue's lock.
g_async_queue_ref_unlocked Increases the reference count of the asynchronous queue by 1.
g_async_queue_unref_and_unlock Decreases the reference count of the asynchronous queue by 1 and releases the lock.
g_async_queue_push_unlocked Pushes the data into the queue. data must not be NULL.
g_async_queue_push_sorted_unlocked Inserts data into queue using func to determine the new position.
g_async_queue_pop_unlocked Pops data from the queue. This function blocks until data become available.
g_async_queue_try_pop_unlocked Tries to pop data from the queue. If no data is available, NULL is returned.
g_async_queue_timed_pop_unlocked Pops data from the queue.
g_async_queue_length_unlocked Returns the length of the queue.
g_async_queue_sort_unlocked Sorts queue using func.

Give feedback of this article

 


Atomic Operations

Function

Description

g_atomic_int_get Reads the value of the integer pointed to by atomic.
g_atomic_int_add Sets the value of the integer pointed to by atomic.
g_atomic_int_exchange_and_add Atomically adds val to the integer pointed to by atomic.
g_atomic_int_compare_and_exchange Atomically adds val to the integer pointed to by atomic.
g_atomic_pointer_get Compares oldval with the integer pointed to by atomic and if they are equal, atomically exchanges *atomic with newval.
g_atomic_pointer_compare_and_exchange Reads the value of the pointer pointed to by atomic.
g_atomic_int_inc Sets the value of the pointer pointed to by atomic.
g_atomic_int_dec_and_test Compares oldval with the pointer pointed to by atomic and if they are equal, atomically exchanges *atomic with newval.

Give feedback of this article

 


Automatic String Completion

Function

Description

GCompletion The data structure used for automatic completion.
g_completion_new Creates a new GCompletion.
GCompletionFunc Specifies the type of the function passed to g_completion_new().
g_completion_add_items Adds items to the GCompletion.
g_completion_remove_items Removes items from a GCompletion.
g_completion_clear_items Removes all items from the GCompletion.
g_completion_complete Attempts to complete the string prefix using the GCompletion target items.
g_completion_complete_utf8 Attempts to complete the string prefix using the GCompletion target items.
g_completion_set_compare Attempts to complete the string prefix using the GCompletion target items.
GCompletionStrncmpFunc Specifies the type of the function passed to g_completion_set_compare().
g_completion_free Frees all memory used by the GCompletion.

Give feedback of this article

 


Balanced Binary Trees

This chapter lists functions belonging to Balanced Binary Trees, which are sorted collection of key/value pairs optimized for searching and traversing in order.

Function

Description

GTree The GTree struct is an opaque data structure representing a Balanced Binary Tree.
g_tree_new Creates a new GTree.
g_tree_new_with_data Creates a new GTree with a comparison function that accepts user data.
g_tree_new_full Creates a new GTree and allows to specify functions to free the memory allocated for the key and value that get called when removing the entry from the GTree.
g_tree_insert Inserts a key/value pair into a GTree.
g_tree_replace Inserts a new key and value into a GTree.
g_tree_nnodes Gets the number of nodes in a GTree.
g_tree_height If the GTree contains no nodes, the height is 0.
g_tree_lookup Gets the value corresponding to the given key.
g_tree_lookup_extended Looks up a key in the GTree, returning the original key and the associated value and a gboolean which is TRUE if the key was found.
g_tree_foreach Calls the given function for each of the key/value pairs in the GTree.
g_tree_traverse Calls the given function for each node in the GTree.
GTraverseFunc Specifies the type of function passed to g_tree_traverse().
GTraverseType Specifies the type of traversal performed by g_tree_traverse(), g_node_traverse() and g_node_find().
g_tree_search Searches a GTree using search_func.
g_tree_remove Removes a key/value pair from a GTree.
g_tree_steal Removes a key and its associated value from a GTree without calling the key and value destroy functions.
g_tree_destroy Destroys the GTree.

Give feedback of this article

 


Basic Types

Function

Description

gboolean A standard boolean type.
gpointer An untyped pointer.
gconstpointer An untyped pointer to constant data.
gchar Corresponds to the standard C char type.
guchar Corresponds to the standard C unsigned char type.
gint Corresponds to the standard C int type.
guint Corresponds to the standard C unsigned int type.
gshort Corresponds to the standard C short type.
gushort Corresponds to the standard C unsigned short type.
glong Corresponds to the standard C long type.
gulong Corresponds to the standard C unsigned long type.
gint8 A signed integer guaranteed to be 8 bits on all platforms.
guint8 An unsigned integer guaranteed to be 8 bits on all platforms.
gint16 A signed integer guaranteed to be 16 bits on all platforms.
guint16 An unsigned integer guaranteed to be 16 bits on all platforms.
gint32 A signed integer guaranteed to be 32 bits on all platforms.
guint32 An unsigned integer guaranteed to be 32 bits on all platforms.
G_HAVE_GINT64 This macro is defined if 64-bit signed and unsigned integers are available on the platform.
gint64 A signed integer guaranteed to be 64 bits on all platforms on which it is available
guint64 An unsigned integer guaranteed to be 64 bits on all platforms on which it is available
G_GINT64_CONSTANT This macro is used to insert 64-bit integer literals into the source code.
gfloat This macro is used to insert 64-bit unsigned integer literals into the source code.
gdouble Corresponds to the standard C float type.
gsize An unsigned 32-bit integer intended to represent sizes of data structures.
gssize A signed 32-bit integer intended to represent sizes of data structures.

Give feedback of this article

 


Byte Arrays

GByteArray is based on GArray, to provide arrays of bytes which grow automatically as elements are added.

Function

Description

GByteArray The GByteArray struct allows access to the public fields of a GByteArray.
g_byte_array_new Creates a new GByteArray with reserved_size bytes preallocated
g_byte_array_sized_new Adds the given bytes at the end of the GByteArray.
g_byte_array_append Adds the given bytes at the end of the GByteArray.
g_byte_array_prepend Adds the given data at the start of the GByteArray.
g_byte_array_remove_index Removes the byte at the given index from a GByteArray.
g_byte_array_remove_index_fast Removes the byte at the given index from a GByteArray.
g_byte_array_remove_range Removes the given number of bytes starting at the given index from a GByteArray.
g_byte_array_sort Sorts a byte array, using compare_func
g_byte_array_sort_with_data Sorts a byte array, but the comparison function takes a user data argument.
g_byte_array_set_size Sets the size of the GByteArray.
g_byte_array_free Frees the memory allocated by the GByteArray.

Give feedback of this article

 


Byte Order Macros

Function

Description

G_BYTE_ORDER The host byte order.
G_LITTLE_ENDIAN Specifies one of the possible types of byte order.
G_BIG_ENDIAN Specifies one of the possible types of byte order.
G_PDP_ENDIAN Specifies one of the possible types of byte order (currently unused).
g_htonl Converts a 32-bit integer value from host to network byte order.
g_htons Converts a 16-bit integer value from host to network byte order.
g_ntohl Converts a 32-bit integer value from network to host byte order.
g_ntohs Converts a 16-bit integer value from network to host byte order.
GINT_FROM_BE Converts a gint value from big-endian to host byte order.
GINT_FROM_LE Converts a gint value from little-endian to host byte order.
GINT_TO_BE Converts a gint value from host byte order to big-endian.
GINT_TO_LE Converts a gint value from host byte order to little-endian.
GUINT_FROM_BE Converts a guint value from big-endian to host byte order.
GUINT_FROM_LE Converts a guint value from little-endian to host byte order.
GUINT_TO_BE Converts a guint value from host byte order to big-endian.
GUINT_TO_LE Converts a guint value from host byte order to little-endian.
GLONG_FROM_BE Converts a glong value from big-endian to the host byte order.
GLONG_FROM_LE Converts a glong value from little-endian to host byte order.
GLONG_TO_BE Converts a glong value from host byte order to big-endian.
GLONG_TO_LE Converts a glong value from host byte order to little-endian.
GULONG_FROM_BE Converts a gulong value from big-endian to host byte order.
GULONG_TO_BE Converts a gulong value from little-endian to host byte order.
GULONG_TO_LE Converts a gulong value from host byte order to big-endian.
GINT16_FROM_BE Converts a gulong value from host byte order to little-endian.
GINT16_FROM_LE Converts a gint16 value from big-endian to host byte order.
GINT16_TO_BE Converts a gint16 value from little-endian to host byte order.
GINT16_TO_LE Converts a gint16 value from host byte order to big-endian.
GUINT16_FROM_BE Converts a gint16 value from host byte order to little-endian.
GUINT16_FROM_LE Converts a guint16 value from big-endian to host byte order.
GUINT16_TO_BE Converts a guint16 value from little-endian to host byte order.
GUINT16_TO_LE Converts a guint16 value from host byte order to big-endian.
GINT32_FROM_BE Converts a guint16 value from host byte order to little-endian.
GINT32_FROM_LE Converts a gint32 value from big-endian to host byte order.
GINT32_TO_BE Converts a gint32 value from little-endian to host byte order.
GINT32_TO_LE Converts a gint32 value from host byte order to big-endian.
GUINT32_FROM_BE Converts a gint32 value from host byte order to little-endian.
GUINT32_FROM_LE Converts a guint32 value from big-endian to host byte order.
GUINT32_TO_BE Converts a guint32 value from little-endian to host byte order.
GUINT32_TO_LE Converts a guint32 value from host byte order to big-endian.
GINT64_FROM_BE Converts a guint32 value from host byte order to little-endian.
GINT64_FROM_LE Converts a gint64 value from big-endian to host byte order.
GINT64_TO_BE Converts a gint64 value from little-endian to host byte order.
GINT64_TO_LE Converts a gint64 value from host byte order to big-endian.
GUINT64_FROM_BE Converts a gint64 value from host byte order to little-endian.
GUINT64_FROM_LE Converts a guint64 value from big-endian to host byte order.
GUINT64_TO_BE Converts a guint64 value from little-endian to host byte order.
GUINT64_TO_LE Converts a guint64 value from host byte order to big-endian.
GUINT16_SWAP_BE_PDP Converts a guint16 value between big-endian and pdp-endian byte order.
GUINT16_SWAP_LE_BE Converts a guint16 value between little-endian and big-endian byte order.
GUINT16_SWAP_LE_PDP Converts a guint16 value between little-endian and pdp-endian byte order.
GUINT32_SWAP_BE_PDP Converts a guint32 value between big-endian and pdp-endian byte order.
GUINT32_SWAP_LE_BE Converts a guint32 value between big-endian and pdp-endian byte order.
GUINT32_SWAP_LE_PDP Converts a guint32 value between little-endian and pdp-endian byte order.
GUINT64_SWAP_LE_BE Converts a guint64 value between little-endian and big-endian byte order.

Give feedback of this article

 


Caches

This chapter lists functions of the category Caches.

Function

Description

GCache The GCache struct is an opaque data structure containing information about a GCache.
g_cache_new Creates a new GCache.
g_cache_insert Gets the value corresponding to the given key, creating it if necessary.
g_cache_remove Decreases the reference count of the given value.
g_cache_destroy Frees the memory allocated for the GCache.
g_cache_key_foreach Calls the given function for each of the keys in the GCache.
g_cache_value_foreach Calls the given function for each of the values in the GCache.
GCacheDestroyFunc Specifies the type of the value_destroy_func and key_destroy_func functions passed to g_cache_new().
GCacheDupFunc Specifies the type of the key_dup_func function passed to g_cache_new().
GCacheNewFunc Specifies the type of the value_new_func function passed to g_cache_new().

Give feedback of this article

 


Character Set Conversion

Function

Description

g_convert Converts a string from one character set to another.
g_convert_with_fallback Converts a string from one character set to another, possibly including fallback sequences for characters not representable in the output.
GIConv The GIConv struct wraps an iconv() conversion descriptor. It contains private data and should only be accessed using the following functions.
g_convert_with_iconv Converts a string from one character set to another.
G_CONVERT_ERROR Error domain for character set conversions.
g_iconv_open Same as the standard UNIX routine iconv_open(), but may be implemented via libiconv on UNIX flavors that lack a native implementation.
g_iconv Same as the standard UNIX routine iconv(), but may be implemented via libiconv on UNIX flavors that lack a native implementation.
g_iconv_close Same as the standard UNIX routine iconv_close(), but may be implemented via libiconv on UNIX flavors that lack a native implementation.
g_locale_to_utf8 Converts a string which is in the encoding used for strings by the C runtime (usually the same as that used by the operating system) in the current locale into a UTF-8 string.
g_filename_to_utf8 Converts a string which is in the encoding used by GLib for filenames into a UTF-8 string. Note that on Windows GLib uses UTF-8 for filenames.
g_filename_from_utf8 Converts a string from UTF-8 to the encoding GLib uses for filenames. Note that on Windows GLib uses UTF-8 for filenames.
g_filename_from_uri Converts an escaped ASCII-encoded URI to a local filename in the encoding used for filenames.
g_filename_to_uri Converts an absolute filename to an escaped ASCII-encoded URI.
g_get_filename_charsets Determines the preferred character sets used for filenames.
g_filename_display_name Converts a filename into a valid UTF-8 string.
g_filename_display_basename Returns the display basename for the particular filename, guaranteed to be valid UTF-8.
g_uri_list_extract_uris Splits an URI list conforming to the text/uri-list mime type defined in RFC 2483 into individual URIs, discarding any comments.
g_locale_from_utf8 Converts a string from UTF-8 to the encoding used for strings by the C runtime (usually the same as that used by the operating system) in the current locale.
GConvertError Error codes returned by character set conversion routines.
g_get_charset Obtains the character set for the current locale; use this character set as an argument to g_convert(), to convert from the current locale's encoding to some other encoding.

Give feedback of this article

 


Commandline option parser

Function

Description

GOptionError Error codes returned by option parsing.
G_OPTION_ERROR Error domain for option parsing.
GOptionArgFunc The type of function to be passed as callback for G_OPTION_ARG_CALLBACK options.
GOptionContext A GOptionContext struct defines which options are accepted by the commandline option parser.
g_option_context_new Creates a new option context.
g_option_context_free Frees context and all the groups which have been added to it.
g_option_context_parse Parses the command line arguments, recognizing options which have been added to context.
g_option_context_set_help_enabled Enables or disables automatic generation of --help output.
g_option_context_get_help_enabled Returns whether automatic --help generation is turned on for context.
g_option_context_set_ignore_unknown_options Sets whether to ignore unknown options or not.
g_option_context_get_ignore_unknown_options Returns whether unknown options are ignored or not.
GOptionArg The GOptionArg enum values determine which type of extra argument the options expect to find.
GOptionFlags Flags which modify individual options.
G_OPTION_REMAINING If a long option in the main group has this name, it is not treated as a regular option.
GOptionEntry A GOptionEntry defines a single option.
g_option_context_add_main_entries A convenience function which creates a main group if it doesn't exist, adds the entries to it and sets the translation domain.
GOptionGroup A GOptionGroup struct defines the options in a single group. The struct has only private fields and should not be directly accessed.
g_option_context_add_group Adds a GOptionGroup to the context, so that parsing with context will recognize the options in the group.
g_option_context_set_main_group Sets a GOptionGroup as main group of the context.
g_option_context_get_main_group Returns a pointer to the main group of context.
g_option_group_new Creates a new GOptionGroup.
g_option_group_free Frees a GOptionGroup. Note: do not free groups which have been added to a GOptionContext.
g_option_group_add_entries Adds the options specified in entries to group.
GOptionParseFunc The type of function that can be called before and after parsing.
g_option_group_set_parse_hooks Associates two functions with group which will be called from g_option_context_parse() before the first option is parsed and after the last option has been parsed, respectively.
GOptionErrorFunc The type of function to be used as callback when a parse error occurs.
g_option_group_set_error_hook Associates a function with group which will be called from g_option_context_parse() when an error occurs.
GTranslateFunc The type of functions which are used to translate user-visible strings, for --help output.
g_option_group_set_translate_func Sets the function which is used to translate user-visible strings, for --help output.
g_option_group_set_translation_domain A convenience function to use gettext() for translating user-visible strings.

Give feedback of this article

 


Datasets

This chapter lists functions of the category Datasets.

Function

Description

g_dataset_id_set_data Sets the data element associated with the given GQuark id.
g_dataset_id_set_data_full Sets the data element associated with the given GQuark id, and also the function to call when the data element is destroyed.
GDestroyNotify Specifies the type of function which is called when a data element is destroyed.
g_dataset_id_get_data Gets the data element corresponding to a GQuark.
g_dataset_id_remove_data Removes a data element from a dataset.
g_dataset_id_remove_no_notify Removes an element, without calling its destroy notification function.
g_dataset_set_data Sets the data corresponding to the given string identifier.
g_dataset_set_data_full Sets the data corresponding to the given string identifier, and the function to call when the data element is destroyed.
g_dataset_get_data Gets the data element corresponding to a string.
g_dataset_remove_data Removes a data element corresponding to a string.
g_dataset_remove_no_notify Removes an element, without calling its destroy notifier.
g_dataset_foreach Calls the given function for each data element which is associated with the given location.
GDataForeachFunc Specifies the type of function passed to g_dataset_foreach().
g_dataset_destroy Destroys the dataset, freeing all memory allocated, and calling any destroy functions set for data elements.

Give feedback of this article

 


Date and Time Functions

Function

Description

G_USEC_PER_SEC Number of microseconds in one second (1 million). This macro is provided for code readability.
GTimeVal Represents a precise time, with seconds and microseconds.
g_get_current_time Equivalent to the UNIX gettimeofday() function, but portable.
g_usleep Pauses the current thread for the given number of microseconds.
g_time_val_add Adds the given number of microseconds to time_. microseconds can also be negative to decrease the value of time_.
GDate Represents a day between January 1, Year 1 and a few thousand years in the future.
GTime Simply a replacement for time_t. Unrelated to GTimer.
GDateDMY This enumeration is not used in the API, but may be useful to mark a number as a day, month, or year.
GDateDay Integer representing a day of the month; between 1 and 31. G_DATE_BAD_DAY represents an invalid day of the month.
GDateMonth Enumeration representing a month; values are G_DATE_JANUARY, G_DATE_FEBRUARY, etc. G_DATE_BAD_MONTH is the invalid value.
GDateYear Integer representing a year; G_DATE_BAD_YEAR is the invalid value. The year must be 1 or higher; negative (BC) years are not allowed. The year is represented with four digits.
GDateWeekday Enumeration representing a day of the week; G_DATE_MONDAY, G_DATE_TUESDAY, etc. G_DATE_BAD_WEEKDAY is an invalid weekday.
G_DATE_BAD_DAY Represents an invalid GDateDay.
G_DATE_BAD_JULIAN Represents an invalid Julian day number.
G_DATE_BAD_YEAR Represents an invalid year.
g_date_new Allocates a GDate and initializes it to a sane state.
g_date_new_dmy Like g_date_new(), but also sets the value of the date.
g_date_new_julian Like g_date_new(), but also sets the value of the date.
g_date_free Initializes one or more GDate structs to a sane but invalid state.
g_date_clear Frees a GDate returned from g_date_new().
g_date_set_day Sets the day of the month for a GDate. If the resulting day-month-year triplet is invalid, the date will be invalid.
g_date_set_month Sets the month of the year for a GDate. If the resulting day-month-year triplet is invalid, the date will be invalid.
g_date_set_year Sets the year for a GDate. If the resulting day-month-year triplet is invalid, the date will be invalid.
g_date_set_dmy Sets the value of a GDate from a day, month, and year.
g_date_set_julian Sets the value of a GDate from a Julian day number.
g_date_set_time Sets the value of a date from a GTime value.
g_date_set_parse Sets the value of a date from a time_t value.
g_date_add_days Sets the value of a date from a GTimeVal value.
g_date_subtract_days Parses a user-inputted string str, and try to figure out what date it represents, taking the current locale into account.
g_date_add_months Increments a date some number of days. To move forward by weeks, add weeks*7 days. The date must be valid.
g_date_subtract_months Moves a date some number of days into the past. To move by weeks, just move by weeks*7 days. The date must be valid.
g_date_add_years Increments a date by some number of months.
g_date_subtract_years Moves a date some number of months into the past.
g_date_days_between Increments a date by some number of years.
g_date_compare Moves a date some number of years into the past.
g_date_clamp Computes the number of days between two dates.
g_date_order qsort()-style comparsion function for dates. Both dates must be valid.
g_date_get_day If date is prior to min_date, sets date equal to min_date.
g_date_get_month Checks if date1 is less than or equal to date2, and swap the values if this is not the case.
g_date_get_year Returns the day of the month. The date must be valid.
g_date_get_julian Returns the month of the year. The date must be valid.
g_date_get_julian Returns the year of a GDate. The date must be valid.
g_date_get_day_of_year Returns the Julian day or "serial number" of the GDate.
g_date_get_days_in_month Returns the day of the week for a GDate. The date must be valid.
g_date_is_first_of_month Returns the day of the year, where Jan 1 is the first day of the year. The date must be valid.
g_date_is_last_of_month Returns the number of days in a month, taking leap years into account.
g_date_is_leap_year Returns TRUE if the date is on the first of a month. The date must be valid.
g_date_get_monday_week_of_year Returns TRUE if the date is the last day of the month. The date must be valid.
g_date_get_monday_weeks_in_year Returns TRUE if the year is a leap year.
g_date_get_sunday_week_of_year Returns the week of the year, where weeks are understood to start on Monday
g_date_get_sunday_weeks_in_year Returns the number of weeks in the year, where weeks are taken to start on Monday.
g_date_get_iso8601_week_of_year Returns the week of the year during which this date falls, if weeks are understood to being on Sunday.
g_date_strftime Generates a printed representation of the date, in a locale-specific way.
g_date_to_struct_tm Fills in the date-related bits of a struct tm using the date value. Initializes the non-date parts with something sane but meaningless.
g_date_valid Generates a printed representation of the date, in a locale-specific way.Returns TRUE if the GDate represents an existing day.
g_date_valid_day Returns TRUE if the day of the month is valid (a day is valid if it's between 1 and 31 inclusive).
g_date_valid_month Returns TRUE if the month value is valid. The 12 GDateMonth enumeration values are the only valid months.
g_date_valid_year Returns TRUE if the year is valid. Any year greater than 0 is valid, though there is a 16-bit limit to what GDate will understand.
g_date_valid_dmy Returns TRUE if the day-month-year triplet forms a valid, existing day in the range of days GDate understands (Year 1 or later, no more than a few thousand years in the future).
g_date_valid_julian Returns TRUE if the Julian day is valid. Anything greater than zero is basically a valid Julian, though there is a 32-bit limit.
g_date_valid_weekday Returns TRUE if the weekday is valid. The 7 GDateWeekday enumeration values are the only valid weekdays.

Give feedback of this article

 


Double-ended Queues

This chapter lists GQueue structure and its associated functions, which provide a standard queue data structure.

Function

Description

GQueue Contains the public fields of a Queue.
g_queue_new Creates a new GQueue.
g_queue_free Frees the memory allocated for the GQueue.
g_queue_is_empty Returns TRUE if the queue is empty.
g_queue_get_length Returns the number of items in queue.
g_queue_reverse Reverses the order of the items in queue.
g_queue_copy Copies a queue.
g_queue_foreach Calls func for each element in the queue passing user_data to the function.
g_queue_find Finds the first link in queue which contains data.
g_queue_find_custom Finds an element in a GQueue, using a supplied function to find the desired element.
g_queue_sort Sorts queue using compare_func.
g_queue_push_head Adds a new element at the head of the queue.
g_queue_push_tail Adds a new element at the tail of the queue
g_queue_push_nth Inserts a new element into queue at the given position
g_queue_pop_head Removes the first element of the queue.
g_queue_pop_tail Removes the last element of the queue.
g_queue_pop_nth Removes the n'th element of queue.
g_queue_peek_head Returns the first element of the queue.
g_queue_peek_tail Returns the last element of the queue.
g_queue_peek_nth Returns the n'th element of queue.
g_queue_index Returns the position of link_ in queue.
g_queue_unlink Unlinks link_ so that it will no longer be part of queue.
g_queue_delete_link Removes link_ from queue and frees it.

Give feedback of this article

 


Doubly Linked lists

This section lists functions containing integer values or pointers to data, which have the ability to iterate over the list in both directions.

Character classification

Function

Description

GList The GList struct is used for each element in a doubly-linked list.
g_list_append Adds a new element at the end of the list.
g_list_prepend Adds a new element at the start of the list.
g_list_insert Inserts a new element at the given point in the list.
g_list_insert_before Inserts a new element before the given point in the list.
g_list_insert_sorted Inserts a new element in the list, using the given comparison function to determine its position.
g_list_remove Removes an element from a GList.
g_list_remove_link Removes an element from GList, without freeing the element.
g_list_delete_link Deletes the node link_ from list.
g_list_remove_all Removes all list nodes with data equal to data.
g_list_free Frees all of the memory used by a GList.
g_list_alloc Allocates space for one GList element.
g_list_free_1 Frees one GList element.
g_list_length Gets the number of elements in a GList.
g_list_copy Copies a GList.
g_list_reverse Reverses a GList.
g_list_sort Sorts a GList using the given comparison function.
GCompareFunc Specifies the type of a comparison function used to compare two values.
g_list_sort_with_data Sorts a GList using the given comparison function and also accepts user data arguments for comparing.
GCompareDataFunc Specifies the type of a comparison function used to compare two values.
g_list_concat Adds the second GList to the end of the first GList.
g_list_foreach Calls a function for each element of a GList.
GFunc Specifies the type of functions passed to g_list_foreach() and g_slist_foreach().
g_list_first Gets the first element in a GList.
g_list_last Gets the last element in a GList.
g_list_previous A macro used to get the previous element in a GList.
g_list_next A macro used to get the next element in a GList.
g_list_nth Gets the element at the given position in a GList.
g_list_nth_data Gets the data of the element at the given position.
g_list_nth_prev Gets the element n and places before list.
g_list_find Finds the element in a GList which contains the given data.
g_list_find_custom Finds an element in a GList, using a supplied function to find the desired element.
g_list_position Gets the position of the given element in the GList (starting from 0).
g_list_index Gets the position of the element containing the given data (starting from 0).
g_list_push_allocator Sets the allocator to use to allocate GList elements.
g_list_pop_allocator Restores the previous GAllocator used when allocating GList elements.

Give feedback of this article

 


Dynamic Loading of Modules

Function

Description

GModule The GModule struct is an opaque data structure to represent a Dynamically-Loaded Module.
g_module_supported Checks if modules are supported on the current platform.
g_module_build_path A portable way to build the filename of a module.
g_module_open Opens a module.
GModuleFlags Flags passed to g_module_open().
g_module_symbol Gets a symbol pointer from a module.
g_module_name Gets the filename from a GModule.
g_module_make_resident Ensures that a module will never be unloaded.
g_module_close Closes a module.
g_module_error Gets a string describing the last module error.
GModuleCheckInit Specifies the type of the module initialization function.
GModuleUnload Specifies the type of the module function called when it is unloaded.
G_MODULE_SUFFIX Expands to the proper shared library suffix for the current platform without the leading dot.
G_MODULE_EXPORT Used to declare functions exported by modules.
G_MODULE_IMPORT Used to declare functions imported from modules.

Give feedback of this article

 


Error Reporting

Function

Description

GError The GError structure contains information about an error that has occurred.
g_error_new Creates a new GError with the given domain and code, and a message formatted with format.
g_error_new_literal Creates a new GError; unlike g_error_new(), message is not a printf()-style format string.
g_error_free Frees a GError and associated resources.
g_error_copy Makes a copy of error.
g_error_matches Returns TRUE if error matches domain and code, FALSE otherwise.
g_error_matches Does nothing if err is NULL; if err is non-NULL, then *err must be NULL. A new GError is created and assigned to *err.
g_propagate_error If dest is NULL, free src; otherwise, moves src into *dest. *dest must be NULL.
g_clear_error If err is NULL, does nothing. If err is non-NULL, calls g_error_free() on *err and sets *err to NULL.

Give feedback of this article

 


File Utilities

Function

Description

GFileError Values corresponding to errno codes returned from file operations on UNIX.
G_FILE_ERROR Error domain for file operations.
GFileTest A test to perform on a file using g_file_test().
g_file_error_from_errno Gets a GFileError constant based on the passed-in errno.
g_file_get_contents Reads an entire file into allocated memory, with good error checking.
g_file_set_contents Writes all of contents to a file named filename, with good error checking.
g_file_test Returns TRUE if any of the tests in the bitfield test are TRUE.
g_mkstemp Opens a temporary file.
g_file_open_tmp Opens a file for writing in the preferred directory for temporary files (as returned by g_get_tmp_dir()).
g_file_read_link Reads the contents of the symbolic link filename like the POSIX readlink() function.
g_mkdir_with_parents Create a directory if it doesn't already exist.
GDir An opaque structure representing an opened directory.
g_dir_open Opens a directory for reading.
g_dir_read_name Retrieves the name of the next entry in the directory.
g_dir_rewind Resets the given directory.
g_dir_close Closes the directory and deallocates all related resources.
GMappedFile The GMappedFile represents a file mapping created with g_mapped_file_new().
g_mapped_file_new Maps a file into memory.
g_mapped_file_free Unmaps the buffer of file and frees it.
g_mapped_file_get_length Returns the length of the contents of a GMappedFile.
g_mapped_file_get_contents Returns the contents of a GMappedFile.
g_open A wrapper for the POSIX open() function.
g_rename A wrapper for the POSIX rename() function.
g_mkdir A wrapper for the POSIX mkdir() function.
g_stat A wrapper for the POSIX stat() function.
g_lstat A wrapper for the POSIX lstat() function.
g_unlink A wrapper for the POSIX unlink() function.
g_remove A wrapper for the POSIX remove() function.
g_rmdir A wrapper for the POSIX rmdir() function.
g_fopen A wrapper for the POSIX fopen() function.
g_freopen A wrapper for the POSIX freopen() function.
g_chmod A wrapper for the POSIX chmod() function.
g_access A wrapper for the POSIX access() function.
g_creat A wrapper for the POSIX creat() function.
g_chdir A wrapper for the POSIX chdir() function.

Give feedback of this article

 


Glob-style pattern matching

Function

Description

GPatternSpec A GPatternSpec is the 'compiled' form of a pattern. This structure is opaque and its fields cannot be accessed directly.
g_pattern_spec_new Compiles a pattern to a GPatternSpec.
g_pattern_spec_free Frees the memory allocated for the GPatternSpec.
g_pattern_spec_equal Compares two compiled pattern specs and returns whether they will match the same set of strings.
g_pattern_match Matches a string against a compiled pattern. Passing the correct length of the string given is mandatory.
g_pattern_match_string Matches a string against a compiled pattern.
g_pattern_match_simple Matches a string against a pattern given as a string.

Give feedback of this article

 


Hash Tables

This chapter lists functions that provide associations between optimized keys and values, so that given a key, the associated value can be found very quickly.

Function

Description

GHashTable The GHashTable struct is an opaque data structure to represent a Hash Table.
g_hash_table_new Creates a new GHashTable.
g_hash_table_new_full Creates a new GHashTable. and allows to specify functions to free the memory allocated.
GHashFunc Specifies the type of the hash function which is passed to g_hash_table_new() when a GHashTable is created.
GEqualFunc Specifies the type of a function used to test two values for equality.
g_hash_table_insert Inserts a new key and value into a GHashTable.
g_hash_table_replace Inserts a new key and value into a GHashTable.
g_hash_table_size Returns the number of elements contained in the GHashTable.
g_hash_table_lookup Looks up a key in a GHashTable.
g_hash_table_lookup_extended Looks up a key in the GHashTable.
g_hash_table_foreach Calls the given function for each of the key/value pairs in the GHashTable.
g_hash_table_find Calls the given function for key/value pairs in the GHashTable until predicate returns TRUE.
GHFunc Specifies the type of the function passed to g_hash_table_foreach().
g_hash_table_remove Removes a key and its associated value from a GHashTable.
g_hash_table_steal Removes a key and its associated value from a GHashTable without calling the key and value destroy functions.
g_hash_table_foreach_remove Calls the given function for each key/value pair in the GHashTable.
g_hash_table_foreach_steal Calls the given function for each key/value pair in the GHashTable.
GHRFunc Specifies the type of the function passed to g_hash_table_foreach_remove().
g_hash_table_freeze This function is deprecated and will be removed in the next major release of GLib.
g_hash_table_thaw This function is deprecated and will be removed in the next major release of GLib. It does nothing.
g_hash_table_destroy Destroys the GHashTable.
g_direct_equal Compares two gpointer arguments and returns TRUE if they are equal.
g_direct_hash Converts a gpointer to a hash value.
g_int_equal Compares the two gint values being pointed to and returns TRUE if they are equal.
g_int_hash Converts a pointer to a gint to a hash value.
g_str_equal Compares two strings and returns TRUE if they are equal.
g_str_hash Converts a string to a hash value.

Give feedback of this article

 


Hook Functions

Function

Description

GHookList The GHookList struct represents a list of hook functions.
GHook The GHook struct represents a single hook function in a GHookList.
GHookFinalizeFunc Defines the type of function to be called when a hook in a list of hooks gets finalized.
GHookFunc Defines the type of a hook function that can be invoked by g_hook_list_invoke().
GHookCheckFunc Defines the type of a hook function that can be invoked by g_hook_list_invoke_check().
g_hook_list_init Initializes a GHookList. This must be called before the GHookList is used.
g_hook_list_invoke Calls all of the GHook functions in a GHookList.
g_hook_list_invoke_check Calls all of the GHook functions in a GHookList. Any function which returns FALSE is removed from the GHookList.
g_hook_list_marshal Calls a function on each valid GHook.
GHookMarshaller Defines the type of function used by g_hook_list_marshal().
g_hook_list_marshal_check Calls a function on each valid GHook and destroys it if the function returns FALSE.
GHookCheckMarshaller Defines the type of function used by g_hook_list_marshal_check().
g_hook_list_clear Removes all the GHook elements from a GHookList.
g_hook_alloc Allocates space for a GHook and initializes it.
g_hook_append Appends a GHook onto the end of a GHookList.
g_hook_prepend Prepends a GHook on the start of a GHookList.
g_hook_insert_before Inserts a GHook into a GHookList, before a given GHook.
g_hook_insert_sorted Inserts a GHook into a GHookList, sorted by the given function.
GHookCompareFunc Defines the type of function used to compare GHook elements in g_hook_insert_sorted().
g_hook_compare_ids Compares the ids of two GHook elements, returning a negative value if the second id is greater than the first.
g_hook_get Returns the GHook with the given id, or NULL if it is not found.
g_hook_find Finds a GHook in a GHookList using the given function to test for a match. .
GHookFindFunc Defines the type of the function passed to g_hook_find().
g_hook_find_data Finds a GHook in a GHookList with the given data.
g_hook_find_func Finds a GHook in a GHookList with the given function.
g_hook_find_func_data Finds a GHook in a GHookList with the given function and data.
g_hook_first_valid Returns the first GHook in a GHookList which has not been destroyed.
g_hook_next_valid Returns the next GHook in a GHookList which has not been destroyed.
GHookFlagMask Flags used internally in the GHook implementation.
G_HOOK_FLAGS Returns the flags of a hook.
G_HOOK_FLAG_USER_SHIFT The position of the first bit which is not reserved for internal use be the GHook implementation, i.e. 1 << G_HOOK_FLAG_USER_SHIFT is the first bit which can be used for application-defined flags.
G_HOOK Casts a pointer to a GHook*.
G_HOOK_IS_VALID Returns TRUE if the GHook is valid, i.e. it is in a GHookList, it is active and it has not been destroyed.
G_HOOK_ACTIVE Returns TRUE if the GHook is active, which is normally TRUE until the GHook is destroyed.
G_HOOK_IN_CALL Returns TRUE if the GHook function is currently executing.
G_HOOK_IS_UNLINKED Returns TRUE if the GHook is not in a GHookList.
g_hook_ref Increments the reference count for a GHook.
g_hook_unref Decrements the reference count of a GHook. If the reference count falls to 0, the GHook is removed from the GHookList and g_hook_free() is called to free it.
g_hook_free Calls the GHookList hook_free function if it exists, and frees the memory allocated for the GHook.
g_hook_destroy Destroys a GHook, given its ID.
g_hook_destroy_link Removes one GHook from a GHookList, marking it inactive and calling g_hook_unref() on it.

Give feedback of this article

 


Internationalization

Function

Description

_() Marks a string for translation, gets replaced with the translated string at runtime.
Q_ Like _(), but applies g_strip_context() to the translation. This has the advantage that the string can be adorned with a prefix to guarantee uniqueness and provide context to the translator.
N_ Marks a string for translation, gets replaced with the untranslated string at runtime. This is useful in situations where the translated strings can't be directly used, e.g. in string array initializers.
g_strip_context An auxiliary function for gettext() support.
g_get_language_names Computes a list of applicable locale names, which can be used to e.g. construct locale-dependent filenames or search paths. The returned list is sorted from most desirable to least desirable and always contains the default locale "C".

Give feedback of this article

 


IO Channels

Function

Description

GIOChannel A data structure representing an IO Channel.
g_io_channel_unix_new Creates a new GIOChannel given a file descriptor.
g_io_channel_unix_get_fd Returns the file descriptor of the GIOChannel.
g_io_channel_win32_new_fd Creates a new GIOChannel given a file descriptor on Windows.
g_io_channel_win32_new_socket Creates a new GIOChannel given a socket on Windows.
g_io_channel_win32_new_messages Creates a new GIOChannel given a window handle on Windows.
g_io_channel_init Initializes a GIOChannel struct.
g_io_channel_new_file Open a file filename as a GIOChannel using mode mode.
g_io_channel_read_chars Replacement for g_io_channel_read() with the new API.
g_io_channel_read_unichar This function cannot be called on a channel with NULL encoding.
g_io_channel_read_line Reads a line, including the terminating character(s), from a GIOChannel into a newly-allocated string.
g_io_channel_read_line_string Reads a line from a GIOChannel, using a GString as a buffer.
g_io_channel_read_to_end Reads all the remaining data from the file.
g_io_channel_write_chars Replacement for g_io_channel_write() with the new API.
g_io_channel_write_unichar This function cannot be called on a channel with NULL encoding.
g_io_channel_flush Flushes the write buffer for the GIOChannel.
g_io_channel_seek_position Replacement for g_io_channel_seek() with the new API.
GSeekType An enumeration specifying the base position for a g_io_channel_seek_position() operation.
g_io_channel_shutdown Close an IO channel.
GIOStatus Stati returned by most of the GIOFuncs functions.
GIOChannelError Error codes returned by GIOChannel operations.
G_IO_CHANNEL_ERROR Error domain for GIOChannel operations.
g_io_channel_error_from_errno Converts an errno error number to a GIOChannelError.
g_io_channel_ref Increments the reference count of a GIOChannel.
g_io_channel_unref Decrements the reference count of a GIOChannel.
g_io_create_watch Creates a GSource that's dispatched when condition is met for the given channel.
g_io_add_watch Adds the GIOChannel into the main event loop with the default priority.
g_io_add_watch_full Adds the GIOChannel into the main event loop with the given priority.
GIOCondition A bitwise combination representing a condition to watch for on an event source.
GIOFunc Specifies the type of function passed to g_io_add_watch() or g_io_add_watch_full(), which is called when the requested condition on a GIOChannel is satisfied.
g_io_channel_get_buffer_size A table of functions used to handle different types of GIOChannel in a generic way.
g_io_channel_set_buffer_size Gets the buffer size.
g_io_channel_get_buffer_condition Sets the buffer size.
g_io_channel_get_flags This function returns a GIOCondition depending on whether there is data to be read/space to write data in the internal buffers in the GIOChannel.
g_io_channel_set_flags Gets the current flags for a GIOChannel, including read-only flags such as G_IO_FLAG_IS_READABLE.
GIOFlags Sets the (writeable) flags in channel to (flags & G_IO_CHANNEL_SET_MASK).
g_io_channel_get_line_term Specifies properties of a GIOChannel.
g_io_channel_set_line_term This sets the string that GIOChannel uses to determine where in the file a line break occurs.
g_io_channel_get_buffered Returns whether channel is buffered.
g_io_channel_set_buffered The buffering state can only be set if the channel's encoding is NULL. For any other encoding, the channel must be buffered.
g_io_channel_get_encoding Gets the encoding for the input/output of the channel.
g_io_channel_set_encoding Sets the encoding for the input/output of the channel.
g_io_channel_get_close_on_unref Returns whether the file/socket/whatever associated with channel will be closed when channel receives its final unref and is destroyed.
g_io_channel_set_close_on_unref Setting this flag to TRUE for a channel already closed can cause problems.
g_io_channel_read Reads data from a GIOChannel.
GIOError GIOError is only used by the deprecated functions g_io_channel_read(), g_io_channel_write(), and g_io_channel_seek().
g_io_channel_write Writes data to a GIOChannel.
g_io_channel_seek Sets the current position in the GIOChannel, similar to the standard library function fseek().
g_io_channel_close Closes an IO channel.

Give feedback of this article

 


Keyed Data Lists

This chapter lists functions belonging to Keyed Data Lists.

Function

Description

GData The GData struct is an opaque data structure to represent a Keyed Data List.
g_datalist_init Resets the datalist to NULL.
g_datalist_id_set_data Sets the data corresponding to the given GQuark id.
g_datalist_id_set_data_full Sets the data corresponding to the given GQuark id, and the function to be called when the element is removed from the datalist.
g_datalist_id_get_data Retrieves the data element corresponding to key_id.
g_datalist_id_remove_data Removes an element, using its GQuark identifier.
g_datalist_id_remove_no_notify Removes an element, without calling its destroy notification function.
g_datalist_set_data Sets the data element corresponding to the given string identifier.
g_datalist_set_data_full Sets the data element corresponding to the given string identifier, and the function to be called when the data element is removed.
g_datalist_get_data Gets a data element, using its string identifer.
g_datalist_remove_data Removes an element using its string identifier.
g_datalist_remove_no_notify Removes an element, without calling its destroy notifier.
g_datalist_foreach Calls the given function for each data element of the datalist.
g_datalist_clear Frees all the data elements of the datalist.
g_datalist_set_flags Turns on flag values for a data list.
g_datalist_unset_flags Turns off flag values for a data list.
g_datalist_get_flags Gets flags values packed in together with the datalist.
G_DATALIST_FLAGS_MASK A bit-mask that restricts the possible flags passed to g_datalist_set_flags().

Give feedback of this article

 


Key-value file parser

Function

Description

GKeyFile The GKeyFile struct contains only private fields and should not be used directly.
G_KEY_FILE_ERROR Error domain for key file parsing.
GKeyFileError Error codes returned by key file parsing.
GKeyFileFlags Flags which influence the parsing.
g_key_file_new Creates a new empty GKeyFile object.
g_key_file_free Frees a GKeyFile.
g_key_file_set_list_separator Sets the character which is used to separate values in lists.
g_key_file_load_from_file Loads a key file into an empty GKeyFile structure.
g_key_file_load_from_data Loads a key file from memory into an empty GKeyFile structure.
g_key_file_load_from_data_dirs This function looks for a key file named file in the paths returned from g_get_user_data_dir() and g_get_system_data_dirs(), loads the file into key_file and returns the file's full path in full_path.
g_key_file_to_data This function outputs key_file as a string.
g_key_file_get_start_group Returns the name of the start group of the file.
g_key_file_get_groups Returns all groups in the key file loaded with key_file. The array of returned groups will be NULL-terminated, so length may optionally be NULL.
g_key_file_get_keys Returns all keys for the group name group_name.
g_key_file_has_group Looks whether the key file has the group group_name.
g_key_file_has_key Looks whether the key file has the key key in the group group_name.
g_key_file_get_value Returns the value associated with key under group_name.
g_key_file_get_string Returns the value associated with key under group_name.
g_key_file_get_locale_string Returns the value associated with key under group_name translated in the given locale if available.
g_key_file_get_boolean Returns the value associated with key under group_name as a boolean.
g_key_file_get_integer Returns the value associated with key under group_name as an integer.
g_key_file_get_string_list Returns the values associated with key under group_name.
g_key_file_get_locale_string_list Returns the values associated with key under group_name translated in the given locale if available.
g_key_file_get_boolean_list Returns the values associated with key under group_name as booleans.
g_key_file_get_integer_list Returns the values associated with key under group_name as integers.
g_key_file_get_comment Retrieves a comment above key from group_name. group_name.
g_key_file_set_value Associates a new value with key under group_name.
g_key_file_set_string Associates a new string value with key under group_name.
g_key_file_set_locale_string Associates a string value for key and locale under group_name.
g_key_file_set_boolean Associates a new boolean value with key under group_name.
g_key_file_set_integer Associates a new integer value with key under group_name.
g_key_file_set_string_list Associates a list of string values for key under group_name.
g_key_file_set_locale_string_list Associates a list of string values for key and locale under group_name.
g_key_file_set_boolean_list Associates a list of boolean values with key under group_name.
g_key_file_set_integer_list Associates a list of integer values with key under group_name.
g_key_file_set_comment Places a comment above key from group_name. group_name.
g_key_file_remove_group Removes the specified group, group_name, from the key file.
g_key_file_remove_key Removes the specified group, group_name, from the key file.
g_key_file_remove_comment Removes a comment above key from group_name. group_name.

Give feedback of this article

 


Lexical Scanner

Function

Description

GScanner The data structure representing a lexical scanner.
g_scanner_new Creates a new GScanner.
GScannerConfig Specifies the GScanner settings.
g_scanner_input_file Prepares to scan a file.
g_scanner_sync_file_offset Rewinds the filedescriptor to the current buffer position and blows the file read ahead buffer.
g_scanner_input_text Prepares to scan a text buffer.
g_scanner_peek_next_token Gets the next token, without removing it from the input stream.
g_scanner_get_next_token Gets the next token, removing it from the input stream.
g_scanner_cur_line Gets the current line in the input stream (counting from 1).
g_scanner_cur_position Gets the current position in the current line (counting from 0).
g_scanner_cur_token Gets the current token type.
g_scanner_cur_value Gets the current token value.
g_scanner_eof Returns TRUE if the scanner has reached the end of the file or text buffer.
g_scanner_set_scope Sets the current scope.
g_scanner_scope_add_symbol Adds a symbol to the given scope.
g_scanner_scope_foreach_symbol Calls the given function for each of the symbol/value pairs in the given scope of the GScanner.
g_scanner_scope_lookup_symbol Looks up a symbol in a scope and return its value.
g_scanner_scope_remove_symbol Removes a symbol from a scope.
g_scanner_freeze_symbol_table Has been deprecated since version 2.2 and should not be used in newly-written code. This macro does nothing.
g_scanner_thaw_symbol_table Has been deprecated since version 2.2 and should not be used in newly-written code. This macro does nothing.
g_scanner_lookup_symbol Looks up a symbol in the current scope and return its value.
g_scanner_warn Outputs a warning message, via the GScanner message handler.
g_scanner_error Outputs an error message, via the GScanner message handler.
g_scanner_unexp_token Outputs a message through the scanner's msg_handler, resulting from an unexpected token in the input stream.
GScannerMsgFunc Specifies the type of the message handler function.
g_scanner_destroy Frees all memory used by the GScanner.
GTokenType The possible types of token returned from each g_scanner_get_next_token() call.
GTokenValue A union holding the value of the token.
GErrorType The possible errors, used in the v_error field of GTokenValue, when the token is a G_TOKEN_ERROR.
G_CSET_a_2_z Used for specifying valid identifier characters in GScannerConfig.
G_CSET_A_2_Z Used for specifying valid identifier characters in GScannerConfig.
G_CSET_DIGITS Used for specifying valid identifier characters in GScannerConfig.
G_CSET_LATINC Used for specifying valid identifier characters in GScannerConfig.
G_CSET_LATINS Used for specifying valid identifier characters in GScannerConfig.
g_scanner_add_symbol Adds a symbol to the default scope.
g_scanner_remove_symbol Removes a symbol from the default scope.
g_scanner_foreach_symbol Calls a function for each symbol in the default scope.

Give feedback of this article

 


Limits of Basic Type

Function

Description

G_MININT The minimum value which can be held in a gint.
G_MAXINT The maximum value which can be held in a gint.
G_MAXUINT The maximum value which can be held in a guint.
G_MINSHORT The minimum value which can be held in a gshort.
G_MAXSHORT The maximum value which can be held in a gshort.
G_MAXUSHORT The maximum value which can be held in a gushort.
G_MINLONG The minimum value which can be held in a glong.
G_MAXLONG The maximum value which can be held in a glong.
G_MAXULONG The maximum value which can be held in a gulong.
G_MININT8 The minimum value which can be held in a gint8.
G_MAXINT8 The maximum value which can be held in a gint8.
G_MAXUINT8 The maximum value which can be held in a guint8.
G_MININT16 The minimum value which can be held in a gint16.
G_MAXINT16 The maximum value which can be held in a gint16.
G_MAXUINT16 The maximum value which can be held in a guint16.
G_MININT32 The minimum value which can be held in a gint32.
G_MAXINT32 The maximum value which can be held in a gint32.
G_MAXUINT32 The maximum value which can be held in a guint32.
G_MININT64 The minimum value which can be held in a gint64.
G_MAXINT64 The maximum value which can be held in a gint64.
G_MAXUINT64 The maximum value which can be held in a guint64.
G_MAXSIZE The maximum value which can be held in a gsize.
G_MINFLOAT The minimum positive value which can be held in a gfloat.
G_MAXFLOAT The maximum value which can be held in a gfloat.
G_MINDOUBLE The minimum positive value which can be held in a gdouble.
G_MAXDOUBLE The maximum value which can be held in a gdouble.

Give feedback of this article

 


Memory Allocation

Function

Description

g_new Allocates n_structs elements of type struct_type.
g_new0 Allocates n_structs elements of type struct_type, initialized to 0's.
g_renew Reallocates the memory pointed to by mem, so that it now has space for n_structs elements of type struct_type.
g_try_new Attempts to allocate n_structs elements of type struct_type, and returns NULL on failure.
g_try_new0 Attempts to allocate n_structs elements of type struct_type, initialized to 0's, and returns NULL on failure
g_try_renew Attempts to reallocate the memory pointed to by mem, so that it now has space for n_structs elements of type struct_type, and returns NULL on failure.
g_malloc Allocates n_bytes bytes of memory.
g_malloc0 Allocates n_bytes bytes of memory, initialized to 0's.
g_realloc Reallocates the memory pointed to by mem, so that it now has space for n_bytes bytes of memory.
g_try_malloc Attempts to allocate n_bytes, and returns NULL on failure.
g_try_malloc0 Attempts to allocate n_bytes, initialized to 0's, and returns NULL on failure.
g_try_realloc Attempts to realloc mem to a new size, n_bytes, and returns NULL on failure.
g_free Frees the memory pointed to by mem. If mem is NULL it simply returns.
g_alloca Allocates size bytes on the stack; these bytes will be freed when the current stack frame is cleaned up.
g_newa Wraps g_alloca() in a more typesafe manner.
g_mem_gc_friendly This variable is TRUE if the G_DEBUG environment variable includes the key gc-friendly.
g_memmove Copies a block of memory len bytes long, from src to dest.
g_memdup Allocates byte_size bytes of memory, and copies byte_size bytes into it from mem.
GMemVTable A set of functions used to perform memory allocation.
g_mem_set_vtable Sets the GMemVTable to use for memory allocation
g_mem_is_system_malloc Checks whether the allocator used by g_malloc() is the system's malloc implementation.
glib_mem_profiler_table A GMemVTable containing profiling variants of the memory allocation functions.
g_mem_profile Outputs a summary of memory usage.

Give feedback of this article

 


Memory Allocators

This chapter lists functions of type Memory Allocators, which allocates chunks of memory for GList, GSList and GNode.

Function

Description

GAllocator The GAllocator struct contains private data.
g_allocator_new Creates a new GAllocator.
g_allocator_free Frees all of the memory allocated by the GAllocator.

Give feedback of this article

 


Memory Chunks

This section lists all the functions belonging to Memory Chunks, which are used to allocate groups of equal-sized chunks of memory.

Function

Description

G_ALLOC_AND_FREE Specifies the type of a GMemChunk. Used in g_mem_chunk_new() and g_mem_chunk_create() to specify that atoms will be freed individually.
G_ALLOC_ONLY Specifies the type of a GMemChunk. Used in g_mem_chunk_new() and g_mem_chunk_create() to specify that atoms will never be freed individually.
g_mem_chunk_new Creates a new GMemChunk.
g_mem_chunk_alloc Allocates an atom of memory from a GMemChunk.
g_mem_chunk_alloc0 Allocates an atom of memory from a GMemChunk, setting the memory to 0
g_mem_chunk_free Frees an atom in a GMemChunk.
g_mem_chunk_destroy Frees all of the memory allocated for a GMemChunk.
g_mem_chunk_create A macro for creating a new GMemChunk.
g_chunk_new A macro to allocate an atom of memory from a GMemChunk.
g_chunk_new0 A macro to allocate an atom of memory from a GMemChunk. It calls g_mem_chunk_alloc0() and casts the returned atom to a pointer to the given type, avoiding a type cast in the source code.
g_chunk_free Macro that switches the arguments and calls g_mem_chunk_free().
g_mem_chunk_reset Resets a GMemChunk to its initial state. It frees all of the currently allocated blocks of memory.
g_mem_chunk_clean Frees any blocks in a GMemChunk which are no longer being used.
g_blow_chunks Calls g_mem_chunk_clean() on all GMemChunk objects.
g_mem_chunk_info Outputs debugging information for all GMemChunk objects currently in use.
g_mem_chunk_print Outputs the name of the GMemChunk, the number of bytes used, and the number of blocks of memory allocated.

Give feedback of this article

 


Memory Slices

Function

Description

g_slice_alloc Allocates a block of memory from the slice allocator.
g_slice_alloc0 Allocates a block of memory via g_slice_alloc() and initializes the returned memory to 0.
g_slice_free1 Frees a block of memory.
g_slice_free_chain_with_offset Frees a linked list of memory blocks of structure type type.
g_slice_new A convenience macro to allocate a block of memory from the slice allocator.
g_slice_new0 A convenience macro to allocate a block of memory from the slice allocator and set the memory to 0.
g_slice_free A convenience macro to free a block of memory that has been allocated from the slice allocator.
g_slice_free_chain Frees a linked list of memory blocks of structure type type.

Give feedback of this article

 


Message Logging

Function

Description

G_LOG_DOMAIN Defines the log domain.
G_LOG_FATAL_MASK GLib log levels that are considered fatal by default.
G_LOG_LEVEL_USER_SHIFT Log level shift offset for user defined log levels (0-7 are used by GLib).
GLogFunc Log level shift offset for user defined log levels (0-7 are used by GLib).
GLogLevelFlags Flags specifying the level of log messages.
g_log Logs an error or debugging message.
g_logv Logs an error or debugging message.
g_message Logs an error or debugging message.
g_warning Logs an error or debugging message.
g_critical Logs a "critical warning" (G_LOG_LEVEL_CRITICAL).
g_error A convenience function/macro to log an error message.
g_debug A convenience function/macro to log an error message.
g_log_set_handler Sets the log handler for a domain and a set of log levels.
g_log_remove_handler Removes the log handler.
g_log_set_always_fatal Sets the message levels which are always fatal, in any log domain.
g_log_set_fatal_mask Sets the log levels which are fatal in the given domain.
g_log_default_handler The default log handler set up by GLib
g_log_set_default_handler Installs a default log handler which is used is used if no log handler has been set for the particular log domain and log level combination.

Give feedback of this article

 


Message Output and Debugging

Function

Description

g_print Outputs a formatted message via the print handler.
g_set_print_handler Outputs a formatted message via the print handler.
GPrintFunc Outputs a formatted message via the print handler.
g_printerr Outputs a formatted message via the error message handler.
g_set_printerr_handler Sets the handler for printing error messages.
g_return_if_fail Returns from the current function if the expression is not true.
g_return_val_if_fail Returns from the current function if the expression is not true.
g_return_val_if_fail Returns from the current function if the expression is not true.
g_return_val_if_reached Returns from the current function if the expression is not true.
g_assert Debugging macro to terminate the application if the assertion fails.
g_assert_not_reached Debugging macro to terminate the application if the assertion fails.
g_on_error_query Debugging macro to terminate the application if the assertion fails.
g_on_error_stack_trace Invokes gdb, which attaches to the current process and shows a stack trace.
G_BREAKPOINT Inserts a breakpoint instruction into the code (on x86 machines only).

Give feedback of this article

 


Miscellaneous Macros

Function

Description

G_INLINE_FUNC This macro is used to export function prototypes so they can be linked with an external version when no in-lining is performed.
G_STMT_START Used within multi-statement macros so that they can be used in places where only one statement is expected by the compiler.
G_STMT_END Used within multi-statement macros so that they can be used in places where only one statement is expected by the compiler.
G_BEGIN_DECLS Used (along with G_END_DECLS) to bracket header files.
G_END_DECLS Used (along with G_BEGIN_DECLS) to bracket header files.
G_N_ELEMENTS Determines the number of elements in an array.
G_VA_COPY Portable way to copy va_list variables.
G_STRINGIFY Accepts a macro or a string and converts it into a string.
G_GNUC_EXTENSION Expands to __extension__ when gcc is used as the compiler.
G_GNUC_CONST Expands to the GNU C const function attribute if the compiler is gcc.
G_GNUC_PURE Expands to the GNU C pure function attribute if the compiler is gcc.
G_GNUC_MALLOC Expands to the GNU C malloc function attribute if the compiler is gcc.
G_GNUC_DEPRECATED Expands to the GNU C deprecated attribute if the compiler is gcc.
G_GNUC_NORETURN Expands to the GNU C noreturn function attribute if the compiler is gcc.
G_GNUC_UNUSED Expands to the GNU C unused function attribute if the compiler is gcc.
G_GNUC_PRINTF Expands to the GNU C format function attribute if the compiler is gcc.
G_GNUC_SCANF Expands to the GNU C format function attribute if the compiler is gcc.
G_GNUC_FORMAT Expands to the GNU C format_arg function attribute if the compiler is gcc.
G_GNUC_NULL_TERMINATED Expands to the GNU C sentinel function attribute if the compiler is gcc, or "" if it isn't.
G_GNUC_WARN_UNUSED_RESULT Expands to the GNU C warn_unused_ersult function attribute if the compiler is gcc, or "" if it isn't.
G_GNUC_FUNCTION Expands to the GNU C __FUNCTION__ variable if the compiler is gcc, or "" if it isn't.
G_GNUC_PRETTY_FUNCTION Expands to the GNU C __PRETTY_FUNCTION__ variable if the compiler is gcc, or "" if it isn't.
G_GNUC_NO_INSTRUMENT Expands to the GNU C no_instrument_function function attribute if the compiler is gcc.
G_HAVE_GNUC_VISIBILITY This macro is defined as 1 if the compiler supports ELF visibility attributes (currently only gcc).
G_GNUC_INTERNAL Expands to the GNU C visibility(hidden) attribute if the compiler supports it (currently only gcc).
G_LIKELY Hints the compiler that the expression is likely to evaluate to a true value. The compiler may use this information for optimizations.
G_UNLIKELY Hints the compiler that the expression is unlikely to evaluate to a true value. The compiler may use this information for optimizations.
G_STRLOC Expands to a string identifying the current code position.
G_STRFUNC Expands to a string identifying the current function.
G_GINT16_MODIFIER The platform dependent length modifier for constructing printf() conversion specifiers for values of type gint16 or guint16.
G_GINT16_FORMAT This is the platform dependent conversion specifier for scanning and printing values of type gint16.
G_GUINT16_FORMAT This is the platform dependent conversion specifier for scanning and printing values of type guint16.
G_GINT32_MODIFIER The platform dependent length modifier for constructing printf() conversion specifiers for values of type gint32 or guint32.
G_GINT32_FORMAT This is the platform dependent conversion specifier for scanning and printing values of type gint32.
G_GUINT32_FORMAT This is the platform dependent conversion specifier for scanning and printing values of type guint32.
G_GINT64_MODIFIER The platform dependent length modifier for constructing printf() conversion specifiers for values of type gint64 or guint64.
G_GINT64_FORMAT This is the platform dependent conversion specifier for scanning and printing values of type gint64.
G_GUINT64_FORMAT This is the platform dependent conversion specifier for scanning and printing values of type guint64.
G_GSIZE_MODIFIER The platform dependent length modifier for constructing printf() conversion specifiers for values of type gsize or gssize.
G_GSIZE_FORMAT This is the platform dependent conversion specifier for scanning and printing values of type gsize.
G_GSSIZE_FORMAT This is the platform dependent conversion specifier for scanning and printing values of type gssize.

Give feedback of this article

 


Miscellaneous Utility Functions

Function

Description

g_get_application_name Gets a human-readable name for the application, as set by g_set_application_name().
g_set_application_name Sets a human-readable name for the application. This name should be localized if possible, and is intended for display to the user.
g_get_prgname Gets the name of the program. This name should not be localized, contrast with g_get_application_name().
g_set_prgname Sets the name of the program. This name should not be localized, contrast with g_set_application_name().
g_getenv Returns the value of an environment variable.
g_setenv Sets an environment variable.
g_unsetenv Removes an environment variable from the environment.
g_listenv Gets the names of all variables set in the environment.
g_get_user_name Gets the user name of the current user.
g_get_real_name Gets the real name of the user.
g_get_user_cache_dir Returns a base directory in which to store non-essential, cached data specific to particular user.
g_get_user_data_dir Returns a base directory in which to access application data such as icons that is customized for a particular user.
g_get_user_config_dir Returns a base directory in which to store user-specific application configuration information such as user preferences and settings.
g_get_system_data_dirs Returns an ordered list of base directories in which to access system-wide application data.
g_get_system_config_dirs Returns an ordered list of base directories in which to access system-wide configuration information.
g_get_host_name Return a name for the machine.
g_get_home_dir Gets the current user's home directory.
g_get_tmp_dir Gets the directory to use for temporary files.
g_get_current_dir Gets the current directory.
g_basename Gets the name of the file without any leading directory components. It returns a pointer into the given file name string.
g_dirname This function is deprecated and will be removed in the next major release of GLib. Use g_path_get_dirname() instead.
g_path_is_absolute Returns TRUE if the given file_name is an absolute file name, i.e. it contains a full path from the root directory such as "/usr/local" on UNIX or "C:\windows" on Windows systems.
g_path_skip_root Returns a pointer into file_name after the root component, i.e. after the "/" in UNIX or "C:\" under Windows. If file_name is not an absolute path it returns NULL.
g_path_get_basename Gets the last component of the filename. If file_name ends with a directory separator it gets the component before the last slash.
g_path_get_dirname Gets the directory components of a file name. If the file name has no directory components "." is returned. The returned string should be freed when no longer needed.
g_build_filename  
g_build_filenamev Behaves exactly like g_build_filename(), but takes the path elements as a string array, instead of varargs. This function is mainly meant for language bindings.
g_build_path Creates a path from a series of elements using separator as the separator between elements.
g_build_pathv Creates a path from a series of elements using separator as the separator between elements.
g_find_program_in_path Creates a path from a series of elements using separator as the separator between elements.
g_bit_nth_lsf Finds the position of the first bit set in mask, searching from (but not including) nth_bit upwards.
g_bit_nth_msf Find the position of the first bit set in mask, searching from (but not including) nth_bit downwards.
g_bit_storage Find the position of the first bit set in mask, searching from (but not including) nth_bit downwards.
g_spaced_primes_closest Gets the smallest prime number from a built-in array of primes which is larger than num.
g_atexit Gets the smallest prime number from a built-in array of primes which is larger than num.
g_parse_debug_string Parses a string containing debugging options separated by ':' into a guint containing bit flags.
GDebugKey Associates a string with a bit flag. Used in g_parse_debug_string().
GVoidFunc Declares a type of function which takes no arguments and has no return value. It is used to specify the type function passed to g_atexit().
GFreeFunc This is just like the standard C qsort() function, but the comparison routine accepts a user data argument.
g_qsort_with_data This is just like the standard C qsort() function, but the comparison routine accepts a user data argument.
g_nullify_pointer Set the pointer at the specified location to NULL.

Give feedback of this article

 


N-ary Trees

This chapter lists the functions of N-ary Trees category.

Function

Description

GNode The GNode struct represents one node in a N-ary Tree.
g_node_new Creates a new GNode containing the given data. Used to create the first node in a tree.
g_node_copy Recursively copies a GNode.
GCopyFunc A function of this signature is used to copy the node data when doing a deep-copy of a tree.
g_node_copy_deep Recursively copies a GNode and its data.
g_node_insert Inserts a GNode beneath the parent at the given position.
g_node_insert_before Inserts a GNode beneath the parent before the given sibling.
g_node_insert_after Inserts a GNode beneath the parent after the given sibling.
g_node_append Inserts a GNode as the last child of the given parent.
g_node_prepend Inserts a GNode as the first child of the given parent.
g_node_insert_data Inserts a new GNode at the given position.
g_node_insert_data_before Inserts a new GNode before the given sibling.
g_node_append_data Inserts a new GNode as the last child of the given parent.
g_node_prepend_data Inserts a new GNode as the first child of the given parent.
g_node_reverse_children Reverses the order of the children of a GNode.
g_node_traverse Traverses a tree starting at the given root GNode.
GTraverseFlags Specifies which nodes are visited during several of the tree functions
GNodeTraverseFunc Specifies the type of function passed to g_node_traverse().
g_node_children_foreach Calls a function for each of the children of a GNode.
GNodeForeachFunc Specifies the type of function passed to g_node_children_foreach().
g_node_get_root Gets the root of a tree.
g_node_find Finds a GNode in a tree.
g_node_find_child Finds the first child of a GNode with the given data.
g_node_child_index Gets the position of the first child of a GNode which contains the given data.
g_node_child_position Gets the position of a GNode with respect to its siblings.
g_node_first_child Gets the first child of a GNode.
g_node_last_child Gets the last child of aGNode.
g_node_nth_child Gets a child of a GNode, using the given index.
g_node_first_sibling Gets the first sibling of a GNode.
g_node_next_sibling Gets the next sibling of a GNode.
g_node_prev_sibling Gets the previous sibling of a GNode.
g_node_last_sibling Gets the last sibling of a GNode.
G_NODE_IS_LEAF Returns TRUE if a GNode is a leaf node.
G_NODE_IS_ROOT Returns TRUE if a GNode is the root of a tree.
g_node_depth Gets the depth of a GNode.
g_node_n_nodes Gets the number of nodes in a tree.
g_node_n_children Gets the number of children of a GNode.
g_node_is_ancestor Returns TRUE if node is an ancestor of descendant.
g_node_max_height Gets the maximum height of all branches beneath a GNode.
g_node_unlink Unlinks a GNode from a tree, resulting in two separate trees.
g_node_destroy Removes the GNode and its children from the tree, freeing any memory allocated.
g_node_push_allocator Sets the allocator to use to allocate GNode elements.
g_node_pop_allocator Restores the previous GAllocator, used when allocating GNode elements.

Give feedback of this article

 


Numerical Definitions

Function

Description

G_IEEE754_FLOAT_BIAS  
G_IEEE754_DOUBLE_BIAS  
GFloatIEEE754  
GDoubleIEEE754 The GFloatIEEE754 and GDoubleIEEE754 unions are used to access the sign, mantissa and exponent of IEEE floats and doubles. These unions are defined as appropriate for a given platform.
G_E The base of natural logarithms.
G_LN2 The natural logarithm of 2.
G_LN10 The natural logarithm of 10.
G_PI The value of pi (ratio of circle's circumference to its diameter).
G_PI_2 Pi divided by 2.
G_PI_4 Pi divided by 4.
G_SQRT2 The square root of two.
G_LOG_2_BASE_10 Used for manipulating with float formats

Give feedback of this article

 


Pointer Arrays

This chapter lists Pointer Arrays, which are similar to Arrays but are used only for storing pointers.

Function

Description

GPtrArray Contains the public fields of a pointer array.
g_ptr_array_new Creates a new GPtrArray.
g_ptr_array_sized_new Creates a new GPtrArray with reserved_size pointers preallocated.
g_ptr_array_add Adds a pointer to the end of the pointer array.
g_ptr_array_remove Removes the first occurrence of the given pointer from the pointer array.
g_ptr_array_remove_index Removes the pointer at the given index from the pointer array.
g_ptr_array_remove_fast Removes the first occurrence of the given pointer from the pointer array.
g_ptr_array_remove_index_fast Removes the pointer at the given index from the pointer array.
g_ptr_array_remove_range Removes the given number of pointers starting at the given index from a GPtrArray.
g_ptr_array_sort Sorts the array, using compare_func
g_ptr_array_sort_with_data Sorts the array but the comparison function has a user data argument.
g_ptr_array_set_size Sets the size of the array
g_ptr_array_index Returns the pointer at the given index of the pointer array.
g_ptr_array_free Frees all of the memory allocated for the pointer array.
g_ptr_array_foreach Calls a function for each element of a GPtrArray.

Give feedback of this article

 


Quarks

This chapter lists functions belonging to the category Quarks, which is a 2-way association between a string and a unique integer identifier.

Function

Description

GQuark A GQuark is an integer which uniquely identifies a particular string.
g_quark_from_string Gets the GQuark identifying the given string.
g_quark_from_static_string Gets the GQuark identifying the given (static) string.
g_quark_to_string Gets the string associated with the given GQuark.
g_quark_try_string Gets the GQuark associated with the given string, or 0 if the string has no associated GQuark.

Give feedback of this article

 


Random Numbers

Function

Description

GRand The GRand struct is an opaque data structure. It should only be accessed through the g_rand_* functions.
g_rand_new_with_seed Creates a new random number generator initialized with seed.
g_rand_new_with_seed_array Creates a new random number generator initialized with seed.
g_rand_new Creates a new random number generator initialized with a seed taken either from /dev/urandom (if existing) or from the current time (as a fallback).
g_rand_copy Copies a GRand into a new one with the same exact state as before.
g_rand_free Frees the memory allocated for the GRand.
g_rand_set_seed Sets the seed for the random number generator GRand to seed.
g_rand_set_seed_array Sets the seed for the random number generator GRand to seed.
g_rand_boolean Returns a random gboolean from rand_.
g_rand_int Returns the next random guint32 from rand_ equally distributed over the range [0..2^32-1].
g_rand_int_range Returns the next random gint32 from rand_ equally distributed over the range [begin..end-1].
g_rand_double Returns the next random gdouble from rand_ equally distributed over the range [0..1).
g_rand_double_range Returns the next random gdouble from rand_ equally distributed over the range [begin..end).
g_random_set_seed Sets the seed for the global random number generator, which is used by the g_random_* functions, to seed.
g_random_boolean Returns a random gboolean. This corresponds to a unbiased coin toss.
g_random_int Return a random guint32 equally distributed over the range [0..2^32-1].
g_random_int_range Returns a random gint32 equally distributed over the range [begin..end-1].
g_random_double Returns a random gdouble equally distributed over the range [0..1).
g_random_double_range Returns a random gdouble equally distributed over the range [begin..end).

Give feedback of this article

 


Relations and Tuples

This chapter lists functions of the type Relations and Tuples.

Function

Description

GRelation The GRelation struct is an opaque data structure to represent a Relation
g_relation_new Creates a new GRelation with the given number of fields.
g_relation_index Creates an index on the given field.
g_relation_insert Inserts a record into a GRelation.
g_relation_exists Returns TRUE if a record with the given values exists in a GRelation.
g_relation_count Returns the number of tuples in a GRelation that have the given value in the given field.
g_relation_select Returns all of the tuples which have the given key in the given field.
g_relation_delete Deletes any records from a GRelation that have the given key value in the given field.
g_relation_destroy Destroys the GRelation, freeing all memory allocated.
g_relation_print Outputs information about all records in a GRelation, as well as the indexes.
GTuples Used to return records (or tuples) from the GRelation by g_relation_select().
g_tuples_destroy Frees the records which were returned by g_relation_select().
g_tuples_index Gets a field from the records returned by g_relation_select().

Give feedback of this article

 


Shell-related Utilities

Function

Description

GShellError Error codes returned by shell functions.
G_SHELL_ERROR Error domain for shell functions.
g_shell_parse_argv Parses a command line into an argument vector, in much the same way the shell would, but without many of the expansions the shell would perform (variable expansion, globs, operators, filename expansion, etc. are not supported).
g_shell_quote Quotes a string so that the shell (/bin/sh) will interpret the quoted string to mean unquoted_string.
g_shell_unquote Unquotes a string as the shell (/bin/sh) would.

Give feedback of this article

 


Simple XML Subset Parser

Function

Description

GMarkupError Error codes returned by markup parsing.
G_MARKUP_ERROR Error domain for markup parsing.
GMarkupParseFlags There are no flags right now. Pass "0" for the flags argument to all functions.
GMarkupParseContext A parse context is used to parse a stream of bytes that are expected to contain marked-up text.
GMarkupParser Any of the fields in GMarkupParser can be NULL, in which case they will be ignored.
g_markup_escape_text Escapes text so that the markup parser will parse it verbatim. Less than, greater than, ampersand, etc. are replaced with the corresponding entities.
g_markup_printf_escaped Formats arguments according to format, escaping all string and character arguments in the fashion of g_markup_escape_text().
g_markup_vprintf_escaped Formats the data in args according to format, escaping all string and character arguments in the fashion of g_markup_escape_text().
g_markup_parse_context_end_parse Signals to the GMarkupParseContext that all data has been fed into the parse context with g_markup_parse_context_parse().
g_markup_parse_context_free Frees a GMarkupParseContext. Can't be called from inside one of the GMarkupParser functions.
g_markup_parse_context_get_position Retrieves the current line number and the number of the character on that line. Intended for use in error messages
g_markup_parse_context_get_element Retrieves the name of the currently open element.
g_markup_parse_context_new Creates a new parse context.
g_markup_parse_context_parse Feed some data to the GMarkupParseContext.

Give feedback of this article

 


Singly Linked Lists

This section lists functions containing integer values or pointers to data, limited to iterating over the list in one direction.

Function

Description

GSList The GSList struct is used for each element in the singly-linked list.
g_slist_alloc Allocates space for one GSList element.
g_slist_append Adds a new element at the end of the list.
g_slist_prepend Adds a new element at the start of the list.
g_slist_insert Inserts a new element into the list at the given position.
g_slist_insert_before Inserts a node before sibling containing data. Returns the new head of the list.
g_slist_insert_sorted Inserts a new element to the list, using the given comparison function to determine its position.
g_slist_remove Removes an element from a GSList.
g_slist_remove_link Removes an element from a GSList, without freeing the element.
g_slist_delete_link Deletes a node of list.
g_slist_remove_all Removes all list nodes with data equal to data.
g_slist_free Frees all of the memory used by a GSList.
g_slist_free_1 Frees one GSList element.
g_slist_length Gets the number of elements in a GSList.
g_slist_copy Copies a GSList.
g_slist_reverse Reverses a GSList.
g_slist_sort Sorts a GSList using the given comparison function.
g_slist_sort_with_data Sorts a GSList using the given comparison function but the sort function accepts a user data argument.
g_slist_concat Adds the second GSList to the end of the first GSList.
g_slist_foreach Calls a function for each element of a GSList.
g_slist_last Gets the last element in a GSList.
g_slist_next A macro used to get the next element in a GSList
g_slist_nth Gets the element at the given position in a GSList.
g_slist_nth_data Gets the data of the element at the given position.
g_slist_find Finds the element in a GSList which contains the given data.
g_slist_find_custom Finds an element in a GSList, using a supplied function to find the desired element.
g_slist_position Gets the position of the given element in the GSList (starting from 0).
g_slist_index Gets the position of the element containing the given data (starting from 0).
g_slist_push_allocator Sets the allocator to use to allocate GSList elements.
g_slist_pop_allocator Restores the previous GAllocator used when allocating GSList elements.

Give feedback of this article

 


Spawning Processes

Function

Description

GSpawnError Error codes returned by spawning processes.
G_SPAWN_ERROR Error domain for spawning processes.
GSpawnFlags Flags passed to g_spawn_sync(), g_spawn_async() and g_spawn_async_with_pipes().
GSpawnChildSetupFunc Specifies the type of the setup function passed to g_spawn_async(), g_spawn_sync() and g_spawn_async_with_pipes().
g_spawn_async_with_pipes Executes a child program asynchronously (the program will not block waiting for the child to exit).
g_spawn_async this function simply calls the g_spawn_async_with_pipes() without any pipes.
g_spawn_sync Executes a child synchronously (waits for the child to exit before returning).
g_spawn_command_line_async A simple version of g_spawn_async() that parses a command line with g_shell_parse_argv() and passes it to g_spawn_async().
g_spawn_command_line_sync A simple version of g_spawn_sync() with little-used parameters removed, taking a command line instead of an argument vector.
g_spawn_close_pid On some platforms, notably WIN32, the GPid type represents a resource which must be closed to prevent resource leaking.

Give feedback of this article

 


Standard Macros

Function

Description

G_OS_WIN32 This macro is defined only on Windows.
G_OS_BEOS This macro is defined only on BeOS.
G_OS_UNIX This macro is defined only on UNIX.
G_DIR_SEPARATOR The directory separator character.
G_DIR_SEPARATOR_S The directory separator as a string.
G_IS_DIR_SEPARATOR Checks whether a character is a directory separator.
G_SEARCHPATH_SEPARATOR The search path separator character.
G_SEARCHPATH_SEPARATOR_S The search path separator as a string.
TRUE Defines the TRUE value for the gboolean type.
FALSE Defines the FALSE value for the gboolean type.
NULL Defines the standard NULL pointer.
MIN Calculates the minimum of a and b.
MAX Calculates the maximum of a and b.
ABS Calculates the absolute value of a.
CLAMP Ensures that x is between the limits set by low and high.
G_STRUCT_MEMBER Returns a member of a structure at a given offset, using the given type.
G_STRUCT_MEMBER_P Returns an untyped pointer to a given offset of a struct.
G_STRUCT_OFFSET Returns the offset, in bytes, of a member of a struct.
G_MEM_ALIGN Indicates the number of bytes to which memory will be aligned on the current platform.
G_CONST_RETURN If G_DISABLE_CONST_RETURNS is defined, this macro expands to nothing. By default, the macro expands to const.

Give feedback of this article

 


Strings

This section lists functions of string category which are text buffers that grow automatically as text is added.

Function

Description

GString The GString struct contains the public fields of a GString.
g_string_new Creates a new GString, initialized with the given string.
g_string_sized_new Creates a new GString, with enough space for dfl_size bytes.
g_string_assign Copies the bytes from a string into a GString, destroying any previous contents.
g_string_sprintf Writes a formatted string into a GString.
g_string_sprintfa Appends a formatted string to the end of a GString.
g_string_printf Writes a formatted string into a GString.
g_string_append_printf Appends a formatted string to the end of a GString.
g_string_append Adds a string to the end of a GString.
g_string_append_c Adds a byte to the end of a GString
g_string_append_unichar Converts a Unicode character into UTF-8, and appends it to the string
g_string_append_len Appends len bytes of val to string.
g_string_prepend Adds a string on to the start of a GString.
g_string_prepend_c Adds a byte to the start of a GString.
g_string_prepend_unichar Converts a Unicode character into UTF-8, and prepends it to the string
g_string_prepend_len Prepends len bytes of val to string.
g_string_insert Inserts a copy of a string into a GString.
g_string_insert_c Inserts a byte into a GString.
g_string_insert_unichar Converts a Unicode character into UTF-8, and insert it into the string at the given position.
g_string_insert_len Inserts len bytes of val into string at pos.
g_string_erase Removes len bytes from a GString, starting at position pos.
g_string_truncate Cuts off the end of the GString, leaving the first len bytes.
g_string_set_size Sets the length of a GString.
g_string_free Frees the memory allocated for the GString.
g_string_up Converts a GString to uppercase.
g_string_down Converts a GString to lowercase.
g_string_hash Creates a hash code for str; for use with GHashTable.
g_string_equal Compares two strings for equality, returning TRUE if they are equal.

Give feedback of this article

 


String Chunks

This chapter lists functions containing integer values or pointers to data, limited to iterating over the list in one direction.

Function

Description

GStringChunk An opaque data structure representing String Chunks.
g_string_chunk_new Creates a new GStringChunk.
g_string_chunk_insert Adds a copy of string to the GStringChunk.
g_string_chunk_insert_const Adds a copy of string to the GStringChunk, unless the same string has already been added to the GStringChunk with g_string_chunk_insert_const().
g_string_chunk_insert_len Adds a copy of the first len bytes of string to the GStringChunk.
g_string_chunk_free Frees all memory allocated by the GStringChunk.

Give feedback of this article

 


String Utility Functions

Function

Description

g_strdup Duplicates a string.
g_strndup Duplicates the first n characters of a string, returning a newly-allocated buffer n + 1 characters long which will always be null-terminated.
g_strdupv Copies NULL-terminated array of strings.
g_strnfill Creates a new string length characters long filled with fill_char.
g_stpcpy Copies a null-terminated string into the dest buffer, include the trailing null, and return a pointer to the trailing null byte.
g_strstr_len Searches the string haystack for the first occurrence of the string needle, limiting the length of the search to haystack_len.
g_strrstr Searches the string haystack for the last occurrence of the string needle.
g_strrstr_len Searches the string haystack for the last occurrence of the string needle, limiting the length of the search to haystack_len.
g_str_has_prefix Looks whether the string str begins with prefix.
g_str_has_suffix Looks whether the string str ends with suffix.
g_strlcpy Portability wrapper that calls strlcpy() on systems which have it, and emulates strlcpy() otherwise.
g_strlcat Appends null-terminated src string to dest.
g_strdup_printf Similar to the standard C sprintf() function but safer, since it calculates the maximum space required and allocates memory to hold the result.
g_strdup_vprintf Similar to the standard C vsprintf() function but safer, since it calculates the maximum space required and allocates memory to hold the result. The returned string should be freed when no longer needed.
g_printf Similar to the standard C vsprintf() function but safer, since it calculates the maximum space required and allocates memory to hold the result. The returned string should be freed when no longer needed.
g_vprintf An implementation of the standard vprintf() function which supports positional parameters, as specified in the Single Unix Specification.
g_fprintf An implementation of the standard fprintf() function which supports positional parameters, as specified in the Single Unix Specification.
g_vfprintf An implementation of the standard fprintf() function which supports positional parameters, as specified in the Single Unix Specification.
g_sprintf An implementation of the standard sprintf() function which supports positional parameters, as specified in the Single Unix Specification.
g_vsprintf An implementation of the standard vsprintf() function which supports positional parameters, as specified in the Single Unix Specification.
g_snprintf A safer form of the standard sprintf() function.
g_vsnprintf A safer form of the standard vsprintf() function.
g_vasprintf An implementation of the GNU vasprintf() function which supports positional parameters, as specified in the Single Unix Specification.
g_printf_string_upper_bound Calculates the maximum space needed to store the output of the sprintf() function.
g_ascii_isalnum Determines whether a character is alphanumeric.
g_ascii_isalpha Determines whether a character is alphabetic (i.e. a letter).
g_ascii_iscntrl Determines whether a character is a control character.
g_ascii_isdigit Determines whether a character is digit (0-9).
g_ascii_isgraph Determines whether a character is a printing character and not a space.
g_ascii_islower Determines whether a character is an ASCII lower case letter.
g_ascii_isprint Determines whether a character is a printing character.
g_ascii_ispunct Determines whether a character is a punctuation character.
g_ascii_isspace Determines whether a character is a white-space character.
g_ascii_isupper Determines whether a character is an ASCII upper case letter.
g_ascii_isupper Determines whether a character is a hexadecimal-digit character.
g_ascii_digit_value Determines the numeric value of a character as a decimal digit.
g_ascii_xdigit_value Determines the numeric value of a character as a hexadecimal digit.
g_ascii_strcasecmp Compares two strings, ignoring the case of ASCII characters.
g_ascii_strncasecmp Compare s1 and s2, ignoring the case of ASCII characters and any characters after the first n in each string.
g_ascii_strup Converts all lower case ASCII letters to upper case ASCII letters.
g_ascii_strdown Converts all upper case ASCII letters to lower case ASCII letters.
g_ascii_tolower Convert a character to ASCII lower case.
g_ascii_toupper Convert a character to ASCII upper case.
g_string_ascii_up Converts all lower case ASCII letters to upper case ASCII letters.
g_string_ascii_down Converts all upper case ASCII letters to lower case ASCII letters.
g_strup Converts a string to upper case.
g_strdown Converts a string to lower case.
g_strcasecmp A case-insensitive string comparison, corresponding to the standard strcasecmp() function on platforms which support it.
g_strncasecmp A case-insensitive string comparison, corresponding to the standard strncasecmp() function on platforms which support it.
g_strreverse Reverses all of the bytes in a string. For example, g_strreverse ("abcdef") will result in "fedcba".
g_ascii_strtoull Converts a string to a guint64 value.
G_ASCII_DTOSTR_BUF_SIZE A good size for a buffer to be passed into g_ascii_dtostr().
g_ascii_strtod Converts a string to a gdouble value.
g_ascii_dtostr Converts a gdouble to a string, using the '.' as decimal point.
g_ascii_formatd Converts a gdouble to a string, using the '.' as decimal point.
g_strtod Converts a string to a gdouble value. It calls the standard strtod() function to handle the conversion, but if the string is not completely converted it attempts the conversion again with g_ascii_strtod(), and returns the best match.
g_strchug Removes leading white space from a string, by moving the rest of the characters forward.
g_strchomp Removes trailing white space from a string.
g_strstrip Removes leading and trailing white space from a string. See g_strchomp() and g_strchug().
g_strdelimit Converts any delimiter characters in string to new_delimiter.
G_STR_DELIMITERS The standard delimiters, used in g_strdelimit().
g_strescape Escapes the special characters '\b', '\f', '\n', '\r', '\t', '\' and '"' in the string source by inserting a '\' before them.
g_strcompress Replaces all escaped characters with their one byte equivalent. It does the reverse conversion of g_strescape().
g_strcanon For each character in string, if the character is not in valid_chars, replaces the character with substitutor.
g_strsplit Splits a string into a maximum of max_tokens pieces, using the given delimiter.
g_strsplit_set Splits string into a number of tokens not containing any of the characters in delimiter.
g_strfreev Frees a NULL-terminated array of strings, and the array itself.
g_strconcat Concatenates all of the given strings into one long string.
g_strjoin Joins a number of strings together to form one long string, with the optional separator inserted between each of them.
g_strjoinv Joins a number of strings together to form one long string, with the optional separator inserted between each of them.
g_strv_length Returns the length of the given NULL-terminated string array str_array.
g_strerror Returns a string corresponding to the given error code, e.g. "no such process".
g_strsignal Returns a string describing the given signal, e.g. "Segmentation fault".

Give feedback of this article

 


The Main Event Loop

Function

Description

GMainLoop The GMainLoop struct is an opaque data type representing the main event loop of a GLib or GTK+ application.
g_main_loop_new Creates a new GMainLoop structure.
g_main_loop_ref Increases the reference count on a GMainLoop object by one.
g_main_loop_unref Decreases the reference count on a GMainLoop object by one.
g_main_loop_run Runs a main loop until g_main_loop_quit() is called on the loop.
g_main_loop_quit Stops a GMainLoop from running.
g_main_loop_is_running Checks to see if the main loop is currently being run via g_main_loop_run().
g_main_loop_get_context Returns the GMainContext of loop.
g_main_new Creates a new GMainLoop for the default main loop.
g_main_destroy Frees the memory allocated for the GMainLoop.
g_main_run Runs a main loop until it stops running.
g_main_quit Stops the GMainLoop. If g_main_run() was called to run the GMainLoop, it will now return.
g_main_is_running Checks if the main loop is running.
G_PRIORITY_HIGH Use this for high priority event sources. It is not used within GLib or GTK+.
G_PRIORITY_DEFAULT Use this for default priority event sources.
G_PRIORITY_HIGH_IDLE Use this for high priority idle functions.
G_PRIORITY_DEFAULT_IDLE Use this for default priority idle functions.
G_PRIORITY_LOW Use this for very low priority background tasks.
GMainContext The GMainContext struct is an opaque data type representing a set of sources to be handled in a main loop.
g_main_context_new Creates a new GMainContext strcuture.
g_main_context_ref Increases the reference count on a GMainContext object by one.
g_main_context_unref Decreases the reference count on a GMainContext object by one. If the result is zero, free the context and free all associated memory.
g_main_context_default Returns the default main context. This is the main context used for main loop functions when a main loop is not explicitly specified.
g_main_context_iteration Runs a single iteration for the given main loop.
g_main_iteration Runs a single iteration for the default GMainContext.
g_main_context_pending Checks if any sources have pending events for the given context.
g_main_pending Checks if any events are pending for the default GMainContext (i.e. ready to be processed).
g_main_context_find_source_by_id Finds a GSource given a pair of context and ID.
g_main_context_find_source_by_user_data Finds a source with the given user data for the callback.
g_main_context_find_source_by_funcs_user_data Finds a source with the given source functions and user data.
g_main_context_wakeup If context is currently waiting in a poll(), interrupt the poll(), and continue the iteration process.
g_main_context_acquire Tries to become the owner of the specified context.
g_main_context_release Releases ownership of a context previously acquired by this thread with g_main_context_acquire()
g_main_context_is_owner Determines whether this thread holds the (recursive) ownership of this GMaincontext.
g_main_context_wait Tries to become the owner of the specified context, as with g_main_context_acquire().
g_main_context_prepare Prepares to poll sources within a main loop.
g_main_context_query Determines information necessary to poll this main loop.
g_main_context_check Passes the results of polling back to the main loop.
g_main_context_dispatch Dispatches all pending sources.
g_main_context_set_poll_func Sets the function to use to handle polling of file descriptors.
g_main_context_get_poll_func Gets the poll function set by g_main_context_set_poll_func().
GPollFunc Specifies the type of function passed to g_main_context_set_poll_func().
g_main_context_add_poll Adds a file descriptor to the set of file descriptors polled for this context.
g_main_context_remove_poll Removes file descriptor from the set of file descriptors to be polled for a particular context.
g_main_depth  
g_main_set_poll_func Sets the function to use for the handle polling of file descriptors for the default main context.
g_timeout_source_new Creates a new timeout source.
g_timeout_add Sets a function to be called at regular intervals, with the default priority, G_PRIORITY_DEFAULT.
g_timeout_add_full Sets a function to be called at regular intervals, with the given priority.
g_idle_source_new Creates a new idle source.
g_idle_add Adds a function to be called whenever there are no higher priority events pending to the default main loop.
g_idle_add_full Adds a function to be called whenever there are no higher priority events pending.
g_idle_remove_by_data Removes the idle function with the given data.
GPid A type which is used to hold a process identification.
GChildWatchFunc The type of functions to be called when a child exists.
g_child_watch_source_new Creates a new child_watch source.
g_child_watch_add Sets a function to be called when the child indicated by pid exits, at a default priority, G_PRIORITY_DEFAULT.
g_child_watch_add_full Sets a function to be called when the child indicated by pid exits, at a default priority, G_PRIORITY_DEFAULT.
GPollFD Defines typedef structure.
GSource The GSource struct is an opaque data type representing an event source.
GSourceDummyMarshal This is just a placeholder for GClosureMarshal, which cannot be used here for dependency reasons.
GSourceFuncs The GSourceFuncs struct contains a table of functions used to handle event sources in a generic manner.
GSourceCallbackFuncs The GSourceCallbackFuncs struct contains functions for managing callback objects.
g_source_new Creates a new GSource structure.
g_source_ref Increases the reference count on a source by one.
g_source_unref Decreases the reference count of a source by one.
g_source_attach Adds a GSource to a context so that it will be executed within that context.
g_source_destroy Removes a source from its GMainContext, if any, and mark it as destroyed.
g_source_set_priority Sets the priority of a source.
g_source_get_priority Gets the priority of a source.
g_source_set_can_recurse Sets whether a source can be called recursively.
g_source_get_can_recurse Checks whether a source is allowed to be called recursively.
g_source_get_id Returns the numeric ID for a particular source.
g_source_get_context Gets the GMainContext with which the source is associated.
g_source_set_callback Sets the callback function for a source.
GSourceFunc Specifies the type of function passed to g_timeout_add(), g_timeout_add_full(), g_idle_add(), and g_idle_add_full().
g_source_set_callback_indirect Sets the callback function storing the data as a refcounted callback "object".
g_source_add_poll Adds a file descriptor to the set of file descriptors polled for this source.
g_source_remove_poll Removes a file descriptor from the set of file descriptors polled for this source.
g_source_get_current_time Gets the "current time" to be used when checking this source.
g_source_remove Removes the source with the given id from the default main context.
g_source_remove_by_funcs_user_data Removes a source from the default main loop context given the source functions and user data.
g_source_remove_by_user_data Removes a source from the default main loop context given the user data for the callback.

Give feedback of this article

 


Threads

Function

Description

G_THREADS_ENABLED This macro is defined, if GLib was compiled with thread support.
G_THREADS_IMPL_POSIX This macro is defined, if POSIX style threads are used.
G_THREADS_IMPL_NONE This macro is defined, if no thread implementation is used.
G_THREAD_ERROR This macro is defined, if no thread implementation is used
GThreadError Possible errors of thread related functions.
GThreadFunctions This function table is used by g_thread_init() to initialize the thread system.
g_thread_init The use of GLib from more than one thread, must be followed by an initialization to the thread system by calling g_thread_init().
g_thread_supported This function returns, whether the thread system is initialized or not.
GThreadFunc Specifies the type of the func functions passed to g_thread_create() or g_thread_create_full().
GThreadPriority Specifies the priority of a thread.
GThread The GThread struct represents a running thread.
g_thread_create This function creates a new thread with the default priority.
g_thread_create_full This function creates a new thread with the priority
priority
.
g_thread_self This function creates a new thread with the priority
priority.
g_thread_join Waits until thread finishes, i.e. the function func, as given to g_thread_create(), returns or g_thread_exit() is called by thread.
g_thread_set_priority Waits until thread finishes, i.e. the function func, as given to g_thread_create(), returns or g_thread_exit() is called by thread.
g_thread_yield Gives way to other threads waiting to be scheduled.
g_thread_exit Exits the current thread.
g_thread_foreach Call thread_func on all existing GThread structures.
GMutex The GMutex struct is an opaque data structure to represent a mutex (mutual exclusion).
g_mutex_new The GMutex struct is an opaque data structure to represent a mutex (mutual exclusion).
g_mutex_lock Locks mutex.
g_mutex_trylock Tries to lock mutex. If mutex is already locked by another thread, it immediately returns FALSE. Otherwise it locks mutex and returns TRUE.
g_mutex_unlock Unlocks mutex. If another thread is blocked in a g_mutex_lock() call for mutex, it will be woken and can lock mutex itself.
g_mutex_free Destroys mutex.
GStaticMutex A GStaticMutex works like a GMutex, but it has one significant advantage. It doesn't need to be created at run-time like a GMutex, but can be defined at compile-time.
G_STATIC_MUTEX_INIT A GStaticMutex must be initialized with this macro, before it can be used.
g_static_mutex_init Initializes mutex.
g_static_mutex_lock Works like g_mutex_lock(), but for a GStaticMutex.
g_static_mutex_trylock Works like g_mutex_trylock(), but for a GStaticMutex.
g_static_mutex_unlock Works like g_mutex_unlock(), but for a GStaticMutex.
g_static_mutex_get_mutex For some operations (like g_cond_wait()) the user must have a GMutex instead of a GStaticMutex.
g_static_mutex_free Releases all resources allocated to mutex.
G_LOCK_DEFINE he G_LOCK_* macros provide a convenient interface to GStaticMutex with the advantage that they will expand to nothing in programs compiled against a thread-disabled GLib, saving code and memory.
G_LOCK_DEFINE_STATIC This works like G_LOCK_DEFINE, but it creates a static object.
G_LOCK_EXTERN This declares a lock, that is defined with G_LOCK_DEFINE in another module.
G_LOCK This declares a lock, that is defined with G_LOCK_DEFINE in another module.
G_TRYLOCK Works like g_mutex_trylock(), but for a lock defined with G_LOCK_DEFINE.
G_UNLOCK Works like g_mutex_unlock(), but for a lock defined with G_LOCK_DEFINE.
GStaticRecMutex A GStaticRecMutex works like a GStaticMutex, but it can be locked multiple times by one thread.
G_STATIC_REC_MUTEX_INIT A GStaticRecMutex must be initialized with this macro, before it can be used.
g_static_rec_mutex_init A GStaticRecMutex must be initialized with this function, before it can be used.
g_static_rec_mutex_lock Locks mutex.
g_static_rec_mutex_trylock Tries to lock mutex.
g_static_rec_mutex_unlock Unlocks mutex.
g_static_rec_mutex_lock_full () Works like calling g_static_rec_mutex_lock() for mutex depth times.
g_static_rec_mutex_unlock_full () Completely unlocks mutex.
g_static_rec_mutex_free () Releases all resources allocated to a GStaticRecMutex.
GStaticRWLock The GStaticRWLock struct represents a read-write lock.
G_STATIC_RW_LOCK_INIT A GStaticRWLock must be initialized with this macro, before it can be used.
g_static_rw_lock_init A GStaticRWLock must be initialized with this function, before it can be used.
g_static_rw_lock_reader_lock Locks lock for reading.
g_static_rw_lock_reader_trylock Tries to lock
lock
for reading.
g_static_rw_lock_reader_unlock Unlocks lock.
g_static_rw_lock_writer_lock Locks lock for writing.
g_static_rw_lock_writer_trylock () Tries to lock lock for writing.
g_static_rw_lock_writer_unlock Unlocks lock.
g_static_rw_lock_free Releases all resources allocated to lock.
GCond The GCond struct is an opaque data structure to represent a condition.
g_cond_signal If threads are waiting for cond, exactly one of them is woken up.
g_cond_new Creates a new GCond.
g_cond_broadcast If threads are waiting for cond, all of them are woken up.
g_cond_wait Waits until this thread is woken up on cond.
g_cond_timed_wait Waits until this thread is woken up on cond, but not longer than until the time, that is specified by abs_time.
g_cond_free () Destroys the GCond.
GPrivate The GPrivate struct is an opaque data structure to represent a thread private data key.
g_private_new Returns the pointer keyed to private_key for the current thread.
g_private_get Returns the pointer keyed to private_key for the current thread.
g_private_set Sets the pointer keyed to private_key for the current thread.
GStaticPrivate A GStaticPrivate works almost like a GPrivate, but it has one significant advantage. It doesn't need to be created at run-time like a GPrivate, but can be defined at compile-time.
G_STATIC_PRIVATE_INIT Every GStaticPrivate must be initialized with this macro, before it can be used.
g_static_private_init Initializes private_key. Alternatively, it can be initialized by G_STATIC_PRIVATE_INIT.
g_static_private_get Works like g_private_get() only for a GStaticPrivate.
g_static_private_set The possible stati of a one-time initialization function controlled by a GOnce struct.
g_static_private_free The possible stati of a one-time initialization function controlled by a GOnce struct.
GOnce The possible stati of a one-time initialization function controlled by a GOnce struct.
GOnceStatus The possible stati of a one-time initialization function controlled by a GOnce struct.
G_ONCE_INIT The first call to this routine by a process with a given GOnce struct calls func with the given argument.
g_once The first call to this routine by a process with a given GOnce struct calls func with the given argument.

Give feedback of this article

 


Thread Pools

Function

Description

GThreadPool The GThreadPool struct represents a thread pool.
g_thread_pool_new This function creates a new thread pool.
g_thread_pool_push Inserts data into the list of tasks to be executed by pool.
g_thread_pool_set_max_threads Sets the maximal allowed number of threads for pool.
g_thread_pool_get_max_threads Returns the maximal number of threads for pool.
g_thread_pool_get_num_threads Returns the number of threads currently running in pool.
g_thread_pool_unprocessed Returns the number of tasks still unprocessed in pool.
g_thread_pool_free Frees all resources allocated for pool.
g_thread_pool_set_max_unused_threads Sets the maximal number of unused threads to max_threads.
g_thread_pool_get_max_unused_threads Returns the maximal allowed number of unused threads.
g_thread_pool_get_num_unused_threads Returns the number of currently unused threads.
g_thread_pool_stop_unused_threads Stops all currently unused threads.
g_thread_pool_set_sort_function Sets the function used to sort the list of tasks
g_thread_pool_set_max_idle_time This function will set the maximum interval that a thread waiting in the pool for new tasks can be idle for before being stopped.
g_thread_pool_get_max_idle_time This function will return the maximum interval that a thread will wait in the thread pool for new tasks before being stopped.

Give feedback of this article

 


Timers

Function

Description

GTimer Opaque datatype that records a start time.
g_timer_new Creates a new timer, and starts timing (i.e. g_timer_start() is called implicitly ).
g_timer_start Marks a start time, so that future calls to g_timer_elapsed() will report the time since g_timer_start() was called.
g_timer_stop Marks an end time, so calls to g_timer_elapsed() will return the difference between this end time and the start time.
g_timer_continue Resumes a timer that has previously been stopped with g_timer_stop(). g_timer_stop() must be called before using this function.
g_timer_elapsed If timer has been started but not stopped, obtains the time since the timer was started.
g_timer_reset This function is useless; it's fine to call g_timer_start() on an already-started timer to reset the start time, so g_timer_reset() serves no purpose.
g_timer_destroy Destroys a timer, freeing associated resources.

Give feedback of this article

 


Trash Stacks

This chapter lists the functions that maintain a stack of unused allocated memory chunks.

Function

Description

GTrashStack Each piece of memory that is pushed onto the stack is cast to a GTrashStack.
g_trash_stack_push Pushes a piece of memory onto a GTrashStack.
g_trash_stack_pop Pops a piece of memory off a GTrashStack.
g_trash_stack_peek Returns the element at the top of a GTrashStack.
g_trash_stack_height Returns the height of a GTrashStack.

Give feedback of this article

 


Type Conversion Macros

Function

Description

GINT_TO_POINTER Stuffs an integer into a pointer type.
GPOINTER_TO_INT Extracts an integer from a pointer.
GUINT_TO_POINTER Stuffs an unsigned integer into a pointer type.
GPOINTER_TO_UINT Extracts an unsigned integer from a pointer.
GSIZE_TO_POINTER Stuffs a gsize into a pointer type.
GPOINTER_TO_SIZE Extracts a gsize from a pointer.

Give feedback of this article

 


Unicode Manipulation

Function

Description

gunichar A type which can hold any UCS-4 character code.
gunichar2 A type which can hold any UTF-16 code point.
g_unichar_validate Checks whether ch is a valid Unicode character.
g_unichar_isalnum Determines whether a character is alphanumeric.
g_unichar_isalpha Determines whether a character is alphabetic (i.e. a letter).
g_unichar_iscntrl Determines whether a character is a control character.
g_unichar_isdigit Determines whether a character is numeric (i.e. a digit).
g_unichar_isgraph Determines whether a character is printable and not a space (returns FALSE for control characters, format characters, and spaces).
g_unichar_islower Determines whether a character is a lowercase letter.
g_unichar_isprint Determines whether a character is printable.
g_unichar_ispunct Determines whether a character is punctuation or a symbol.
g_unichar_isspace Determines whether a character is a space, tab, or line separator (new line, carriage return, etc.).
g_unichar_isupper Determines if a character is uppercase.
g_unichar_isxdigit Determines if a character is a hexadecimal digit.
g_unichar_istitle Determines if a character is titlecase.
g_unichar_isdefined Determines if a given character is assigned in the Unicode standard.
g_unichar_iswide Determines if a character is typically rendered in a double-width cell.
g_unichar_toupper Converts a character to uppercase.
g_unichar_tolower Converts a character to lower case.
g_unichar_totitle Converts a character to the titlecase.
g_unichar_digit_value Determines the numeric value of a character as a decimal digit.
g_unichar_xdigit_value Determines the numeric value of a character as a hexadecimal digit.
GUnicodeType These are the possible character classifications.
g_unichar_type Classifies a Unicode character by type.
GUnicodeBreakType These are the possible line break classifications.
g_unichar_break_type Determines the break type of c. c should be a Unicode character.
g_unicode_canonical_ordering Determines the break type of c. c should be a Unicode character
g_unicode_canonical_decomposition Computes the canonical decomposition of a Unicode character.
g_unichar_get_mirror_char In Unicode, some characters are mirrored. This means that their images are mirrored horizontally in text that is laid out from right to left. For instance, "(" would become its mirror image, ")", in right-to-left text.
g_utf8_next_char Skips to the next character in a UTF-8 string.
g_utf8_get_char Converts a sequence of bytes encoded as UTF-8 to a Unicode character.
g_utf8_get_char_validated Convert a sequence of bytes encoded as UTF-8 to a Unicode character.
g_utf8_offset_to_pointer Converts from an integer character offset to a pointer to a position within the string.
g_utf8_pointer_to_offset Converts from a pointer to position within a string to a integer character offset.
g_utf8_prev_char Finds the previous UTF-8 character in the string before p.
g_utf8_find_next_char Finds the start of the next UTF-8 character in the string after p.
g_utf8_find_prev_char Given a position p with a UTF-8 encoded string str, find the start of the previous UTF-8 character starting before p. Returns NULL if no UTF-8 characters are present in str before p .
g_utf8_strlen Returns the length of the string in characters.
g_utf8_strncpy Like the standard C strncpy() function, but copies a given number of characters instead of a given number of bytes. The src string must be valid UTF-8 encoded text. (Use g_utf8_validate() on all text before trying to use UTF-8 utility functions with it.)
g_utf8_strchr Finds the leftmost occurrence of the given Unicode character in a UTF-8 encoded string, while limiting the search to len bytes. If len is -1, allow unbounded search.
g_utf8_strrchr Find the rightmost occurrence of the given Unicode character in a UTF-8 encoded string, while limiting the search to len bytes. If len is -1, allow unbounded search.
g_utf8_strreverse Reverses a UTF-8 string. str must be valid UTF-8 encoded text. (Use g_utf8_validate() on all text before trying to use UTF-8 utility functions with it.)
g_utf8_validate Validates UTF-8 encoded text.
g_utf8_strup Converts all Unicode characters in the string that have a case to uppercase.
g_utf8_strdown Converts all Unicode characters in the string that have a case to lowercase.
g_utf8_casefold Converts a string into a form that is independent of case.
g_utf8_normalize Converts a string into canonical form, standardizing such issues as whether a character with an accent is represented as a base character and combining accent or as a single pre-composed character.
GNormalizeMode Defines how a Unicode string is transformed in a canonical form, standardizing such issues as whether a character with an accent is represented as a base character and combining accent or as a single pre-composed character.
g_utf8_collate Compares two strings for ordering using the linguistically correct rules for the current locale.
g_utf8_collate_key Converts a string into a collation key that can be compared with other collation keys produced by the same function using strcmp().
g_utf8_collate_key_for_filename Converts a string into a collation key that can be compared with other collation keys produced by the same function using strcmp().
g_utf8_to_utf16 Convert a string from UTF-8 to UTF-16. A 0 word will be added to the result after the converted text.
g_utf8_to_ucs4 Convert a string from UTF-8 to a 32-bit fixed width representation as UCS-4. A trailing 0 will be added to the string after the converted text.
g_utf8_to_ucs4_fast Convert a string from UTF-8 to a 32-bit fixed width representation as UCS-4, assuming valid UTF-8 input. This function is roughly twice as fast as g_utf8_to_ucs4() but does no error checking on the input.
g_utf16_to_ucs4 Convert a string from UTF-16 to UCS-4. The result will be terminated with a 0 character.
g_utf16_to_utf8 Convert a string from UTF-16 to UTF-8. The result will be terminated with a 0 byte.
g_ucs4_to_utf16 Convert a string from UCS-4 to UTF-16. A 0 character will be added to the result after the converted text.
g_ucs4_to_utf8 Convert a string from a 32-bit fixed width representation as UCS-4. to UTF-8. The result will be terminated with a 0 byte.
g_unichar_to_utf8 Converts a single character to UTF-8.

Give feedback of this article

 


Version Information

This chapter lists functions of type Version Information.

Function

Description

glib_major_version The major version number of the GLib library.
glib_minor_version The minor version number of the GLib library.
glib_micro_version The micro version number of the GLib library.
glib_binary_age This is the binary age passed to libtool.
glib_interface_age This is the interface age passed to libtool.
glib_check_version Checks that the GLib library in use is compatible with the given version.
GLIB_MAJOR_VERSION The major version number of the GLib library.
GLIB_MINOR_VERSION The minor version number of the GLib library.
GLIB_MICRO_VERSION The micro version number of the GLib library.
GLIB_CHECK_VERSION Checks the version of the GLib library.

Give feedback of this article


©Nokia 2007

Back to top


This material, including documentation and any related computer programs, is protected by copyright controlled by Nokia. All rights are reserved. Copying, including reproducing, storing, adapting or translating, any or all of this material requires the prior written consent of Nokia. This material also contains confidential information, which may not be disclosed to others without the prior written consent of Nokia.

Nokia is a registered trademark of Nokia Corporation. S60 and logo is a trademark of Nokia Corporation. Java and all Java-based marks are trademarks or registered trademarks of Sun Microsystems, Inc. Other company and product names mentioned herein may be trademarks or tradenames of their respective owners.