ceptr
|
stream abstraction implementation More...
#include "stream.h"
#include <stdlib.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <arpa/inet.h>
#include <sys/wait.h>
#include <signal.h>
#include <stdio.h>
#include <unistd.h>
#include "process.h"
#include "debug.h"
#include "util.h"
Go to the source code of this file.
#define | BACKLOG 10 |
char * | DELIM_LF = "\n" |
char * | DELIM_CRLF = "\r\n" |
void | __st_realloc_reader (Stream *st) |
size_t | __st_unix_stream_load (Stream *st) |
size_t | __st_socket_stream_load (Stream *st) |
void | __st_scan (Stream *st) |
char * | ss2str (int s) |
void | __st_stream_read (Stream *st) |
void * | _st_stream_read (void *arg) |
Stream * | __st_alloc_stream () |
void | __st_start_reader (Stream *s, size_t reader_buffer_size) |
Stream * | __st_new_unix_stream (FILE *stream, size_t reader_buffer_size) |
Stream * | _st_new_socket_stream (int sockfd) |
void * | get_in_addr (struct sockaddr *sa) |
void * | __st_socket_stream_accept (void *arg) |
SocketListener * | _st_new_socket_listener (int port, lisenterConnectionCallbackFn fn, void *callback_arg, char *delim) |
void | _st_close_listener (SocketListener *l) |
void | _st_start_read (Stream *st) |
void | _st_data_consumed (Stream *st) |
void | _st_kill (Stream *st) |
void | _st_free (Stream *st) |
int | _st_write (Stream *st, char *buf, size_t len) |
int | _st_writeln (Stream *stream, char *str) |
stream abstraction implementation
Definition in file stream.c.
Stream* __st_new_unix_stream | ( | FILE * | stream, |
size_t | reader_buffer_size | ||
) |
void __st_scan | ( | Stream * | st | ) |
size_t __st_socket_stream_load | ( | Stream * | st | ) |
load socket data into the stream buffer
returns the number of bytes loaded if 0 bytes loaded, st->err will hold the reason, which is either because socket error condition, or a some other unix error (from errno)
if the buffer is already full when this function is called, it will attempt to increase the buffer size with a realloc before reading.
void __st_start_reader | ( | Stream * | s, |
size_t | reader_buffer_size | ||
) |
void __st_stream_read | ( | Stream * | st | ) |
reads a unit from a stream
calls the stream loading function according to stream type when needed to get stream data into the read buffer, and then scans along that buffer setting the StreamHasData flag for each unit found. If the scan returns Partial (i.e. no terminator found yet) and then stream is terminated (indicate by 0 value from the load function) then the partial will be treated as a successfully read unit.
size_t __st_unix_stream_load | ( | Stream * | st | ) |
load file data into the stream buffer
returns the number of bytes loaded if 0 bytes loaded, st->err will hold the reason, which is either because and EndOfFile condition, or a some other unix error (from errno)
if the buffer is already full when this function is called, it will attempt to increase the buffer size with a realloc before reading.
void _st_close_listener | ( | SocketListener * | l | ) |
void _st_data_consumed | ( | Stream * | st | ) |
void _st_free | ( | Stream * | st | ) |
void _st_kill | ( | Stream * | st | ) |
SocketListener* _st_new_socket_listener | ( | int | port, |
lisenterConnectionCallbackFn | fn, | ||
void * | callback_arg, | ||
char * | delim | ||
) |
Stream* _st_new_socket_stream | ( | int | sockfd | ) |
void _st_start_read | ( | Stream * | st | ) |
int _st_write | ( | Stream * | st, |
char * | buf, | ||
size_t | len | ||
) |