r14821 - gnucash/trunk - Add new file with utility functions to retrieve the needed directory
Christian Stimming
cstim at cvs.gnucash.org
Thu Sep 7 16:37:54 EDT 2006
Author: cstim
Date: 2006-09-07 16:37:53 -0400 (Thu, 07 Sep 2006)
New Revision: 14821
Trac: http://svn.gnucash.org/trac/changeset/14821
Added:
gnucash/trunk/src/engine/gnc-path.c
gnucash/trunk/src/engine/gnc-path.h
Modified:
gnucash/trunk/ChangeLog
gnucash/trunk/src/engine/Makefile.am
gnucash/trunk/src/engine/gncla-dir.h.in
Log:
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.
Modified: gnucash/trunk/ChangeLog
===================================================================
--- gnucash/trunk/ChangeLog 2006-09-07 18:31:38 UTC (rev 14820)
+++ gnucash/trunk/ChangeLog 2006-09-07 20:37:53 UTC (rev 14821)
@@ -1,3 +1,9 @@
+2006-09-07 Christian Stimming <stimming at 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 at employees.org>
* src/backend/postgres: Include config.h a couple of places.
Modified: gnucash/trunk/src/engine/Makefile.am
===================================================================
--- gnucash/trunk/src/engine/Makefile.am 2006-09-07 18:31:38 UTC (rev 14820)
+++ gnucash/trunk/src/engine/Makefile.am 2006-09-07 20:37:53 UTC (rev 14821)
@@ -4,6 +4,10 @@
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 @@
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 @@
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 @@
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 $@
Added: gnucash/trunk/src/engine/gnc-path.c
===================================================================
--- gnucash/trunk/src/engine/gnc-path.c 2006-09-07 18:31:38 UTC (rev 14820)
+++ gnucash/trunk/src/engine/gnc-path.c 2006-09-07 20:37:53 UTC (rev 14821)
@@ -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 at 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);
+}
+
Added: gnucash/trunk/src/engine/gnc-path.h
===================================================================
--- gnucash/trunk/src/engine/gnc-path.h 2006-09-07 18:31:38 UTC (rev 14820)
+++ gnucash/trunk/src/engine/gnc-path.h 2006-09-07 20:37:53 UTC (rev 14821)
@@ -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 at 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 */
Modified: gnucash/trunk/src/engine/gncla-dir.h.in
===================================================================
--- gnucash/trunk/src/engine/gncla-dir.h.in 2006-09-07 18:31:38 UTC (rev 14820)
+++ gnucash/trunk/src/engine/gncla-dir.h.in 2006-09-07 20:37:53 UTC (rev 14821)
@@ -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-@"
More information about the gnucash-changes
mailing list