GnuCash  2.6.99
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
business-options.c
1 /*
2  * business-options.c -- Non-GUI Option Utilities for GNC Business Objects
3  *
4  * Written By: Derek Atkins <[email protected]>
5  * Copyright (C) 2003 Derek Atkins
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License as
9  * published by the Free Software Foundation; either version 2 of
10  * the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, contact:
19  *
20  * Free Software Foundation Voice: +1-617-542-5942
21  * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
22  * Boston, MA 02110-1301, USA [email protected]
23  */
24 
25 #include "config.h"
26 
27 #include "business-options.h"
28 #include "swig-runtime.h"
29 
30 #define FUNC_NAME G_STRFUNC
31 
32 #define LOOKUP_OPTION(fcn) \
33  GNCOption *option; \
34  SCM getter; \
35  SCM value; \
36  \
37  option = gnc_option_db_get_option_by_name (odb, section, name); \
38  \
39  if (option == NULL) \
40  return default_value; \
41  \
42  getter = gnc_option_getter (option); \
43  if (getter == SCM_UNDEFINED) \
44  return default_value; \
45  \
46  value = scm_call_0 (getter); \
47  if (value == SCM_BOOL_F) \
48  return NULL; \
49  SWIG_GetModule(NULL); /* Work-around for SWIG bug. */ \
50  if (!SWIG_IsPointer(value)) \
51  scm_misc_error(fcn, "SCM is not a wrapped pointer.", value)
52 
54 gnc_option_db_lookup_taxtable_option(GNCOptionDB *odb,
55  const char *section,
56  const char *name,
57  GncTaxTable * default_value)
58 {
59  LOOKUP_OPTION("gnc_option_db_lookup_taxtable_option");
60  return SWIG_MustGetPtr(value, SWIG_TypeQuery("_p__gncTaxTable"), 1, 0);
61 }
62 
64 gnc_option_db_lookup_invoice_option(GNCOptionDB *odb,
65  const char *section,
66  const char *name,
67  GncInvoice * default_value)
68 {
69  LOOKUP_OPTION("gnc_option_db_lookup_invoice_option");
70  return SWIG_MustGetPtr(value, SWIG_TypeQuery("_p__gncInvoice"), 1, 0);
71 }
72 
74 gnc_option_db_lookup_customer_option(GNCOptionDB *odb,
75  const char *section,
76  const char *name,
77  GncCustomer * default_value)
78 {
79  LOOKUP_OPTION("gnc_option_db_lookup_customer_option");
80  return SWIG_MustGetPtr(value, SWIG_TypeQuery("_p__gncCustomer"), 1, 0);
81 }
82 
83 GncVendor*
84 gnc_option_db_lookup_vendor_option(GNCOptionDB *odb,
85  const char *section,
86  const char *name,
87  GncVendor * default_value)
88 {
89  LOOKUP_OPTION("gnc_option_db_lookup_vendor_option");
90  return SWIG_MustGetPtr(value, SWIG_TypeQuery("_p__gncVendor"), 1, 0);
91 }