libctru  v2.3.1
Functions
srv.h File Reference

Service API. More...

Go to the source code of this file.

Functions

Result srvInit (void)
 Initializes the service API.
 
void srvExit (void)
 Exits the service API.
 
void srvSetBlockingPolicy (bool nonBlocking)
 Makes srvGetServiceHandle non-blocking for the current thread (or blocking, the default), in case of unavailable (full) requested services. More...
 
HandlesrvGetSessionHandle (void)
 Gets the current service API session handle. More...
 
Result srvGetServiceHandle (Handle *out, const char *name)
 Retrieves a service handle, retrieving from the environment handle list if possible. More...
 
Result srvRegisterClient (void)
 Registers the current process as a client to the service API.
 
Result srvEnableNotification (Handle *semaphoreOut)
 Enables service notificatios, returning a notification semaphore. More...
 
Result srvRegisterService (Handle *out, const char *name, int maxSessions)
 Registers the current process as a service. More...
 
Result srvUnregisterService (const char *name)
 Unregisters the current process as a service. More...
 
Result srvGetServiceHandleDirect (Handle *out, const char *name)
 Retrieves a service handle. More...
 
Result srvRegisterPort (const char *name, Handle clientHandle)
 Registers a port. More...
 
Result srvUnregisterPort (const char *name)
 Unregisters a port. More...
 
Result srvGetPort (Handle *out, const char *name)
 Retrieves a port handle. More...
 
Result srvWaitForPortRegistered (const char *name)
 Waits for a port to be registered. More...
 
Result srvSubscribe (u32 notificationId)
 Subscribes to a notification. More...
 
Result srvUnsubscribe (u32 notificationId)
 Unsubscribes from a notification. More...
 
Result srvReceiveNotification (u32 *notificationIdOut)
 Receives a notification. More...
 
Result srvPublishToSubscriber (u32 notificationId, u32 flags)
 Publishes a notification to subscribers. More...
 
Result srvPublishAndGetSubscriber (u32 *processIdCountOut, u32 *processIdsOut, u32 notificationId)
 Publishes a notification to subscribers and retrieves a list of all processes that were notified. More...
 
Result srvIsServiceRegistered (bool *registeredOut, const char *name)
 Checks whether a service is registered. More...
 
Result srvIsPortRegistered (bool *registeredOut, const char *name)
 Checks whether a port is registered. More...
 

Detailed Description

Service API.

Function Documentation

◆ srvEnableNotification()

Result srvEnableNotification ( Handle semaphoreOut)

Enables service notificatios, returning a notification semaphore.

Parameters
semaphoreOutPointer to output the notification semaphore to.

◆ srvGetPort()

Result srvGetPort ( Handle out,
const char *  name 
)

Retrieves a port handle.

Parameters
outPointer to output the handle to.
nameName of the port.

◆ srvGetServiceHandle()

Result srvGetServiceHandle ( Handle out,
const char *  name 
)

Retrieves a service handle, retrieving from the environment handle list if possible.

Parameters
outPointer to write the handle to.
nameName of the service.
Returns
0 if no error occured, 0xD8E06406 if the caller has no right to access the service, 0xD0401834 if the requested service port is full and srvGetServiceHandle is non-blocking (see srvSetBlockingPolicy).

◆ srvGetServiceHandleDirect()

Result srvGetServiceHandleDirect ( Handle out,
const char *  name 
)

Retrieves a service handle.

Parameters
outPointer to output the handle to.
nameName of the service.
Returns
0 if no error occured, 0xD8E06406 if the caller has no right to access the service, 0xD0401834 if the requested service port is full and srvGetServiceHandle is non-blocking (see srvSetBlockingPolicy).

◆ srvGetSessionHandle()

Handle* srvGetSessionHandle ( void  )

Gets the current service API session handle.

Returns
The current service API session handle.

◆ srvIsPortRegistered()

Result srvIsPortRegistered ( bool *  registeredOut,
const char *  name 
)

Checks whether a port is registered.

Parameters
registeredOutPointer to output the registration status to.
nameName of the port to check.

◆ srvIsServiceRegistered()

Result srvIsServiceRegistered ( bool *  registeredOut,
const char *  name 
)

Checks whether a service is registered.

Parameters
registeredOutPointer to output the registration status to.
nameName of the service to check.

◆ srvPublishAndGetSubscriber()

Result srvPublishAndGetSubscriber ( u32 processIdCountOut,
u32 processIdsOut,
u32  notificationId 
)

Publishes a notification to subscribers and retrieves a list of all processes that were notified.

Parameters
processIdCountOutPointer to output the number of process IDs to.
processIdsOutPointer to output the process IDs to. Should have size "60 * sizeof(u32)".
notificationIdID of the notification.

◆ srvPublishToSubscriber()

Result srvPublishToSubscriber ( u32  notificationId,
u32  flags 
)

Publishes a notification to subscribers.

Parameters
notificationIdID of the notification.
flagsFlags to publish with. (bit 0 = only fire if not fired, bit 1 = do not report an error if there are more than 16 pending notifications)

◆ srvReceiveNotification()

Result srvReceiveNotification ( u32 notificationIdOut)

Receives a notification.

Parameters
notificationIdOutPointer to output the ID of the received notification to.

◆ srvRegisterPort()

Result srvRegisterPort ( const char *  name,
Handle  clientHandle 
)

Registers a port.

Parameters
nameName of the port.
clientHandleClient handle of the port.

◆ srvRegisterService()

Result srvRegisterService ( Handle out,
const char *  name,
int  maxSessions 
)

Registers the current process as a service.

Parameters
outPointer to write the service handle to.
nameName of the service.
maxSessionsMaximum number of sessions the service can handle.

◆ srvSetBlockingPolicy()

void srvSetBlockingPolicy ( bool  nonBlocking)

Makes srvGetServiceHandle non-blocking for the current thread (or blocking, the default), in case of unavailable (full) requested services.

Parameters
blockingWhether srvGetServiceHandle should be non-blocking. srvGetServiceHandle will always block if the service hasn't been registered yet, use srvIsServiceRegistered to check whether that is the case or not.

◆ srvSubscribe()

Result srvSubscribe ( u32  notificationId)

Subscribes to a notification.

Parameters
notificationIdID of the notification.

◆ srvUnregisterPort()

Result srvUnregisterPort ( const char *  name)

Unregisters a port.

Parameters
nameName of the port.

◆ srvUnregisterService()

Result srvUnregisterService ( const char *  name)

Unregisters the current process as a service.

Parameters
nameName of the service.

◆ srvUnsubscribe()

Result srvUnsubscribe ( u32  notificationId)

Unsubscribes from a notification.

Parameters
notificationIdID of the notification.

◆ srvWaitForPortRegistered()

Result srvWaitForPortRegistered ( const char *  name)

Waits for a port to be registered.

Parameters
nameName of the port to wait for registration.