code format

This commit is contained in:
2022-12-14 14:13:52 +03:00
parent 430a41fefc
commit c2b8a8d6da
297 changed files with 27331 additions and 24162 deletions

View File

@@ -1,29 +1,30 @@
/*
PIP - Platform Independent Primitives
Dynamic library
Ivan Pelipenko peri4ko@yandex.ru
PIP - Platform Independent Primitives
Dynamic library
Ivan Pelipenko peri4ko@yandex.ru
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 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 Lesser General Public License for more details.
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 Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef MICRO_PIP
#include "pilibrary.h"
#include "piincludes_p.h"
#ifndef WINDOWS
# include <dlfcn.h>
#endif
# include "pilibrary.h"
# include "piincludes_p.h"
# ifndef WINDOWS
# include <dlfcn.h>
# endif
//! \class PILibrary pilibrary.h
@@ -122,12 +123,12 @@
PRIVATE_DEFINITION_START(PILibrary)
#ifdef WINDOWS
# ifdef WINDOWS
HMODULE
#else
# else
void *
#endif
hLib;
# endif
hLib;
PRIVATE_DEFINITION_END(PILibrary)
@@ -155,11 +156,11 @@ bool PILibrary::load() {
void PILibrary::unload() {
if (PRIVATE->hLib == 0) return;
#ifdef WINDOWS
# ifdef WINDOWS
FreeLibrary(PRIVATE->hLib);
#else
# else
dlclose(PRIVATE->hLib);
#endif
# endif
PRIVATE->hLib = 0;
}
@@ -197,11 +198,11 @@ bool PILibrary::isLoaded() const {
void * PILibrary::resolve(const char * symbol) {
if (!isLoaded()) return 0;
void * ret;
#ifdef WINDOWS
ret = (void*)GetProcAddress(PRIVATE->hLib, symbol);
#else
ret = dlsym(PRIVATE->hLib, symbol);
#endif
# ifdef WINDOWS
ret = (void *)GetProcAddress(PRIVATE->hLib, symbol);
# else
ret = dlsym(PRIVATE->hLib, symbol);
# endif
getLastError();
return ret;
}
@@ -210,24 +211,26 @@ void * PILibrary::resolve(const char * symbol) {
bool PILibrary::loadInternal() {
unload();
if (libpath.isEmpty()) return false;
#ifdef WINDOWS
# ifdef WINDOWS
PRIVATE->hLib = LoadLibraryA(libpath.data());
#else
PRIVATE->hLib = dlopen(libpath.data(), RTLD_LAZY);
#endif
# else
PRIVATE->hLib = dlopen(libpath.data(), RTLD_LAZY);
# endif
getLastError();
return PRIVATE->hLib;
}
void PILibrary::getLastError() {
#ifdef WINDOWS
# ifdef WINDOWS
liberror = errorString();
#else
# else
const char * e = dlerror();
if (e) liberror = e;
else liberror.clear();
#endif
if (e)
liberror = e;
else
liberror.clear();
# endif
}
#endif // MICRO_PIP