version bump to 1.1.3, binary age 0, interface age 0.

Sun Aug 16 20:28:27 1998  Tim Janik  <timj@gtk.org>

        * version bump to 1.1.3, binary age 0, interface age 0.

        * glib.h: be nice to platforms that don't have gint64 and don't
        issue #warning on every compilation. since glib doesn't require
        gint64 itself, packages that need gint64 should test for this
        themselves.

        * glib.h:
        * gutils.c: added a new function g_vsnprintf().

Fri Aug 14 16:41:53 1998  Tim Janik  <timj@gtk.org>

        * glib.h: added static inline functions for bit mask tests:
        g_bit_nth_lsf, g_bit_nth_msf and g_bit_storage.

Fri Aug 13 14:23:37 1998  Tim Janik  <timj@gtk.org>

        * glib.h:
        * gmessages.c:
        revised the message handling system, which is now based on a new
        mechanism g_log*. most of the assertment macros got adapted to
        feature the new g_log() call with an additional specification of
        the log level in a preprocessor macro G_LOG_DOMAIN. if G_LOG_DOMAIN
        is undefined upon the includion of glib.h, it'll be defined with a
        value of (NULL) and thus preserves the original bahaviour for
        warning and error messages. the message handler setting functions
        for g_warning, g_error and g_message are only provided for backwards
        compatibility and might get removed somewhen.

        * Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
        to "GLib" upon compilation. we currently have to add this definition
        to the DEFS variable.
        * testglib.c: we need an ugly #undef G_LOG_DOMAIN at the start
        of this file currently, since automake doesn't support per target
        _CFLAGS yet.

        * glib.h: changed some gints to gbooleans, made a few const corrections,
        removed some superfluous G_STMT_START{}G_STMT_END wrappers, added some
        in other required places.

        * gnode.c:
        (g_node_prepend):
        (g_node_insert_before):
        (g_node_insert):
        (g_node_append_data):
        (g_node_prepend_data):
        (g_node_insert_data_before):
        (g_node_insert_data):
        (g_node_append):
        return (node), so these macros/functions can be usefully chained with
        g_node_new().

[GModule]
Fri Aug 14 02:24:39 1998  Tim Janik  <timj@gtk.org>

        * Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
        to "GModule" upon compilation. we currently have to add this definition
        to the DEFS variable.
        * testgmodule.c: we need an ugly #undef G_LOG_DOMAIN at the start
        of this file currently, since automake doesn't support per target
        _CFLAGS yet.
This commit is contained in:
Tim Janik 1998-08-16 21:14:11 +00:00 committed by Tim Janik
parent ab385b6f05
commit d5803865b4
37 changed files with 2513 additions and 747 deletions

View File

@ -1,6 +1,61 @@
Sun Aug 16 20:28:27 1998 Tim Janik <timj@gtk.org>
* version bump to 1.1.3, binary age 0, interface age 0.
* glib.h: be nice to platforms that don't have gint64 and don't
issue #warning on every compilation. since glib doesn't require
gint64 itself, packages that need gint64 should test for this
themselves.
* glib.h:
* gutils.c: added a new function g_vsnprintf().
Sun Aug 16 Elliot Lee
glib.h - #error out if we don't recognize the SIZEOF_VOID_P
#warning if no gint64
glib.h: #error out if we don't recognize the SIZEOF_VOID_P
#warning if no gint64
Fri Aug 14 16:41:53 1998 Tim Janik <timj@gtk.org>
* glib.h: added static inline functions for bit mask tests:
g_bit_nth_lsf, g_bit_nth_msf and g_bit_storage.
Fri Aug 13 14:23:37 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gmessages.c:
revised the message handling system, which is now based on a new
mechanism g_log*. most of the assertment macros got adapted to
feature the new g_log() call with an additional specification of
the log level in a preprocessor macro G_LOG_DOMAIN. if G_LOG_DOMAIN
is undefined upon the includion of glib.h, it'll be defined with a
value of (NULL) and thus preserves the original bahaviour for
warning and error messages. the message handler setting functions
for g_warning, g_error and g_message are only provided for backwards
compatibility and might get removed somewhen.
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GLib" upon compilation. we currently have to add this definition
to the DEFS variable.
* testglib.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
* glib.h: changed some gints to gbooleans, made a few const corrections,
removed some superfluous G_STMT_START{}G_STMT_END wrappers, added some
in other required places.
* gnode.c:
(g_node_prepend):
(g_node_insert_before):
(g_node_insert):
(g_node_append_data):
(g_node_prepend_data):
(g_node_insert_data_before):
(g_node_insert_data):
(g_node_append):
return (node), so these macros/functions can be usefully chained with
g_node_new().
Mon Aug 10 17:56:11 PDT 1998 Manish Singh <yosh@gimp.org>

View File

@ -1,6 +1,61 @@
Sun Aug 16 20:28:27 1998 Tim Janik <timj@gtk.org>
* version bump to 1.1.3, binary age 0, interface age 0.
* glib.h: be nice to platforms that don't have gint64 and don't
issue #warning on every compilation. since glib doesn't require
gint64 itself, packages that need gint64 should test for this
themselves.
* glib.h:
* gutils.c: added a new function g_vsnprintf().
Sun Aug 16 Elliot Lee
glib.h - #error out if we don't recognize the SIZEOF_VOID_P
#warning if no gint64
glib.h: #error out if we don't recognize the SIZEOF_VOID_P
#warning if no gint64
Fri Aug 14 16:41:53 1998 Tim Janik <timj@gtk.org>
* glib.h: added static inline functions for bit mask tests:
g_bit_nth_lsf, g_bit_nth_msf and g_bit_storage.
Fri Aug 13 14:23:37 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gmessages.c:
revised the message handling system, which is now based on a new
mechanism g_log*. most of the assertment macros got adapted to
feature the new g_log() call with an additional specification of
the log level in a preprocessor macro G_LOG_DOMAIN. if G_LOG_DOMAIN
is undefined upon the includion of glib.h, it'll be defined with a
value of (NULL) and thus preserves the original bahaviour for
warning and error messages. the message handler setting functions
for g_warning, g_error and g_message are only provided for backwards
compatibility and might get removed somewhen.
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GLib" upon compilation. we currently have to add this definition
to the DEFS variable.
* testglib.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
* glib.h: changed some gints to gbooleans, made a few const corrections,
removed some superfluous G_STMT_START{}G_STMT_END wrappers, added some
in other required places.
* gnode.c:
(g_node_prepend):
(g_node_insert_before):
(g_node_insert):
(g_node_append_data):
(g_node_prepend_data):
(g_node_insert_data_before):
(g_node_insert_data):
(g_node_append):
return (node), so these macros/functions can be usefully chained with
g_node_new().
Mon Aug 10 17:56:11 PDT 1998 Manish Singh <yosh@gimp.org>

View File

@ -1,6 +1,61 @@
Sun Aug 16 20:28:27 1998 Tim Janik <timj@gtk.org>
* version bump to 1.1.3, binary age 0, interface age 0.
* glib.h: be nice to platforms that don't have gint64 and don't
issue #warning on every compilation. since glib doesn't require
gint64 itself, packages that need gint64 should test for this
themselves.
* glib.h:
* gutils.c: added a new function g_vsnprintf().
Sun Aug 16 Elliot Lee
glib.h - #error out if we don't recognize the SIZEOF_VOID_P
#warning if no gint64
glib.h: #error out if we don't recognize the SIZEOF_VOID_P
#warning if no gint64
Fri Aug 14 16:41:53 1998 Tim Janik <timj@gtk.org>
* glib.h: added static inline functions for bit mask tests:
g_bit_nth_lsf, g_bit_nth_msf and g_bit_storage.
Fri Aug 13 14:23:37 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gmessages.c:
revised the message handling system, which is now based on a new
mechanism g_log*. most of the assertment macros got adapted to
feature the new g_log() call with an additional specification of
the log level in a preprocessor macro G_LOG_DOMAIN. if G_LOG_DOMAIN
is undefined upon the includion of glib.h, it'll be defined with a
value of (NULL) and thus preserves the original bahaviour for
warning and error messages. the message handler setting functions
for g_warning, g_error and g_message are only provided for backwards
compatibility and might get removed somewhen.
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GLib" upon compilation. we currently have to add this definition
to the DEFS variable.
* testglib.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
* glib.h: changed some gints to gbooleans, made a few const corrections,
removed some superfluous G_STMT_START{}G_STMT_END wrappers, added some
in other required places.
* gnode.c:
(g_node_prepend):
(g_node_insert_before):
(g_node_insert):
(g_node_append_data):
(g_node_prepend_data):
(g_node_insert_data_before):
(g_node_insert_data):
(g_node_append):
return (node), so these macros/functions can be usefully chained with
g_node_new().
Mon Aug 10 17:56:11 PDT 1998 Manish Singh <yosh@gimp.org>

View File

@ -1,6 +1,61 @@
Sun Aug 16 20:28:27 1998 Tim Janik <timj@gtk.org>
* version bump to 1.1.3, binary age 0, interface age 0.
* glib.h: be nice to platforms that don't have gint64 and don't
issue #warning on every compilation. since glib doesn't require
gint64 itself, packages that need gint64 should test for this
themselves.
* glib.h:
* gutils.c: added a new function g_vsnprintf().
Sun Aug 16 Elliot Lee
glib.h - #error out if we don't recognize the SIZEOF_VOID_P
#warning if no gint64
glib.h: #error out if we don't recognize the SIZEOF_VOID_P
#warning if no gint64
Fri Aug 14 16:41:53 1998 Tim Janik <timj@gtk.org>
* glib.h: added static inline functions for bit mask tests:
g_bit_nth_lsf, g_bit_nth_msf and g_bit_storage.
Fri Aug 13 14:23:37 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gmessages.c:
revised the message handling system, which is now based on a new
mechanism g_log*. most of the assertment macros got adapted to
feature the new g_log() call with an additional specification of
the log level in a preprocessor macro G_LOG_DOMAIN. if G_LOG_DOMAIN
is undefined upon the includion of glib.h, it'll be defined with a
value of (NULL) and thus preserves the original bahaviour for
warning and error messages. the message handler setting functions
for g_warning, g_error and g_message are only provided for backwards
compatibility and might get removed somewhen.
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GLib" upon compilation. we currently have to add this definition
to the DEFS variable.
* testglib.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
* glib.h: changed some gints to gbooleans, made a few const corrections,
removed some superfluous G_STMT_START{}G_STMT_END wrappers, added some
in other required places.
* gnode.c:
(g_node_prepend):
(g_node_insert_before):
(g_node_insert):
(g_node_append_data):
(g_node_prepend_data):
(g_node_insert_data_before):
(g_node_insert_data):
(g_node_append):
return (node), so these macros/functions can be usefully chained with
g_node_new().
Mon Aug 10 17:56:11 PDT 1998 Manish Singh <yosh@gimp.org>

View File

@ -1,6 +1,61 @@
Sun Aug 16 20:28:27 1998 Tim Janik <timj@gtk.org>
* version bump to 1.1.3, binary age 0, interface age 0.
* glib.h: be nice to platforms that don't have gint64 and don't
issue #warning on every compilation. since glib doesn't require
gint64 itself, packages that need gint64 should test for this
themselves.
* glib.h:
* gutils.c: added a new function g_vsnprintf().
Sun Aug 16 Elliot Lee
glib.h - #error out if we don't recognize the SIZEOF_VOID_P
#warning if no gint64
glib.h: #error out if we don't recognize the SIZEOF_VOID_P
#warning if no gint64
Fri Aug 14 16:41:53 1998 Tim Janik <timj@gtk.org>
* glib.h: added static inline functions for bit mask tests:
g_bit_nth_lsf, g_bit_nth_msf and g_bit_storage.
Fri Aug 13 14:23:37 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gmessages.c:
revised the message handling system, which is now based on a new
mechanism g_log*. most of the assertment macros got adapted to
feature the new g_log() call with an additional specification of
the log level in a preprocessor macro G_LOG_DOMAIN. if G_LOG_DOMAIN
is undefined upon the includion of glib.h, it'll be defined with a
value of (NULL) and thus preserves the original bahaviour for
warning and error messages. the message handler setting functions
for g_warning, g_error and g_message are only provided for backwards
compatibility and might get removed somewhen.
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GLib" upon compilation. we currently have to add this definition
to the DEFS variable.
* testglib.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
* glib.h: changed some gints to gbooleans, made a few const corrections,
removed some superfluous G_STMT_START{}G_STMT_END wrappers, added some
in other required places.
* gnode.c:
(g_node_prepend):
(g_node_insert_before):
(g_node_insert):
(g_node_append_data):
(g_node_prepend_data):
(g_node_insert_data_before):
(g_node_insert_data):
(g_node_append):
return (node), so these macros/functions can be usefully chained with
g_node_new().
Mon Aug 10 17:56:11 PDT 1998 Manish Singh <yosh@gimp.org>

View File

@ -1,6 +1,61 @@
Sun Aug 16 20:28:27 1998 Tim Janik <timj@gtk.org>
* version bump to 1.1.3, binary age 0, interface age 0.
* glib.h: be nice to platforms that don't have gint64 and don't
issue #warning on every compilation. since glib doesn't require
gint64 itself, packages that need gint64 should test for this
themselves.
* glib.h:
* gutils.c: added a new function g_vsnprintf().
Sun Aug 16 Elliot Lee
glib.h - #error out if we don't recognize the SIZEOF_VOID_P
#warning if no gint64
glib.h: #error out if we don't recognize the SIZEOF_VOID_P
#warning if no gint64
Fri Aug 14 16:41:53 1998 Tim Janik <timj@gtk.org>
* glib.h: added static inline functions for bit mask tests:
g_bit_nth_lsf, g_bit_nth_msf and g_bit_storage.
Fri Aug 13 14:23:37 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gmessages.c:
revised the message handling system, which is now based on a new
mechanism g_log*. most of the assertment macros got adapted to
feature the new g_log() call with an additional specification of
the log level in a preprocessor macro G_LOG_DOMAIN. if G_LOG_DOMAIN
is undefined upon the includion of glib.h, it'll be defined with a
value of (NULL) and thus preserves the original bahaviour for
warning and error messages. the message handler setting functions
for g_warning, g_error and g_message are only provided for backwards
compatibility and might get removed somewhen.
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GLib" upon compilation. we currently have to add this definition
to the DEFS variable.
* testglib.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
* glib.h: changed some gints to gbooleans, made a few const corrections,
removed some superfluous G_STMT_START{}G_STMT_END wrappers, added some
in other required places.
* gnode.c:
(g_node_prepend):
(g_node_insert_before):
(g_node_insert):
(g_node_append_data):
(g_node_prepend_data):
(g_node_insert_data_before):
(g_node_insert_data):
(g_node_append):
return (node), so these macros/functions can be usefully chained with
g_node_new().
Mon Aug 10 17:56:11 PDT 1998 Manish Singh <yosh@gimp.org>

View File

@ -1,6 +1,61 @@
Sun Aug 16 20:28:27 1998 Tim Janik <timj@gtk.org>
* version bump to 1.1.3, binary age 0, interface age 0.
* glib.h: be nice to platforms that don't have gint64 and don't
issue #warning on every compilation. since glib doesn't require
gint64 itself, packages that need gint64 should test for this
themselves.
* glib.h:
* gutils.c: added a new function g_vsnprintf().
Sun Aug 16 Elliot Lee
glib.h - #error out if we don't recognize the SIZEOF_VOID_P
#warning if no gint64
glib.h: #error out if we don't recognize the SIZEOF_VOID_P
#warning if no gint64
Fri Aug 14 16:41:53 1998 Tim Janik <timj@gtk.org>
* glib.h: added static inline functions for bit mask tests:
g_bit_nth_lsf, g_bit_nth_msf and g_bit_storage.
Fri Aug 13 14:23:37 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gmessages.c:
revised the message handling system, which is now based on a new
mechanism g_log*. most of the assertment macros got adapted to
feature the new g_log() call with an additional specification of
the log level in a preprocessor macro G_LOG_DOMAIN. if G_LOG_DOMAIN
is undefined upon the includion of glib.h, it'll be defined with a
value of (NULL) and thus preserves the original bahaviour for
warning and error messages. the message handler setting functions
for g_warning, g_error and g_message are only provided for backwards
compatibility and might get removed somewhen.
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GLib" upon compilation. we currently have to add this definition
to the DEFS variable.
* testglib.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
* glib.h: changed some gints to gbooleans, made a few const corrections,
removed some superfluous G_STMT_START{}G_STMT_END wrappers, added some
in other required places.
* gnode.c:
(g_node_prepend):
(g_node_insert_before):
(g_node_insert):
(g_node_append_data):
(g_node_prepend_data):
(g_node_insert_data_before):
(g_node_insert_data):
(g_node_append):
return (node), so these macros/functions can be usefully chained with
g_node_new().
Mon Aug 10 17:56:11 PDT 1998 Manish Singh <yosh@gimp.org>

