Process the --namespace command-line option from C, not guile.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@12911 57a11ea4-9604-0410-9ed3-97b8803252fd
zzzoldfeatures/register-rewrite
Chris Shoemaker 21 years ago
parent e50a31f89c
commit 555652140f

@ -7,6 +7,7 @@ AM_CFLAGS = -I${top_builddir} ${GLIB_CFLAGS} ${GNOME_CFLAGS} ${GTK_CFLAGS} \
-DGNC_SHAREDIR=\"${GNC_SHAREDIR}\" \
-DGNC_HELPDIR=\"${GNC_HELPDIR}\" \
-I${top_srcdir}/src \
-I${top_srcdir}/src/core-utils \
-I${top_srcdir}/src/app-utils \
-I${top_srcdir}/src/gnome-utils \
-I${top_srcdir}/src/engine \
@ -22,6 +23,7 @@ ${top_builddir}/src/engine/libgncmod-engine.la \
${top_builddir}/src/gnome/libgncgnome.la \
${top_builddir}/src/gnome-utils/libgncmod-gnome-utils.la \
${top_builddir}/src/app-utils/libgncmod-app-utils.la \
${top_builddir}/src/core-utils/libcore-utils.la \
${top_builddir}/src/gnc-module/libgncmodule.la
gnucash: gnucash.in ${top_builddir}/config.status Makefile

@ -40,6 +40,7 @@
#include "gnc-hooks.h"
#include "top-level.h"
#include "gfec.h"
#include "gnc-main.h"
static int gnucash_show_version;
/* GNUCASH_SVN is defined whenever we're building from an SVN tree */
@ -149,7 +150,7 @@ load_user_config(void)
static const gchar *stylesheet_files[] = { "stylesheets-2.0", NULL};
static int is_user_config_loaded = FALSE;
if (is_user_config_loaded)
if (is_user_config_loaded)
return;
else is_user_config_loaded = TRUE;
@ -183,6 +184,7 @@ gnucash_command_line(int argc, char **argv)
poptContext pc;
char *p;
int rc;
char *namespace_regexp = NULL;
struct poptOption options[] = {
POPT_AUTOHELP
@ -205,7 +207,7 @@ gnucash_command_line(int argc, char **argv)
_("Set the search path for documentation files"), _("DOCPATH")},
{"add-price-quotes", '\0', POPT_ARG_STRING, NULL, 0,
_("Add price quotes to given FILE"), _("FILE")},
{"namespace", '\0', POPT_ARG_STRING, NULL, 0,
{"namespace", '\0', POPT_ARG_STRING, &namespace_regexp, 0,
_("Regular expression determining which namespace commodities will be retrieved"),
_("REGEXP")},
POPT_TABLEEND
@ -225,6 +227,9 @@ gnucash_command_line(int argc, char **argv)
printf(_("built %s from r%s\n"), GNUCASH_BUILD_DATE, GNUCASH_SVN_REV);
exit(0);
}
if (namespace_regexp)
gnc_main_set_namespace_regexp(namespace_regexp);
poptFreeContext(pc);
}

@ -2,6 +2,7 @@
lib_LTLIBRARIES = libcore-utils.la libgw-core-utils.la
libcore_utils_la_SOURCES = \
gnc-main.c \
gnc-gconf-utils.c \
gnc-gdate-utils.c \
gnc-gkeyfile-utils.c \
@ -22,6 +23,7 @@ libgw_core_utils_la_LIBADD = \
${GUILE_LIBS}
noinst_HEADERS = \
gnc-main.h \
gnc-gconf-utils.h \
gnc-gdate-utils.h \
gnc-gkeyfile-utils.h \

@ -0,0 +1,43 @@
/*
* gnc-main.c:
*
* Copyright (C) 2006 Chris Shoemaker <c.shoemaker@cox.net>
*
* 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-main.h"
static char *namespace_regexp = NULL;
void
gnc_main_set_namespace_regexp(const char *str)
{
if (namespace_regexp)
g_free(namespace_regexp);
if (str)
namespace_regexp = g_strdup(str);
}
const char *gnc_main_get_namespace_regexp(void)
{
return namespace_regexp;
}

@ -0,0 +1,33 @@
/*
* gnc-main.h:
*
* Copyright (C) 2006 Chris Shoemaker <c.shoemaker@cox.net>
*
* 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_MAIN_H
#define GNC_MAIN_H
#include <glib.h>
void gnc_main_set_namespace_regexp(const char *str);
const char *gnc_main_get_namespace_regexp(void);
#endif /* GNC_MAIN_H */

