|
GnuCash 2.4.99
|
00001 /********************************************************************* 00002 * gncmod-locale-reports-us.c 00003 * module definition/initialization for the US reports 00004 * 00005 * Copyright (c) 2001 Linux Developers Group, Inc. 00006 *********************************************************************/ 00007 00008 #include "config.h" 00009 #ifdef LOCALE_SPECIFIC_TAX 00010 #include <string.h> 00011 #include <locale.h> 00012 #endif // LOCALE_SPECIFIC_TAX 00013 #include <gmodule.h> 00014 #include <libguile.h> 00015 00016 #include "gnc-module.h" 00017 #include "gnc-module-api.h" 00018 00019 GNC_MODULE_API_DECL(libgncmod_locale_reports_us) 00020 00021 /* version of the gnc module system interface we require */ 00022 int libgncmod_locale_reports_us_gnc_module_system_interface = 0; 00023 00024 /* module versioning uses libtool semantics. */ 00025 int libgncmod_locale_reports_us_gnc_module_current = 0; 00026 int libgncmod_locale_reports_us_gnc_module_revision = 0; 00027 int libgncmod_locale_reports_us_gnc_module_age = 0; 00028 00029 00030 char * 00031 libgncmod_locale_reports_us_gnc_module_path(void) 00032 { 00033 /* const char *thislocale = setlocale(LC_ALL, NULL); 00034 if (strncmp(thislocale, "de_DE", 5) == 0) 00035 return g_strdup("gnucash/report/locale-specific/de_DE"); 00036 else */ 00037 return g_strdup("gnucash/report/locale-specific/us"); 00038 } 00039 00040 char * 00041 libgncmod_locale_reports_us_gnc_module_description(void) 00042 { 00043 return g_strdup("US income tax reports and related material"); 00044 } 00045 00046 int 00047 libgncmod_locale_reports_us_gnc_module_init(int refcount) 00048 { 00049 const gchar *tax_module, *report_taxtxf, *report_locale; 00050 /* load the tax info */ 00051 #ifdef LOCALE_SPECIFIC_TAX 00052 /* This is a very simple hack that loads the (new, special) German 00053 tax definition file in a German locale, or (default) loads the 00054 previous US tax file. */ 00055 # ifdef G_OS_WIN32 00056 gchar *thislocale = g_win32_getlocale(); 00057 gboolean is_de_DE = (strncmp(thislocale, "de_DE", 5) == 0); 00058 g_free(thislocale); 00059 # else /* !G_OS_WIN32 */ 00060 const char *thislocale = setlocale(LC_ALL, NULL); 00061 gboolean is_de_DE = (strncmp(thislocale, "de_DE", 5) == 0); 00062 # endif /* G_OS_WIN32 */ 00063 #else /* !LOCALE_SPECIFIC_TAX */ 00064 gboolean is_de_DE = FALSE; 00065 #endif /* LOCALE_SPECIFIC_TAX */ 00066 if (is_de_DE) 00067 { 00068 tax_module = "gnucash/tax/de_DE"; 00069 report_taxtxf = "(use-modules (gnucash report taxtxf-de_DE))"; 00070 report_locale = "(use-modules (gnucash report locale-specific de_DE))"; 00071 } 00072 else 00073 { 00074 tax_module = "gnucash/tax/us"; 00075 report_taxtxf = "(use-modules (gnucash report taxtxf))"; 00076 report_locale = "(use-modules (gnucash report locale-specific us))"; 00077 } 00078 00079 /* The gchar* cast is only because the function declaration expects 00080 a non-const string -- probably an api error. */ 00081 if (!gnc_module_load((gchar*)tax_module, 0)) 00082 { 00083 return FALSE; 00084 } 00085 00086 /* load the report system */ 00087 if (!gnc_module_load("gnucash/report/report-system", 0)) 00088 { 00089 return FALSE; 00090 } 00091 00092 /* load the report generation scheme code */ 00093 if (scm_c_eval_string(report_taxtxf) 00094 == SCM_BOOL_F) 00095 { 00096 g_warning("failed to load %s\n", report_taxtxf); 00097 return FALSE; 00098 } 00099 00100 /* Load the module scheme code */ 00101 if (scm_c_eval_string(report_locale) 00102 == SCM_BOOL_F) 00103 { 00104 return FALSE; 00105 } 00106 00107 return TRUE; 00108 } 00109 00110 int 00111 libgncmod_locale_reports_us_gnc_module_end(int refcount) 00112 { 00113 return TRUE; 00114 }
1.7.4