FMI Library: part of JModelica.org
jm_portability.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2012 Modelon AB
3 
4  This program is free software: you can redistribute it and/or modify
5  it under the terms of the BSD style license.
6 
7  This program is distributed in the hope that it will be useful,
8  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  FMILIB_License.txt file for more details.
11 
12  You should have received a copy of the FMILIB_License.txt file
13  along with this program. If not, contact Modelon AB <http://www.modelon.com>.
14 */
15 
16 #ifndef JM_PORTABILITY_H_
17 #define JM_PORTABILITY_H_
18 #include <fmilib_config.h>
19 #include "jm_callbacks.h"
20 
21 /* Include platform dependent headers */
22 #if defined(_MSC_VER) || defined(WIN32) || defined(__MINGW32__)
23 #include <windows.h> /* Microsoft Windows API */
24 #define DLL_HANDLE HANDLE
25 #else
26 #define DLL_HANDLE void*
27 #include <dlfcn.h> /* Standard POSIX/UNIX API */
28 #endif
29 
30 #include "jm_types.h"
43 DLL_HANDLE jm_portability_load_dll_handle (const char* dll_file_path);
44 
47 
49 #ifdef WIN32
50 #define jm_dll_function_ptr FARPROC
51 #else
52 typedef void* jm_dll_function_ptr;
53 #endif
54 
56 jm_status_enu_t jm_portability_load_dll_function (DLL_HANDLE dll_handle, char* dll_function_name, jm_dll_function_ptr* dll_function_ptrptr);
57 
60 
63 
66 
68 const char* jm_get_system_temp_dir();
69 
80 char *jm_mkdtemp(jm_callbacks *cb, char *tmplt);
81 
82 
91 char* jm_get_dir_abspath(jm_callbacks* cb, const char* dir, char* outPath, size_t len);
92 
102 char* jm_mk_temp_dir(jm_callbacks* cb, const char* systemTempDir, const char* tempPrefix);
103 
111 char* jm_create_URL_from_abs_path(jm_callbacks* cb, const char* absPath);
112 
116 jm_status_enu_t jm_mkdir(jm_callbacks* cb, const char* dir);
117 
121 jm_status_enu_t jm_rmdir(jm_callbacks* cb, const char* dir);
122 
127 int jm_vsnprintf(char * str, size_t size, const char * fmt, va_list al);
128 
133 int jm_snprintf(char * str, size_t size, const char * fmt, ...);
134 
135 #ifdef HAVE_VA_COPY
136 #define JM_VA_COPY va_copy
137 #elif defined(HAVE___VA_COPY)
138 #define JM_VA_COPY __va_copy
139 #elif defined(WIN32)
140 #define JM_VA_COPY(dest,src) dest=src
141 #endif
142 
144 #endif /* End of header file JM_PORTABILITY_H_ */
#define DLL_HANDLE
char * jm_portability_get_last_dll_error(void)
Return error associated with Dll handling.
Library configuration file generated by the build system.
char * jm_create_URL_from_abs_path(jm_callbacks *cb, const char *absPath)
Create a file:// URL from absolute path.
jm_status_enu_t jm_rmdir(jm_callbacks *cb, const char *dir)
Remove directory and all it contents.
FMILIB_EXPORT int jm_snprintf(char *str, size_t size, const char *fmt,...)
C89 compatible implementation of C99 snprintf.
jm_status_enu_t jm_portability_get_current_working_directory(char *buffer, size_t len)
Get current working directory name.
char * jm_mk_temp_dir(jm_callbacks *cb, const char *systemTempDir, const char *tempPrefix)
Create a unique temporary directory.
v size
void * jm_dll_function_ptr
A function pointer as returned when DLL symbol is loaded.
DLL_HANDLE jm_portability_load_dll_handle(const char *dll_file_path)
Load a dll/so library into the process and return a handle.
#define FMILIB_EXPORT
Used to declare the public API of the library needed for dynamic linking.
The callbacks struct is sent to all the modules in the library.
Definition: jm_callbacks.h:73
char * jm_get_dir_abspath(jm_callbacks *cb, const char *dir, char *outPath, size_t len)
Get absolute path to an existing directory.
jm_status_enu_t jm_mkdir(jm_callbacks *cb, const char *dir)
Make a directory.
jm_status_enu_t jm_portability_free_dll_handle(DLL_HANDLE dll_handle)
Unload a Dll and release the handle.
jm_status_enu_t
Return status codes.
Definition: jm_types.h:44
const char * jm_get_system_temp_dir()
Get system-wide temporary directory.
jm_status_enu_t jm_portability_set_current_working_directory(const char *cwd)
Set current working directory.
jm_status_enu_t jm_portability_load_dll_function(DLL_HANDLE dll_handle, char *dll_function_name, jm_dll_function_ptr *dll_function_ptrptr)
Find a function in the Dll and return a function pointer.
char * jm_mkdtemp(jm_callbacks *cb, char *tmplt)
Create a uniquely named temporary directory.
FMILIB_EXPORT int jm_vsnprintf(char *str, size_t size, const char *fmt, va_list al)
C89 compatible implementation of C99 vsnprintf.