Path: blob/master/src/java.base/share/native/libjli/splashscreen_stubs.c
67735 views
/*1* Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425#include <stdio.h>26#include "splashscreen.h"27#include "jni.h"28extern void* SplashProcAddress(const char* name); /* in java_md.c */2930/*31* Prototypes of pointers to functions in splashscreen shared lib32*/33typedef int (*SplashLoadMemory_t)(void* pdata, int size);34typedef int (*SplashLoadFile_t)(const char* filename);35typedef int (*SplashInit_t)(void);36typedef void (*SplashClose_t)(void);37typedef void (*SplashSetFileJarName_t)(const char* fileName,38const char* jarName);39typedef void (*SplashSetScaleFactor_t)(float scaleFactor);40typedef jboolean (*SplashGetScaledImageName_t)(const char* fileName,41const char* jarName, float* scaleFactor,42char *scaleImageName, const size_t scaleImageNameLength);43typedef int (*SplashGetScaledImgNameMaxPstfixLen_t)(const char* filename);4445/*46* This macro invokes a function from the shared lib.47* it locates a function with SplashProcAddress on demand.48* if SplashProcAddress fails, def value is returned.49*50* it is further wrapped with INVOKEV (works with functions which return51* void and INVOKE (for all other functions). INVOKEV looks a bit ugly,52* that's due being unable to return a value of type void in C. INVOKEV53* works around this by using semicolon instead of return operator.54*/55#define _INVOKE(name,def,ret) \56static void* proc = NULL; \57if (!proc) { proc = SplashProcAddress(#name); } \58if (!proc) { return def; } \59ret ((name##_t)proc)6061#define INVOKE(name,def) _INVOKE(name,def,return)62#define INVOKEV(name) _INVOKE(name, ,;)636465int DoSplashLoadMemory(void* pdata, int size) {66INVOKE(SplashLoadMemory, 0)(pdata, size);67}6869int DoSplashLoadFile(const char* filename) {70INVOKE(SplashLoadFile, 0)(filename);71}7273int DoSplashInit(void) {74INVOKE(SplashInit, 0)();75}7677void DoSplashClose(void) {78INVOKEV(SplashClose)();79}8081void DoSplashSetFileJarName(const char* fileName, const char* jarName) {82INVOKEV(SplashSetFileJarName)(fileName, jarName);83}8485void DoSplashSetScaleFactor(float scaleFactor) {86INVOKEV(SplashSetScaleFactor)(scaleFactor);87}8889jboolean DoSplashGetScaledImageName(const char* fileName, const char* jarName,90float* scaleFactor, char *scaledImageName, const size_t scaledImageNameLength) {91INVOKE(SplashGetScaledImageName, 0)(fileName, jarName, scaleFactor,92scaledImageName, scaledImageNameLength);93}9495int DoSplashGetScaledImgNameMaxPstfixLen(const char *fileName) {96INVOKE(SplashGetScaledImgNameMaxPstfixLen, 0)(fileName);97}9899100101