libgimpbase/Makefile.am libgimpbase/libgimpbase-docs.sgml do not generate

2005-12-14  Sven Neumann  <sven@gimp.org>

	* libgimpbase/Makefile.am
	* libgimpbase/libgimpbase-docs.sgml
	* libgimpbase/libgimpbase-sections.txt: do not generate API docs
	for the private wire protocol API.

	* libgimp/libgimp-sections.txt: added new path API.

	* libgimpbase/tmpl/gimpprotocol.sgml
	* libgimpbase/tmpl/gimpwire.sgml: removed from CVS.

	* libgimp/tmpl/gimppaths.sgml
	* libgimpbase/tmpl/gimpenv.sgml: regenerated.
This commit is contained in:
Sven Neumann 2005-12-14 13:36:12 +00:00 committed by Sven Neumann
parent 4ec5642b50
commit 493cd140f8
12 changed files with 429 additions and 1046 deletions

View File

@ -5,6 +5,11 @@
* libgimp/gimp.c (gimp_destroy_params): removed extern declaration.
* libgimpbase/gimpenv.h: changed parameter name to match what's
used in gimpenv.c.
* libgimpbase/gimpreloc.c: changed comments to please gtk-doc.
2005-12-13 Sven Neumann <sven@gimp.org>
* libgimpbase/gimpwire.[ch]: let the private wire methods live in

View File

@ -1,3 +1,18 @@
2005-12-14 Sven Neumann <sven@gimp.org>
* libgimpbase/Makefile.am
* libgimpbase/libgimpbase-docs.sgml
* libgimpbase/libgimpbase-sections.txt: do not generate API docs
for the private wire protocol API.
* libgimp/libgimp-sections.txt: added new path API.
* libgimpbase/tmpl/gimpprotocol.sgml
* libgimpbase/tmpl/gimpwire.sgml: removed from CVS.
* libgimp/tmpl/gimppaths.sgml
* libgimpbase/tmpl/gimpenv.sgml: regenerated.
2005-11-06 Sven Neumann <sven@gimp.org>
* devel-docs/libgimpbase/Makefile.am: ignore gimpreloc.h.

View File

@ -659,6 +659,8 @@ gimp_get_path_by_tattoo
gimp_path_delete
gimp_path_get_locked
gimp_path_set_locked
gimp_path_get_visible
gimp_path_set_visible
gimp_path_set_tattoo
gimp_path_to_selection
gimp_path_import

View File

@ -144,6 +144,27 @@ Operations related to paths.
@Returns:
<!-- ##### FUNCTION gimp_path_get_visible ##### -->
<para>
</para>
@image_ID:
@name:
@Returns:
<!-- ##### FUNCTION gimp_path_set_visible ##### -->
<para>
</para>
@image_ID:
@name:
@visible:
@Returns:
<!-- ##### FUNCTION gimp_path_set_tattoo ##### -->
<para>

View File

