football
socket abstraction layer
Loading...
Searching...
No Matches
Macros | Functions
fb_service.c File Reference

Football service and connection creation/destruction. More...

#include <config.h>
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <assert.h>
#include "fb_transport.h"
#include "fb_service.h"

Macros

#define _BSD_SOURCE   /* strdup, realpath */
 
#define _DEFAULT_SOURCE
 

Functions

bool fb_services_are_open (void)
 Indicate whether there are any services open.
 
FB_SERVICEfb_create_service (const FB_SERVICE_OPTIONS *options)
 Create a new service and initialize its listeners.
 
void fb_destroy_service (FB_SERVICE *service)
 
void fb_close_service (FB_SERVICE *service)
 Initiate closure of a service.
 
bool fb_validate_connection (FB_SERVICE *service, FB_CONNECTION *connection)
 Validate connection with hosts_access.
 
FB_CONNECTIONfb_accept_connection (FB_SERVICE *service, FB_SOCKETID id)
 
bool fb_transfer (FB_CONNECTION *connection, FB_SERVICE *service)
 Transfer a connection to a new service.
 
bool fb_transfer_by_name (FB_CONNECTION *connection, const char *name)
 
void fb_destroy_connection (FB_CONNECTION *connection)
 
void fb_close_connection (FB_CONNECTION *connection)
 Initiate connection closure.
 
FB_EVENTfb_accept_file (FB_SERVICE *service, char *filename)
 Make a connection that reads from a file.
 
FB_EVENTfb_loopback_socket (FB_SERVICE *service)
 Make a connection with a pipe.
 
FB_ITERATORfb_new_iterator (FB_SERVICE *service)
 Create a new iterator.
 
FB_EVENTfb_iterate_next (FB_ITERATOR *it)
 Get the next iteration.
 
void fb_destroy_iterator (FB_ITERATOR *it)
 Destroy an iterator and release its resources.
 

Detailed Description

Football service and connection creation/destruction.

Function Documentation

◆ fb_accept_file()

FB_EVENT * fb_accept_file ( FB_SERVICE service,
char *  filename 
)

Make a connection that reads from a file.

Parameters
servicethe service to register the connection with
filenamethe file to read from
Returns
a pointer to the connection, or NULL on failure.

◆ fb_close_connection()

void fb_close_connection ( FB_CONNECTION connection)

Initiate connection closure.

If the socket is in an open state, change its state and enable writes. The next write attempt will generate a close event. If the connection is already on its way out, leave it alone.

Parameters
connectionthe connection to close

◆ fb_close_service()

void fb_close_service ( FB_SERVICE service)

Initiate closure of a service.

Returns
Nothing.

◆ fb_create_service()

FB_SERVICE * fb_create_service ( const FB_SERVICE_OPTIONS options)

Create a new service and initialize its listeners.

Subsequent changes made to the options do not effect behavior.

Parameters
optionsOptions for the new service's behavior.
Returns
a pointer to the service, or NULL on failure.

◆ fb_destroy_iterator()

void fb_destroy_iterator ( FB_ITERATOR it)

Destroy an iterator and release its resources.

Parameters
itThe iterator

◆ fb_iterate_next()

FB_EVENT * fb_iterate_next ( FB_ITERATOR it)

Get the next iteration.

See also
FB_EVENTTYPE
Parameters
itThe iterator
Returns
An event, or NULL if there are no more connections.

◆ fb_loopback_socket()

FB_EVENT * fb_loopback_socket ( FB_SERVICE service)

Make a connection with a pipe.

Parameters
servicethe service to register the connection with
Returns
a pointer to the connection, or NULL on failure.

◆ fb_new_iterator()

FB_ITERATOR * fb_new_iterator ( FB_SERVICE service)

Create a new iterator.

Create and initialize a new iterator for a service.

See also
fb_destroy_iterator().
Returns
an iterator or NULL on error.

◆ fb_services_are_open()

bool fb_services_are_open ( void  )

Indicate whether there are any services open.

Returns
true if services exist, false otherwise.

◆ fb_transfer()

bool fb_transfer ( FB_CONNECTION connection,
FB_SERVICE service 
)

Transfer a connection to a new service.

Parameters
connectionThe connection to transfer.
serviceThe service to reassign it to.

◆ fb_validate_connection()

bool fb_validate_connection ( FB_SERVICE service,
FB_CONNECTION connection 
)

Validate connection with hosts_access.

Parameters
serviceThe service on which the connection is arriving.
connectionThe connection.
Returns
True if access is allowed, false if denied.