Room Manager 0.1
room reservation management system
Library functions

API-Definitions for the roomman library. More...

Functions

roomman_result_t roomman_set_username (char *username)
 Set the name of the current user (required for room reservations).
 
roomman_result_t roomman_create_room (char *building_name, char *room_name, uint16_t max_pers, roomman_id_t *rid)
 Create a new room.
 
roomman_result_t roomman_delete_room (roomman_id_t rid)
 Delete a room.
 
roomman_result_t roomman_update_capacity (roomman_id_t rid, uint16_t new_capacity)
 Update the capacity of a room.
 
roomman_result_t roomman_reserve_room (roomman_id_t rid)
 Reserve a room.
 
roomman_result_t roomman_clear_reservation (roomman_id_t rid)
 Reserve a room.
 
roomman_result_t roomman_add_persons (roomman_id_t rid, uint16_t persons)
 Increase the number of persons currently using the room.
 
roomman_result_t roomman_remove_persons (roomman_id_t rid, uint16_t persons)
 Decrease the number of persons currently using the room.
 
roomman_result_t roomman_readentry (roomman_id_t rid, char *building, char *name, uint16_t *occupied, uint16_t *capacity, char *reserved_by)
 Get contents of an entry in the database.
 
roomman_result_t roomman_lookup (const char *building, const char *room_name, roomman_id_t *rid)
 Find room in the database.
 
roomman_result_t roomman_directory (int32_t *fdptr, const char *building, const char *room_name, roomman_id_t *rid)
 Get a directory of entries in the database.
 

Detailed Description

API-Definitions for the roomman library.

This file is to be included by all applications making use of any of the room manager library's functions. It declares prototypes for all user-callable functions of the library. It does not contain library-internal definitions.

Function Documentation

◆ roomman_add_persons()

roomman_result_t roomman_add_persons ( roomman_id_t rid,
uint16_t persons )

Increase the number of persons currently using the room.

Parameters
[in]ridID of the room to update
[in]personsNumber of additional persons using the room
Returns
ROOMMAN_SUCCESS If the room was successfully updated
On error a negative value (either ROOMMAN_ERR_INVALID_ROOM or ROOMMAN_ERR_EXCEED)

◆ roomman_clear_reservation()

roomman_result_t roomman_clear_reservation ( roomman_id_t rid)

Reserve a room.

Note
Clearing the reservation for an existing room should always succeed (unless errors with the database access occur).
Parameters
[in]ridThe ID of the room to be unreserved
Returns
ROOMMAN_SUCCESS If the room was successfully updated
On error a negative value (ROOMMAN_ERR_INVALID_ROOM)

◆ roomman_create_room()

roomman_result_t roomman_create_room ( char * building_name,
char * room_name,
uint16_t max_pers,
roomman_id_t * rid )

Create a new room.

Note
Rooms are created empty and not reserved.
Parameters
[in]building_nameThe building's name
[in]room_nameThe room's name
[in]max_persThe maximum number of persons for this room. If 0 is provided the default capacity will be set.
[out]ridThe ID of the newly created room. Undefined if room creation fails.
Returns
ROOMMAN_SUCCESS on success
On error a negative value (ROOMMAN_ERR_DUPLICATE_ROOM)

◆ roomman_delete_room()

roomman_result_t roomman_delete_room ( roomman_id_t rid)

Delete a room.

Parameters
[in]ridID of the room to delete
Returns
ROOMMAN_SUCCESS If the room was successfully deleted
A negative value (ROOMMAN_ERR_INVALID_ROOM)

◆ roomman_directory()

roomman_result_t roomman_directory ( int32_t * fdptr,
const char * building,
const char * room_name,
roomman_id_t * rid )

Get a directory of entries in the database.

