Add new file with utility functions to retrieve the needed directory

paths. All compile-time vs. runtime path lookups will be implemented
exactly in this file.




git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@14821 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Christian Stimming 2006-09-07 20:37:53 +00:00
parent e256fdbfc6
commit df175ce6b8
5 changed files with 209 additions and 0 deletions

View File

@ -1,3 +1,9 @@
2006-09-07 Christian Stimming <stimming@tuhh.de>
* src/engine/gnc-path.h, gnc-path.c: Add new file with utility
functions to retrieve the needed directory paths. All compile-time
vs. runtime path lookups will be implemented exactly in this file.
2006-09-07 David Hampton <hampton@employees.org>
* src/backend/postgres: Include config.h a couple of places.

View File

@ -4,6 +4,10 @@ PWD := $(shell pwd)
pkglib_LTLIBRARIES = libgncmod-engine.la libgw-engine.la libgw-kvp.la
AM_CFLAGS = \
-DPREFIX=\"${prefix}\" \
-DSYSCONFDIR=\"${GNC_CONFIGDIR}\" \
-DDATADIR=\"${GNC_SHAREDIR}\" \
-DLIBDIR=\"${GNC_LIBDIR}\" \
-I${top_srcdir}/lib/libc \
-I${top_srcdir}/src/core-utils \
-I${top_srcdir}/src \
@ -37,6 +41,7 @@ libgncmod_engine_la_SOURCES = \
gnc-filepath-utils.c \
gnc-hooks.c \
gnc-lot.c \
gnc-path.c \
gnc-pricedb.c \
gnc-session.c \
gnc-session-scm.c \
@ -78,6 +83,7 @@ gncinclude_HEADERS = \
gnc-event.h \
gnc-filepath-utils.h \
gnc-hooks.h \
gnc-path.h \
gnc-pricedb.h \
gnc-session.h \
gnc-session-scm.h \
@ -221,6 +227,10 @@ gwrap-files2: \
gncla-dir.h: gncla-dir.h.in ${top_builddir}/config.status
rm -f $@.tmp
sed < $< > $@.tmp \
-e 's#@-LOCALE_DIR-@#${LOCALE_DIR}#g' \
-e 's#@-GNC_ACCOUNTS_DIR-@#${GNC_ACCOUNTS_DIR}#g' \
-e 's#@-GNC_GLADE_DIR-@#${GNC_GLADE_DIR}#g' \
-e 's#@-GCONF_SCHEMA_CONFIG_SOURCE_DIRONLY-@#${GCONF_SCHEMA_CONFIG_SOURCE_DIRONLY}#g' \
-e 's#@-libdir-@#${libdir}#g'
mv $@.tmp $@

103
src/engine/gnc-path.c Normal file
View File

