/* Hey EMACS -*- linux-c -*- */ /* libcalcfiles - file format library, a part of the CalcForge project * Copyright (C) 1999-2005 Romain Lievin * * 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, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* This unit contains the interface of the libcalcfiles library. */ #ifdef HAVE_CONFIG_H # include #endif #include #include #ifdef ENABLE_NLS #include #endif #ifdef __WIN32__ #include #endif #include "gettext.h" #include "calcfiles.h" #include "logging.h" /****************/ /* Entry points */ /****************/ // not static, must be shared between instances int calcfiles_instance = 0; // counts # of instances /** * calcfiles_library_init: * * This function must be the first one to call. It inits library internals. * * Return value: the handle count. **/ CALCFILES_EXPORT int CALCFORGE_CALL calcfiles_library_init() { char locale_dir[65536]; #ifdef __WIN32__ HANDLE hDll; int i; hDll = GetModuleHandle("libcalcfiles-0.dll"); GetModuleFileName(hDll, locale_dir, 65535); for (i = strlen(locale_dir); i >= 0; i--) { if (locale_dir[i] == '\\') break; } locale_dir[i] = '\0'; #ifdef __MINGW32__ strcat(locale_dir, "\\..\\share\\locale"); #else strcat(locale_dir, "\\locale"); #endif #else strcpy(locale_dir, LOCALEDIR); #endif if (calcfiles_instance) return (++calcfiles_instance); calcfiles_info( _("libcalcfiles version %s"), VERSION); #if defined(ENABLE_NLS) calcfiles_info("setlocale: %s", setlocale(LC_ALL, "")); calcfiles_info("bindtextdomain: %s", bindtextdomain(PACKAGE, locale_dir)); //bind_textdomain_codeset(PACKAGE, "UTF-8"/*"ISO-8859-15"*/); calcfiles_info("textdomain: %s", textdomain(PACKAGE)); #endif return (++calcfiles_instance); } /** * calcfiles_library_exit: * * This function must be the last one to call. Used to release internal resources. * * Return value: the handle count. **/ CALCFILES_EXPORT int CALCFORGE_CALL calcfiles_library_exit() { return (--calcfiles_instance); } /***********/ /* Methods */ /***********/ /** * calcfiles_version_get: * * This function returns the library version like "X.Y.Z". * * Return value: a string. **/ CALCFILES_EXPORT const char *CALCFORGE_CALL calcfiles_version_get(void) { return VERSION; }