@ -29,7 +29,9 @@ CFILE_GLOB = $(DOC_SOURCE_DIR)/*.c
IGNORE_HFILES = \
gimpbase.h \
gimpbase-private.h \
gimpprotocol.h \
gimpreloc.h \
gimpwire.h \
gimpwin32-io.h
# Images to copy into HTML directory

View File

@ -26,8 +26,6 @@
<xi:include href="xml/gimpsignal.xml" />
<xi:include href="xml/gimpunit.xml" />
<xi:include href="xml/gimputils.xml" />
<xi:include href="xml/gimpprotocol.xml" />
<xi:include href="xml/gimpwire.xml" />
</part>
<index>

View File

@ -110,6 +110,7 @@ gimp_checks_get_shades
<SECTION>
<FILE>gimpenv</FILE>
gimp_env_init
gimp_directory
gimp_personal_rc_file
gimp_data_directory
@ -180,35 +181,6 @@ gimp_pixpipe_params_parse
gimp_pixpipe_params_build
</SECTION>
<SECTION>
<FILE>gimpprotocol</FILE>
GIMP_PROTOCOL_VERSION
GPConfig
GPTileReq
GPTileAck
GPTileData
GPParam
GPParamDef
GPProcRun
GPProcReturn
GPProcInstall
GPProcUninstall
gp_init
gp_has_init_write
gp_quit_write
gp_config_write
gp_tile_req_write
gp_tile_ack_write
gp_tile_data_write
gp_proc_run_write
gp_proc_return_write
gp_temp_proc_run_write
gp_temp_proc_return_write
gp_proc_install_write
gp_proc_uninstall_write
gp_extension_ack_write
</SECTION>
<SECTION>
<FILE>gimpsignal</FILE>
GimpSignalHandlerFunc
@ -258,38 +230,6 @@ gimp_flags_value_get_desc
gimp_flags_value_get_help
</SECTION>
<SECTION>
<FILE>gimpwire</FILE>
WireMessage
WireReadFunc
WireWriteFunc
WireDestroyFunc
WireIOFunc
WireFlushFunc
wire_register
wire_set_reader
wire_set_writer
wire_set_flusher
wire_read
wire_write
wire_flush
wire_error
wire_clear_error
wire_read_msg
wire_write_msg
wire_destroy
wire_read_int32
wire_read_int16
wire_read_int8
wire_read_double
wire_read_string
wire_write_int32
wire_write_int16
wire_write_int8
wire_write_double
wire_write_string
</SECTION>
<SECTION>
<FILE>gimpversion</FILE>
GIMP_MAJOR_VERSION

View File

@ -18,6 +18,16 @@ configuration files.
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### FUNCTION gimp_env_init ##### -->
<para>
</para>
@plug_in:
<!-- # Unused Parameters # -->
@library:
<!-- ##### FUNCTION gimp_directory ##### -->
<para>

View File

@ -1,297 +0,0 @@
<!-- ##### SECTION Title ##### -->
gimpprotocol
<!-- ##### SECTION Short_Description ##### -->
The communication protocol between GIMP and it's plug-ins.
<!-- ##### SECTION Long_Description ##### -->
<para>
The communication protocol between GIMP and it's plug-ins.
</para>
<!-- ##### SECTION See_Also ##### -->
<para>
#libgimp-gimpwire
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### MACRO GIMP_PROTOCOL_VERSION ##### -->
<para>
</para>
<!-- ##### STRUCT GPConfig ##### -->
<para>
</para>
@version:
@tile_width:
@tile_height:
@shm_ID:
@check_size:
@check_type:
@show_help_button:
@gimp_reserved_4:
@gimp_reserved_5:
@gimp_reserved_6:
@gimp_reserved_7:
@gimp_reserved_8:
@install_cmap:
@show_tool_tips:
@min_colors:
@gdisp_ID:
@app_name:
@wm_class:
@display_name:
@monitor_number:
<!-- ##### STRUCT GPTileReq ##### -->
<para>
</para>
@drawable_ID:
@tile_num:
@shadow:
<!-- ##### STRUCT GPTileAck ##### -->
<para>
</para>
<!-- ##### STRUCT GPTileData ##### -->
<para>
</para>
@drawable_ID:
@tile_num:
@shadow:
@bpp:
@width:
@height:
@use_shm:
@data:
<!-- ##### STRUCT GPParam ##### -->
<para>
</para>
@type:
@d_display:
@d_image:
@d_layer:
@d_channel:
@d_drawable:
@d_selection:
@d_boundary:
@d_path:
@d_status:
<!-- ##### STRUCT GPParamDef ##### -->
<para>
</para>
@type:
@name:
@description:
<!-- ##### STRUCT GPProcRun ##### -->
<para>
</para>
@name:
@nparams:
@params:
<!-- ##### STRUCT GPProcReturn ##### -->
<para>
</para>
@name:
@nparams:
@params:
<!-- ##### STRUCT GPProcInstall ##### -->
<para>
</para>
@name:
@blurb:
@help:
@author:
@copyright:
@date:
@menu_path:
@image_types:
@type:
@nparams:
@nreturn_vals:
@params:
@return_vals:
<!-- ##### STRUCT GPProcUninstall ##### -->
<para>
</para>
@name:
<!-- ##### FUNCTION gp_init ##### -->
<para>
</para>
<!-- ##### FUNCTION gp_has_init_write ##### -->
<para>
</para>
@channel:
@user_data:
@Returns:
<!-- ##### FUNCTION gp_quit_write ##### -->
<para>
</para>
@channel:
@user_data:
@Returns:
<!-- ##### FUNCTION gp_config_write ##### -->
<para>
</para>
@channel:
@config:
@user_data:
@Returns:
<!-- ##### FUNCTION gp_tile_req_write ##### -->
<para>
</para>
@channel:
@tile_req:
@user_data:
@Returns:
<!-- ##### FUNCTION gp_tile_ack_write ##### -->
<para>
</para>
@channel:
@user_data:
@Returns:
<!-- ##### FUNCTION gp_tile_data_write ##### -->
<para>
</para>
@channel:
@tile_data:
@user_data:
@Returns:
<!-- ##### FUNCTION gp_proc_run_write ##### -->
<para>
</para>
@channel:
@proc_run:
@user_data:
@Returns:
<!-- ##### FUNCTION gp_proc_return_write ##### -->
<para>
</para>
@channel:
@proc_return:
@user_data:
@Returns:
<!-- ##### FUNCTION gp_temp_proc_run_write ##### -->
<para>
</para>
@channel:
@proc_run:
@user_data:
@Returns:
<!-- ##### FUNCTION gp_temp_proc_return_write ##### -->
<para>
</para>
@channel:
@proc_return:
@user_data:
@Returns:
<!-- ##### FUNCTION gp_proc_install_write ##### -->
<para>
</para>
@channel:
@proc_install:
@user_data:
@Returns:
<!-- ##### FUNCTION gp_proc_uninstall_write ##### -->
<para>
</para>
@channel:
@proc_uninstall:
@user_data:
@Returns:
<!-- ##### FUNCTION gp_extension_ack_write ##### -->
<para>
</para>
@channel:
@user_data:
@Returns:

View File

@ -1,314 +0,0 @@
<!-- ##### SECTION Title ##### -->
gimpwire
<!-- ##### SECTION Short_Description ##### -->
The lowlevel I/O protocol used for communication between GIMP and
it's plug-ins.
<!-- ##### SECTION Long_Description ##### -->
<para>
The lowlevel I/O protocol used for communication between GIMP and
it's plug-ins.
</para>
<!-- ##### SECTION See_Also ##### -->
<para>
#libgimp-gimpprotocol
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### STRUCT WireMessage ##### -->
<para>
</para>
@type:
@data:
<!-- ##### USER_FUNCTION WireReadFunc ##### -->
<para>
</para>
@channel:
@msg:
@user_data:
<!-- ##### USER_FUNCTION WireWriteFunc ##### -->
<para>
</para>
@channel:
@msg:
@user_data:
<!-- ##### USER_FUNCTION WireDestroyFunc ##### -->
<para>
</para>
@msg:
<!-- ##### USER_FUNCTION WireIOFunc ##### -->
<para>
</para>
@channel:
@buf:
@count:
@user_data:
@Returns:
<!-- ##### USER_FUNCTION WireFlushFunc ##### -->
<para>
</para>
@channel:
@user_data:
@Returns:
<!-- ##### FUNCTION wire_register ##### -->
<para>
</para>
@type:
@read_func:
@write_func:
@destroy_func:
<!-- ##### FUNCTION wire_set_reader ##### -->
<para>
</para>
@read_func:
<!-- ##### FUNCTION wire_set_writer ##### -->
<para>
</para>
@write_func:
<!-- ##### FUNCTION wire_set_flusher ##### -->
<para>
</para>
@flush_func:
<!-- ##### FUNCTION wire_read ##### -->
<para>
</para>
@channel:
@buf:
@count:
@user_data:
@Returns:
<!-- ##### FUNCTION wire_write ##### -->
<para>
</para>
@channel:
@buf:
@count:
@user_data:
@Returns:
<!-- ##### FUNCTION wire_flush ##### -->
<para>
</para>
@channel:
@user_data:
@Returns:
<!-- ##### FUNCTION wire_error ##### -->
<para>
</para>
@Returns:
<!-- ##### FUNCTION wire_clear_error ##### -->
<para>
</para>
<!-- ##### FUNCTION wire_read_msg ##### -->
<para>
</para>
@channel:
@msg:
@user_data:
@Returns:
<!-- ##### FUNCTION wire_write_msg ##### -->
<para>
</para>
@channel:
@msg:
@user_data:
@Returns:
<!-- ##### FUNCTION wire_destroy ##### -->
<para>
</para>
@msg:
<!-- ##### FUNCTION wire_read_int32 ##### -->
<para>
</para>
@channel:
@data:
@count:
@user_data:
@Returns:
<!-- ##### FUNCTION wire_read_int16 ##### -->
<para>
</para>
@channel:
@data:
@count:
@user_data:
@Returns:
<!-- ##### FUNCTION wire_read_int8 ##### -->
<para>
</para>
@channel:
@data:
@count:
@user_data:
@Returns:
<!-- ##### FUNCTION wire_read_double ##### -->
<para>
</para>
@channel:
@data:
@count:
@user_data:
@Returns:
<!-- ##### FUNCTION wire_read_string ##### -->
<para>
</para>
@channel:
@data:
@count:
@user_data:
@Returns:
<!-- ##### FUNCTION wire_write_int32 ##### -->
<para>
</para>
@channel:
@data:
@count:
@user_data:
@Returns:
<!-- ##### FUNCTION wire_write_int16 ##### -->
<para>
</para>
@channel:
@data:
@count:
@user_data:
@Returns:
<!-- ##### FUNCTION wire_write_int8 ##### -->
<para>
</para>
@channel:
@data:
@count:
@user_data:
@Returns:
<!-- ##### FUNCTION wire_write_double ##### -->
<para>
</para>
@channel:
@data:
@count:
@user_data:
@Returns:
<!-- ##### FUNCTION wire_write_string ##### -->
<para>
</para>
@channel:
@data:
@count:
@user_data:
@Returns:

View File

@ -48,7 +48,7 @@ gchar * gimp_path_get_user_writable_dir (GList *path);
/* should be considered private, don't use! */
void gimp_env_init (gboolean library);
void gimp_env_init (gboolean plug_in);
G_END_DECLS

