diff --git a/CMakeLists.txt b/CMakeLists.txt index d0a6abb..583b00b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -210,7 +210,7 @@ if (RAGEPHOTO_PYTHON) # Python Package Source files + Target set(PYRAGEPHOTO_SOURCES "src/python/__init__.py" - "src/python/libragephoto.py" + "src/python/libragephoto_loader.py" "src/python/ragephoto.py" ) add_custom_target(pyragephoto SOURCES ${PYRAGEPHOTO_SOURCES}) diff --git a/cmake/wasm.cmake b/cmake/wasm.cmake index ad3e1d6..0aa5e77 100644 --- a/cmake/wasm.cmake +++ b/cmake/wasm.cmake @@ -1,6 +1,6 @@ #[[************************************************************************** * libragephoto RAGE Photo Parser -* Copyright (C) 2023 Syping +* Copyright (C) 2023-2024 Syping * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: @@ -17,8 +17,13 @@ ****************************************************************************]] if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.13.0") - add_executable(ragephoto-wasm ${RAGEPHOTO_HEADERS} ${RAGEPHOTO_SOURCES}) + add_executable(ragephoto-wasm + ${RAGEPHOTO_HEADERS} + ${RAGEPHOTO_SOURCES} + ) set_target_properties(ragephoto-wasm PROPERTIES + CXX_STANDARD ${RAGEPHOTO_CXX_STANDARD} + CXX_STANDARD_REQUIRED ON PREFIX "lib" OUTPUT_NAME "ragephoto" ) diff --git a/src/core/RagePhoto.c b/src/core/RagePhoto.c index ff4326b..7dec565 100644 --- a/src/core/RagePhoto.c +++ b/src/core/RagePhoto.c @@ -1,6 +1,6 @@ /***************************************************************************** * libragephoto RAGE Photo Parser -* Copyright (C) 2021-2023 Syping +* Copyright (C) 2021-2024 Syping * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: @@ -697,6 +697,16 @@ uint64_t ragephoto_getphotosign(ragephoto_t instance_t) return ragephotodata_getphotosignf(instance->data, instance->data->photoFormat); } +void ragephoto_getphotosigns(ragephoto_t instance, char *data, size_t size) +{ + snprintf(data, size, "%" PRIu64, ragephoto_getphotosign(instance)); +} + +void ragephoto_getphotosignsf(ragephoto_t instance, char *data, size_t size, uint32_t photoFormat) +{ + snprintf(data, size, "%" PRIu64, ragephoto_getphotosignf(instance, photoFormat)); +} + uint32_t ragephoto_getphotosize(ragephoto_t instance_t) { RagePhotoInstance *instance = (RagePhotoInstance*)instance_t; diff --git a/src/core/RagePhoto.cpp b/src/core/RagePhoto.cpp index d1a6ca0..a34e18c 100644 --- a/src/core/RagePhoto.cpp +++ b/src/core/RagePhoto.cpp @@ -19,6 +19,7 @@ #include "ragephoto_cxx.hpp" #ifdef LIBRAGEPHOTO_CXX_C #include "RagePhoto.h" +#include #endif #include @@ -27,10 +28,6 @@ #include #include -#if (RAGEPHOTO_CXX_STD >= 17) && (__cplusplus >= 201703L) -#include -#endif - #ifdef RAGEPHOTO_BENCHMARK #include #endif @@ -607,11 +604,7 @@ bool RagePhoto::load(const std::string &data) bool RagePhoto::loadFile(const std::string &filename) { -#if (RAGEPHOTO_CXX_STD >= 17) && (__cplusplus >= 201703L) - std::ifstream ifs(std::filesystem::u8path(filename), std::ios::in | std::ios::binary); -#else std::ifstream ifs(filename, std::ios::in | std::ios::binary); -#endif if (ifs.is_open()) { std::string sdata(std::istreambuf_iterator{ifs}, {}); ifs.close(); @@ -1382,6 +1375,18 @@ uint64_t ragephoto_getphotosignf(ragephoto_t instance, uint32_t photoFormat) return ragePhoto->jpegSign(photoFormat); } +void ragephoto_getphotosigns(ragephoto_t instance, char *data, size_t size) +{ + RagePhoto *ragePhoto = static_cast(instance); + snprintf(data, size, "%" PRIu64, ragePhoto->jpegSign()); +} + +void ragephoto_getphotosignsf(ragephoto_t instance, char *data, size_t size, uint32_t photoFormat) +{ + RagePhoto *ragePhoto = static_cast(instance); + snprintf(data, size, "%" PRIu64, ragePhoto->jpegSign(photoFormat)); +} + uint64_t ragephotodata_getphotosign(RagePhotoData *rp_data) { return RagePhoto::jpegSign(rp_data); diff --git a/src/core/RagePhoto.h b/src/core/RagePhoto.h index ff51ca0..5623e76 100644 --- a/src/core/RagePhoto.h +++ b/src/core/RagePhoto.h @@ -1,6 +1,6 @@ /***************************************************************************** * libragephoto RAGE Photo Parser -* Copyright (C) 2021-2023 Syping +* Copyright (C) 2021-2024 Syping * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: @@ -133,6 +133,21 @@ LIBRAGEPHOTO_C_PUBLIC uint64_t ragephoto_getphotosign(ragephoto_t instance); */ LIBRAGEPHOTO_C_PUBLIC uint64_t ragephoto_getphotosignf(ragephoto_t instance, uint32_t photoFormat); +/** Returns the Photo JPEG sign as string. +* \param instance \p ragephoto_t instance +* \param data String data +* \param size String size +*/ +LIBRAGEPHOTO_C_PUBLIC void ragephoto_getphotosigns(ragephoto_t instance, char *data, size_t size); + +/** Returns the Photo JPEG sign as string. +* \param instance \p ragephoto_t instance +* \param data String data +* \param size String size +* \param photoFormat Photo Format (GTA V or RDR 2) +*/ +LIBRAGEPHOTO_C_PUBLIC void ragephoto_getphotosignsf(ragephoto_t instance, char *data, size_t size, uint32_t photoFormat); + /** Returns the Photo JPEG sign. * \param rp_data RagePhotoData object */ diff --git a/src/python/__init__.py b/src/python/__init__.py index b01d1a8..b3a7697 100644 --- a/src/python/__init__.py +++ b/src/python/__init__.py @@ -1,6 +1,6 @@ ############################################################################## # libragephoto for Python -# Copyright (C) 2023 Syping +# Copyright (C) 2023-2024 Syping # # Redistribution and use in source and binary forms, with or without modification, # are permitted provided that the following conditions are met: @@ -19,7 +19,7 @@ from .ragephoto import RagePhoto __all__ = [ - "libragephoto", # libragephoto Loader Module + "libragephoto_loader", # libragephoto Loader Module "ragephoto", # RagePhoto Module "RagePhoto" # RagePhoto API ] diff --git a/src/python/libragephoto.py b/src/python/libragephoto_loader.py similarity index 99% rename from src/python/libragephoto.py rename to src/python/libragephoto_loader.py index e129293..2401359 100644 --- a/src/python/libragephoto.py +++ b/src/python/libragephoto_loader.py @@ -1,6 +1,6 @@ ############################################################################## # libragephoto for Python -# Copyright (C) 2023 Syping +# Copyright (C) 2023-2024 Syping # # Redistribution and use in source and binary forms, with or without modification, # are permitted provided that the following conditions are met: diff --git a/src/python/ragephoto.py b/src/python/ragephoto.py index 5e7e26d..b44a802 100644 --- a/src/python/ragephoto.py +++ b/src/python/ragephoto.py @@ -1,6 +1,6 @@ ############################################################################## # libragephoto for Python -# Copyright (C) 2023 Syping +# Copyright (C) 2023-2024 Syping # # Redistribution and use in source and binary forms, with or without modification, # are permitted provided that the following conditions are met: @@ -16,7 +16,7 @@ # responsible for anything with use of the software, you are self responsible. ############################################################################## -from .libragephoto import * +from .libragephoto_loader import * from enum import IntEnum from json import loads as parseJson from json import dumps as serializeJson