mirror of
https://github.com/switchbrew/libnx.git
synced 2025-07-04 18:42:15 +02:00
Fix up spacing
This commit is contained in:
parent
84408ba5b9
commit
dfe1022a5c
@ -12,23 +12,23 @@ static Service g_nifmSrv;
|
|||||||
static IGeneralService g_nifmIGS;
|
static IGeneralService g_nifmIGS;
|
||||||
static u64 g_refCnt;
|
static u64 g_refCnt;
|
||||||
|
|
||||||
static Result _nifmCreateGeneralService(IGeneralService * out, u64 in);
|
static Result _nifmCreateGeneralService(IGeneralService* out, u64 in);
|
||||||
static Result _nifmCreateGeneralServiceOld(IGeneralService * out);
|
static Result _nifmCreateGeneralServiceOld(IGeneralService* out);
|
||||||
|
|
||||||
Result nifmInitialize(void) {
|
Result nifmInitialize(void) {
|
||||||
atomicIncrement64(&g_refCnt);
|
atomicIncrement64(&g_refCnt);
|
||||||
|
|
||||||
if (serviceIsActive( & g_nifmSrv))
|
if (serviceIsActive(&g_nifmSrv))
|
||||||
return 0;
|
return 0;
|
||||||
Result rc;
|
Result rc;
|
||||||
|
|
||||||
rc = smGetService( & g_nifmSrv, "nifm:u");
|
rc = smGetService(&g_nifmSrv, "nifm:u");
|
||||||
|
|
||||||
if (R_SUCCEEDED(rc)) {
|
if (R_SUCCEEDED(rc)) {
|
||||||
if (kernelAbove200())
|
if (kernelAbove200())
|
||||||
rc = _nifmCreateGeneralService( & g_nifmIGS, 0); // What does this parameter do?
|
rc = _nifmCreateGeneralService(&g_nifmIGS, 0); // What does this parameter do?
|
||||||
else
|
else
|
||||||
rc = _nifmCreateGeneralServiceOld( & g_nifmIGS);
|
rc = _nifmCreateGeneralServiceOld(&g_nifmIGS);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (R_FAILED(rc))
|
if (R_FAILED(rc))
|
||||||
@ -38,99 +38,27 @@ Result nifmInitialize(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void nifmExit(void) {
|
void nifmExit(void) {
|
||||||
if (atomicDecrement64(&g_refCnt) == 0){
|
if (atomicDecrement64(&g_refCnt) == 0) {
|
||||||
serviceClose( & g_nifmIGS.s);
|
serviceClose(&g_nifmIGS.s);
|
||||||
serviceClose( & g_nifmSrv);
|
serviceClose(&g_nifmSrv);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Result nifmGetCurrentIpAddress(u32 * out) {
|
Result nifmGetCurrentIpAddress(u32* out) {
|
||||||
IpcCommand c;
|
|
||||||
ipcInitialize( & c);
|
|
||||||
|
|
||||||
struct {
|
|
||||||
u64 magic;
|
|
||||||
u64 cmd_id;
|
|
||||||
} * raw;
|
|
||||||
|
|
||||||
raw = ipcPrepareHeader( & c, sizeof( * raw));
|
|
||||||
|
|
||||||
raw -> magic = SFCI_MAGIC;
|
|
||||||
raw -> cmd_id = 12;
|
|
||||||
|
|
||||||
Result rc = serviceIpcDispatch(&g_nifmIGS.s);
|
|
||||||
|
|
||||||
if (R_SUCCEEDED(rc)) {
|
|
||||||
IpcParsedCommand r;
|
|
||||||
ipcParse( & r);
|
|
||||||
|
|
||||||
struct {
|
|
||||||
u64 magic;
|
|
||||||
u64 result;
|
|
||||||
u32 out;
|
|
||||||
} * resp = r.Raw;
|
|
||||||
|
|
||||||
rc = resp -> result; * out = resp -> out;
|
|
||||||
}
|
|
||||||
|
|
||||||
return rc;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
static Result _nifmCreateGeneralService(IGeneralService * out, u64 in) {
|
|
||||||
IpcCommand c;
|
|
||||||
ipcInitialize( & c);
|
|
||||||
ipcSendPid( & c);
|
|
||||||
|
|
||||||
struct {
|
|
||||||
u64 magic;
|
|
||||||
u64 cmd_id;
|
|
||||||
u64 param;
|
|
||||||
}
|
|
||||||
PACKED * raw;
|
|
||||||
|
|
||||||
raw = ipcPrepareHeader( & c, sizeof( * raw));
|
|
||||||
|
|
||||||
raw -> magic = SFCI_MAGIC;
|
|
||||||
raw -> cmd_id = 5;
|
|
||||||
raw -> param = in ;
|
|
||||||
|
|
||||||
Result rc = serviceIpcDispatch( & g_nifmSrv);
|
|
||||||
|
|
||||||
if (R_SUCCEEDED(rc)) {
|
|
||||||
IpcParsedCommand r;
|
|
||||||
ipcParse(&r);
|
|
||||||
|
|
||||||
struct {
|
|
||||||
u64 magic;
|
|
||||||
u64 result;
|
|
||||||
} * resp = r.Raw;
|
|
||||||
|
|
||||||
rc = resp -> result;
|
|
||||||
|
|
||||||
if (R_SUCCEEDED(rc))
|
|
||||||
serviceCreate(&out->s, r.Handles[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
static Result _nifmCreateGeneralServiceOld(IGeneralService * out) {
|
|
||||||
IpcCommand c;
|
IpcCommand c;
|
||||||
ipcInitialize(&c);
|
ipcInitialize(&c);
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
u64 magic;
|
u64 magic;
|
||||||
u64 cmd_id;
|
u64 cmd_id;
|
||||||
}
|
} * raw;
|
||||||
PACKED * raw;
|
|
||||||
|
|
||||||
raw = ipcPrepareHeader( & c, sizeof( * raw));
|
raw = ipcPrepareHeader(&c, sizeof(*raw));
|
||||||
|
|
||||||
raw -> magic = SFCI_MAGIC;
|
raw->magic = SFCI_MAGIC;
|
||||||
raw -> cmd_id = 4;
|
raw->cmd_id = 12;
|
||||||
|
|
||||||
Result rc = serviceIpcDispatch( & g_nifmSrv);
|
Result rc = serviceIpcDispatch(&g_nifmIGS.s);
|
||||||
|
|
||||||
if (R_SUCCEEDED(rc)) {
|
if (R_SUCCEEDED(rc)) {
|
||||||
IpcParsedCommand r;
|
IpcParsedCommand r;
|
||||||
@ -139,9 +67,79 @@ static Result _nifmCreateGeneralServiceOld(IGeneralService * out) {
|
|||||||
struct {
|
struct {
|
||||||
u64 magic;
|
u64 magic;
|
||||||
u64 result;
|
u64 result;
|
||||||
} * resp = r.Raw;
|
u32 out;
|
||||||
|
}* resp = r.Raw;
|
||||||
|
|
||||||
rc = resp -> result;
|
rc = resp->result;
|
||||||
|
*out = resp->out;
|
||||||
|
}
|
||||||
|
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Result _nifmCreateGeneralService(IGeneralService* out, u64 in) {
|
||||||
|
IpcCommand c;
|
||||||
|
ipcInitialize(&c);
|
||||||
|
ipcSendPid(&c);
|
||||||
|
|
||||||
|
struct {
|
||||||
|
u64 magic;
|
||||||
|
u64 cmd_id;
|
||||||
|
u64 param;
|
||||||
|
} PACKED* raw;
|
||||||
|
|
||||||
|
raw = ipcPrepareHeader(&c, sizeof(*raw));
|
||||||
|
|
||||||
|
raw->magic = SFCI_MAGIC;
|
||||||
|
raw->cmd_id = 5;
|
||||||
|
raw->param = in;
|
||||||
|
|
||||||
|
Result rc = serviceIpcDispatch(&g_nifmSrv);
|
||||||
|
|
||||||
|
if (R_SUCCEEDED(rc)) {
|
||||||
|
IpcParsedCommand r;
|
||||||
|
ipcParse(&r);
|
||||||
|
|
||||||
|
struct {
|
||||||
|
u64 magic;
|
||||||
|
u64 result;
|
||||||
|
}* resp = r.Raw;
|
||||||
|
|
||||||
|
rc = resp->result;
|
||||||
|
|
||||||
|
if (R_SUCCEEDED(rc))
|
||||||
|
serviceCreate(&out->s, r.Handles[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Result _nifmCreateGeneralServiceOld(IGeneralService* out) {
|
||||||
|
IpcCommand c;
|
||||||
|
ipcInitialize(&c);
|
||||||
|
|
||||||
|
struct {
|
||||||
|
u64 magic;
|
||||||
|
u64 cmd_id;
|
||||||
|
} PACKED* raw;
|
||||||
|
|
||||||
|
raw = ipcPrepareHeader(&c, sizeof(*raw));
|
||||||
|
|
||||||
|
raw->magic = SFCI_MAGIC;
|
||||||
|
raw->cmd_id = 4;
|
||||||
|
|
||||||
|
Result rc = serviceIpcDispatch(&g_nifmSrv);
|
||||||
|
|
||||||
|
if (R_SUCCEEDED(rc)) {
|
||||||
|
IpcParsedCommand r;
|
||||||
|
ipcParse(&r);
|
||||||
|
|
||||||
|
struct {
|
||||||
|
u64 magic;
|
||||||
|
u64 result;
|
||||||
|
}* resp = r.Raw;
|
||||||
|
|
||||||
|
rc = resp->result;
|
||||||
|
|
||||||
if (R_SUCCEEDED(rc))
|
if (R_SUCCEEDED(rc))
|
||||||
serviceCreate(&out->s, r.Handles[0]);
|
serviceCreate(&out->s, r.Handles[0]);
|
||||||
|
Loading…
Reference in New Issue
Block a user