Room Manager 0.1
room reservation management system
Functions
Library functions

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

Functions

int16_t roomman_init (bool clear)
 Initialize room manager library.
 
roomid_t roomman_create_room (char *building_name, char *room_name, uint16_t max_pers)
 Create a new room.
 
int16_t roomman_delete_room (roomid_t rid)
 Delete a room.
 
int16_t roomman_update_capacity (roomid_t rid, uint16_t new_capacity)
 Update the capacity of a room.
 
int16_t roomman_reserve_room (roomid_t rid)
 Reserve a room.
 
int16_t roomman_clear_reservation (roomid_t rid)
 Reserve a room.
 
int16_t roomman_readentry (roomid_t ID, char *building, char *name, uint16_t *capacity)
 Get contents of an entry in the database.
 
roomid_t roomman_lookup (const char *building, const char *room_name)
 Find room in the database.
 
roomid_t roomman_directory (int32_t *fdptr, const char *building, const char *room_name)
 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_clear_reservation()

int16_t roomman_clear_reservation ( roomid_t  rid)

Reserve a room.

Parameters
[in]ridThe ID of the room to be unreserved
Return values
0If the room was successfully updated
Returns
On error a negative value (either ROOMMAN_ERR_STORE or ROOMMAN_ERR_NOTFOUND)

◆ roomman_create_room()

roomid_t roomman_create_room ( char *  building_name,
char *  room_name,
uint16_t  max_pers 
)

Create a new room.

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.
Returns
On success the room ID for the created room
On error a negative value (either ROOMMAN_ERR_INVALID_ROOM or ROOMMAN_ERR_DUPLICATE_ROOM)

◆ roomman_delete_room()

int16_t roomman_delete_room ( roomid_t  rid)

Delete a room.

Parameters
[in]ridId of the room to delete
Return values
0If the room was successfully deleted
Returns
A negative value (either ROOMMAN_ERR_INVALID_ROOM or ROOMMAN_ERR_STORE or ROOMMAN_ERR_CORRUPT)

◆ roomman_directory()

roomid_t roomman_directory ( int32_t *  fdptr,
const char *  building,
const char *  room_name 
)

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.

Returns
If successful: Unique ID (always >= 0) of the next matching entry
On error: Error code (always < 0)
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

◆ roomman_init()

int16_t roomman_init ( bool  clear)

Initialize room manager library.

Parameters
[in]clearSet to true if the database shall be cleared at initialization.
Returns
EXIT_SUCCESS on success
A negative value on error

◆ roomman_lookup()

roomid_t roomman_lookup ( const char *  building,
const char *  room_name 
)

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
If successful: Unique ID (always >= 0) of the entry
On error: Error code (always < 0)
Parameters
[in]buildingname of building
[in]room_namename of room

◆ roomman_readentry()

int16_t roomman_readentry ( roomid_t  ID,
char *  building,
char *  name,
uint16_t *  capacity 
)

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
1 if room is currently reserved
0 if room is currently free
a negative value if the room was not found
Parameters
[in]IDRoom's unique ID
[out]buildingWhere to store name of building
[out]nameWhere to store name of room
[out]capacityWhere to store cost (up to now)

◆ roomman_reserve_room()

int16_t roomman_reserve_room ( roomid_t  rid)

Reserve a room.

Parameters
[in]ridThe ID of the room to be reserved
Return values
0If the room was successfully updated
Returns
On error a negative value (either ROOMMAN_ERR_STORE or ROOMMAN_ERR_NOTFOUND)

◆ roomman_update_capacity()

int16_t roomman_update_capacity ( roomid_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
Return values
0If the room was successfully updated
Returns
On error a negative value (either ROOMMAN_ERR_STORE or ROOMMAN_ERR_NOTFOUND)