business-options.c

00001 /*
00002  * business-options.c -- Non-GUI Option Utilities for GNC Business Objects
00003  *
00004  * Written By: Derek Atkins <warlord@MIT.EDU>
00005  * Copyright (C) 2003  Derek Atkins
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License as
00009  * published by the Free Software Foundation; either version 2 of
00010  * the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, contact:
00019  *
00020  * Free Software Foundation           Voice:  +1-617-542-5942
00021  * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
00022  * Boston, MA  02110-1301,  USA       gnu@gnu.org
00023  */
00024 
00025 #include "config.h"
00026 
00027 #include "business-options.h"
00028 #include "swig-runtime.h"
00029 
00030 #define FUNC_NAME G_STRFUNC
00031 
00032 #define LOOKUP_OPTION(fcn) \
00033   GNCOption *option; \
00034   SCM getter; \
00035   SCM value; \
00036   \
00037   option = gnc_option_db_get_option_by_name (odb, section, name); \
00038   \
00039   if (option == NULL) \
00040     return default_value; \
00041   \
00042   getter = gnc_option_getter (option); \
00043   if (getter == SCM_UNDEFINED) \
00044     return default_value; \
00045   \
00046   value = scm_call_0 (getter); \
00047   if (value == SCM_BOOL_F) \
00048     return NULL; \
00049   SWIG_GetModule(NULL); /* Work-around for SWIG bug. */       \
00050   if (!SWIG_IsPointer(value))             \
00051     scm_misc_error(fcn, "SCM is not a wrapped pointer.", value)
00052 
00053 GncTaxTable*
00054 gnc_option_db_lookup_taxtable_option(GNCOptionDB *odb,
00055                                      const char *section,
00056                                      const char *name,
00057                                      GncTaxTable * default_value)
00058 {
00059   LOOKUP_OPTION("gnc_option_db_lookup_taxtable_option");
00060   return SWIG_MustGetPtr(value, SWIG_TypeQuery("_p__gncTaxTable"), 1, 0);
00061 }
00062 
00063 GncInvoice*
00064 gnc_option_db_lookup_invoice_option(GNCOptionDB *odb,
00065                                     const char *section,
00066                                     const char *name,
00067                                     GncInvoice * default_value)
00068 {
00069   LOOKUP_OPTION("gnc_option_db_lookup_invoice_option");
00070   return SWIG_MustGetPtr(value, SWIG_TypeQuery("_p__gncInvoice"), 1, 0);
00071 }
00072 
00073 GncCustomer*
00074 gnc_option_db_lookup_customer_option(GNCOptionDB *odb,
00075                                      const char *section,
00076                                      const char *name,
00077                                      GncCustomer * default_value)
00078 {
00079   LOOKUP_OPTION("gnc_option_db_lookup_customer_option");
00080   return SWIG_MustGetPtr(value, SWIG_TypeQuery("_p__gncCustomer"), 1, 0);
00081 }
00082 
00083 GncVendor*
00084 gnc_option_db_lookup_vendor_option(GNCOptionDB *odb,
00085                                    const char *section,
00086                                    const char *name,
00087                                    GncVendor * default_value)
00088 {
00089   LOOKUP_OPTION("gnc_option_db_lookup_vendor_option");
00090   return SWIG_MustGetPtr(value, SWIG_TypeQuery("_p__gncVendor"), 1, 0);
00091 }

Generated on Fri Oct 10 05:06:02 2008 for GnuCash by  doxygen 1.5.2