// Copyright 2014-2025 Jesper Larsson
//
// This file is part of Klipspringer, <https://klipspringer.avadeaux.net/>
//
// Klipspringer 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 3 of the
// License, or (at your option) any later version.
//
// Klipspringer 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 Klipspringer. If
// not, see <https://www.gnu.org/licenses/>.
// The Library module contains common utilities for JNI calls. It is initialized when
// net.avadeaux.klipspringer.codec.Library is loaded.
#ifndef LIBRARY_H
#define LIBRARY_H
#include <jni.h>
#include <stdbool.h>
void init_error(const char *message, ...);
jobject platform_order();
jobject wrapByteBuffer(JNIEnv *env, void *p, jlong capacity, jboolean bigend);
bool byteBufferClear(JNIEnv *env, jobject bb);
bool byteBufferPosition(JNIEnv *env, jobject bb, jint pos);
bool byteBufferLimit(JNIEnv *env, jobject bb, jint lim);
const char *raiseError(JNIEnv *env, const char *message);
const char *raiseIOException(JNIEnv *env, const char *message);
const char *raiseFileNotFound(JNIEnv *env, const char *message);
const char *raiseErrorCodeException(JNIEnv *env, jint code, const char *message);
bool accepts_picture(JNIEnv *env, jobject pictarget);
bool picture(JNIEnv *env, jobject pictarget, const char *mime_type, const char *type, const char *desc, void *data, jlong data_length);
#ifdef __APPLE__
#include <architecture/byte_order.h>
#define htobe16(x) OSSwapHostToBigInt16(x)
#define htole16(x) OSSwapHostToLittleInt16(x)
#define be16toh(x) OSSwapBigToHostInt16(x)
#define le16toh(x) OSSwapLittleToHostInt16(x)
#define htobe32(x) OSSwapHostToBigInt32(x)
#define htole32(x) OSSwapHostToLittleInt32(x)
#define be32toh(x) OSSwapBigToHostInt32(x)
#define le32toh(x) OSSwapLittleToHostInt32(x)
#else
// Plausibly, more cases are needed for other OSs. For instance, BSD may may need <sys/endian.h>.
#include <endian.h>
#endif
#define platform_bigend() (htobe16(1) == 1)
#endif
Version: v4.3.2.2 (2026-05-16T17:03:34+02:00)
Raw file
Source code overview
Klipspringer home