2018-12-28 22:06:18 +01:00
|
|
|
#include "es.h"
|
|
|
|
|
2019-10-30 12:19:45 +01:00
|
|
|
#include "../service_guard.h"
|
|
|
|
|
2018-12-28 22:06:18 +01:00
|
|
|
#include <switch/kernel/ipc.h>
|
|
|
|
#include <switch/services/sm.h>
|
|
|
|
|
|
|
|
static Service g_esSrv;
|
|
|
|
|
2019-10-30 12:19:45 +01:00
|
|
|
NX_GENERATE_SERVICE_GUARD(es);
|
2018-12-28 22:06:18 +01:00
|
|
|
|
2019-10-30 12:19:45 +01:00
|
|
|
Result _esInitialize() {
|
2018-12-28 22:06:18 +01:00
|
|
|
return smGetService(&g_esSrv, "es");
|
|
|
|
}
|
|
|
|
|
2019-10-30 12:19:45 +01:00
|
|
|
void _esCleanup() {
|
|
|
|
serviceClose(&g_esSrv);
|
2018-12-28 22:06:18 +01:00
|
|
|
}
|
|
|
|
|
2020-03-16 00:25:15 +01:00
|
|
|
Result esCountCommonTicket(u32 *out_count)
|
2018-12-28 22:06:18 +01:00
|
|
|
{
|
2020-03-16 00:25:15 +01:00
|
|
|
u32 num_tickets;
|
2018-12-28 22:06:18 +01:00
|
|
|
|
2020-03-16 00:25:15 +01:00
|
|
|
Result rc = serviceDispatchOut(&g_esSrv, 9, num_tickets);
|
|
|
|
if (R_SUCCEEDED(rc) && out_count) *out_count = num_tickets;
|
2018-12-28 22:06:18 +01:00
|
|
|
|
2019-03-07 17:06:32 +01:00
|
|
|
return rc;
|
2018-12-28 22:06:18 +01:00
|
|
|
}
|
|
|
|
|
2020-03-16 00:25:15 +01:00
|
|
|
Result esCountPersonalizedTicket(u32 *out_count)
|
2018-12-28 22:06:18 +01:00
|
|
|
{
|
2020-03-16 00:25:15 +01:00
|
|
|
u32 num_tickets;
|
2018-12-28 22:06:18 +01:00
|
|
|
|
2020-03-16 00:25:15 +01:00
|
|
|
Result rc = serviceDispatchOut(&g_esSrv, 10, num_tickets);
|
|
|
|
if (R_SUCCEEDED(rc) && out_count) *out_count = num_tickets;
|
2018-12-28 22:06:18 +01:00
|
|
|
|
2019-03-07 17:06:32 +01:00
|
|
|
return rc;
|
2018-12-28 22:06:18 +01:00
|
|
|
}
|
|
|
|
|
2020-03-16 00:25:15 +01:00
|
|
|
Result esListCommonTicket(u32 *numRightsIdsWritten, RightsId *outBuf, size_t bufSize)
|
2019-10-30 12:19:45 +01:00
|
|
|
{
|
2020-03-16 00:25:15 +01:00
|
|
|
u32 num_rights_ids_written;
|
2018-12-28 22:06:18 +01:00
|
|
|
|
2020-03-16 00:25:15 +01:00
|
|
|
Result rc = serviceDispatchOut(&g_esSrv, 11, num_rights_ids_written,
|
2019-10-30 12:19:45 +01:00
|
|
|
.buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_Out },
|
|
|
|
.buffers = { { outBuf, bufSize } },
|
|
|
|
);
|
2020-03-16 00:25:15 +01:00
|
|
|
if (R_SUCCEEDED(rc) && numRightsIdsWritten) *numRightsIdsWritten = num_rights_ids_written;
|
2019-03-07 17:06:32 +01:00
|
|
|
|
2018-12-28 22:06:18 +01:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2020-03-16 00:25:15 +01:00
|
|
|
Result esListPersonalizedTicket(u32 *numRightsIdsWritten, RightsId *outBuf, size_t bufSize)
|
2019-10-30 12:19:45 +01:00
|
|
|
{
|
2020-03-16 00:25:15 +01:00
|
|
|
u32 num_rights_ids_written;
|
2019-10-30 12:19:45 +01:00
|
|
|
|
2020-03-16 00:25:15 +01:00
|
|
|
Result rc = serviceDispatchOut(&g_esSrv, 12, num_rights_ids_written,
|
2019-10-30 12:19:45 +01:00
|
|
|
.buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_Out },
|
|
|
|
.buffers = { { outBuf, bufSize } },
|
|
|
|
);
|
2020-03-16 00:25:15 +01:00
|
|
|
if (R_SUCCEEDED(rc) && numRightsIdsWritten) *numRightsIdsWritten = num_rights_ids_written;
|
2019-03-07 17:06:32 +01:00
|
|
|
|
2018-12-28 22:06:18 +01:00
|
|
|
return rc;
|
2020-03-16 00:25:15 +01:00
|
|
|
}
|