mirror of
https://github.com/switchbrew/libnx.git
synced 2025-07-06 11:22:15 +02:00
address review
This commit is contained in:
parent
862c675713
commit
71e8162436
@ -9,9 +9,12 @@
|
|||||||
#include "../kernel/event.h"
|
#include "../kernel/event.h"
|
||||||
#include "../sf/service.h"
|
#include "../sf/service.h"
|
||||||
|
|
||||||
Result capmtpInitialize(void* mem, size_t size, u32 app_count, u32 max_img, u32 max_vid, const uint_least16_t *other_name);
|
Result capmtpInitialize(void* mem, size_t size, u32 app_count, u32 max_img, u32 max_vid, const char *other_name);
|
||||||
void capmtpExit(void);
|
void capmtpExit(void);
|
||||||
|
|
||||||
|
Service* capmtpGetRootServiceSession(void);
|
||||||
|
Service* capmtpGetServiceSession(void);
|
||||||
|
|
||||||
Result capmtpStartCommandHandler(void);
|
Result capmtpStartCommandHandler(void);
|
||||||
Result capmtpStopCommandHandler(void);
|
Result capmtpStopCommandHandler(void);
|
||||||
bool capmtpIsRunning(void);
|
bool capmtpIsRunning(void);
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#include "service_guard.h"
|
#include "service_guard.h"
|
||||||
#include "kernel/tmem.h"
|
#include "kernel/tmem.h"
|
||||||
#include "runtime/hosversion.h"
|
#include "runtime/hosversion.h"
|
||||||
|
#include "runtime/util/utf.h"
|
||||||
#include "services/capmtp.h"
|
#include "services/capmtp.h"
|
||||||
#include "services/sm.h"
|
#include "services/sm.h"
|
||||||
|
|
||||||
@ -10,13 +11,13 @@ static TransferMemory g_tmem;
|
|||||||
static Event g_connectEvent, g_scanErrorEvent;
|
static Event g_connectEvent, g_scanErrorEvent;
|
||||||
|
|
||||||
static Result _capmtpOpenSession(Service *srv);
|
static Result _capmtpOpenSession(Service *srv);
|
||||||
static Result _capmtpOpen(u32 max_folders, u32 max_img, u32 max_vid, const uint_least16_t *other_name);
|
static Result _capmtpOpen(u32 max_folders, u32 max_img, u32 max_vid, const char *other_name);
|
||||||
static Result _capmtpClose(void);
|
static Result _capmtpClose(void);
|
||||||
static Result _capmtpNoInEventOut(u32 id, Event* event, bool autoclear);
|
static Result _capmtpNoInEventOut(u32 id, Event* event, bool autoclear);
|
||||||
|
|
||||||
NX_GENERATE_SERVICE_GUARD_PARAMS(capmtp, (void* mem, size_t size, u32 max_folders, u32 max_img, u32 max_vid, const uint_least16_t *other_name), (mem, size, max_folders, max_img, max_vid, other_name));
|
NX_GENERATE_SERVICE_GUARD_PARAMS(capmtp, (void* mem, size_t size, u32 max_folders, u32 max_img, u32 max_vid, const char *other_name), (mem, size, max_folders, max_img, max_vid, other_name));
|
||||||
|
|
||||||
Result _capmtpInitialize(void* mem, size_t size, u32 max_folders, u32 max_img, u32 max_vid, const uint_least16_t *other_name) {
|
Result _capmtpInitialize(void* mem, size_t size, u32 max_folders, u32 max_img, u32 max_vid, const char *other_name) {
|
||||||
Result rc=0;
|
Result rc=0;
|
||||||
|
|
||||||
if (hosversionBefore(11,0,0))
|
if (hosversionBefore(11,0,0))
|
||||||
@ -33,8 +34,6 @@ Result _capmtpInitialize(void* mem, size_t size, u32 max_folders, u32 max_img, u
|
|||||||
if (R_SUCCEEDED(rc)) rc = _capmtpNoInEventOut(5, &g_connectEvent, false);
|
if (R_SUCCEEDED(rc)) rc = _capmtpNoInEventOut(5, &g_connectEvent, false);
|
||||||
if (R_SUCCEEDED(rc)) rc = _capmtpNoInEventOut(7, &g_scanErrorEvent, false);
|
if (R_SUCCEEDED(rc)) rc = _capmtpNoInEventOut(7, &g_scanErrorEvent, false);
|
||||||
|
|
||||||
if (R_FAILED(rc)) capmtpExit();
|
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,6 +46,14 @@ void _capmtpCleanup(void) {
|
|||||||
tmemClose(&g_tmem);
|
tmemClose(&g_tmem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Service* capmtpGetRootServiceSession(void) {
|
||||||
|
return &g_capmtpRoot;
|
||||||
|
}
|
||||||
|
|
||||||
|
Service* capmtpGetServiceSession(void) {
|
||||||
|
return &g_capmtp;
|
||||||
|
}
|
||||||
|
|
||||||
static Result _capmtpNoIO(u32 id) {
|
static Result _capmtpNoIO(u32 id) {
|
||||||
return serviceDispatch(&g_capmtp, id);
|
return serviceDispatch(&g_capmtp, id);
|
||||||
}
|
}
|
||||||
@ -77,10 +84,9 @@ static Result _capmtpOpenSession(Service *srv) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Result _capmtpOpen(u32 max_folders, u32 max_img, u32 max_vid, const uint_least16_t *other_name) {
|
static Result _capmtpOpen(u32 max_folders, u32 max_img, u32 max_vid, const char *other_name) {
|
||||||
size_t len=0;
|
u16 buffer[0x100];
|
||||||
const uint_least16_t *tmp =other_name;
|
size_t len = utf8_to_utf16(buffer, (const u8*)other_name, sizeof(buffer)/sizeof(u16));
|
||||||
while(*tmp++) ++len;
|
|
||||||
const struct {
|
const struct {
|
||||||
u32 tmem_size;
|
u32 tmem_size;
|
||||||
u32 folder_count;
|
u32 folder_count;
|
||||||
@ -90,7 +96,7 @@ static Result _capmtpOpen(u32 max_folders, u32 max_img, u32 max_vid, const uint_
|
|||||||
|
|
||||||
return serviceDispatchIn(&g_capmtp, 0, in,
|
return serviceDispatchIn(&g_capmtp, 0, in,
|
||||||
.buffer_attrs = { SfBufferAttr_In | SfBufferAttr_HipcMapAlias },
|
.buffer_attrs = { SfBufferAttr_In | SfBufferAttr_HipcMapAlias },
|
||||||
.buffers = { { other_name, 2*len + 1 } },
|
.buffers = { { buffer, 2*len } },
|
||||||
.in_num_handles = 1,
|
.in_num_handles = 1,
|
||||||
.in_handles = { g_tmem.handle },
|
.in_handles = { g_tmem.handle },
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user