View File

@ -1,6 +1,61 @@
Sun Aug 16 20:28:27 1998 Tim Janik <timj@gtk.org>
* version bump to 1.1.3, binary age 0, interface age 0.
* glib.h: be nice to platforms that don't have gint64 and don't
issue #warning on every compilation. since glib doesn't require
gint64 itself, packages that need gint64 should test for this
themselves.
* glib.h:
* gutils.c: added a new function g_vsnprintf().
Sun Aug 16 Elliot Lee
glib.h - #error out if we don't recognize the SIZEOF_VOID_P
#warning if no gint64
glib.h: #error out if we don't recognize the SIZEOF_VOID_P
#warning if no gint64
Fri Aug 14 16:41:53 1998 Tim Janik <timj@gtk.org>
* glib.h: added static inline functions for bit mask tests:
g_bit_nth_lsf, g_bit_nth_msf and g_bit_storage.
Fri Aug 13 14:23:37 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gmessages.c:
revised the message handling system, which is now based on a new
mechanism g_log*. most of the assertment macros got adapted to
feature the new g_log() call with an additional specification of
the log level in a preprocessor macro G_LOG_DOMAIN. if G_LOG_DOMAIN
is undefined upon the includion of glib.h, it'll be defined with a
value of (NULL) and thus preserves the original bahaviour for
warning and error messages. the message handler setting functions
for g_warning, g_error and g_message are only provided for backwards
compatibility and might get removed somewhen.
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GLib" upon compilation. we currently have to add this definition
to the DEFS variable.
* testglib.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
* glib.h: changed some gints to gbooleans, made a few const corrections,
removed some superfluous G_STMT_START{}G_STMT_END wrappers, added some
in other required places.
* gnode.c:
(g_node_prepend):
(g_node_insert_before):
(g_node_insert):
(g_node_append_data):
(g_node_prepend_data):
(g_node_insert_data_before):
(g_node_insert_data):
(g_node_append):
return (node), so these macros/functions can be usefully chained with
g_node_new().
Mon Aug 10 17:56:11 PDT 1998 Manish Singh <yosh@gimp.org>

View File

@ -1,8 +1,8 @@
Simple install procedure
========================
% gzip -cd glib-1.1.2.tar.gz | tar xvf - # unpack the sources
% cd glib-1.1.2 # change to the toplevel directory
% gzip -cd glib-1.1.3.tar.gz | tar xvf - # unpack the sources
% cd glib-1.1.3 # change to the toplevel directory
% ./configure # run the `configure' script
% make # build GLIB
[ Become root if necessary ]

View File

@ -8,6 +8,8 @@ bin_SCRIPTS=glib-config
BUILT_SOURCES=glib-config
glib-config: glib-config.in
DEFS += -DG_LOG_DOMAIN=g_log_domain_glib
EXTRA_DIST = \
glib.m4 \
glib.spec

6
NEWS
View File

@ -1,3 +1,9 @@
Overview of Changes in GLib 1.1.3:
* New library gmodule included which basically wraps dlopen() facilities.
* New g_log() mechanism for logging of messages at different log levels,
associated with certain log domains.
Overview of Changes in GLib 1.1.2:
* Fixed packaging mistake which occured in 1.1.1

2
README
View File

@ -1,7 +1,7 @@
General Information
===================
This is GLib version 1.1.2. GLib, is a library which includes support
This is GLib version 1.1.3. GLib, is a library which includes support
routines for C such as lists, trees, hashes, memory allocation, and
many other things.

View File

@ -14,9 +14,9 @@ cflags_set=${CFLAGS+set}
#
GLIB_MAJOR_VERSION=1
GLIB_MINOR_VERSION=1
GLIB_MICRO_VERSION=2
GLIB_INTERFACE_AGE=1
GLIB_BINARY_AGE=2
GLIB_MICRO_VERSION=3
GLIB_INTERFACE_AGE=0
GLIB_BINARY_AGE=0
GLIB_VERSION=$GLIB_MAJOR_VERSION.$GLIB_MINOR_VERSION.$GLIB_MICRO_VERSION
AC_SUBST(GLIB_VERSION)

View File