This function enables a "wildcard search" of the database. It delivers UIDs of matching entries. The caller may specify a building name or a room name, thus specifying a particular entry (in this case the function is similar to roomman_lookup()). However, it is also possible to specify only an building name or only a room name by passing a NULL value for the name that should not be specified. In this case, the function delivers UIDs of all entries matching the specified name. If both names are passed as NULL, the function delivers the UIDs of all entries in the database.

The function delivers one UID per call. In order to keep the context across calls, the caller must pass a pointer to an int variable. This variable (not the pointer!) must be initialized with -1 before making the first call.

If there are no more remaining entries in the database the function will return ROOMMAN_ERR_INVALID_ROOM.

Returns
ROOMMAN_SUCCESS on success
An error code otherwise ROOMMAN_ERR_INVALID_ROOM or ROOMMAN_ERR_NAMETOOLONG)
Parameters
fdptr[in/out] pointer where to store the open file handle across calls
[in]buildingname of room's building or NULL if not specified
[in]room_namename of room or NULL if not specified
[out]ridThe room ID for the next matching entry. (Undefined if room is not found.)

◆ roomman_lookup()

roomman_result_t roomman_lookup ( const char * building,
const char * room_name,
roomman_id_t * rid )

Find room in the database.

This function locates an entry in the database. It returns a unique ID by which the room can be referenced. A room is uniquely identified by the combination of the building's name and the room's name.

Returns
ROOMMAN_SUCCESS on success
An error code otherwise ROOMMAN_ERR_INVALID_ROOM or ROOMMAN_ERR_NAMETOOLONG)
Parameters
[in]buildingname of building
[in]room_namename of room
[out]ridThe room ID for the requested room. (Undefined if room is not found.)

◆ roomman_readentry()

roomman_result_t roomman_readentry ( roomman_id_t rid,
char * building,
char * name,
uint16_t * occupied,
uint16_t * capacity,
char * reserved_by )

Get contents of an entry in the database.

This function delivers details of a room identified by UID. The room is not changed by a call to this function.

Returns
ROOMMAN_SUCCESS if the entry for the given room has been found
a negative value if the room was not found (ROOMMAN_ERR_INVALID_ROOM)
Parameters
[in]ridRoom's unique ID
[out]buildingWhere to store name of building
[out]nameWhere to store name of room
[out]occupiedWhere to store the number of occupied places
[out]capacityWhere to store capacity
[out]reserved_byContains the name of the person currently reserving the room (if any)

◆ roomman_remove_persons()

roomman_result_t roomman_remove_persons ( roomman_id_t rid,
uint16_t persons )

Decrease the number of persons currently using the room.

Parameters
[in]ridID of the room to update
[in]personsNumber of persons leaving the room
Returns
ROOMMAN_SUCCESS If the room was successfully updated
On error a negative value (either ROOMMAN_ERR_INVALID_ROOM or ROOMMAN_ERR_EXCEED)

◆ roomman_reserve_room()

roomman_result_t roomman_reserve_room ( roomman_id_t rid)

Reserve a room.

Note
In order to reserve a room, the user must be set (roomman_set_username).
Parameters
[in]ridThe ID of the room to be reserved
Returns
ROOMMAN_SUCCESS If the room was successfully updated
On error a negative value (either ROOMMAN_ERR_NOUSER or ROOMMAN_ERR_INVALID_ROOM or ROOMMAN_ERR_NOT_EMPTY)

◆ roomman_set_username()

roomman_result_t roomman_set_username ( char * username)

Set the name of the current user (required for room reservations).

Parameters
[in]usernameName of the user.
Returns
ROOMMAN_SUCCESS on success
On error a negative value (either ROOMMAN_ERR_NAMETOOLONG)

◆ roomman_update_capacity()

roomman_result_t roomman_update_capacity ( roomman_id_t rid,
uint16_t new_capacity )

Update the capacity of a room.

Parameters
[in]ridID of the room to update
[in]new_capacityNew capacity of the room
Returns
ROOMMAN_SUCCESS If the room was successfully updated
On error a negative value (ROOMMAN_ERR_INVALID_ROOM)