@ -106,6 +106,7 @@ libgncmod_engine_la_LIBADD = ${GNUCASH_ENGINE_BASE_LIBS} \
libgw-engine.la \
libgw-kvp.la \
../gnc-module/libgncmodule.la \
${top_builddir}/src/core-utils/libcore-utils.la \
../../lib/libc/libc-missing.la
libgw_kvp_la_SOURCES = gw-kvp.c kvp-scm.c

@ -36,6 +36,7 @@
#include <regex.h>
#include "gnc-commodity.h"
#include "gnc-main.h"
static QofLogModule log_module = GNC_MOD_COMMODITY;
@ -1364,14 +1365,14 @@ get_quotables_helper2 (gnc_commodity *comm, gpointer data)
}
GList *
gnc_commodity_table_get_quotable_commodities(const gnc_commodity_table * table,
const char *expression)
gnc_commodity_table_get_quotable_commodities(const gnc_commodity_table * table)
{
gnc_commodity_namespace * ns = NULL;
const char *namespace;
GList * nslist, * tmp;
GList * l = NULL;
regex_t pattern;
const char *expression = gnc_main_get_namespace_regexp();
ENTER("table=%p, expression=%s", table, expression);
if (!table)

@ -784,22 +784,21 @@ GList * gnc_commodity_table_get_commodities(const gnc_commodity_table * table,
* should be retrieved. It will scan the entire commodity table (or
* a subset) and check each commodity to see if the price_quote_flag
* field has been set. All matching commodities are queued onto a
* list, and the head of that list is returned.
* list, and the head of that list is returned. Use the command-line
* given expression as a filter on the commodities to be returned. If
* non-null, only commodities in namespace that match the specified
* regular expression are checked. If none was given, all
* commodities are checked.
*
* @param table A pointer to the commodity table
*
* @param expression Use the given expression as a filter on the
* commodities to be returned. If non-null, only commodities in
* namespace that match the specified regular expression are checked.
* If null, all commodities are checked.
*
* @return A pointer to a list of commodities. NULL if invalid
* arguments were supplied or if there no commodities are flagged for
* quote retrieval.
*
* @note It is the callers responsibility to free the list. */
GList * gnc_commodity_table_get_quotable_commodities(const gnc_commodity_table * table,
const char * expression);
GList * gnc_commodity_table_get_quotable_commodities(
const gnc_commodity_table * table);
/** Call a function once for each commodity in the commodity table.
* This table walk returns whenever the end of the table is reached,

@ -729,7 +729,7 @@ to another account, it will be removed from that account first.")
"xaccAccountFixSplitDateOrder"
'((<gnc:Account*> a) (<gnc:Split*> s))
"Check to see if split s is in proper sorted date order with respect
to the other splits in account a.")
to the other splits in account a.")
(gw:wrap-function
ws
@ -2172,8 +2172,7 @@ of having a parent transaction with which one is working...")
'gnc:commodity-table-get-quotable-commodities
'(gw:glist-of <gnc:commodity*> caller-owned)
"gnc_commodity_table_get_quotable_commodities"
'((<gnc:commodity-table*> table)
((<gw:mchars> caller-owned const) namespace))
'((<gnc:commodity-table*> table))
"Return a list of all the quotable commodities in a given namespace in the table.")
(gw:wrap-function

@ -23,9 +23,9 @@
(define-module (gnucash price-quotes))
(export yahoo-get-historical-quotes)
(export gnc:fq-check-sources)
(export gnc:book-add-quotes)
(export gnc:add-quotes-to-book-at-url)
(export gnc:fq-check-sources) ;; called in main.scm
(export gnc:book-add-quotes) ;; called from gnome/dialog-price-edit-db.c
(export gnc:add-quotes-to-book-at-url) ;; called in command-line.scm
(use-modules (gnucash process))
(use-modules (www main))
@ -373,17 +373,16 @@
(let* ((ct (gnc:book-get-commodity-table book))
(big-list
(gnc:commodity-table-get-quotable-commodities-info
ct
(gnc:config-var-value-get gnc:*namespace-regexp*)))
ct))
(commodity-list #f)
(currency-list (filter
(lambda (a) (not (equal? (cadr a) (caddr a))))
(call-with-values
(lambda () (partition!
(lambda (cmd)
(not (string=? (car cmd) "currency")))
big-list))
(lambda (a b) (set! commodity-list a) b))))
(lambda () (partition!
(lambda (cmd)
(not (string=? (car cmd) "currency")))
big-list))
(lambda (a b) (set! commodity-list a) b))))
(quote-hash (make-hash-table 31)))
(if (null? big-list)

Loading…
Cancel
Save