@ -0,0 +1,103 @@
/********************************************************************\
* gnc-path.c -- Path lookup of gnucash installation locations *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation; either version 2 of *
* the License, or (at your option) any later version. *
* *
* This program 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 General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License*
* along with this program; if not, contact: *
* *
* Free Software Foundation Voice: +1-617-542-5942 *
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
* Boston, MA 02110-1301, USA gnu@gnu.org *
\********************************************************************/
#include "config.h"
#include "gnc-path.h"
#include "gncla-dir.h"
gchar *gnc_path_get_prefix()
{
return g_strdup (PREFIX);
}
/** Returns the libdir path, usually
* "$prefix/lib". Needed for gnome_program_init().
*
* @returns A newly allocated string. */
gchar *gnc_path_get_libdir()
{
return g_strdup (LIBDIR);
}
/** Returns the datadir path, usually
* "$prefix/share". Needed for gnome_program_init().
*
* @returns A newly allocated string. */
gchar *gnc_path_get_datadir()
{
return g_strdup (DATADIR);
}
/** Returns the sysconfdir path, usually
* "$prefix/etc". Needed for gnome_program_init().
*
* @returns A newly allocated string. */
gchar *gnc_path_get_sysconfdir()
{
return g_strdup (SYSCONFDIR);
}
/** Returns the pkglibdir path, usually
* "$prefix/lib/gnucash".
*
* @returns A newly allocated string. */
gchar *gnc_path_get_pkglibdir()
{
return g_strdup (GNC_LIBDIR);
}
/** Returns the glade file path, usually
* "$prefix/share/gnucash/glade".
*
* @returns A newly allocated string. */
gchar *gnc_path_get_gladedir()
{
return g_strdup (GNC_GLADE_DIR);
}
/** Returns the localedir path, usually
* "$prefix/share/locale".
*
* @returns A newly allocated string. */
gchar *gnc_path_get_localedir()
{
return g_strdup (LOCALE_DIR);
}
/** Returns the glade file path, usually
* "$prefix/share/gnucash/accounts".
*
* @returns A newly allocated string. */
gchar *gnc_path_get_accountsdir()
{
return g_strdup (GNC_ACCOUNTS_DIR);
}
/** Returns the gconf schema config source path, usually
* "$prefix/etc/gconf/gconf.xml.defaults".
*
* @returns A newly allocated string. */
gchar *gnc_path_get_gconfdir()
{
return g_strdup (GNC_GCONF_DIR);
}

85
src/engine/gnc-path.h Normal file
View File

@ -0,0 +1,85 @@
/********************************************************************\
* gnc-path.h -- Path lookup of gnucash installation locations *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation; either version 2 of *
* the License, or (at your option) any later version. *
* *
* This program 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 General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License*
* along with this program; if not, contact: *
* *
* Free Software Foundation Voice: +1-617-542-5942 *
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
* Boston, MA 02110-1301, USA gnu@gnu.org *
\********************************************************************/
#ifndef GNC_PATH_H
#define GNC_PATH_H
#include <glib.h>
/** Returns the installation prefix path, usually
* "$prefix". Needed for gnome_program_init().
*
* @returns A newly allocated string. */
gchar *gnc_path_get_prefix(void);
/** Returns the libdir path, usually
* "$prefix/lib". Needed for gnome_program_init(void).
*
* @returns A newly allocated string. */
gchar *gnc_path_get_libdir(void);
/** Returns the datadir path, usually
* "$prefix/share". Needed for gnome_program_init(void).
*
* @returns A newly allocated string. */
gchar *gnc_path_get_datadir(void);
/** Returns the sysconfdir path, usually
* "$prefix/etc". Needed for gnome_program_init(void).
*
* @returns A newly allocated string. */
gchar *gnc_path_get_sysconfdir(void);
/** Returns the pkglibdir path, usually
* "$prefix/lib/gnucash".
*
* @returns A newly allocated string. */
gchar *gnc_path_get_pkglibdir(void);
/** Returns the glade file path, usually
* "$prefix/share/gnucash/glade".
*
* @returns A newly allocated string. */
gchar *gnc_path_get_gladedir(void);
/** Returns the localedir path, usually
* "$prefix/share/locale".
*
* @returns A newly allocated string. */
gchar *gnc_path_get_localedir(void);
/** Returns the glade file path, usually
* "$prefix/share/gnucash/accounts".
*
* @returns A newly allocated string. */
gchar *gnc_path_get_accountsdir(void);
/** Returns the gconf schema config source path, usually
* "$prefix/etc/gconf/gconf.xml.defaults".
*
* @returns A newly allocated string. */
gchar *gnc_path_get_gconfdir(void);
#endif /* GNC_PATH_H */

View File

@ -25,3 +25,8 @@
#define GNC_LIBDIR "@-libdir-@"
#define LOCALE_DIR "@-LOCALE_DIR-@"
#define GNC_ACCOUNTS_DIR "@-GNC_ACCOUNTS_DIR-@"
#define GNC_GLADE_DIR "@-GNC_GLADE_DIR-@"
#define GNC_GCONF_DIR "@-GCONF_SCHEMA_CONFIG_SOURCE_DIRONLY-@"