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...
Handle * | srvGetSessionHandle (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

  semaphoreOut | Pointer to output the notification semaphore to.

## srvGetPort()

Result srvGetPort | ( | Handle * | out,
|  | const char * | name
| ) |  |

Retrieves a port handle.

Parameters

  out | Pointer to output the handle to.
  name | Name of the port.

## srvGetServiceHandle()

Result srvGetServiceHandle | ( | Handle * | out,
|  | const char * | name
| ) |  |

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

Parameters

  out | Pointer to write the handle to.
  name | Name 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

  out | Pointer to output the handle to.

  name

  Name 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

  registeredOut | Pointer to output the registration status to.
  name | Name of the port to check.

## srvIsServiceRegistered()

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

Checks whether a service is registered.

Parameters

  registeredOut | Pointer to output the registration status to.
  name | Name 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

  processIdCountOut | Pointer to output the number of process IDs to.
  processIdsOut | Pointer to output the process IDs to. Should have size "60 * sizeof(u32)".
  notificationId | ID of the notification.

## srvPublishToSubscriber()

Result srvPublishToSubscriber | ( | u32 | notificationId,
|  | u32 | flags
| ) |  |

Publishes a notification to subscribers.

Parameters

  notificationId | ID of the notification.
  flags | Flags 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

  notificationIdOut | Pointer to output the ID of the received notification to.

## srvRegisterPort()

Result srvRegisterPort | ( | const char * | name,
|  | Handle | clientHandle
| ) |  |

Registers a port.

Parameters

  name | Name of the port.
  clientHandle | Client handle of the port.

## srvRegisterService()

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

Registers the current process as a service.

Parameters

  out | Pointer to write the service handle to.
  name | Name of the service.
  maxSessions | Maximum 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

  blocking | Whether 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

  notificationId | ID of the notification.

## srvUnregisterPort()

Result srvUnregisterPort | ( | const char * | name | ) |

Unregisters a port.

Parameters

  name | Name of the port.

## srvUnregisterService()

Result srvUnregisterService | ( | const char * | name | ) |

Unregisters the current process as a service.

Parameters

  name | Name of the service.

## srvUnsubscribe()

Result srvUnsubscribe | ( | u32 | notificationId | ) |

Unsubscribes from a notification.

Parameters

  notificationId | ID of the notification.

## srvWaitForPortRegistered()

Result srvWaitForPortRegistered | ( | const char * | name | ) |

Waits for a port to be registered.

Parameters

  name | Name of the port to wait for registration.