View File

@ -28,7 +28,7 @@
#include "gimpreloc.h"
/** @internal
/*
* Find the canonical filename of the executable. Returns the filename
* (which must be freed) or NULL on error. If the parameter 'error' is
* not NULL, the error code will be stored there, if an error occured.
@ -37,138 +37,138 @@ static char *
_br_find_exe (GimpBinrelocInitError *error)
{
#ifndef ENABLE_BINRELOC
if (error)
*error = GIMP_RELOC_INIT_ERROR_DISABLED;
return NULL;
if (error)
*error = GIMP_RELOC_INIT_ERROR_DISABLED;
return NULL;
#else
char *path, *path2, *line, *result;
size_t buf_size;
ssize_t size;
struct stat stat_buf;
FILE *f;
char *path, *path2, *line, *result;
size_t buf_size;
ssize_t size;
struct stat stat_buf;
FILE *f;
/* Read from /proc/self/exe (symlink) */
if (sizeof (path) > SSIZE_MAX)
buf_size = SSIZE_MAX - 1;
else
buf_size = PATH_MAX - 1;
path = g_try_new (char, buf_size);
if (path == NULL) {
/* Cannot allocate memory. */
if (error)
*error = GIMP_RELOC_INIT_ERROR_NOMEM;
return NULL;
}
path2 = g_try_new (char, buf_size);
if (path2 == NULL) {
/* Cannot allocate memory. */
if (error)
*error = GIMP_RELOC_INIT_ERROR_NOMEM;
g_free (path);
return NULL;
}
/* Read from /proc/self/exe (symlink) */
if (sizeof (path) > SSIZE_MAX)
buf_size = SSIZE_MAX - 1;
else
buf_size = PATH_MAX - 1;
path = g_try_new (char, buf_size);
if (path == NULL) {
/* Cannot allocate memory. */
if (error)
*error = GIMP_RELOC_INIT_ERROR_NOMEM;
return NULL;
}
path2 = g_try_new (char, buf_size);
if (path2 == NULL) {
/* Cannot allocate memory. */
if (error)
*error = GIMP_RELOC_INIT_ERROR_NOMEM;
g_free (path);
return NULL;
}
strncpy (path2, "/proc/self/exe", buf_size - 1);
strncpy (path2, "/proc/self/exe", buf_size - 1);
while (1) {
int i;
while (1) {
int i;
size = readlink (path2, path, buf_size - 1);
if (size == -1) {
/* Error. */
g_free (path2);
break;
}
size = readlink (path2, path, buf_size - 1);
if (size == -1) {
/* Error. */
g_free (path2);
break;
}
/* readlink() success. */
path[size] = '\0';
/* readlink() success. */
path[size] = '\0';
/* Check whether the symlink's target is also a symlink.
* We want to get the final target. */
i = stat (path, &stat_buf);
if (i == -1) {
/* Error. */
g_free (path2);
break;
}
/* Check whether the symlink's target is also a symlink.
* We want to get the final target. */
i = stat (path, &stat_buf);
if (i == -1) {
/* Error. */
g_free (path2);
break;
}
/* stat() success. */
if (!S_ISLNK (stat_buf.st_mode)) {
/* path is not a symlink. Done. */
g_free (path2);
return path;
}
/* stat() success. */
if (!S_ISLNK (stat_buf.st_mode)) {
/* path is not a symlink. Done. */
g_free (path2);
return path;
}
/* path is a symlink. Continue loop and resolve this. */
strncpy (path, path2, buf_size - 1);
}
/* path is a symlink. Continue loop and resolve this. */
strncpy (path, path2, buf_size - 1);
}
/* readlink() or stat() failed; this can happen when the program is
* running in Valgrind 2.2. Read from /proc/self/maps as fallback. */
/* readlink() or stat() failed; this can happen when the program is
* running in Valgrind 2.2. Read from /proc/self/maps as fallback. */
buf_size = PATH_MAX + 128;
line = (char *) g_try_realloc (path, buf_size);
if (line == NULL) {
/* Cannot allocate memory. */
g_free (path);
if (error)
*error = GIMP_RELOC_INIT_ERROR_NOMEM;
return NULL;
}
buf_size = PATH_MAX + 128;
line = (char *) g_try_realloc (path, buf_size);
if (line == NULL) {
/* Cannot allocate memory. */
g_free (path);
if (error)
*error = GIMP_RELOC_INIT_ERROR_NOMEM;
return NULL;
}
f = g_fopen ("/proc/self/maps", "r");
if (f == NULL) {
g_free (line);
if (error)
*error = GIMP_RELOC_INIT_ERROR_OPEN_MAPS;
return NULL;
}
f = g_fopen ("/proc/self/maps", "r");
if (f == NULL) {
g_free (line);
if (error)
*error = GIMP_RELOC_INIT_ERROR_OPEN_MAPS;
return NULL;
}
/* The first entry should be the executable name. */
result = fgets (line, (int) buf_size, f);
if (result == NULL) {
fclose (f);
g_free (line);
if (error)
*error = GIMP_RELOC_INIT_ERROR_READ_MAPS;
return NULL;
}
/* The first entry should be the executable name. */
result = fgets (line, (int) buf_size, f);
if (result == NULL) {
fclose (f);
g_free (line);
if (error)
*error = GIMP_RELOC_INIT_ERROR_READ_MAPS;
return NULL;
}
/* Get rid of newline character. */
buf_size = strlen (line);
if (buf_size <= 0) {
/* Huh? An empty string? */
fclose (f);
g_free (line);
if (error)
*error = GIMP_RELOC_INIT_ERROR_INVALID_MAPS;
return NULL;
}
if (line[buf_size - 1] == 10)
line[buf_size - 1] = 0;
/* Get rid of newline character. */
buf_size = strlen (line);
if (buf_size <= 0) {
/* Huh? An empty string? */
fclose (f);
g_free (line);
if (error)
*error = GIMP_RELOC_INIT_ERROR_INVALID_MAPS;
return NULL;
}
if (line[buf_size - 1] == 10)
line[buf_size - 1] = 0;
/* Extract the filename; it is always an absolute path. */
path = strchr (line, '/');
/* Extract the filename; it is always an absolute path. */
path = strchr (line, '/');
/* Sanity check. */
if (strstr (line, " r-xp ") == NULL || path == NULL) {
fclose (f);
g_free (line);
if (error)
*error = GIMP_RELOC_INIT_ERROR_INVALID_MAPS;
return NULL;
}
/* Sanity check. */
if (strstr (line, " r-xp ") == NULL || path == NULL) {
fclose (f);
g_free (line);
if (error)
*error = GIMP_RELOC_INIT_ERROR_INVALID_MAPS;
return NULL;
}
path = g_strdup (path);
g_free (line);
fclose (f);
return path;
path = g_strdup (path);
g_free (line);
fclose (f);
return path;
#endif /* ENABLE_BINRELOC */
}
/** @internal
/*
* Find the canonical filename of the executable which owns symbol.
* Returns a filename which must be freed, or NULL on error.
*/
@ -176,102 +176,102 @@ static char *
_br_find_exe_for_symbol (const void *symbol, GimpBinrelocInitError *error)
{
#ifndef ENABLE_BINRELOC
if (error)
*error = GIMP_RELOC_INIT_ERROR_DISABLED;
return (char *) NULL;
if (error)
*error = GIMP_RELOC_INIT_ERROR_DISABLED;
return (char *) NULL;
#else
#define SIZE PATH_MAX + 100
FILE *f;
size_t address_string_len;
char *address_string, line[SIZE], *found;
#define SIZE PATH_MAX + 100
FILE *f;
size_t address_string_len;
char *address_string, line[SIZE], *found;
if (symbol == NULL)
return (char *) NULL;
if (symbol == NULL)
return (char *) NULL;
f = g_fopen ("/proc/self/maps", "r");
if (f == NULL)
return (char *) NULL;
f = g_fopen ("/proc/self/maps", "r");
if (f == NULL)
return (char *) NULL;
address_string_len = 4;
address_string = g_try_new (char, address_string_len);
found = (char *) NULL;
address_string_len = 4;
address_string = g_try_new (char, address_string_len);
found = (char *) NULL;
while (!feof (f)) {
char *start_addr, *end_addr, *end_addr_end, *file;
void *start_addr_p, *end_addr_p;
size_t len;
while (!feof (f)) {
char *start_addr, *end_addr, *end_addr_end, *file;
void *start_addr_p, *end_addr_p;
size_t len;
if (fgets (line, SIZE, f) == NULL)
break;
if (fgets (line, SIZE, f) == NULL)
break;
/* Sanity check. */
if (strstr (line, " r-xp ") == NULL || strchr (line, '/') == NULL)
continue;
/* Sanity check. */
if (strstr (line, " r-xp ") == NULL || strchr (line, '/') == NULL)
continue;
/* Parse line. */
start_addr = line;
end_addr = strchr (line, '-');
file = strchr (line, '/');
/* Parse line. */
start_addr = line;
end_addr = strchr (line, '-');
file = strchr (line, '/');
/* More sanity check. */
if (!(file > end_addr && end_addr != NULL && end_addr[0] == '-'))
continue;
/* More sanity check. */
if (!(file > end_addr && end_addr != NULL && end_addr[0] == '-'))
continue;
end_addr[0] = '\0';
end_addr++;
end_addr_end = strchr (end_addr, ' ');
if (end_addr_end == NULL)
continue;
end_addr[0] = '\0';
end_addr++;
end_addr_end = strchr (end_addr, ' ');
if (end_addr_end == NULL)
continue;
end_addr_end[0] = '\0';
len = strlen (file);
if (len == 0)
continue;
if (file[len - 1] == '\n')
file[len - 1] = '\0';
end_addr_end[0] = '\0';
len = strlen (file);
if (len == 0)
continue;
if (file[len - 1] == '\n')
file[len - 1] = '\0';
/* Get rid of "(deleted)" from the filename. */
len = strlen (file);
if (len > 10 && strcmp (file + len - 10, " (deleted)") == 0)
file[len - 10] = '\0';
/* Get rid of "(deleted)" from the filename. */
len = strlen (file);
if (len > 10 && strcmp (file + len - 10, " (deleted)") == 0)
file[len - 10] = '\0';
/* I don't know whether this can happen but better safe than sorry. */
len = strlen (start_addr);
if (len != strlen (end_addr))
continue;
/* I don't know whether this can happen but better safe than sorry. */
len = strlen (start_addr);
if (len != strlen (end_addr))
continue;
/* Transform the addresses into a string in the form of 0xdeadbeef,
* then transform that into a pointer. */
if (address_string_len < len + 3) {
address_string_len = len + 3;
address_string = (char *) g_try_realloc (address_string, address_string_len);
}
/* Transform the addresses into a string in the form of 0xdeadbeef,
* then transform that into a pointer. */
if (address_string_len < len + 3) {
address_string_len = len + 3;
address_string = (char *) g_try_realloc (address_string, address_string_len);
}
memcpy (address_string, "0x", 2);
memcpy (address_string + 2, start_addr, len);
address_string[2 + len] = '\0';
sscanf (address_string, "%p", &start_addr_p);
memcpy (address_string, "0x", 2);
memcpy (address_string + 2, start_addr, len);
address_string[2 + len] = '\0';
sscanf (address_string, "%p", &start_addr_p);
memcpy (address_string, "0x", 2);
memcpy (address_string + 2, end_addr, len);
address_string[2 + len] = '\0';
sscanf (address_string, "%p", &end_addr_p);
memcpy (address_string, "0x", 2);
memcpy (address_string + 2, end_addr, len);
address_string[2 + len] = '\0';
sscanf (address_string, "%p", &end_addr_p);
if (symbol >= start_addr_p && symbol < end_addr_p) {
found = file;
break;
}
}
if (symbol >= start_addr_p && symbol < end_addr_p) {
found = file;
break;
}
}
g_free (address_string);
fclose (f);
g_free (address_string);
fclose (f);
if (found == NULL)
return (char *) NULL;
else
return g_strdup (found);
if (found == NULL)
return (char *) NULL;
else
return g_strdup (found);
#endif /* ENABLE_BINRELOC */
}
@ -281,7 +281,7 @@ static gchar *exe = NULL;
static void set_gerror (GError **error, GimpBinrelocInitError errcode);
/** Initialize the BinReloc library (for applications).
/* Initialize the BinReloc library (for applications).
*
* This function must be called before using any other BinReloc functions.
* It attempts to locate the application's canonical filename.
@ -301,25 +301,25 @@ static void set_gerror (GError **error, GimpBinrelocInitError errcode);
gboolean
_gimp_reloc_init (GError **error)
{
GimpBinrelocInitError errcode;
GimpBinrelocInitError errcode;
/* Shut up compiler warning about uninitialized variable. */
errcode = GIMP_RELOC_INIT_ERROR_NOMEM;
/* Shut up compiler warning about uninitialized variable. */
errcode = GIMP_RELOC_INIT_ERROR_NOMEM;
/* Locate the application's filename. */
exe = _br_find_exe (&errcode);
if (exe != NULL)
/* Success! */
return TRUE;
else {
/* Failed :-( */
set_gerror (error, errcode);
return FALSE;
}
/* Locate the application's filename. */
exe = _br_find_exe (&errcode);
if (exe != NULL)
/* Success! */
return TRUE;
else {
/* Failed :-( */
set_gerror (error, errcode);
return FALSE;
}
}
/** Initialize the BinReloc library (for libraries).
/* Initialize the BinReloc library (for libraries).
*
* This function must be called before using any other BinReloc functions.
* It attempts to locate the calling library's canonical filename.
@ -334,56 +334,56 @@ _gimp_reloc_init (GError **error)
gboolean
_gimp_reloc_init_lib (GError **error)
{
GimpBinrelocInitError errcode;
GimpBinrelocInitError errcode;
/* Shut up compiler warning about uninitialized variable. */
errcode = GIMP_RELOC_INIT_ERROR_NOMEM;
/* Shut up compiler warning about uninitialized variable. */
errcode = GIMP_RELOC_INIT_ERROR_NOMEM;
exe = _br_find_exe_for_symbol ((const void *) "", &errcode);
if (exe != NULL)
/* Success! */
return TRUE;
else {
/* Failed :-( */
set_gerror (error, errcode);
return exe != NULL;
}
exe = _br_find_exe_for_symbol ((const void *) "", &errcode);
if (exe != NULL)
/* Success! */
return TRUE;
else {
/* Failed :-( */
set_gerror (error, errcode);
return exe != NULL;
}
}
static void
set_gerror (GError **error, GimpBinrelocInitError errcode)
{
gchar *error_message;
gchar *error_message;
if (error == NULL)
return;
if (error == NULL)
return;
switch (errcode) {
case GIMP_RELOC_INIT_ERROR_NOMEM:
error_message = "Cannot allocate memory.";
break;
case GIMP_RELOC_INIT_ERROR_OPEN_MAPS:
error_message = "Unable to open /proc/self/maps for reading.";
break;
case GIMP_RELOC_INIT_ERROR_READ_MAPS:
error_message = "Unable to read from /proc/self/maps.";
break;
case GIMP_RELOC_INIT_ERROR_INVALID_MAPS:
error_message = "The file format of /proc/self/maps is invalid.";
break;
case GIMP_RELOC_INIT_ERROR_DISABLED:
error_message = "Binary relocation support is disabled.";
break;
default:
error_message = "Unknown error.";
break;
};
g_set_error (error, g_quark_from_static_string ("GBinReloc"),
errcode, "%s", error_message);
switch (errcode) {
case GIMP_RELOC_INIT_ERROR_NOMEM:
error_message = "Cannot allocate memory.";
break;
case GIMP_RELOC_INIT_ERROR_OPEN_MAPS:
error_message = "Unable to open /proc/self/maps for reading.";
break;
case GIMP_RELOC_INIT_ERROR_READ_MAPS:
error_message = "Unable to read from /proc/self/maps.";
break;
case GIMP_RELOC_INIT_ERROR_INVALID_MAPS:
error_message = "The file format of /proc/self/maps is invalid.";
break;
case GIMP_RELOC_INIT_ERROR_DISABLED:
error_message = "Binary relocation support is disabled.";
break;
default:
error_message = "Unknown error.";
break;
};
g_set_error (error, g_quark_from_static_string ("GBinReloc"),
errcode, "%s", error_message);
}
/** Find the canonical filename of the current application.
/* Find the canonical filename of the current application.
*
* @param default_exe A default filename which will be used as fallback.
* @returns A string containing the application's canonical filename,
@ -395,18 +395,18 @@ set_gerror (GError **error, GimpBinrelocInitError errcode)
gchar *
_gimp_reloc_find_exe (const gchar *default_exe)
{
if (exe == NULL) {
/* BinReloc is not initialized. */
if (default_exe != NULL)
return g_strdup (default_exe);
else
return NULL;
}
return g_strdup (exe);
if (exe == NULL) {
/* BinReloc is not initialized. */
if (default_exe != NULL)
return g_strdup (default_exe);
else
return NULL;
}
return g_strdup (exe);
}
/** Locate the directory in which the current application is installed.
/* Locate the directory in which the current application is installed.
*
* The prefix is generated by the following pseudo-code evaluation:
* \code
@ -423,19 +423,19 @@ _gimp_reloc_find_exe (const gchar *default_exe)
gchar *
_gimp_reloc_find_exe_dir (const gchar *default_dir)
{
if (exe == NULL) {
/* BinReloc not initialized. */
if (default_dir != NULL)
return g_strdup (default_dir);
else
return NULL;
}
if (exe == NULL) {
/* BinReloc not initialized. */
if (default_dir != NULL)
return g_strdup (default_dir);
else
return NULL;
}
return g_path_get_dirname (exe);
return g_path_get_dirname (exe);
}
/** Locate the prefix in which the current application is installed.
/* Locate the prefix in which the current application is installed.
*
* The prefix is generated by the following pseudo-code evaluation:
* \code
@ -452,24 +452,24 @@ _gimp_reloc_find_exe_dir (const gchar *default_dir)
gchar *
_gimp_reloc_find_prefix (const gchar *default_prefix)
{
gchar *dir1, *dir2;
gchar *dir1, *dir2;
if (exe == NULL) {
/* BinReloc not initialized. */
if (default_prefix != NULL)
return g_strdup (default_prefix);
else
return NULL;
}
if (exe == NULL) {
/* BinReloc not initialized. */
if (default_prefix != NULL)
return g_strdup (default_prefix);
else
return NULL;
}
dir1 = g_path_get_dirname (exe);
dir2 = g_path_get_dirname (dir1);
g_free (dir1);
return dir2;
dir1 = g_path_get_dirname (exe);
dir2 = g_path_get_dirname (dir1);
g_free (dir1);
return dir2;
}
/** Locate the application's binary folder.
/* Locate the application's binary folder.
*
* The path is generated by the following pseudo-code evaluation:
* \code
@ -485,24 +485,24 @@ _gimp_reloc_find_prefix (const gchar *default_prefix)
gchar *
_gimp_reloc_find_bin_dir (const gchar *default_bin_dir)
{
gchar *prefix, *dir;
gchar *prefix, *dir;
prefix = _gimp_reloc_find_prefix (NULL);
if (prefix == NULL) {
/* BinReloc not initialized. */
if (default_bin_dir != NULL)
return g_strdup (default_bin_dir);
else
return NULL;
}
prefix = _gimp_reloc_find_prefix (NULL);
if (prefix == NULL) {
/* BinReloc not initialized. */
if (default_bin_dir != NULL)
return g_strdup (default_bin_dir);
else
return NULL;
}
dir = g_build_filename (prefix, "bin", NULL);
g_free (prefix);
return dir;
dir = g_build_filename (prefix, "bin", NULL);
g_free (prefix);
return dir;
}
/** Locate the application's data folder.
/* Locate the application's data folder.
*
* The path is generated by the following pseudo-code evaluation:
* \code
@ -519,49 +519,49 @@ _gimp_reloc_find_bin_dir (const gchar *default_bin_dir)
gchar *
_gimp_reloc_find_data_dir (const gchar *default_data_dir)
{
gchar *prefix, *dir;
gchar *prefix, *dir;
prefix = _gimp_reloc_find_prefix (NULL);
if (prefix == NULL) {
/* BinReloc not initialized. */
if (default_data_dir != NULL)
return g_strdup (default_data_dir);
else
return NULL;
}
prefix = _gimp_reloc_find_prefix (NULL);
if (prefix == NULL) {
/* BinReloc not initialized. */
if (default_data_dir != NULL)
return g_strdup (default_data_dir);
else
return NULL;
}
dir = g_build_filename (prefix, "share",
GIMP_PACKAGE,
GIMP_DATA_VERSION,
NULL);
g_free (prefix);
return dir;
dir = g_build_filename (prefix, "share",
GIMP_PACKAGE,
GIMP_DATA_VERSION,
NULL);
g_free (prefix);
return dir;
}
gchar *
_gimp_reloc_find_plugin_dir (const gchar *default_plugin_dir)
{
gchar *libdir, *dir;
gchar *libdir, *dir;
libdir = _gimp_reloc_find_lib_dir (NULL);
if (libdir == NULL) {
/* BinReloc not initialized. */
if (default_plugin_dir != NULL)
return g_strdup (default_plugin_dir);
else
return NULL;
}
libdir = _gimp_reloc_find_lib_dir (NULL);
if (libdir == NULL) {
/* BinReloc not initialized. */
if (default_plugin_dir != NULL)
return g_strdup (default_plugin_dir);
else
return NULL;
}
dir = g_build_filename (libdir,
GIMP_PACKAGE,
GIMP_PLUGIN_VERSION,
NULL);
g_free (libdir);
return dir;
dir = g_build_filename (libdir,
GIMP_PACKAGE,
GIMP_PLUGIN_VERSION,
NULL);
g_free (libdir);
return dir;
}
/** Locate the application's localization folder.
/* Locate the application's localization folder.
*
* The path is generated by the following pseudo-code evaluation:
* \code
@ -577,24 +577,24 @@ _gimp_reloc_find_plugin_dir (const gchar *default_plugin_dir)
gchar *
_gimp_reloc_find_locale_dir (const gchar *default_locale_dir)
{
gchar *data_dir, *dir;
gchar *data_dir, *dir;
data_dir = _gimp_reloc_find_data_dir (NULL);
if (data_dir == NULL) {
/* BinReloc not initialized. */
if (default_locale_dir != NULL)
return g_strdup (default_locale_dir);
else
return NULL;
}
data_dir = _gimp_reloc_find_data_dir (NULL);
if (data_dir == NULL) {
/* BinReloc not initialized. */
if (default_locale_dir != NULL)
return g_strdup (default_locale_dir);
else
return NULL;
}
dir = g_build_filename (data_dir, "locale", NULL);
g_free (data_dir);
return dir;
dir = g_build_filename (data_dir, "locale", NULL);
g_free (data_dir);
return dir;
}
/** Locate the application's library folder.
/* Locate the application's library folder.
*
* The path is generated by the following pseudo-code evaluation:
* \code
@ -610,24 +610,24 @@ _gimp_reloc_find_locale_dir (const gchar *default_locale_dir)
gchar *
_gimp_reloc_find_lib_dir (const gchar *default_lib_dir)
{
gchar *prefix, *dir;
gchar *prefix, *dir;
prefix = _gimp_reloc_find_prefix (NULL);
if (prefix == NULL) {
/* BinReloc not initialized. */
if (default_lib_dir != NULL)
return g_strdup (default_lib_dir);
else
return NULL;
}
prefix = _gimp_reloc_find_prefix (NULL);
if (prefix == NULL) {
/* BinReloc not initialized. */
if (default_lib_dir != NULL)
return g_strdup (default_lib_dir);
else
return NULL;
}
dir = g_build_filename (prefix, "lib", NULL);
g_free (prefix);
return dir;
dir = g_build_filename (prefix, "lib", NULL);
g_free (prefix);
return dir;
}
/** Locate the application's libexec folder.
/* Locate the application's libexec folder.
*
* The path is generated by the following pseudo-code evaluation:
* \code
@ -643,24 +643,24 @@ _gimp_reloc_find_lib_dir (const gchar *default_lib_dir)
gchar *
_gimp_reloc_find_libexec_dir (const gchar *default_libexec_dir)
{
gchar *prefix, *dir;
gchar *prefix, *dir;
prefix = _gimp_reloc_find_prefix (NULL);
if (prefix == NULL) {
/* BinReloc not initialized. */
if (default_libexec_dir != NULL)
return g_strdup (default_libexec_dir);
else
return NULL;
}
prefix = _gimp_reloc_find_prefix (NULL);
if (prefix == NULL) {
/* BinReloc not initialized. */
if (default_libexec_dir != NULL)
return g_strdup (default_libexec_dir);
else
return NULL;
}
dir = g_build_filename (prefix, "libexec", NULL);
g_free (prefix);
return dir;
dir = g_build_filename (prefix, "libexec", NULL);
g_free (prefix);
return dir;
}
/** Locate the application's configuration files folder.
/* Locate the application's configuration files folder.
*
* The path is generated by the following pseudo-code evaluation:
* \code
@ -669,28 +669,29 @@ _gimp_reloc_find_libexec_dir (const gchar *default_libexec_dir)
*
* @param default_etc_dir A default path which will used as fallback.
* @return A string containing the etc folder's path, which must be freed when
* no longer necessary. If BinReloc is not initialized, or if the initialization
* function failed, then a copy of default_etc_dir will be returned.
* If default_etc_dir is NULL, then NULL will be returned.
* no longer necessary. If BinReloc is not initialized, or if the
* initialization function failed, then a copy of default_etc_dir
* will be returned. If default_etc_dir is NULL, then NULL will be
* returned.
*/
gchar *
_gimp_reloc_find_etc_dir (const gchar *default_etc_dir)
{
gchar *prefix, *dir;
gchar *prefix, *dir;
prefix = _gimp_reloc_find_prefix (NULL);
if (prefix == NULL) {
/* BinReloc not initialized. */
if (default_etc_dir != NULL)
return g_strdup (default_etc_dir);
else
return NULL;
}
prefix = _gimp_reloc_find_prefix (NULL);
if (prefix == NULL) {
/* BinReloc not initialized. */
if (default_etc_dir != NULL)
return g_strdup (default_etc_dir);
else
return NULL;
}
dir = g_build_filename (prefix, "etc",
GIMP_PACKAGE,
GIMP_SYSCONF_VERSION,
NULL);
g_free (prefix);
return dir;
dir = g_build_filename (prefix, "etc",
GIMP_PACKAGE,
GIMP_SYSCONF_VERSION,
NULL);
g_free (prefix);
return dir;
}