mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-12-05 17:11:09 +00:00
Consolidate the four notification exports into the one public header include/Api.hpp, per review: the canonical sceNotificationSend declaration is updated to the implemented (int, std::uint8_t, std::uint8_t*) signature, the duplicate declarations are removed with Notification.hpp, and the implementation and the test include that public header, which the library umbrella already reaches. The debt entry now states that whether the 0x1800-byte message limit and the 0x20-byte id limit include the terminating NUL is not established and that AnyPS5 counts characters before the NUL, including the one-past-the-end read of a buffer with no terminator.
50 lines
1.7 KiB
C++
50 lines
1.7 KiB
C++
#include <cstdint>
|
|
#include <cstddef>
|
|
#include <cstring>
|
|
#include "SceTypes.hpp"
|
|
#include "prx/libc/include/General.hpp"
|
|
#include "prx/libc/include/general/LogMacros.hpp"
|
|
|
|
#include "prx/libSceNotification/include/Api.hpp"
|
|
|
|
extern "C" {
|
|
|
|
int APS5_VABI sceNotificationSend(int type, std::uint8_t flag, std::uint8_t* message) {
|
|
if (message == nullptr) {
|
|
return Notification::InvalidMessage;
|
|
}
|
|
const auto* text = reinterpret_cast<const char*>(message);
|
|
const void* end = std::memchr(text, '\0', Notification::MessageCapacity + 1);
|
|
if (end == nullptr || end == text) {
|
|
return Notification::InvalidMessage;
|
|
}
|
|
APS5_LOG_OUT("type=%d flag=%u message=%s", type, flag, text);
|
|
return 0;
|
|
}
|
|
|
|
int APS5_VABI sceNotificationSendById(int type, std::uint8_t flag, std::uint8_t* id, std::uint8_t* jsonData) {
|
|
if (id == nullptr || jsonData == nullptr) {
|
|
return Notification::InvalidMessage;
|
|
}
|
|
const auto* name = reinterpret_cast<const char*>(id);
|
|
const auto* body = reinterpret_cast<const char*>(jsonData);
|
|
const void* nameEnd = std::memchr(name, '\0', Notification::IdCapacity + 1);
|
|
const void* bodyEnd = std::memchr(body, '\0', Notification::MessageCapacity + 1);
|
|
if (nameEnd == nullptr || nameEnd == name || bodyEnd == nullptr || bodyEnd == body) {
|
|
return Notification::InvalidMessage;
|
|
}
|
|
APS5_LOG_OUT("type=%d flag=%u id=%s json=%s", type, flag, name, body);
|
|
return 0;
|
|
}
|
|
|
|
int APS5_VABI sceNotificationShowPsButtonPersistentBanner(std::uint8_t* jsonParam) {
|
|
const auto* json = jsonParam != nullptr ? reinterpret_cast<const char*>(jsonParam) : "{}";
|
|
APS5_LOG_OUT("banner=%s", json);
|
|
return 0;
|
|
}
|
|
|
|
void APS5_VABI sceNotificationHidePsButtonPersistentBanner() {
|
|
}
|
|
|
|
}
|