football
socket abstraction layer
Macros | Functions
fb_event.c File Reference

Football I/O event handlers. More...

#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <stdarg.h>
#include <ctype.h>
#include <errno.h>
#include <assert.h>
#include <sys/types.h>
#include <stdbool.h>
#include "fb_service.h"

Macros

#define _BSD_SOURCE   /* snprintf() */
 
#define _DEFAULT_SOURCE
 
#define _POSIX_C_SOURCE   200112L
 

Functions

ssize_t fb_queue_message (void *thing, FB_MESSAGE *message, bool broadcast)
 
ssize_t fb_fprint (void *thing, const char *bytes, ssize_t length)
 Adds an unformatted message to the output queue. More...
 
ssize_t fb_fprintf (void *thing, const char *format,...)
 Add messages to output queues in various forms and styles. More...
 
ssize_t fb_vfprintf (void *thing, const char *format, va_list parameters)
 
ssize_t fb_bfprintf (void *thing, const char *format,...)
 
ssize_t fb_bvfprintf (void *thing, const char *format, va_list parameters)
 
ssize_t fb_cbfprintf (void *thing, bool(*callback)(FB_CONNECTION *), const char *format,...)
 
ssize_t fb_cbvfprintf (void *thing, bool(*callback)(FB_CONNECTION *), const char *format, va_list parameters)
 
FB_EVENTfb_send_output (FB_EVENT *event, FB_CONNECTION *connection)
 
bool fb_set_input_buffer_size (FB_CONNECTION *connection, size_t size)
 
bool fb_recv_input (FB_CONNECTION *connection, ssize_t byte_count)
 
FB_EVENTfb_read_line_input (FB_EVENT *event, FB_CONNECTION *connection)
 
FB_EVENTfb_read_input (FB_EVENT *ev, FB_CONNECTION *connection)
 
FB_EVENTfb_new_connect (FB_EVENT *event, FB_SERVICE *service)
 

Detailed Description

Football I/O event handlers.

Function Documentation

◆ fb_bfprintf()

ssize_t fb_bfprintf ( void *  thing,
const char *  format,
  ... 
)
See also
fb_fprintf

◆ fb_bvfprintf()

ssize_t fb_bvfprintf ( void *  thing,
const char *  format,
va_list  parameters 
)
See also
fb_fprintf

◆ fb_cbfprintf()

ssize_t fb_cbfprintf ( void *  thing,
bool(*)(FB_CONNECTION *)  callback,
const char *  format,
  ... 
)
See also
fb_fprintf

◆ fb_cbvfprintf()

ssize_t fb_cbvfprintf ( void *  thing,
bool(*)(FB_CONNECTION *)  callback,
const char *  format,
va_list  parameters 
)
See also
fb_fprintf

◆ fb_fprint()

ssize_t fb_fprint ( void *  thing,
const char *  bytes,
ssize_t  length 
)

Adds an unformatted message to the output queue.

Parameters
thingthe destined service, connection or event.
bytesthe bytes to transmit.
lengthnumber of bytes in the message.
Returns
-1 on error, number of bytes written on success or partial success.

◆ fb_fprintf()

ssize_t fb_fprintf ( void *  thing,
const char *  format,
  ... 
)

Add messages to output queues in various forms and styles.

All forms take an opaque type and determine if it's a connection or service, so you can write code once and deal with both single and broadcast messages.

  • 'b' variants broadcast, given either a connection or service. Services always broadcast, regardless of service.
  • 'cb' variants broadcast only to those connections identified buy the supplied callback function returning true.
  • 'v' accepts a pointer to the format arguments.
    Parameters
    thingthe destined service, connection or event.
    formata printf format string, with values to follow.
    Returns
    -1 on error, number of bytes written on success or partial success.

◆ fb_vfprintf()

ssize_t fb_vfprintf ( void *  thing,
const char *  format,
va_list  parameters 
)
See also
fb_fprintf