@ -43,7 +43,7 @@ static GMemChunk *array_mem_chunk = NULL;
GArray*
g_array_new (gint zero_terminated)
g_array_new (gboolean zero_terminated)
{
GRealArray *array;
@ -63,8 +63,8 @@ g_array_new (gint zero_terminated)
}
void
g_array_free (GArray *array,
gint free_segment)
g_array_free (GArray *array,
gboolean free_segment)
{
if (free_segment)
g_free (array->data);

View File

@ -83,7 +83,7 @@ g_debug (const gchar *progname)
void
g_attach_process (const gchar *progname,
int query)
gboolean query)
{
if (!query || do_query ("attach to process"))
debug (progname, INTERACTIVE);
@ -91,7 +91,7 @@ g_attach_process (const gchar *progname,
void
g_stack_trace (const gchar *progname,
int query)
gboolean query)
{
if (!query || do_query ("print stack trace"))
debug (progname, STACK_TRACE);

View File

@ -83,7 +83,7 @@ g_debug (const gchar *progname)
void
g_attach_process (const gchar *progname,
int query)
gboolean query)
{
if (!query || do_query ("attach to process"))
debug (progname, INTERACTIVE);
@ -91,7 +91,7 @@ g_attach_process (const gchar *progname,
void
g_stack_trace (const gchar *progname,
int query)
gboolean query)
{
if (!query || do_query ("print stack trace"))
debug (progname, STACK_TRACE);

610
glib.h
View File

@ -19,8 +19,16 @@
#ifndef __G_LIB_H__
#define __G_LIB_H__
/* system specific config file
*/
#include <glibconfig.h>
/* support standard arg inline functions for assertment macros
*/
#include <stdarg.h>
/* optionally feature DMALLOC memory allocation debugger
*/
#ifdef USE_DMALLOC
#include "dmalloc.h"
#endif
@ -60,7 +68,6 @@
#endif /* HAVE_VALUES_H */
#ifdef HAVE_LIMITS_H
#include <limits.h>
@ -118,8 +125,8 @@
#define CLAMP(x, low, high) (((x) > (high)) ? (high) : (((x) < (low)) ? (low) : (x)))
/* Provide simple enum value macro wrappers that ease automated enum value
* stringification code.
/* Provide simple enum value macro wrappers that ease automated
* enum value stringification code. [abandoned]
*/
#if !defined (G_CODE_GENERATION)
#define G_ENUM( EnumerationName ) EnumerationName
@ -158,6 +165,7 @@
# endif
#endif
/* Provide macros to feature the GCC function attribute.
*/
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
@ -179,17 +187,9 @@
#define G_GNUC_CONST
#endif /* !__GNUC__ */
/* Hacker macro to place breakpoints for x86 machines.
* Actual use is strongly deprecated of course ;)
*/
#if defined (__i386__)
#define G_BREAKPOINT() G_STMT_START{ __asm__ ("int $03"); }G_STMT_END
#else /* !__i386__ */
#define G_BREAKPOINT()
#endif /* __i386__ */
/* Wrap the __PRETTY_FUNCTION__ and __FUNCTION__ variables with macros,
* so we can refer to them as strings unconditionally.
/* Wrap the gcc __PRETTY_FUNCTION__ and __FUNCTION__ variables with
* macros, so we can refer to them as strings unconditionally.
*/
#ifdef __GNUC__
#define G_GNUC_FUNCTION (__FUNCTION__)
@ -200,6 +200,16 @@
#endif /* !__GNUC__ */
/* Hacker macro to place breakpoints for x86 machines.
* Actual use is strongly deprecated of course ;)
*/
#if defined (__i386__)
#define G_BREAKPOINT() G_STMT_START{ __asm__ ("int $03"); }G_STMT_END
#else /* !__i386__ */
#define G_BREAKPOINT()
#endif /* __i386__ */
#ifndef ATEXIT
# ifdef HAVE_ATEXIT
# define ATEXIT(proc) (atexit (proc))
@ -216,8 +226,8 @@
#ifdef __DMALLOC_H__
#define g_new(type,count) ALLOC(type,count)
#define g_new0(type,count) CALLOC(type,count)
#define g_new(type, count) (ALLOC (type, count))
#define g_new0(type, count) (CALLOC (type, count))
#else /* __DMALLOC_H__ */
@ -243,13 +253,15 @@
g_mem_chunk_free ((mem_chunk), (mem)); \
} G_STMT_END
#define g_string(x) #x
/* Provide macros for error handling. The "assert" macros will
* exit on failure. The "return" macros will exit the current
* function. Two different definitions are given for the macros
* in order to support gcc's __PRETTY_FUNCTION__ capability.
* if G_DISABLE_ASSERT is not defined, in order to support gcc's
* __PRETTY_FUNCTION__ capability.
*/
#ifdef G_DISABLE_ASSERT
@ -261,37 +273,46 @@
#ifdef __GNUC__
#define g_assert(expr) G_STMT_START{\
if (!(expr)) \
g_error ("file %s: line %d (%s): \"%s\"", \
__FILE__, \
__LINE__, \
__PRETTY_FUNCTION__, \
#expr); }G_STMT_END
#define g_assert(expr) G_STMT_START{ \
if (!(expr)) \
g_log (G_LOG_DOMAIN, \
G_LOG_LEVEL_ERROR, \
"file %s: line %d (%s): assertion failed: (%s)", \
__FILE__, \
__LINE__, \
__PRETTY_FUNCTION__, \
#expr); }G_STMT_END
#define g_assert_not_reached() G_STMT_START{ \
g_error ("file %s: line %d (%s): \"should not be reached\"", \
__FILE__, \
__LINE__, \
__PRETTY_FUNCTION__); }G_STMT_END
#define g_assert_not_reached() G_STMT_START{ \
g_log (G_LOG_DOMAIN, \
G_LOG_LEVEL_ERROR, \
"file %s: line %d (%s): should not be reached", \
__FILE__, \
__LINE__, \
__PRETTY_FUNCTION__); }G_STMT_END
#else /* !__GNUC__ */
#define g_assert(expr) G_STMT_START{\
if (!(expr)) \
g_error ("file %s: line %d: \"%s\"", \
__FILE__, \
__LINE__, \
#expr); }G_STMT_END
#define g_assert(expr) G_STMT_START{ \
if (!(expr)) \
g_log (G_LOG_DOMAIN, \
G_LOG_LEVEL_ERROR, \
"file %s: line %d: assertion failed: (%s)", \
__FILE__, \
__LINE__, \
#expr); }G_STMT_END
#define g_assert_not_reached() G_STMT_START{ \
g_error ("file %s: line %d: \"should not be reached\"", \
__FILE__, \
__LINE__); }G_STMT_END
#define g_assert_not_reached() G_STMT_START{ \
g_log (G_LOG_DOMAIN, \
G_LOG_LEVEL_ERROR, \
"file %s: line %d: should not be reached", \
__FILE__, \
__LINE__); }G_STMT_END
#endif /* __GNUC__ */
#endif /* G_DISABLE_ASSERT */
#endif /* !G_DISABLE_ASSERT */
#ifdef G_DISABLE_CHECKS
@ -302,60 +323,74 @@
#ifdef __GNUC__
#define g_return_if_fail(expr) G_STMT_START{ \
if (!(expr)) \
{ \
g_warning ("file %s: line %d (%s): assertion \"%s\" failed.", \
__FILE__, \
__LINE__, \
__PRETTY_FUNCTION__, \
#expr); \
return; \
#define g_return_if_fail(expr) G_STMT_START{ \
if (!(expr)) \
{ \
g_log (G_LOG_DOMAIN, \
G_LOG_LEVEL_WARNING, \
"file %s: line %d (%s): assertion failed: (%s)", \
__FILE__, \
__LINE__, \
__PRETTY_FUNCTION__, \
#expr); \
return; \
}; }G_STMT_END
#define g_return_val_if_fail(expr,val) G_STMT_START{ \
if (!(expr)) \
{ \
g_warning ("file %s: line %d (%s): assertion \"%s\" failed.", \
__FILE__, \
__LINE__, \
__PRETTY_FUNCTION__, \
#expr); \
return val; \
#define g_return_val_if_fail(expr,val) G_STMT_START{ \
if (!(expr)) \
{ \
g_log (G_LOG_DOMAIN, \
G_LOG_LEVEL_WARNING, \
"file %s: line %d (%s): assertion failed: (%s)", \
__FILE__, \
__LINE__, \
__PRETTY_FUNCTION__, \
#expr); \
return val; \
}; }G_STMT_END
#else /* !__GNUC__ */
#define g_return_if_fail(expr) G_STMT_START{ \
if (!(expr)) \
{ \
g_warning ("file %s: line %d: assertion. \"%s\" failed", \
__FILE__, \
__LINE__, \
#expr); \
return; \
#define g_return_if_fail(expr) G_STMT_START{ \
if (!(expr)) \
{ \
g_log (G_LOG_DOMAIN, \
G_LOG_LEVEL_WARNING, \
"file %s: line %d: assertion failed: (%s)", \
__FILE__, \
__LINE__, \
#expr); \
return; \
}; }G_STMT_END
#define g_return_val_if_fail(expr, val) G_STMT_START{ \
if (!(expr)) \
{ \
g_warning ("file %s: line %d: assertion \"%s\" failed.", \
__FILE__, \
__LINE__, \
#expr); \
return val; \
#define g_return_val_if_fail(expr, val) G_STMT_START{ \
if (!(expr)) \
{ \
g_log (G_LOG_DOMAIN, \
G_LOG_LEVEL_WARNING, \
"file %s: line %d: assertion failed: (%s)", \
__FILE__, \
__LINE__, \
#expr); \
return val; \
}; }G_STMT_END
#endif /* !__GNUC__ */
#endif /* G_DISABLE_CHECKS */
#endif /* !G_DISABLE_CHECKS */
#ifdef __cplusplus
/* the #pragma } statment is used to fix up emacs' c-mode which gets
* confused by extern "C" {. the ansi standard says that compilers
* have to ignore #pragma directives that they don't know about,
* so we should be save in using this.
*/
extern "C" {
#pragma }
#endif /* __cplusplus */
/* Provide type definitions for commonly used types.
* These are useful because a "gint8" can be adjusted
* to be 1 byte (8 bits) on all platforms. Similarly and
@ -378,8 +413,8 @@ typedef float gfloat;
typedef double gdouble;
/* HAVE_LONG_DOUBLE doesn't work correctly on all platforms.
* Since gldouble isn't used anywhere, just disable it for now */
* Since gldouble isn't used anywhere, just disable it for now
*/
#if 0
#ifdef HAVE_LONG_DOUBLE
typedef long double gldouble;
@ -396,13 +431,11 @@ typedef signed char gint8;
typedef unsigned char guint8;
#endif /* SIZEOF_CHAR */
#if (SIZEOF_SHORT == 2)
typedef signed short gint16;
typedef unsigned short guint16;
#endif /* SIZEOF_SHORT */
#if (SIZEOF_INT == 4)
typedef signed int gint32;
typedef unsigned int guint32;
@ -422,12 +455,11 @@ typedef unsigned long long guint64;
#else
/* No gint64 */
#undef HAVE_GINT64
#warning "No gint64 available"
#endif
/* Define macros for storing integers inside pointers */
/* Define macros for storing integers inside pointers
*/
#if (SIZEOF_INT == SIZEOF_VOID_P)
#define GPOINTER_TO_INT(p) ((gint)(p))
@ -445,8 +477,7 @@ typedef unsigned long long guint64;
#define GUINT_TO_POINTER(u) ((gpointer)(gulong)(u))
#else
/* This should never happen */
#error "Unhandled SIZEOF_VOID_P"
#error SIZEOF_VOID_P unknown - This should never happen
#endif
typedef gint32 gssize;
@ -454,6 +485,19 @@ typedef guint32 gsize;
typedef guint32 GQuark;
typedef gint32 GTime;
/* Glib version.
*/
extern const guint glib_major_version;
extern const guint glib_minor_version;
extern const guint glib_micro_version;
extern const guint glib_interface_age;
extern const guint glib_binary_age;
/* Forward declarations of glib types.
*/
typedef struct _GList GList;
typedef struct _GSList GSList;
typedef struct _GHashTable GHashTable;
@ -477,35 +521,80 @@ typedef struct _GTuples GTuples;
typedef struct _GNode GNode;
typedef void (*GFunc) (gpointer data,
gpointer user_data);
typedef void (*GHFunc) (gpointer key,
gpointer value,
gpointer user_data);
typedef gpointer (*GCacheNewFunc) (gpointer key);
typedef gpointer (*GCacheDupFunc) (gpointer value);
typedef void (*GCacheDestroyFunc) (gpointer value);
typedef gint (*GTraverseFunc) (gpointer key,
gpointer value,
gpointer data);
typedef gboolean (*GNodeTraverseFunc) (GNode *node,
gpointer data);
typedef void (*GNodeForeachFunc) (GNode *node,
gpointer data);
typedef gint (*GSearchFunc) (gpointer key,
gpointer data);
typedef void (*GErrorFunc) (gchar *str);
typedef void (*GWarningFunc) (gchar *str);
typedef void (*GPrintFunc) (gchar *str);
typedef void (*GScannerMsgFunc) (GScanner *scanner,
gchar *message,
gint error);
typedef void (*GDestroyNotify) (gpointer data);
typedef enum
{
G_TRAVERSE_LEAFS = 1 << 0,
G_TRAVERSE_NON_LEAFS = 1 << 1,
G_TRAVERSE_ALL = G_TRAVERSE_LEAFS | G_TRAVERSE_NON_LEAFS,
G_TRAVERSE_MASK = 0x03
} GTraverseFlags;
typedef guint (*GHashFunc) (gconstpointer key);
typedef gint (*GCompareFunc) (gconstpointer a,
gconstpointer b);
typedef enum
{
G_IN_ORDER,
G_PRE_ORDER,
G_POST_ORDER,
G_LEVEL_ORDER
} GTraverseType;
/* Log level shift offset for user defined
* log levels (0-7 are used by GLib).
*/
#define G_LOG_LEVEL_USER_SHIFT (8)
/* Glib log levels and flags.
*/
typedef enum
{
/* log flags */
G_LOG_FLAG_RECURSION = 1 << 0,
G_LOG_FLAG_FATAL = 1 << 1,
/* GLib log levels */
G_LOG_LEVEL_ERROR = 1 << 2, /* always fatal */
G_LOG_LEVEL_CRITICAL = 1 << 3,
G_LOG_LEVEL_WARNING = 1 << 4,
G_LOG_LEVEL_MESSAGE = 1 << 5,
G_LOG_LEVEL_INFO = 1 << 6,
G_LOG_LEVEL_DEBUG = 1 << 7,
G_LOG_LEVEL_MASK = ~(G_LOG_FLAG_RECURSION | G_LOG_FLAG_FATAL)
} GLogLevelFlags;
/* GLib log levels that are considered fatal by default */
#define G_LOG_FATAL_MASK (G_LOG_FLAG_RECURSION | G_LOG_LEVEL_ERROR)
typedef gpointer (*GCacheNewFunc) (gpointer key);
typedef gpointer (*GCacheDupFunc) (gpointer value);
typedef void (*GCacheDestroyFunc) (gpointer value);
typedef gint (*GCompareFunc) (gconstpointer a,
gconstpointer b);
typedef gchar* (*GCompletionFunc) (gpointer);
typedef void (*GDestroyNotify) (gpointer data);
typedef void (*GFunc) (gpointer data,
gpointer user_data);
typedef guint (*GHashFunc) (gconstpointer key);
typedef void (*GHFunc) (gpointer key,
gpointer value,
gpointer user_data);
typedef void (*GLogFunc) (const gchar *log_domain,
GLogLevelFlags log_level,
const gchar *message,
gpointer user_data);
typedef gboolean (*GNodeTraverseFunc) (GNode *node,
gpointer data);
typedef void (*GNodeForeachFunc) (GNode *node,
gpointer data);
typedef gint (*GSearchFunc) (gpointer key,
gpointer data);
typedef void (*GScannerMsgFunc) (GScanner *scanner,
gchar *message,
gint error);
typedef gint (*GTraverseFunc) (gpointer key,
gpointer value,
gpointer data);
struct _GList
{
@ -562,21 +651,6 @@ struct _GMemChunk { gint dummy; };
struct _GListAllocator { gint dummy; };
struct _GStringChunk { gint dummy; };
typedef enum
{
G_IN_ORDER,
G_PRE_ORDER,
G_POST_ORDER,
G_LEVEL_ORDER
} GTraverseType;
typedef enum
{
G_TRAVERSE_LEAFS = 1 << 0,
G_TRAVERSE_NON_LEAFS = 1 << 1,
G_TRAVERSE_ALL = G_TRAVERSE_LEAFS | G_TRAVERSE_NON_LEAFS,
G_TRAVERSE_MASK = 0x03
} GTraverseFlags;
/* Doubly linked lists
*/
@ -619,10 +693,10 @@ void g_list_foreach (GList *list,
gpointer user_data);
gpointer g_list_nth_data (GList *list,
guint n);
#define g_list_previous(list) ((list) ? (((GList *)(list))->prev) : NULL)
#define g_list_next(list) ((list) ? (((GList *)(list))->next) : NULL)
/* Singly linked lists
*/
GSList* g_slist_alloc (void);
@ -663,9 +737,9 @@ void g_slist_foreach (GSList *list,
gpointer user_data);
gpointer g_slist_nth_data (GSList *list,
guint n);
#define g_slist_next(slist) ((slist) ? (((GSList *)(slist))->next) : NULL)
/* List Allocators
*/
GListAllocator* g_list_allocator_new (void);
@ -748,10 +822,10 @@ gint g_tree_nnodes (GTree *tree);
struct _GNode
{
gpointer data;
GNode *next;
GNode *prev;
GNode *parent;
GNode *children;
GNode *next;
GNode *prev;
GNode *parent;
GNode *children;
};
#define G_NODE_IS_ROOT(node) (((GNode*) (node))->parent == NULL && \
@ -762,13 +836,13 @@ struct _GNode
GNode* g_node_new (gpointer data);
void g_node_destroy (GNode *root);
void g_node_unlink (GNode *node);
void g_node_insert (GNode *parent,
GNode* g_node_insert (GNode *parent,
gint position,
GNode *node);
void g_node_insert_before (GNode *parent,
GNode* g_node_insert_before (GNode *parent,
GNode *sibling,
GNode *node);
void g_node_prepend (GNode *parent,
GNode* g_node_prepend (GNode *parent,
GNode *node);
guint g_node_n_nodes (GNode *root,
GTraverseFlags flags);
@ -782,21 +856,16 @@ GNode* g_node_find (GNode *root,
gpointer data);
/* convenience macros */
#define g_node_append(parent, node) G_STMT_START { \
g_node_insert_before ((parent), NULL, (node)); \
} G_STMT_END
#define g_node_insert_data(parent, position, data) G_STMT_START { \
g_node_insert ((parent), (position), g_node_new ((data))); \
} G_STMT_END
#define g_node_insert_data_before(parent, sibling, data) G_STMT_START { \
g_node_insert_before ((parent), (sibling), g_node_new ((data))); \
} G_STMT_END
#define g_node_prepend_data(parent, data) G_STMT_START { \
g_node_prepend ((parent), g_node_new ((data))); \
} G_STMT_END
#define g_node_append_data(parent, data) G_STMT_START { \
g_node_insert_before ((parent), NULL, g_node_new ((data))); \
} G_STMT_END
#define g_node_append(parent, node) \
g_node_insert_before ((parent), NULL, (node))
#define g_node_insert_data(parent, position, data) \
g_node_insert ((parent), (position), g_node_new (data))
#define g_node_insert_data_before(parent, sibling, data) \
g_node_insert_before ((parent), (sibling), g_node_new (data))
#define g_node_prepend_data(parent, data) \
g_node_prepend ((parent), g_node_new (data))
#define g_node_append_data(parent, data) \
g_node_insert_before ((parent), NULL, g_node_new (data))
/* traversal function, assumes that `node' is root
* (only traverses `node' and its subtree).
@ -845,18 +914,108 @@ GNode* g_node_last_sibling (GNode *node);
((GNode*) (node))->children : NULL)
/* Memory
/* Fatal error handlers
*/
void g_attach_process (const gchar *progname,
gboolean query);
void g_debug (const gchar *progname);
void g_stack_trace (const gchar *progname,
gboolean query);
/* Logging mechanism
*/
extern const gchar *g_log_domain_glib;
guint g_log_set_handler (const gchar *log_domain,
GLogLevelFlags log_levels,
GLogFunc log_func,
gpointer user_data);
void g_log_remove_handler (const gchar *log_domain,
guint handler_id);
void g_log_default_handler (const gchar *log_domain,
GLogLevelFlags log_level,
const gchar *message,
gpointer unused_data);
void g_log (const gchar *log_domain,
GLogLevelFlags log_level,
const gchar *format,
...) G_GNUC_PRINTF (3, 4);
void g_logv (const gchar *log_domain,
GLogLevelFlags log_level,
const gchar *format,
va_list *args1,
va_list *args2);
GLogLevelFlags g_log_set_fatal_mask (const gchar *log_domain,
GLogLevelFlags fatal_mask);
#ifndef G_LOG_DOMAIN
#define G_LOG_DOMAIN (NULL)
#endif /* G_LOG_DOMAIN */
#ifdef __GNUC__
#define g_error(format, args...) g_log (G_LOG_DOMAIN, \
G_LOG_LEVEL_ERROR, \
format, ##args)
#define g_message(format, args...) g_log (G_LOG_DOMAIN, \
G_LOG_LEVEL_MESSAGE, \
format, ##args)
#define g_warning(format, args...) g_log (G_LOG_DOMAIN, \
G_LOG_LEVEL_WARNING, \
format, ##args)
#else /* !__GNUC__ */
static inline void
g_error (const gchar *format,
...)
{
va_list arg_list1, arg_list2;
va_start (arg_list1, format); va_start (arg_list2, format);
g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_ERROR, format, &arg_list1, &arg_list2);
va_end (arg_list2); va_end (arg_list1);
}
static inline void
g_message (const gchar *format,
...)
{
va_list arg_list1, arg_list2;
va_start (arg_list1, format); va_start (arg_list2, format);
g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, format, &arg_list1, &arg_list2);
va_end (arg_list2); va_end (arg_list1);
}
static inline void
g_warning (const gchar *format,
...)
{
va_list arg_list1, arg_list2;
va_start (arg_list1, format); va_start (arg_list2, format);
g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, format, &arg_list1, &arg_list2);
va_end (arg_list2); va_end (arg_list1);
}
#endif /* !__GNUC__ */
typedef void (*GPrintFunc) (const gchar *string);
void g_print (const gchar *format,
...) G_GNUC_PRINTF (1, 2);
GPrintFunc g_set_print_handler (GPrintFunc func);
void g_printerr (const gchar *format,
...) G_GNUC_PRINTF (1, 2);
GPrintFunc g_set_printerr_handler (GPrintFunc func);
/* deprecated compatibility functions, use g_log_set_handler() instead */
typedef void (*GErrorFunc) (const gchar *str);
typedef void (*GWarningFunc) (const gchar *str);
GErrorFunc g_set_error_handler (GErrorFunc func);
GWarningFunc g_set_warning_handler (GWarningFunc func);
GPrintFunc g_set_message_handler (GPrintFunc func);
/* Memory allocation and debugging
*/
#ifdef USE_DMALLOC
#define g_malloc(size) (gpointer) MALLOC(size)
#define g_malloc0(size) (gpointer) CALLOC(char,size)
#define g_realloc(mem,size) (gpointer) REALLOC(mem,char,size)
#define g_free(mem) FREE(mem)
#define g_malloc(size) ((gpointer) MALLOC (size))
#define g_malloc0(size) ((gpointer) CALLOC (char, size))
#define g_realloc(mem,size) ((gpointer) REALLOC (mem, char, size))
#define g_free(mem) FREE (mem)
#else /* USE_DMALLOC */
#else /* !USE_DMALLOC */
gpointer g_malloc (gulong size);
gpointer g_malloc0 (gulong size);
@ -864,7 +1023,7 @@ gpointer g_realloc (gpointer mem,
gulong size);
void g_free (gpointer mem);
#endif /* USE_DMALLOC */
#endif /* !USE_DMALLOC */
void g_mem_profile (void);
void g_mem_check (gpointer mem);
@ -927,17 +1086,9 @@ gdouble g_timer_elapsed (GTimer *timer,
gulong *microseconds);
/* Output
*/
void g_error (const gchar *format, ...) G_GNUC_PRINTF (1, 2);
void g_warning (const gchar *format, ...) G_GNUC_PRINTF (1, 2);
void g_message (const gchar *format, ...) G_GNUC_PRINTF (1, 2);
void g_print (const gchar *format, ...) G_GNUC_PRINTF (1, 2);
/* String utility functions
*/
#define G_STR_DELIMITERS "_-|> <."
#define G_STR_DELIMITERS "_-|> <."
void g_strdelimit (gchar *string,
const gchar *delimiters,
gchar new_delimiter);
@ -955,7 +1106,7 @@ void g_strup (gchar *string);
void g_strreverse (gchar *string);
/* Retrive static info
/* Retrive static string info
*/
gchar* g_get_user_name (void);
gchar* g_get_real_name (void);
@ -974,35 +1125,75 @@ gint g_snprintf (gchar *string,
gulong n,
gchar const *format,
...) G_GNUC_PRINTF (3, 4);
gint g_vsnprintf (gchar *string,
gulong n,
gchar const *format,
va_list *args1,
va_list *args2);
gchar* g_basename (const gchar *file_name);
/* strings are newly allocated with g_malloc() */
gchar* g_dirname (const gchar *file_name);
gchar* g_get_current_dir (void);
/* We make the assumption that if memmove isn't available, then
* bcopy will do the job. This isn't safe everywhere. (bcopy can't
* necessarily handle overlapping copies) */
* necessarily handle overlapping copies).
* Either way, g_memmove() will not return a value.
*/
#ifdef HAVE_MEMMOVE
#define g_memmove memmove
#define g_memmove(dest, src, size) G_STMT_START { \
memmove ((dest), (src), (size)); \
} G_STMT_END
#else
#define g_memmove(a,b,c) bcopy((b), (a), (c))
#define g_memmove(dest, src, size) G_STMT_START { \
bcopy ((src), (dest), (size)); \
} G_STMT_END
#endif
/* Errors
/* Bit tests
*/
GErrorFunc g_set_error_handler (GErrorFunc func);
GWarningFunc g_set_warning_handler (GWarningFunc func);
GPrintFunc g_set_message_handler (GPrintFunc func);
GPrintFunc g_set_print_handler (GPrintFunc func);
void g_debug (const gchar *progname);
void g_attach_process (const gchar *progname,
gint query);
void g_stack_trace (const gchar *progname,
gint query);
static inline gint
g_bit_nth_lsf (guint32 mask,
gint nth_bit)
{
do
{
nth_bit++;
if (mask & (1 << (guint) nth_bit))
return nth_bit;
}
while (nth_bit < 32);
return -1;
}
static inline gint
g_bit_nth_msf (guint32 mask,
gint nth_bit)
{
if (nth_bit < 0)
nth_bit = 33;
do
{
nth_bit--;
if (mask & (1 << (guint) nth_bit))
return nth_bit;
}
while (nth_bit > 0);
return -1;
}
static inline guint
g_bit_storage (guint number)
{
register guint n_bits = 0;
do
{
n_bits++;
number = number >> 1;
} while (number);
return n_bits;
}
/* String Chunks
@ -1014,6 +1205,7 @@ gchar* g_string_chunk_insert (GStringChunk *chunk,
gchar* g_string_chunk_insert_const (GStringChunk *chunk,
const gchar *string);
/* Strings
*/
GString* g_string_new (const gchar *init);
@ -1050,6 +1242,7 @@ void g_string_sprintfa (GString *string,
const gchar *format,
...) G_GNUC_PRINTF (2, 3);
/* Resizable arrays
*/
#define g_array_length(array,type) \
@ -1067,9 +1260,9 @@ void g_string_sprintfa (GString *string,
#define g_array_index(array,type,index) \
((type*) array->data)[index]
GArray* g_array_new (gint zero_terminated);
GArray* g_array_new (gboolean zero_terminated);
void g_array_free (GArray *array,
gint free_segment);
gboolean free_segment);
GArray* g_rarray_append (GArray *array,
gpointer data,
gint size);
@ -1080,13 +1273,12 @@ GArray* g_rarray_truncate (GArray *array,
gint length,
gint size);
/* Resizable pointer array. This interface is much less complicated
* than the above. Add appends appends a pointer. Remove fills any
* cleared spot and shortens the array.
*/
#define g_ptr_array_index(array,index) (array->pdata)[index]
GPtrArray* g_ptr_array_new (void);
void g_ptr_array_free (GPtrArray *array,
gboolean free_seg);
@ -1099,14 +1291,13 @@ gboolean g_ptr_array_remove (GPtrArray *array,
void g_ptr_array_add (GPtrArray *array,
gpointer data);
/* Byte arrays, an array of guint8. Implemented as a GArray,
* but type-safe.
*/
GByteArray* g_byte_array_new (void);
void g_byte_array_free (GByteArray *array,
gint free_segment);
GByteArray* g_byte_array_append (GByteArray *array,
const guint8 *data,
guint len);
@ -1123,11 +1314,11 @@ GByteArray* g_byte_array_truncate (GByteArray *array,
*/
gint g_str_equal (gconstpointer v,
gconstpointer v2);
guint g_str_hash (gconstpointer v);
guint g_str_hash (gconstpointer v);
gint g_int_equal (gconstpointer v,
gconstpointer v2);
guint g_int_hash (gconstpointer v);
gint g_int_equal (gconstpointer v,
gconstpointer v2);
guint g_int_hash (gconstpointer v);
/* This "hash" function will just return the key's adress as an
* unsigned integer. Useful for hashing on plain adresses or
@ -1145,6 +1336,7 @@ GQuark g_quark_from_static_string (const gchar *string);
GQuark g_quark_from_string (const gchar *string);
gchar* g_quark_to_string (GQuark quark);
/* Location Associated Data
*/
void g_dataset_destroy (gconstpointer dataset_location);
@ -1157,14 +1349,20 @@ void g_dataset_id_set_data_full (gconstpointer dataset_location,
void g_dataset_id_set_destroy (gconstpointer dataset_location,
GQuark key_id,
GDestroyNotify destroy_func);
#define g_dataset_id_set_data(l,k,d) G_STMT_START{g_dataset_id_set_data_full((l),(k),(d),NULL);}G_STMT_END
#define g_dataset_id_remove_data(l,k) G_STMT_START{g_dataset_id_set_data((l),(k),NULL);}G_STMT_END
#define g_dataset_get_data(l,k) (g_dataset_id_get_data((l),g_quark_try_string(k)))
#define g_dataset_set_data_full(l,k,d,f) G_STMT_START{g_dataset_id_set_data_full((l),g_quark_from_string(k),(d),(f));}G_STMT_END
#define g_dataset_set_destroy(l,k,f) G_STMT_START{g_dataset_id_set_destroy((l),g_quark_from_string(k),(f));}G_STMT_END
#define g_dataset_set_data(l,k,d) G_STMT_START{g_dataset_set_data_full((l),(k),(d),NULL);}G_STMT_END
#define g_dataset_remove_data(l,k) G_STMT_START{g_dataset_set_data((l),(k),NULL);}G_STMT_END
#define g_dataset_id_set_data(l, k, d) \
g_dataset_id_set_data_full ((l), (k), (d), NULL)
#define g_dataset_id_remove_data(l, k) \
g_dataset_id_set_data ((l), (k), NULL)
#define g_dataset_get_data(l, k) \
(g_dataset_id_get_data ((l), g_quark_try_string (k)))
#define g_dataset_set_data_full(l, k, d, f) \
g_dataset_id_set_data_full ((l), g_quark_from_string (k), (d), (f))
#define g_dataset_set_destroy(l, k, f) \
g_dataset_id_set_destroy ((l), g_quark_from_string (k), (f))
#define g_dataset_set_data(l, k, d) \
g_dataset_set_data_full ((l), (k), (d), NULL)
#define g_dataset_remove_data(l,k) \
g_dataset_set_data ((l), (k), NULL)
/* GScanner: Flexible lexical scanner for general purpose.
@ -1385,7 +1583,6 @@ gint g_scanner_stat_mode (const gchar *filename);
} G_STMT_END
/* Completion */
struct _GCompletion
@ -1457,13 +1654,8 @@ gpointer g_tuples_index (GTuples *tuples,
gint field);
/* Glib version.
*/
extern const guint glib_major_version;
extern const guint glib_minor_version;
extern const guint glib_micro_version;
extern const guint glib_interface_age;
extern const guint glib_binary_age;
#ifdef __cplusplus
}

View File

@ -8,6 +8,8 @@ bin_SCRIPTS=glib-config
BUILT_SOURCES=glib-config
glib-config: glib-config.in
DEFS += -DG_LOG_DOMAIN=g_log_domain_glib
EXTRA_DIST = \
glib.m4 \
glib.spec

View File

@ -43,7 +43,7 @@ static GMemChunk *array_mem_chunk = NULL;
GArray*
g_array_new (gint zero_terminated)
g_array_new (gboolean zero_terminated)
{
GRealArray *array;
@ -63,8 +63,8 @@ g_array_new (gint zero_terminated)
}
void
g_array_free (GArray *array,
gint free_segment)
g_array_free (GArray *array,
gboolean free_segment)
{
if (free_segment)
g_free (array->data);

View File

@ -83,7 +83,7 @@ g_debug (const gchar *progname)
void
g_attach_process (const gchar *progname,
int query)
gboolean query)
{
if (!query || do_query ("attach to process"))
debug (progname, INTERACTIVE);
@ -91,7 +91,7 @@ g_attach_process (const gchar *progname,
void
g_stack_trace (const gchar *progname,
int query)
gboolean query)
{
if (!query || do_query ("print stack trace"))
debug (progname, STACK_TRACE);

View File

@ -83,7 +83,7 @@ g_debug (const gchar *progname)
void
g_attach_process (const gchar *progname,
int query)
gboolean query)
{
if (!query || do_query ("attach to process"))
debug (progname, INTERACTIVE);
@ -91,7 +91,7 @@ g_attach_process (const gchar *progname,
void
g_stack_trace (const gchar *progname,
int query)
gboolean query)
{
if (!query || do_query ("print stack trace"))
debug (progname, STACK_TRACE);

View File

@ -19,8 +19,16 @@
#ifndef __G_LIB_H__
#define __G_LIB_H__
/* system specific config file
*/
#include <glibconfig.h>
/* support standard arg inline functions for assertment macros
*/
#include <stdarg.h>
/* optionally feature DMALLOC memory allocation debugger
*/
#ifdef USE_DMALLOC
#include "dmalloc.h"
#endif
@ -60,7 +68,6 @@
#endif /* HAVE_VALUES_H */
#ifdef HAVE_LIMITS_H
#include <limits.h>
@ -118,8 +125,8 @@
#define CLAMP(x, low, high) (((x) > (high)) ? (high) : (((x) < (low)) ? (low) : (x)))
/* Provide simple enum value macro wrappers that ease automated enum value
* stringification code.
/* Provide simple enum value macro wrappers that ease automated
* enum value stringification code. [abandoned]
*/
#if !defined (G_CODE_GENERATION)
#define G_ENUM( EnumerationName ) EnumerationName
@ -158,6 +165,7 @@
# endif
#endif
/* Provide macros to feature the GCC function attribute.
*/
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
@ -179,17 +187,9 @@
#define G_GNUC_CONST
#endif /* !__GNUC__ */
/* Hacker macro to place breakpoints for x86 machines.
* Actual use is strongly deprecated of course ;)
*/
#if defined (__i386__)
#define G_BREAKPOINT() G_STMT_START{ __asm__ ("int $03"); }G_STMT_END
#else /* !__i386__ */
#define G_BREAKPOINT()
#endif /* __i386__ */
/* Wrap the __PRETTY_FUNCTION__ and __FUNCTION__ variables with macros,
* so we can refer to them as strings unconditionally.
/* Wrap the gcc __PRETTY_FUNCTION__ and __FUNCTION__ variables with
* macros, so we can refer to them as strings unconditionally.
*/
#ifdef __GNUC__
#define G_GNUC_FUNCTION (__FUNCTION__)
@ -200,6 +200,16 @@
#endif /* !__GNUC__ */
/* Hacker macro to place breakpoints for x86 machines.
* Actual use is strongly deprecated of course ;)
*/
#if defined (__i386__)
#define G_BREAKPOINT() G_STMT_START{ __asm__ ("int $03"); }G_STMT_END
#else /* !__i386__ */
#define G_BREAKPOINT()
#endif /* __i386__ */
#ifndef ATEXIT
# ifdef HAVE_ATEXIT
# define ATEXIT(proc) (atexit (proc))
@ -216,8 +226,8 @@
#ifdef __DMALLOC_H__
#define g_new(type,count) ALLOC(type,count)
#define g_new0(type,count) CALLOC(type,count)
#define g_new(type, count) (ALLOC (type, count))
#define g_new0(type, count) (CALLOC (type, count))
#else /* __DMALLOC_H__ */
@ -243,13 +253,15 @@
g_mem_chunk_free ((mem_chunk), (mem)); \
} G_STMT_END
#define g_string(x) #x
/* Provide macros for error handling. The "assert" macros will
* exit on failure. The "return" macros will exit the current
* function. Two different definitions are given for the macros
* in order to support gcc's __PRETTY_FUNCTION__ capability.
* if G_DISABLE_ASSERT is not defined, in order to support gcc's
* __PRETTY_FUNCTION__ capability.
*/
#ifdef G_DISABLE_ASSERT
@ -261,37 +273,46 @@
#ifdef __GNUC__
#define g_assert(expr) G_STMT_START{\
if (!(expr)) \
g_error ("file %s: line %d (%s): \"%s\"", \
__FILE__, \
__LINE__, \
__PRETTY_FUNCTION__, \
#expr); }G_STMT_END
#define g_assert(expr) G_STMT_START{ \
if (!(expr)) \
g_log (G_LOG_DOMAIN, \
G_LOG_LEVEL_ERROR, \
"file %s: line %d (%s): assertion failed: (%s)", \
__FILE__, \
__LINE__, \
__PRETTY_FUNCTION__, \
#expr); }G_STMT_END
#define g_assert_not_reached() G_STMT_START{ \
g_error ("file %s: line %d (%s): \"should not be reached\"", \
__FILE__, \
__LINE__, \
__PRETTY_FUNCTION__); }G_STMT_END
#define g_assert_not_reached() G_STMT_START{ \
g_log (G_LOG_DOMAIN, \
G_LOG_LEVEL_ERROR, \
"file %s: line %d (%s): should not be reached", \
__FILE__, \
__LINE__, \
__PRETTY_FUNCTION__); }G_STMT_END
#else /* !__GNUC__ */
#define g_assert(expr) G_STMT_START{\
if (!(expr)) \
g_error ("file %s: line %d: \"%s\"", \
__FILE__, \
__LINE__, \
#expr); }G_STMT_END
#define g_assert(expr) G_STMT_START{ \
if (!(expr)) \
g_log (G_LOG_DOMAIN, \
G_LOG_LEVEL_ERROR, \
"file %s: line %d: assertion failed: (%s)", \
__FILE__, \
__LINE__, \
#expr); }G_STMT_END
#define g_assert_not_reached() G_STMT_START{ \
g_error ("file %s: line %d: \"should not be reached\"", \
__FILE__, \
__LINE__); }G_STMT_END
#define g_assert_not_reached() G_STMT_START{ \
g_log (G_LOG_DOMAIN, \
G_LOG_LEVEL_ERROR, \
"file %s: line %d: should not be reached", \
__FILE__, \
__LINE__); }G_STMT_END
#endif /* __GNUC__ */
#endif /* G_DISABLE_ASSERT */
#endif /* !G_DISABLE_ASSERT */
#ifdef G_DISABLE_CHECKS
@ -302,60 +323,74 @@
#ifdef __GNUC__
#define g_return_if_fail(expr) G_STMT_START{ \
if (!(expr)) \
{ \
g_warning ("file %s: line %d (%s): assertion \"%s\" failed.", \
__FILE__, \
__LINE__, \
__PRETTY_FUNCTION__, \
#expr); \
return; \
#define g_return_if_fail(expr) G_STMT_START{ \
if (!(expr)) \
{ \
g_log (G_LOG_DOMAIN, \
G_LOG_LEVEL_WARNING, \
"file %s: line %d (%s): assertion failed: (%s)", \
__FILE__, \
__LINE__, \
__PRETTY_FUNCTION__, \
#expr); \
return; \
}; }G_STMT_END
#define g_return_val_if_fail(expr,val) G_STMT_START{ \
if (!(expr)) \
{ \
g_warning ("file %s: line %d (%s): assertion \"%s\" failed.", \
__FILE__, \
__LINE__, \
__PRETTY_FUNCTION__, \
#expr); \
return val; \
#define g_return_val_if_fail(expr,val) G_STMT_START{ \
if (!(expr)) \
{ \
g_log (G_LOG_DOMAIN, \
G_LOG_LEVEL_WARNING, \
"file %s: line %d (%s): assertion failed: (%s)", \
__FILE__, \
__LINE__, \
__PRETTY_FUNCTION__, \
#expr); \
return val; \
}; }G_STMT_END
#else /* !__GNUC__ */
#define g_return_if_fail(expr) G_STMT_START{ \
if (!(expr)) \
{ \
g_warning ("file %s: line %d: assertion. \"%s\" failed", \
__FILE__, \
__LINE__, \
#expr); \
return; \
#define g_return_if_fail(expr) G_STMT_START{ \
if (!(expr)) \
{ \
g_log (G_LOG_DOMAIN, \
G_LOG_LEVEL_WARNING, \
"file %s: line %d: assertion failed: (%s)", \
__FILE__, \
__LINE__, \
#expr); \
return; \
}; }G_STMT_END
#define g_return_val_if_fail(expr, val) G_STMT_START{ \
if (!(expr)) \
{ \
g_warning ("file %s: line %d: assertion \"%s\" failed.", \
__FILE__, \
__LINE__, \
#expr); \
return val; \
#define g_return_val_if_fail(expr, val) G_STMT_START{ \
if (!(expr)) \
{ \
g_log (G_LOG_DOMAIN, \
G_LOG_LEVEL_WARNING, \
"file %s: line %d: assertion failed: (%s)", \
__FILE__, \
__LINE__, \
#expr); \
return val; \
}; }G_STMT_END
#endif /* !__GNUC__ */
#endif /* G_DISABLE_CHECKS */
#endif /* !G_DISABLE_CHECKS */
#ifdef __cplusplus
/* the #pragma } statment is used to fix up emacs' c-mode which gets
* confused by extern "C" {. the ansi standard says that compilers
* have to ignore #pragma directives that they don't know about,
* so we should be save in using this.
*/
extern "C" {
#pragma }
#endif /* __cplusplus */
/* Provide type definitions for commonly used types.
* These are useful because a "gint8" can be adjusted
* to be 1 byte (8 bits) on all platforms. Similarly and
@ -378,8 +413,8 @@ typedef float gfloat;
typedef double gdouble;
/* HAVE_LONG_DOUBLE doesn't work correctly on all platforms.
* Since gldouble isn't used anywhere, just disable it for now */
* Since gldouble isn't used anywhere, just disable it for now
*/
#if 0
#ifdef HAVE_LONG_DOUBLE
typedef long double gldouble;
@ -396,13 +431,11 @@ typedef signed char gint8;
typedef unsigned char guint8;
#endif /* SIZEOF_CHAR */
#if (SIZEOF_SHORT == 2)
typedef signed short gint16;
typedef unsigned short guint16;
#endif /* SIZEOF_SHORT */
#if (SIZEOF_INT == 4)
typedef signed int gint32;
typedef unsigned int guint32;
@ -422,12 +455,11 @@ typedef unsigned long long guint64;
#else
/* No gint64 */
#undef HAVE_GINT64
#warning "No gint64 available"
#endif
/* Define macros for storing integers inside pointers */
/* Define macros for storing integers inside pointers
*/
#if (SIZEOF_INT == SIZEOF_VOID_P)
#define GPOINTER_TO_INT(p) ((gint)(p))
@ -445,8 +477,7 @@ typedef unsigned long long guint64;
#define GUINT_TO_POINTER(u) ((gpointer)(gulong)(u))
#else
/* This should never happen */
#error "Unhandled SIZEOF_VOID_P"
#error SIZEOF_VOID_P unknown - This should never happen
#endif
typedef gint32 gssize;
@ -454,6 +485,19 @@ typedef guint32 gsize;
typedef guint32 GQuark;
typedef gint32 GTime;
/* Glib version.
*/
extern const guint glib_major_version;
extern const guint glib_minor_version;
extern const guint glib_micro_version;
extern const guint glib_interface_age;
extern const guint glib_binary_age;
/* Forward declarations of glib types.
*/
typedef struct _GList GList;
typedef struct _GSList GSList;
typedef struct _GHashTable GHashTable;
@ -477,35 +521,80 @@ typedef struct _GTuples GTuples;
typedef struct _GNode GNode;
typedef void (*GFunc) (gpointer data,
gpointer user_data);
typedef void (*GHFunc) (gpointer key,
gpointer value,
gpointer user_data);
typedef gpointer (*GCacheNewFunc) (gpointer key);
typedef gpointer (*GCacheDupFunc) (gpointer value);
typedef void (*GCacheDestroyFunc) (gpointer value);
typedef gint (*GTraverseFunc) (gpointer key,
gpointer value,
gpointer data);
typedef gboolean (*GNodeTraverseFunc) (GNode *node,
gpointer data);
typedef void (*GNodeForeachFunc) (GNode *node,
gpointer data);
typedef gint (*GSearchFunc) (gpointer key,
gpointer data);
typedef void (*GErrorFunc) (gchar *str);
typedef void (*GWarningFunc) (gchar *str);
typedef void (*GPrintFunc) (gchar *str);
typedef void (*GScannerMsgFunc) (GScanner *scanner,
gchar *message,
gint error);
typedef void (*GDestroyNotify) (gpointer data);
typedef enum
{
G_TRAVERSE_LEAFS = 1 << 0,
G_TRAVERSE_NON_LEAFS = 1 << 1,
G_TRAVERSE_ALL = G_TRAVERSE_LEAFS | G_TRAVERSE_NON_LEAFS,
G_TRAVERSE_MASK = 0x03
} GTraverseFlags;
typedef guint (*GHashFunc) (gconstpointer key);
typedef gint (*GCompareFunc) (gconstpointer a,
gconstpointer b);
typedef enum
{
G_IN_ORDER,
G_PRE_ORDER,
G_POST_ORDER,
G_LEVEL_ORDER
} GTraverseType;
/* Log level shift offset for user defined
* log levels (0-7 are used by GLib).
*/
#define G_LOG_LEVEL_USER_SHIFT (8)
/* Glib log levels and flags.
*/
typedef enum
{
/* log flags */
G_LOG_FLAG_RECURSION = 1 << 0,
G_LOG_FLAG_FATAL = 1 << 1,
/* GLib log levels */
G_LOG_LEVEL_ERROR = 1 << 2, /* always fatal */
G_LOG_LEVEL_CRITICAL = 1 << 3,
G_LOG_LEVEL_WARNING = 1 << 4,
G_LOG_LEVEL_MESSAGE = 1 << 5,
G_LOG_LEVEL_INFO = 1 << 6,
G_LOG_LEVEL_DEBUG = 1 << 7,
G_LOG_LEVEL_MASK = ~(G_LOG_FLAG_RECURSION | G_LOG_FLAG_FATAL)
} GLogLevelFlags;
/* GLib log levels that are considered fatal by default */
#define G_LOG_FATAL_MASK (G_LOG_FLAG_RECURSION | G_LOG_LEVEL_ERROR)
typedef gpointer (*GCacheNewFunc) (gpointer key);
typedef gpointer (*GCacheDupFunc) (gpointer value);
typedef void (*GCacheDestroyFunc) (gpointer value);
typedef gint (*GCompareFunc) (gconstpointer a,
gconstpointer b);
typedef gchar* (*GCompletionFunc) (gpointer);
typedef void (*GDestroyNotify) (gpointer data);
typedef void (*GFunc) (gpointer data,
gpointer user_data);
typedef guint (*GHashFunc) (gconstpointer key);
typedef void (*GHFunc) (gpointer key,
gpointer value,
gpointer user_data);
typedef void (*GLogFunc) (const gchar *log_domain,
GLogLevelFlags log_level,
const gchar *message,
gpointer user_data);
typedef gboolean (*GNodeTraverseFunc) (GNode *node,
gpointer data);
typedef void (*GNodeForeachFunc) (GNode *node,
gpointer data);
typedef gint (*GSearchFunc) (gpointer key,
gpointer data);
typedef void (*GScannerMsgFunc) (GScanner *scanner,
gchar *message,
gint error);
typedef gint (*GTraverseFunc) (gpointer key,
gpointer value,
gpointer data);
struct _GList
{
@ -562,21 +651,6 @@ struct _GMemChunk { gint dummy; };
struct _GListAllocator { gint dummy; };
struct _GStringChunk { gint dummy; };
typedef enum
{
G_IN_ORDER,
G_PRE_ORDER,
G_POST_ORDER,
G_LEVEL_ORDER
} GTraverseType;
typedef enum
{
G_TRAVERSE_LEAFS = 1 << 0,
G_TRAVERSE_NON_LEAFS = 1 << 1,
G_TRAVERSE_ALL = G_TRAVERSE_LEAFS | G_TRAVERSE_NON_LEAFS,
G_TRAVERSE_MASK = 0x03
} GTraverseFlags;
/* Doubly linked lists
*/
@ -619,10 +693,10 @@ void g_list_foreach (GList *list,
gpointer user_data);
gpointer g_list_nth_data (GList *list,
guint n);
#define g_list_previous(list) ((list) ? (((GList *)(list))->prev) : NULL)
#define g_list_next(list) ((list) ? (((GList *)(list))->next) : NULL)
/* Singly linked lists
*/
GSList* g_slist_alloc (void);
@ -663,9 +737,9 @@ void g_slist_foreach (GSList *list,
gpointer user_data);
gpointer g_slist_nth_data (GSList *list,
guint n);
#define g_slist_next(slist) ((slist) ? (((GSList *)(slist))->next) : NULL)
/* List Allocators
*/
GListAllocator* g_list_allocator_new (void);
@ -748,10 +822,10 @@ gint g_tree_nnodes (GTree *tree);
struct _GNode
{
gpointer data;
GNode *next;
GNode *prev;
GNode *parent;
GNode *children;
GNode *next;
GNode *prev;
GNode *parent;
GNode *children;
};
#define G_NODE_IS_ROOT(node) (((GNode*) (node))->parent == NULL && \
@ -762,13 +836,13 @@ struct _GNode
GNode* g_node_new (gpointer data);
void g_node_destroy (GNode *root);
void g_node_unlink (GNode *node);
void g_node_insert (GNode *parent,
GNode* g_node_insert (GNode *parent,
gint position,
GNode *node);
void g_node_insert_before (GNode *parent,
GNode* g_node_insert_before (GNode *parent,
GNode *sibling,
GNode *node);
void g_node_prepend (GNode *parent,
GNode* g_node_prepend (GNode *parent,
GNode *node);
guint g_node_n_nodes (GNode *root,
GTraverseFlags flags);
@ -782,21 +856,16 @@ GNode* g_node_find (GNode *root,
gpointer data);
/* convenience macros */
#define g_node_append(parent, node) G_STMT_START { \
g_node_insert_before ((parent), NULL, (node)); \
} G_STMT_END
#define g_node_insert_data(parent, position, data) G_STMT_START { \
g_node_insert ((parent), (position), g_node_new ((data))); \
} G_STMT_END
#define g_node_insert_data_before(parent, sibling, data) G_STMT_START { \
g_node_insert_before ((parent), (sibling), g_node_new ((data))); \
} G_STMT_END
#define g_node_prepend_data(parent, data) G_STMT_START { \
g_node_prepend ((parent), g_node_new ((data))); \
} G_STMT_END
#define g_node_append_data(parent, data) G_STMT_START { \
g_node_insert_before ((parent), NULL, g_node_new ((data))); \
} G_STMT_END
#define g_node_append(parent, node) \
g_node_insert_before ((parent), NULL, (node))
#define g_node_insert_data(parent, position, data) \
g_node_insert ((parent), (position), g_node_new (data))
#define g_node_insert_data_before(parent, sibling, data) \
g_node_insert_before ((parent), (sibling), g_node_new (data))
#define g_node_prepend_data(parent, data) \
g_node_prepend ((parent), g_node_new (data))
#define g_node_append_data(parent, data) \
g_node_insert_before ((parent), NULL, g_node_new (data))
/* traversal function, assumes that `node' is root
* (only traverses `node' and its subtree).
@ -845,18 +914,108 @@ GNode* g_node_last_sibling (GNode *node);
((GNode*) (node))->children : NULL)
/* Memory
/* Fatal error handlers
*/
void g_attach_process (const gchar *progname,
gboolean query);
void g_debug (const gchar *progname);
void g_stack_trace (const gchar *progname,
gboolean query);
/* Logging mechanism
*/
extern const gchar *g_log_domain_glib;
guint g_log_set_handler (const gchar *log_domain,
GLogLevelFlags log_levels,
GLogFunc log_func,
gpointer user_data);
void g_log_remove_handler (const gchar *log_domain,
guint handler_id);
void g_log_default_handler (const gchar *log_domain,
GLogLevelFlags log_level,
const gchar *message,
gpointer unused_data);
void g_log (const gchar *log_domain,
GLogLevelFlags log_level,
const gchar *format,
...) G_GNUC_PRINTF (3, 4);
void g_logv (const gchar *log_domain,
GLogLevelFlags log_level,
const gchar *format,
va_list *args1,
va_list *args2);
GLogLevelFlags g_log_set_fatal_mask (const gchar *log_domain,
GLogLevelFlags fatal_mask);
#ifndef G_LOG_DOMAIN
#define G_LOG_DOMAIN (NULL)
#endif /* G_LOG_DOMAIN */
#ifdef __GNUC__
#define g_error(format, args...) g_log (G_LOG_DOMAIN, \
G_LOG_LEVEL_ERROR, \
format, ##args)
#define g_message(format, args...) g_log (G_LOG_DOMAIN, \
G_LOG_LEVEL_MESSAGE, \
format, ##args)
#define g_warning(format, args...) g_log (G_LOG_DOMAIN, \
G_LOG_LEVEL_WARNING, \
format, ##args)
#else /* !__GNUC__ */
static inline void
g_error (const gchar *format,
...)
{
va_list arg_list1, arg_list2;
va_start (arg_list1, format); va_start (arg_list2, format);
g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_ERROR, format, &arg_list1, &arg_list2);
va_end (arg_list2); va_end (arg_list1);
}
static inline void
g_message (const gchar *format,
...)
{
va_list arg_list1, arg_list2;
va_start (arg_list1, format); va_start (arg_list2, format);
g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, format, &arg_list1, &arg_list2);
va_end (arg_list2); va_end (arg_list1);
}
static inline void
g_warning (const gchar *format,
...)
{
va_list arg_list1, arg_list2;
va_start (arg_list1, format); va_start (arg_list2, format);
g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, format, &arg_list1, &arg_list2);
va_end (arg_list2); va_end (arg_list1);
}
#endif /* !__GNUC__ */
typedef void (*GPrintFunc) (const gchar *string);
void g_print (const gchar *format,
...) G_GNUC_PRINTF (1, 2);
GPrintFunc g_set_print_handler (GPrintFunc func);
void g_printerr (const gchar *format,
...) G_GNUC_PRINTF (1, 2);
GPrintFunc g_set_printerr_handler (GPrintFunc func);
/* deprecated compatibility functions, use g_log_set_handler() instead */
typedef void (*GErrorFunc) (const gchar *str);
typedef void (*GWarningFunc) (const gchar *str);
GErrorFunc g_set_error_handler (GErrorFunc func);
GWarningFunc g_set_warning_handler (GWarningFunc func);
GPrintFunc g_set_message_handler (GPrintFunc func);
/* Memory allocation and debugging
*/
#ifdef USE_DMALLOC
#define g_malloc(size) (gpointer) MALLOC(size)
#define g_malloc0(size) (gpointer) CALLOC(char,size)
#define g_realloc(mem,size) (gpointer) REALLOC(mem,char,size)
#define g_free(mem) FREE(mem)
#define g_malloc(size) ((gpointer) MALLOC (size))
#define g_malloc0(size) ((gpointer) CALLOC (char, size))
#define g_realloc(mem,size) ((gpointer) REALLOC (mem, char, size))
#define g_free(mem) FREE (mem)
#else /* USE_DMALLOC */
#else /* !USE_DMALLOC */
gpointer g_malloc (gulong size);
gpointer g_malloc0 (gulong size);
@ -864,7 +1023,7 @@ gpointer g_realloc (gpointer mem,
gulong size);
void g_free (gpointer mem);
#endif /* USE_DMALLOC */
#endif /* !USE_DMALLOC */
void g_mem_profile (void);
void g_mem_check (gpointer mem);
@ -927,17 +1086,9 @@ gdouble g_timer_elapsed (GTimer *timer,
gulong *microseconds);
/* Output
*/
void g_error (const gchar *format, ...) G_GNUC_PRINTF (1, 2);
void g_warning (const gchar *format, ...) G_GNUC_PRINTF (1, 2);
void g_message (const gchar *format, ...) G_GNUC_PRINTF (1, 2);
void g_print (const gchar *format, ...) G_GNUC_PRINTF (1, 2);
/* String utility functions
*/
#define G_STR_DELIMITERS "_-|> <."
#define G_STR_DELIMITERS "_-|> <."
void g_strdelimit (gchar *string,
const gchar *delimiters,
gchar new_delimiter);
@ -955,7 +1106,7 @@ void g_strup (gchar *string);
void g_strreverse (gchar *string);
/* Retrive static info
/* Retrive static string info
*/
gchar* g_get_user_name (void);
gchar* g_get_real_name (void);
@ -974,35 +1125,75 @@ gint g_snprintf (gchar *string,
gulong n,
gchar const *format,
...) G_GNUC_PRINTF (3, 4);
gint g_vsnprintf (gchar *string,
gulong n,
gchar const *format,
va_list *args1,
va_list *args2);
gchar* g_basename (const gchar *file_name);
/* strings are newly allocated with g_malloc() */
gchar* g_dirname (const gchar *file_name);
gchar* g_get_current_dir (void);
/* We make the assumption that if memmove isn't available, then
* bcopy will do the job. This isn't safe everywhere. (bcopy can't
* necessarily handle overlapping copies) */
* necessarily handle overlapping copies).
* Either way, g_memmove() will not return a value.
*/
#ifdef HAVE_MEMMOVE
#define g_memmove memmove
#define g_memmove(dest, src, size) G_STMT_START { \
memmove ((dest), (src), (size)); \
} G_STMT_END
#else
#define g_memmove(a,b,c) bcopy((b), (a), (c))
#define g_memmove(dest, src, size) G_STMT_START { \
bcopy ((src), (dest), (size)); \
} G_STMT_END
#endif
/* Errors
/* Bit tests
*/
GErrorFunc g_set_error_handler (GErrorFunc func);
GWarningFunc g_set_warning_handler (GWarningFunc func);
GPrintFunc g_set_message_handler (GPrintFunc func);
GPrintFunc g_set_print_handler (GPrintFunc func);
void g_debug (const gchar *progname);
void g_attach_process (const gchar *progname,
gint query);
void g_stack_trace (const gchar *progname,
gint query);
static inline gint
g_bit_nth_lsf (guint32 mask,
gint nth_bit)
{
do
{
nth_bit++;
if (mask & (1 << (guint) nth_bit))
return nth_bit;
}
while (nth_bit < 32);
return -1;
}
static inline gint
g_bit_nth_msf (guint32 mask,
gint nth_bit)
{
if (nth_bit < 0)
nth_bit = 33;
do
{
nth_bit--;
if (mask & (1 << (guint) nth_bit))
return nth_bit;
}
while (nth_bit > 0);
return -1;
}
static inline guint
g_bit_storage (guint number)
{
register guint n_bits = 0;
do
{
n_bits++;
number = number >> 1;
} while (number);
return n_bits;
}
/* String Chunks
@ -1014,6 +1205,7 @@ gchar* g_string_chunk_insert (GStringChunk *chunk,
gchar* g_string_chunk_insert_const (GStringChunk *chunk,
const gchar *string);
/* Strings
*/
GString* g_string_new (const gchar *init);
@ -1050,6 +1242,7 @@ void g_string_sprintfa (GString *string,
const gchar *format,
...) G_GNUC_PRINTF (2, 3);
/* Resizable arrays
*/
#define g_array_length(array,type) \
@ -1067,9 +1260,9 @@ void g_string_sprintfa (GString *string,
#define g_array_index(array,type,index) \
((type*) array->data)[index]
GArray* g_array_new (gint zero_terminated);
GArray* g_array_new (gboolean zero_terminated);
void g_array_free (GArray *array,
gint free_segment);
gboolean free_segment);
GArray* g_rarray_append (GArray *array,
gpointer data,
gint size);
@ -1080,13 +1273,12 @@ GArray* g_rarray_truncate (GArray *array,
gint length,
gint size);
/* Resizable pointer array. This interface is much less complicated
* than the above. Add appends appends a pointer. Remove fills any
* cleared spot and shortens the array.
*/
#define g_ptr_array_index(array,index) (array->pdata)[index]
GPtrArray* g_ptr_array_new (void);
void g_ptr_array_free (GPtrArray *array,
gboolean free_seg);
@ -1099,14 +1291,13 @@ gboolean g_ptr_array_remove (GPtrArray *array,
void g_ptr_array_add (GPtrArray *array,
gpointer data);
/* Byte arrays, an array of guint8. Implemented as a GArray,
* but type-safe.
*/
GByteArray* g_byte_array_new (void);
void g_byte_array_free (GByteArray *array,
gint free_segment);
GByteArray* g_byte_array_append (GByteArray *array,
const guint8 *data,
guint len);
@ -1123,11 +1314,11 @@ GByteArray* g_byte_array_truncate (GByteArray *array,
*/
gint g_str_equal (gconstpointer v,
gconstpointer v2);
guint g_str_hash (gconstpointer v);
guint g_str_hash (gconstpointer v);
gint g_int_equal (gconstpointer v,
gconstpointer v2);
guint g_int_hash (gconstpointer v);
gint g_int_equal (gconstpointer v,
gconstpointer v2);
guint g_int_hash (gconstpointer v);
/* This "hash" function will just return the key's adress as an
* unsigned integer. Useful for hashing on plain adresses or
@ -1145,6 +1336,7 @@ GQuark g_quark_from_static_string (const gchar *string);
GQuark g_quark_from_string (const gchar *string);
gchar* g_quark_to_string (GQuark quark);
/* Location Associated Data
*/
void g_dataset_destroy (gconstpointer dataset_location);
@ -1157,14 +1349,20 @@ void g_dataset_id_set_data_full (gconstpointer dataset_location,
void g_dataset_id_set_destroy (gconstpointer dataset_location,
GQuark key_id,
GDestroyNotify destroy_func);
#define g_dataset_id_set_data(l,k,d) G_STMT_START{g_dataset_id_set_data_full((l),(k),(d),NULL);}G_STMT_END
#define g_dataset_id_remove_data(l,k) G_STMT_START{g_dataset_id_set_data((l),(k),NULL);}G_STMT_END
#define g_dataset_get_data(l,k) (g_dataset_id_get_data((l),g_quark_try_string(k)))
#define g_dataset_set_data_full(l,k,d,f) G_STMT_START{g_dataset_id_set_data_full((l),g_quark_from_string(k),(d),(f));}G_STMT_END
#define g_dataset_set_destroy(l,k,f) G_STMT_START{g_dataset_id_set_destroy((l),g_quark_from_string(k),(f));}G_STMT_END
#define g_dataset_set_data(l,k,d) G_STMT_START{g_dataset_set_data_full((l),(k),(d),NULL);}G_STMT_END
#define g_dataset_remove_data(l,k) G_STMT_START{g_dataset_set_data((l),(k),NULL);}G_STMT_END
#define g_dataset_id_set_data(l, k, d) \
g_dataset_id_set_data_full ((l), (k), (d), NULL)
#define g_dataset_id_remove_data(l, k) \
g_dataset_id_set_data ((l), (k), NULL)
#define g_dataset_get_data(l, k) \
(g_dataset_id_get_data ((l), g_quark_try_string (k)))
#define g_dataset_set_data_full(l, k, d, f) \
g_dataset_id_set_data_full ((l), g_quark_from_string (k), (d), (f))
#define g_dataset_set_destroy(l, k, f) \
g_dataset_id_set_destroy ((l), g_quark_from_string (k), (f))
#define g_dataset_set_data(l, k, d) \
g_dataset_set_data_full ((l), (k), (d), NULL)
#define g_dataset_remove_data(l,k) \
g_dataset_set_data ((l), (k), NULL)
/* GScanner: Flexible lexical scanner for general purpose.
@ -1385,7 +1583,6 @@ gint g_scanner_stat_mode (const gchar *filename);
} G_STMT_END
/* Completion */
struct _GCompletion
@ -1457,13 +1654,8 @@ gpointer g_tuples_index (GTuples *tuples,
gint field);
/* Glib version.
*/
extern const guint glib_major_version;
extern const guint glib_minor_version;
extern const guint glib_micro_version;
extern const guint glib_interface_age;
extern const guint glib_binary_age;
#ifdef __cplusplus
}

View File

@ -8,7 +8,7 @@
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
@ -16,165 +16,592 @@
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include "glib.h"
static GErrorFunc glib_error_func = NULL;
static GWarningFunc glib_warning_func = NULL;
static GPrintFunc glib_message_func = NULL;
static GPrintFunc glib_print_func = NULL;
extern char* g_vsprintf (const gchar *fmt, va_list *args, va_list *args2);
void
g_error (const gchar *format, ...)
/* --- structures --- */
typedef struct _GLogDomain GLogDomain;
typedef struct _GLogHandler GLogHandler;
struct _GLogDomain
{
va_list args, args2;
char *buf;
static gboolean errored = 0;
gchar *log_domain;
GLogLevelFlags fatal_mask;
GLogHandler *handlers;
GLogDomain *next;
};
struct _GLogHandler
{
guint id;
GLogLevelFlags log_level;
GLogFunc log_func;
gpointer data;
GLogHandler *next;
};
if (errored++)
{
write (2, "g_error: recursed!\n", 19);
return;
}
/* --- prototypes --- */
extern gchar* g_vsprintf (const gchar *fmt,
va_list *args,
va_list *args2);
/* --- variables --- */
const gchar *g_log_domain_glib = "GLib";
static GLogDomain *g_log_domains = NULL;
static GPrintFunc glib_print_func = NULL;
static GPrintFunc glib_printerr_func = NULL;
static GErrorFunc glib_error_func = NULL;
static GWarningFunc glib_warning_func = NULL;
static GPrintFunc glib_message_func = NULL;
/* --- functions --- */
static inline GLogDomain*
g_log_find_domain (const gchar *log_domain)
{
register GLogDomain *domain;
va_start (args, format);
va_start (args2, format);
buf = g_vsprintf (format, &args, &args2);
va_end (args);
va_end (args2);
if (glib_error_func)
domain = g_log_domains;
while (domain)
{
(* glib_error_func) (buf);
}
else
{
/* Use write() here because we might be out of memory */
write (2, "\n** ERROR **: ", 14);
write (2, buf, strlen(buf));
write (2, "\n", 1);
if (strcmp (domain->log_domain, log_domain) == 0)
return domain;
domain = domain->next;
}
return NULL;
}
abort ();
static inline GLogDomain*
g_log_domain_new (const gchar *log_domain)
{
register GLogDomain *domain;
domain = g_new (GLogDomain, 1);
domain->log_domain = g_strdup (log_domain);
domain->fatal_mask = G_LOG_FATAL_MASK;
domain->handlers = NULL;
domain->next = g_log_domains;
g_log_domains = domain;
return domain;
}
static inline void
g_log_domain_check_free (GLogDomain *domain)
{
if (domain->fatal_mask == G_LOG_FATAL_MASK &&
domain->handlers == NULL)
{
register GLogDomain *last, *work;
last = NULL;
work = g_log_domains;
while (work)
{
if (work == domain)
{
if (last)
last->next = domain->next;
else
g_log_domains = domain->next;
g_free (domain->log_domain);
g_free (domain);
break;
}
work = work->next;
}
}
}
static inline GLogFunc
g_log_domain_get_handler (GLogDomain *domain,
GLogLevelFlags log_level,
gpointer *data)
{
if (domain && log_level)
{
register GLogHandler *handler;
handler = domain->handlers;
while (handler)
{
if ((handler->log_level & log_level) == log_level)
{
*data = handler->data;
return handler->log_func;
}
handler = handler->next;
}
}
return g_log_default_handler;
}
GLogLevelFlags
g_log_set_fatal_mask (const gchar *log_domain,
GLogLevelFlags fatal_mask)
{
GLogLevelFlags old_flags;
register GLogDomain *domain;
if (!log_domain)
log_domain = "";
/* force errors to be fatal */
fatal_mask |= G_LOG_LEVEL_ERROR;
/* remove bogus flag */
fatal_mask &= ~G_LOG_FLAG_FATAL;
domain = g_log_find_domain (log_domain);
if (!domain)
domain = g_log_domain_new (log_domain);
old_flags = domain->fatal_mask;
domain->fatal_mask = fatal_mask;
g_log_domain_check_free (domain);
return old_flags;
}
guint
g_log_set_handler (const gchar *log_domain,
GLogLevelFlags log_levels,
GLogFunc log_func,
gpointer user_data)
{
register GLogDomain *domain;
register GLogHandler *handler;
static guint handler_id = 0;
g_return_val_if_fail ((log_levels & G_LOG_LEVEL_MASK) != 0, 0);
g_return_val_if_fail (log_func != NULL, 0);
if (!log_domain)
log_domain = "";
domain = g_log_find_domain (log_domain);
if (!domain)
domain = g_log_domain_new (log_domain);
handler = g_new (GLogHandler, 1);
handler->id = ++handler_id;
handler->log_level = log_levels;
handler->log_func = log_func;
handler->data = user_data;
handler->next = domain->handlers;
domain->handlers = handler;
return handler_id;
}
void
g_warning (const gchar *format, ...)
g_log_remove_handler (const gchar *log_domain,
guint handler_id)
{
va_list args, args2;
char *buf;
va_start (args, format);
va_start (args2, format);
buf = g_vsprintf (format, &args, &args2);
va_end (args);
va_end (args2);
if (glib_warning_func)
register GLogDomain *domain;
g_return_if_fail (handler_id > 0);
if (!log_domain)
log_domain = "";
domain = g_log_find_domain (log_domain);
if (domain)
{
(* glib_warning_func) (buf);
register GLogHandler *work, *last;
last = NULL;
work = domain->handlers;
while (work)
{
if (work->id == handler_id)
{
if (last)
last->next = work->next;
else
domain->handlers = work->next;
g_free (work);
g_log_domain_check_free (domain);
return;
}
work = work->next;
}
}
else
g_warning ("g_log_remove_handler(): could not find handler with id `%d' for domain \"%s\"",
handler_id,
log_domain);
}
void
g_logv (const gchar *log_domain,
GLogLevelFlags log_level,
const gchar *format,
va_list *args1,
va_list *args2)
{
gchar buffer[1025];
register gint i;
log_level &= G_LOG_LEVEL_MASK;
if (!log_level)
return;
/* we use a stack buffer of fixed size, because we might get called
* recursively, and we can also be out of memory.
*/
g_vsnprintf (buffer, 1025, format, args1, args2);
for (i = g_bit_nth_msf (log_level, -1); i >= 0; i = g_bit_nth_msf (log_level, i))
{
fputs ("\n** WARNING **: ", stderr);
fputs (buf, stderr);
fputc ('\n', stderr);
register GLogLevelFlags test_level;
test_level = 1 << i;
if (log_level & test_level)
{
static guint g_log_depth = 0;
GLogDomain *domain;
GLogFunc log_func;
gpointer data = NULL;
domain = g_log_find_domain (log_domain);
if (g_log_depth++)
test_level |= G_LOG_FLAG_RECURSION;
if (((domain ? domain->fatal_mask : G_LOG_FATAL_MASK) & test_level) != 0)
test_level |= G_LOG_FLAG_FATAL;
log_func = g_log_domain_get_handler (domain, test_level, &data);
log_func (log_domain, test_level, buffer, data);
/* *domain can be cluttered now */
if (test_level & G_LOG_FLAG_FATAL)
abort ();
g_log_depth--;
}
}
}
void
g_message (const gchar *format, ...)
g_log (const gchar *log_domain,
GLogLevelFlags log_level,
const gchar *format,
...)
{
va_list args, args2;
char *buf;
va_start (args, format);
va_start (args2, format);
buf = g_vsprintf (format, &args, &args2);
va_end (args);
va_end (args2);
if (glib_message_func)
{
(* glib_message_func) (buf);
}
else
{
fputs ("message: ", stdout);
fputs (buf, stdout);
fputc ('\n', stdout);
}
va_list arg_list1, arg_list2;
va_start (arg_list1, format);
va_start (arg_list2, format);
g_logv (log_domain, log_level, format, &arg_list1, &arg_list2);
va_end (arg_list2);
va_end (arg_list1);
}
void
g_print (const gchar *format, ...)
g_log_default_handler (const gchar *log_domain,
GLogLevelFlags log_level,
const gchar *message,
gpointer unused_data)
{
va_list args, args2;
char *buf;
va_start (args, format);
va_start (args2, format);
buf = g_vsprintf (format, &args, &args2);
va_end (args);
va_end (args2);
if (glib_print_func)
gint fd;
gboolean in_recursion;
gboolean is_fatal;
in_recursion = (log_level & G_LOG_FLAG_RECURSION) != 0;
is_fatal = (log_level & G_LOG_FLAG_FATAL) != 0;
log_level &= G_LOG_LEVEL_MASK;
if (!message)
message = "g_log_default_handler(): (NULL) message";
fd = (log_level >= G_LOG_LEVEL_MESSAGE) ? 1 : 2;
switch (log_level)
{
(* glib_print_func) (buf);
case G_LOG_LEVEL_ERROR:
if (!log_domain && glib_error_func)
{
/* compatibility code */
glib_error_func (message);
return;
}
/* use write(2) for output, in case we are out of memeory */
if (log_domain)
{
write (fd, "\n", 1);
write (fd, log_domain, strlen (log_domain));
write (fd, "-", 1);
}
else
write (fd, "\n** ", 4);
if (in_recursion)
write (fd, "ERROR (recursed) **: ", 21);
else
write (fd, "ERROR **: ", 10);
write (fd, message, strlen(message));
if (is_fatal)
write (fd, "\naborting...\n", 13);
else
write (fd, "\n", 1);
break;
case G_LOG_LEVEL_CRITICAL:
if (log_domain)
{
write (fd, "\n", 1);
write (fd, log_domain, strlen (log_domain));
write (fd, "-", 1);
}
else
write (fd, "\n** ", 4);
if (in_recursion)
write (fd, "CRITICAL (recursed) **: ", 24);
else
write (fd, "CRITICAL **: ", 13);
write (fd, message, strlen(message));
if (is_fatal)
write (fd, "\naborting...\n", 13);
else
write (fd, "\n", 1);
break;
case G_LOG_LEVEL_WARNING:
if (!log_domain && glib_warning_func)
{
/* compatibility code */
glib_warning_func (message);
return;
}
if (log_domain)
{
write (fd, "\n", 1);
write (fd, log_domain, strlen (log_domain));
write (fd, "-", 1);
}
else
write (fd, "\n** ", 4);
if (in_recursion)
write (fd, "WARNING (recursed) **: ", 23);
else
write (fd, "WARNING **: ", 12);
write (fd, message, strlen(message));
if (is_fatal)
write (fd, "\naborting...\n", 13);
else
write (fd, "\n", 1);
break;
case G_LOG_LEVEL_MESSAGE:
if (!log_domain && glib_message_func)
{
/* compatibility code */
glib_message_func (message);
return;
}
if (log_domain)
{
write (fd, log_domain, strlen (log_domain));
write (fd, "-", 1);
}
if (in_recursion)
write (fd, "Message (recursed): ", 20);
else
write (fd, "Message: ", 9);
write (fd, message, strlen(message));
if (is_fatal)
write (fd, "\naborting...\n", 13);
else
write (fd, "\n", 1);
break;
case G_LOG_LEVEL_INFO:
if (log_domain)
{
write (fd, log_domain, strlen (log_domain));
write (fd, "-", 1);
}
if (in_recursion)
write (fd, "INFO (recursed): ", 17);
else
write (fd, "INFO: ", 6);
write (fd, message, strlen(message));
if (is_fatal)
write (fd, "\naborting...\n", 13);
else
write (fd, "\n", 1);
break;
case G_LOG_LEVEL_DEBUG:
if (log_domain)
{
write (fd, log_domain, strlen (log_domain));
write (fd, "-", 1);
}
if (in_recursion)
write (fd, "DEBUG (recursed): ", 18);
else
write (fd, "DEBUG: ", 7);
write (fd, message, strlen(message));
if (is_fatal)
write (fd, "\naborting...\n", 13);
else
write (fd, "\n", 1);
break;
default:
/* we are used for a log level that is not defined by GLib itself,
* try to make the best out of it.
*/
if (log_domain)
{
write (fd, log_domain, strlen (log_domain));
if (in_recursion)
write (fd, "-LOG (recursed:", 15);
else
write (fd, "-LOG (", 6);
}
else if (in_recursion)
write (fd, "LOG (recursed:", 14);
else
write (fd, "LOG (", 5);
if (log_level)
{
gchar string[] = "0x00): ";
gchar *p = string + 2;
guint i;
i = g_bit_nth_msf (log_level, -1);
*p = i >> 4;
p++;
*p = '0' + (i & 0xf);
if (*p > '9')
*p += 'A' - '9' - 1;
write (fd, string, 7);
}
else
write (fd, "): ", 3);
write (fd, message, strlen(message));
if (is_fatal)
write (fd, "\naborting...\n", 13);
else
write (fd, "\n", 1);
break;
}
else
{
fputs (buf, stdout);
}
}
GErrorFunc
g_set_error_handler (GErrorFunc func)
{
GErrorFunc old_error_func;
old_error_func = glib_error_func;
glib_error_func = func;
return old_error_func;
}
GWarningFunc
g_set_warning_handler (GWarningFunc func)
{
GWarningFunc old_warning_func;
old_warning_func = glib_warning_func;
glib_warning_func = func;
return old_warning_func;
}
GPrintFunc
g_set_message_handler (GPrintFunc func)
{
GPrintFunc old_message_func;
old_message_func = glib_message_func;
glib_message_func = func;
return old_message_func;
}
GPrintFunc
g_set_print_handler (GPrintFunc func)
{
GPrintFunc old_print_func;
old_print_func = glib_print_func;
glib_print_func = func;
return old_print_func;
}
void
g_print (const gchar *format,
...)
{
va_list args, args2;
char *buf;
g_return_if_fail (format != NULL);
va_start (args, format);
va_start (args2, format);
buf = g_vsprintf (format, &args, &args2);
va_end (args);
va_end (args2);
if (glib_print_func)
{
gchar *string;
string = g_strdup (buf);
glib_print_func (string);
g_free (string);
}
else
{
fputs (buf, stdout);
fflush (stdout);
}
}
GPrintFunc
g_set_printerr_handler (GPrintFunc func)
{
GPrintFunc old_printerr_func;
old_printerr_func = glib_printerr_func;
glib_printerr_func = func;
return old_printerr_func;
}
void
g_printerr (const gchar *format,
...)
{
va_list args, args2;
char *buf;
g_return_if_fail (format != NULL);
va_start (args, format);
va_start (args2, format);
buf = g_vsprintf (format, &args, &args2);
va_end (args);
va_end (args2);
if (glib_printerr_func)
{
gchar *string;
string = g_strdup (buf);
glib_printerr_func (string);
g_free (string);
}
else
{
fputs (buf, stderr);
fflush (stderr);
}
}
/* compatibility code */
GErrorFunc
g_set_error_handler (GErrorFunc func)
{
GErrorFunc old_error_func;
old_error_func = glib_error_func;
glib_error_func = func;
return old_error_func;
}
/* compatibility code */
GWarningFunc
g_set_warning_handler (GWarningFunc func)
{
GWarningFunc old_warning_func;
old_warning_func = glib_warning_func;
glib_warning_func = func;
return old_warning_func;
}
/* compatibility code */
GPrintFunc
g_set_message_handler (GPrintFunc func)
{
GPrintFunc old_message_func;
old_message_func = glib_message_func;
glib_message_func = func;
return old_message_func;
}

View File

@ -113,35 +113,35 @@ g_node_unlink (GNode *node)
node->prev = NULL;
}
void
GNode*
g_node_insert (GNode *parent,
gint position,
GNode *node)
{
g_return_if_fail (parent != NULL);
g_return_if_fail (node != NULL);
g_return_if_fail (G_NODE_IS_ROOT (node));
g_return_val_if_fail (parent != NULL, node);
g_return_val_if_fail (node != NULL, node);
g_return_val_if_fail (G_NODE_IS_ROOT (node), node);
if (position > 0)
g_node_insert_before (parent,
g_node_nth_child (parent, position),
node);
return g_node_insert_before (parent,
g_node_nth_child (parent, position),
node);
else if (position == 0)
g_node_prepend (parent, node);
else if (position < 0)
g_node_append (parent, node);
return g_node_prepend (parent, node);
else /* if (position < 0) */
return g_node_append (parent, node);
}
void
GNode*
g_node_insert_before (GNode *parent,
GNode *sibling,
GNode *node)
{
g_return_if_fail (parent != NULL);
g_return_if_fail (node != NULL);
g_return_if_fail (G_NODE_IS_ROOT (node));
g_return_val_if_fail (parent != NULL, node);
g_return_val_if_fail (node != NULL, node);
g_return_val_if_fail (G_NODE_IS_ROOT (node), node);
if (sibling)
g_return_if_fail (sibling->parent == parent);
g_return_val_if_fail (sibling->parent == parent, node);
node->parent = parent;
@ -174,15 +174,17 @@ g_node_insert_before (GNode *parent,
else
node->parent->children = node;
}
return node;
}
void
GNode*
g_node_prepend (GNode *parent,
GNode *node)
{
g_return_if_fail (parent != NULL);
g_return_val_if_fail (parent != NULL, node);
g_node_insert_before (parent, parent->children, node);
return g_node_insert_before (parent, parent->children, node);
}
GNode*

View File

@ -593,7 +593,7 @@ g_vsprintf (const gchar *fmt,
if (buf)
g_free (buf);
alloc = nearest_pow (MAX(len + 1, 1024));
alloc = nearest_pow (MAX(len + 1, 1024 + 1));
buf = g_new (char, alloc);
}

View File

@ -40,7 +40,7 @@ g_snprintf (gchar *str,
gchar const *fmt,
...)
{
#ifdef HAVE_VSNPRINTF
#ifdef HAVE_VSNPRINTF
va_list args;
gint retval;
@ -49,8 +49,7 @@ g_snprintf (gchar *str,
va_end (args);
return retval;
#else
#else /* !HAVE_VSNPRINTF */
gchar *printed;
va_list args, args2;
@ -65,8 +64,31 @@ g_snprintf (gchar *str,
va_end (args);
return strlen (str);
#endif /* !HAVE_VSNPRINTF */
}
gint
g_vsnprintf (gchar *str,
gulong n,
gchar const *fmt,
va_list *args1,
va_list *args2)
{
#ifdef HAVE_VSNPRINTF
gint retval;
#endif
retval = vsnprintf (str, n, fmt, *args1);
return retval;
#else /* !HAVE_VSNPRINTF */
gchar *printed;
printed = g_vsprintf (fmt, args1, args2);
strncpy (str, printed, n);
str[n-1] = '\0';
return strlen (str);
#endif /* !HAVE_VSNPRINTF */
}
guint

View File

@ -8,7 +8,7 @@
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
@ -16,165 +16,592 @@
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include "glib.h"
static GErrorFunc glib_error_func = NULL;
static GWarningFunc glib_warning_func = NULL;
static GPrintFunc glib_message_func = NULL;
static GPrintFunc glib_print_func = NULL;
extern char* g_vsprintf (const gchar *fmt, va_list *args, va_list *args2);
void
g_error (const gchar *format, ...)
/* --- structures --- */
typedef struct _GLogDomain GLogDomain;
typedef struct _GLogHandler GLogHandler;
struct _GLogDomain
{
va_list args, args2;
char *buf;
static gboolean errored = 0;
gchar *log_domain;
GLogLevelFlags fatal_mask;
GLogHandler *handlers;
GLogDomain *next;
};
struct _GLogHandler
{
guint id;
GLogLevelFlags log_level;
GLogFunc log_func;
gpointer data;
GLogHandler *next;
};
if (errored++)
{
write (2, "g_error: recursed!\n", 19);
return;
}
/* --- prototypes --- */
extern gchar* g_vsprintf (const gchar *fmt,
va_list *args,
va_list *args2);
/* --- variables --- */
const gchar *g_log_domain_glib = "GLib";
static GLogDomain *g_log_domains = NULL;
static GPrintFunc glib_print_func = NULL;
static GPrintFunc glib_printerr_func = NULL;
static GErrorFunc glib_error_func = NULL;
static GWarningFunc glib_warning_func = NULL;
static GPrintFunc glib_message_func = NULL;
/* --- functions --- */
static inline GLogDomain*
g_log_find_domain (const gchar *log_domain)
{
register GLogDomain *domain;
va_start (args, format);
va_start (args2, format);
buf = g_vsprintf (format, &args, &args2);
va_end (args);
va_end (args2);
if (glib_error_func)
domain = g_log_domains;
while (domain)
{
(* glib_error_func) (buf);
}
else
{
/* Use write() here because we might be out of memory */
write (2, "\n** ERROR **: ", 14);
write (2, buf, strlen(buf));
write (2, "\n", 1);
if (strcmp (domain->log_domain, log_domain) == 0)
return domain;
domain = domain->next;
}
return NULL;
}
abort ();
static inline GLogDomain*
g_log_domain_new (const gchar *log_domain)
{
register GLogDomain *domain;
domain = g_new (GLogDomain, 1);
domain->log_domain = g_strdup (log_domain);
domain->fatal_mask = G_LOG_FATAL_MASK;
domain->handlers = NULL;
domain->next = g_log_domains;
g_log_domains = domain;
return domain;
}
static inline void
g_log_domain_check_free (GLogDomain *domain)
{
if (domain->fatal_mask == G_LOG_FATAL_MASK &&
domain->handlers == NULL)
{
register GLogDomain *last, *work;
last = NULL;
work = g_log_domains;
while (work)
{
if (work == domain)
{
if (last)
last->next = domain->next;
else
g_log_domains = domain->next;
g_free (domain->log_domain);
g_free (domain);
break;
}
work = work->next;
}
}
}
static inline GLogFunc
g_log_domain_get_handler (GLogDomain *domain,
GLogLevelFlags log_level,
gpointer *data)
{
if (domain && log_level)
{
register GLogHandler *handler;
handler = domain->handlers;
while (handler)
{
if ((handler->log_level & log_level) == log_level)
{
*data = handler->data;
return handler->log_func;
}
handler = handler->next;
}
}
return g_log_default_handler;
}
GLogLevelFlags
g_log_set_fatal_mask (const gchar *log_domain,
GLogLevelFlags fatal_mask)
{
GLogLevelFlags old_flags;
register GLogDomain *domain;
if (!log_domain)
log_domain = "";
/* force errors to be fatal */
fatal_mask |= G_LOG_LEVEL_ERROR;
/* remove bogus flag */
fatal_mask &= ~G_LOG_FLAG_FATAL;
domain = g_log_find_domain (log_domain);
if (!domain)
domain = g_log_domain_new (log_domain);
old_flags = domain->fatal_mask;
domain->fatal_mask = fatal_mask;
g_log_domain_check_free (domain);
return old_flags;
}
guint
g_log_set_handler (const gchar *log_domain,
GLogLevelFlags log_levels,
GLogFunc log_func,
gpointer user_data)
{
register GLogDomain *domain;
register GLogHandler *handler;
static guint handler_id = 0;
g_return_val_if_fail ((log_levels & G_LOG_LEVEL_MASK) != 0, 0);
g_return_val_if_fail (log_func != NULL, 0);
if (!log_domain)
log_domain = "";
domain = g_log_find_domain (log_domain);
if (!domain)
domain = g_log_domain_new (log_domain);
handler = g_new (GLogHandler, 1);
handler->id = ++handler_id;
handler->log_level = log_levels;
handler->log_func = log_func;
handler->data = user_data;
handler->next = domain->handlers;
domain->handlers = handler;
return handler_id;
}
void
g_warning (const gchar *format, ...)
g_log_remove_handler (const gchar *log_domain,
guint handler_id)
{
va_list args, args2;
char *buf;
va_start (args, format);
va_start (args2, format);
buf = g_vsprintf (format, &args, &args2);
va_end (args);
va_end (args2);
if (glib_warning_func)
register GLogDomain *domain;
g_return_if_fail (handler_id > 0);
if (!log_domain)
log_domain = "";
domain = g_log_find_domain (log_domain);
if (domain)
{
(* glib_warning_func) (buf);
register GLogHandler *work, *last;
last = NULL;
work = domain->handlers;
while (work)
{
if (work->id == handler_id)
{
if (last)
last->next = work->next;
else
domain->handlers = work->next;
g_free (work);
g_log_domain_check_free (domain);
return;
}
work = work->next;
}
}
else
g_warning ("g_log_remove_handler(): could not find handler with id `%d' for domain \"%s\"",
handler_id,
log_domain);
}
void
g_logv (const gchar *log_domain,
GLogLevelFlags log_level,
const gchar *format,
va_list *args1,
va_list *args2)
{
gchar buffer[1025];
register gint i;
log_level &= G_LOG_LEVEL_MASK;
if (!log_level)
return;
/* we use a stack buffer of fixed size, because we might get called
* recursively, and we can also be out of memory.
*/
g_vsnprintf (buffer, 1025, format, args1, args2);
for (i = g_bit_nth_msf (log_level, -1); i >= 0; i = g_bit_nth_msf (log_level, i))
{
fputs ("\n** WARNING **: ", stderr);
fputs (buf, stderr);
fputc ('\n', stderr);
register GLogLevelFlags test_level;
test_level = 1 << i;
if (log_level & test_level)
{
static guint g_log_depth = 0;
GLogDomain *domain;
GLogFunc log_func;
gpointer data = NULL;
domain = g_log_find_domain (log_domain);
if (g_log_depth++)
test_level |= G_LOG_FLAG_RECURSION;
if (((domain ? domain->fatal_mask : G_LOG_FATAL_MASK) & test_level) != 0)
test_level |= G_LOG_FLAG_FATAL;
log_func = g_log_domain_get_handler (domain, test_level, &data);
log_func (log_domain, test_level, buffer, data);
/* *domain can be cluttered now */
if (test_level & G_LOG_FLAG_FATAL)
abort ();
g_log_depth--;
}
}
}
void
g_message (const gchar *format, ...)
g_log (const gchar *log_domain,
GLogLevelFlags log_level,
const gchar *format,
...)
{
va_list args, args2;
char *buf;
va_start (args, format);
va_start (args2, format);
buf = g_vsprintf (format, &args, &args2);
va_end (args);
va_end (args2);
if (glib_message_func)
{
(* glib_message_func) (buf);
}
else
{
fputs ("message: ", stdout);
fputs (buf, stdout);
fputc ('\n', stdout);
}
va_list arg_list1, arg_list2;
va_start (arg_list1, format);
va_start (arg_list2, format);
g_logv (log_domain, log_level, format, &arg_list1, &arg_list2);
va_end (arg_list2);
va_end (arg_list1);
}
void
g_print (const gchar *format, ...)
g_log_default_handler (const gchar *log_domain,
GLogLevelFlags log_level,
const gchar *message,
gpointer unused_data)
{
va_list args, args2;
char *buf;
va_start (args, format);
va_start (args2, format);
buf = g_vsprintf (format, &args, &args2);
va_end (args);
va_end (args2);
if (glib_print_func)
gint fd;
gboolean in_recursion;
gboolean is_fatal;
in_recursion = (log_level & G_LOG_FLAG_RECURSION) != 0;
is_fatal = (log_level & G_LOG_FLAG_FATAL) != 0;
log_level &= G_LOG_LEVEL_MASK;
if (!message)
message = "g_log_default_handler(): (NULL) message";
fd = (log_level >= G_LOG_LEVEL_MESSAGE) ? 1 : 2;
switch (log_level)
{
(* glib_print_func) (buf);
case G_LOG_LEVEL_ERROR:
if (!log_domain && glib_error_func)
{
/* compatibility code */
glib_error_func (message);
return;
}
/* use write(2) for output, in case we are out of memeory */
if (log_domain)
{
write (fd, "\n", 1);
write (fd, log_domain, strlen (log_domain));
write (fd, "-", 1);
}
else
write (fd, "\n** ", 4);
if (in_recursion)
write (fd, "ERROR (recursed) **: ", 21);
else
write (fd, "ERROR **: ", 10);
write (fd, message, strlen(message));
if (is_fatal)
write (fd, "\naborting...\n", 13);
else
write (fd, "\n", 1);
break;
case G_LOG_LEVEL_CRITICAL:
if (log_domain)
{
write (fd, "\n", 1);
write (fd, log_domain, strlen (log_domain));
write (fd, "-", 1);
}
else
write (fd, "\n** ", 4);
if (in_recursion)
write (fd, "CRITICAL (recursed) **: ", 24);
else
write (fd, "CRITICAL **: ", 13);
write (fd, message, strlen(message));
if (is_fatal)
write (fd, "\naborting...\n", 13);
else
write (fd, "\n", 1);
break;
case G_LOG_LEVEL_WARNING:
if (!log_domain && glib_warning_func)
{
/* compatibility code */
glib_warning_func (message);
return;
}
if (log_domain)
{
write (fd, "\n", 1);
write (fd, log_domain, strlen (log_domain));
write (fd, "-", 1);
}
else
write (fd, "\n** ", 4);
if (in_recursion)
write (fd, "WARNING (recursed) **: ", 23);
else
write (fd, "WARNING **: ", 12);
write (fd, message, strlen(message));
if (is_fatal)
write (fd, "\naborting...\n", 13);
else
write (fd, "\n", 1);
break;
case G_LOG_LEVEL_MESSAGE:
if (!log_domain && glib_message_func)
{
/* compatibility code */
glib_message_func (message);
return;
}
if (log_domain)
{
write (fd, log_domain, strlen (log_domain));
write (fd, "-", 1);
}
if (in_recursion)
write (fd, "Message (recursed): ", 20);
else
write (fd, "Message: ", 9);
write (fd, message, strlen(message));
if (is_fatal)
write (fd, "\naborting...\n", 13);
else
write (fd, "\n", 1);
break;
case G_LOG_LEVEL_INFO:
if (log_domain)
{
write (fd, log_domain, strlen (log_domain));
write (fd, "-", 1);
}
if (in_recursion)
write (fd, "INFO (recursed): ", 17);
else
write (fd, "INFO: ", 6);
write (fd, message, strlen(message));
if (is_fatal)
write (fd, "\naborting...\n", 13);
else
write (fd, "\n", 1);
break;
case G_LOG_LEVEL_DEBUG:
if (log_domain)
{
write (fd, log_domain, strlen (log_domain));
write (fd, "-", 1);
}
if (in_recursion)
write (fd, "DEBUG (recursed): ", 18);
else
write (fd, "DEBUG: ", 7);
write (fd, message, strlen(message));
if (is_fatal)
write (fd, "\naborting...\n", 13);
else
write (fd, "\n", 1);
break;
default:
/* we are used for a log level that is not defined by GLib itself,
* try to make the best out of it.
*/
if (log_domain)
{
write (fd, log_domain, strlen (log_domain));
if (in_recursion)
write (fd, "-LOG (recursed:", 15);
else
write (fd, "-LOG (", 6);
}
else if (in_recursion)
write (fd, "LOG (recursed:", 14);
else
write (fd, "LOG (", 5);
if (log_level)
{
gchar string[] = "0x00): ";
gchar *p = string + 2;
guint i;
i = g_bit_nth_msf (log_level, -1);
*p = i >> 4;
p++;
*p = '0' + (i & 0xf);
if (*p > '9')
*p += 'A' - '9' - 1;
write (fd, string, 7);
}
else
write (fd, "): ", 3);
write (fd, message, strlen(message));
if (is_fatal)
write (fd, "\naborting...\n", 13);
else
write (fd, "\n", 1);
break;
}
else
{
fputs (buf, stdout);
}
}
GErrorFunc
g_set_error_handler (GErrorFunc func)
{
GErrorFunc old_error_func;
old_error_func = glib_error_func;
glib_error_func = func;
return old_error_func;
}
GWarningFunc
g_set_warning_handler (GWarningFunc func)
{
GWarningFunc old_warning_func;
old_warning_func = glib_warning_func;
glib_warning_func = func;
return old_warning_func;
}
GPrintFunc
g_set_message_handler (GPrintFunc func)
{
GPrintFunc old_message_func;
old_message_func = glib_message_func;
glib_message_func = func;
return old_message_func;
}
GPrintFunc
g_set_print_handler (GPrintFunc func)
{
GPrintFunc old_print_func;
old_print_func = glib_print_func;
glib_print_func = func;
return old_print_func;
}
void
g_print (const gchar *format,
...)
{
va_list args, args2;
char *buf;
g_return_if_fail (format != NULL);
va_start (args, format);
va_start (args2, format);
buf = g_vsprintf (format, &args, &args2);
va_end (args);
va_end (args2);
if (glib_print_func)
{
gchar *string;
string = g_strdup (buf);
glib_print_func (string);
g_free (string);
}
else
{
fputs (buf, stdout);
fflush (stdout);
}
}
GPrintFunc
g_set_printerr_handler (GPrintFunc func)
{
GPrintFunc old_printerr_func;
old_printerr_func = glib_printerr_func;
glib_printerr_func = func;
return old_printerr_func;
}
void
g_printerr (const gchar *format,
...)
{
va_list args, args2;
char *buf;
g_return_if_fail (format != NULL);
va_start (args, format);
va_start (args2, format);
buf = g_vsprintf (format, &args, &args2);
va_end (args);
va_end (args2);
if (glib_printerr_func)
{
gchar *string;
string = g_strdup (buf);
glib_printerr_func (string);
g_free (string);
}
else
{
fputs (buf, stderr);
fflush (stderr);
}
}
/* compatibility code */
GErrorFunc
g_set_error_handler (GErrorFunc func)
{
GErrorFunc old_error_func;
old_error_func = glib_error_func;
glib_error_func = func;
return old_error_func;
}
/* compatibility code */
GWarningFunc
g_set_warning_handler (GWarningFunc func)
{
GWarningFunc old_warning_func;
old_warning_func = glib_warning_func;
glib_warning_func = func;
return old_warning_func;
}
/* compatibility code */
GPrintFunc
g_set_message_handler (GPrintFunc func)
{
GPrintFunc old_message_func;
old_message_func = glib_message_func;
glib_message_func = func;
return old_message_func;
}

View File

@ -1,3 +1,12 @@
Fri Aug 14 02:24:39 1998 Tim Janik <timj@gtk.org>
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GModule" upon compilation. we currently have to add this definition
to the DEFS variable.
* testgmodule.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
Mon Aug 10 03:35:57 1998 Tim Janik <timj@gtk.org>
* gmodule.c: minor changes to internal interface.

View File

@ -1,6 +1,7 @@
## Process this file with automake to produce Makefile.in
INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/gmodule
DEFS += -DG_LOG_DOMAIN=g_log_domain_gmodule
EXTRA_DIST = \
gmoduleconf.h.in

View File

@ -56,6 +56,7 @@ static inline GModule* g_module_find_by_name (const gchar *name);
/* --- variables --- */
const char *g_log_domain_gmodule = "GModule";
static GModule *modules = NULL;
static GModule *main_module = NULL;
static gchar *module_error = NULL;
@ -264,7 +265,7 @@ g_module_error (void)
gboolean
g_module_symbol (GModule *module,
const gchar *symbol_name,
gconstpointer *symbol)
gpointer *symbol)
{
if (symbol)
*symbol = NULL;

View File

@ -20,13 +20,14 @@
#define __GMODULE_H__
#include <glib.h>
#ifdef __cplusplus
extern "C" {
#pragma }
#endif /* __cplusplus */
extern const char *g_log_domain_gmodule;
#include <glib.h>
/* exporting and importing functions,
* we need autoconf support here for supporting windows.
@ -61,7 +62,7 @@ gchar* g_module_error (void);
/* retrive a symbol pointer from `module', returns TRUE on success */
gboolean g_module_symbol (GModule *module,
const gchar *symbol_name,
gconstpointer *symbol);
gpointer *symbol);
/* retrive the file name from an existing module */
gchar* g_module_name (GModule *module);

View File

@ -16,6 +16,7 @@
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#undef G_LOG_DOMAIN
#include <gmodule.h>
@ -30,7 +31,6 @@ typedef void (*GModuleFunc) (GModule *);
SimpleFunc gplugin_clash_func;
int
main (int arg,
char *argv[])
@ -166,5 +166,11 @@ main (int arg,
if (!g_module_close (module_b))
g_print ("error: %s\n", g_module_error ());
#if 0
g_log_set_fatal_mask ("GModule", G_LOG_FATAL_MASK|G_LOG_LEVEL_WARNING);
g_module_symbol (0, 0, 0);
g_warning("jahoooo");
#endif
return 0;
}

38
gnode.c
View File

@ -113,35 +113,35 @@ g_node_unlink (GNode *node)
node->prev = NULL;
}
void
GNode*
g_node_insert (GNode *parent,
gint position,
GNode *node)
{
g_return_if_fail (parent != NULL);
g_return_if_fail (node != NULL);
g_return_if_fail (G_NODE_IS_ROOT (node));
g_return_val_if_fail (parent != NULL, node);
g_return_val_if_fail (node != NULL, node);
g_return_val_if_fail (G_NODE_IS_ROOT (node), node);
if (position > 0)
g_node_insert_before (parent,
g_node_nth_child (parent, position),
node);
return g_node_insert_before (parent,
g_node_nth_child (parent, position),
node);
else if (position == 0)
g_node_prepend (parent, node);
else if (position < 0)
g_node_append (parent, node);
return g_node_prepend (parent, node);
else /* if (position < 0) */
return g_node_append (parent, node);
}
void
GNode*
g_node_insert_before (GNode *parent,
GNode *sibling,
GNode *node)
{
g_return_if_fail (parent != NULL);
g_return_if_fail (node != NULL);
g_return_if_fail (G_NODE_IS_ROOT (node));
g_return_val_if_fail (parent != NULL, node);
g_return_val_if_fail (node != NULL, node);
g_return_val_if_fail (G_NODE_IS_ROOT (node), node);
if (sibling)
g_return_if_fail (sibling->parent == parent);
g_return_val_if_fail (sibling->parent == parent, node);
node->parent = parent;
@ -174,15 +174,17 @@ g_node_insert_before (GNode *parent,
else
node->parent->children = node;
}
return node;
}
void
GNode*
g_node_prepend (GNode *parent,
GNode *node)
{
g_return_if_fail (parent != NULL);
g_return_val_if_fail (parent != NULL, node);
g_node_insert_before (parent, parent->children, node);
return g_node_insert_before (parent, parent->children, node);
}
GNode*

View File

@ -593,7 +593,7 @@ g_vsprintf (const gchar *fmt,
if (buf)
g_free (buf);
alloc = nearest_pow (MAX(len + 1, 1024));
alloc = nearest_pow (MAX(len + 1, 1024 + 1));
buf = g_new (char, alloc);
}

View File

@ -40,7 +40,7 @@ g_snprintf (gchar *str,
gchar const *fmt,
...)
{
#ifdef HAVE_VSNPRINTF
#ifdef HAVE_VSNPRINTF
va_list args;
gint retval;
@ -49,8 +49,7 @@ g_snprintf (gchar *str,
va_end (args);
return retval;
#else
#else /* !HAVE_VSNPRINTF */
gchar *printed;
va_list args, args2;
@ -65,8 +64,31 @@ g_snprintf (gchar *str,
va_end (args);
return strlen (str);
#endif /* !HAVE_VSNPRINTF */
}
gint
g_vsnprintf (gchar *str,
gulong n,
gchar const *fmt,
va_list *args1,
va_list *args2)
{
#ifdef HAVE_VSNPRINTF
gint retval;
#endif
retval = vsnprintf (str, n, fmt, *args1);
return retval;
#else /* !HAVE_VSNPRINTF */
gchar *printed;
printed = g_vsprintf (fmt, args1, args2);
strncpy (str, printed, n);
str[n-1] = '\0';
return strlen (str);
#endif /* !HAVE_VSNPRINTF */
}
guint

View File

@ -16,6 +16,7 @@
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#undef G_LOG_DOMAIN
#include <stdio.h>
#include <string.h>
@ -716,8 +717,13 @@ main (int argc,
}
g_byte_array_free (gbarray, TRUE);
g_print ("ok\n");
g_printerr ("g_log tests:");
g_warning ("harmless warning");
g_message ("the next warning is a test:");
string = NULL;
g_print (string);
return 0;
}

View File

@ -16,6 +16,7 @@
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#undef G_LOG_DOMAIN
#include <stdio.h>
#include <string.h>
@ -716,8 +717,13 @@ main (int argc,
}
g_byte_array_free (gbarray, TRUE);
g_print ("ok\n");
g_printerr ("g_log tests:");
g_warning ("harmless warning");
g_message ("the next warning is a test:");
string = NULL;
g_print (string);
return 0;
}