LispBM
Data Structures | Macros | Typedefs | Functions
lbm_channel.h File Reference
#include <stdint.h>
#include <stdbool.h>
#include <platform_mutex.h>
Include dependency graph for lbm_channel.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  lbm_buffered_channel_state_t
 
struct  lbm_string_channel_state_t
 
struct  lbm_char_channel_s
 

Macros

#define TOKENIZER_BUFFER_SIZE   257
 
#define CHANNEL_SUCCESS   1
 
#define CHANNEL_MORE   2
 
#define CHANNEL_END   3
 
#define CHANNEL_FULL   4
 
#define CHANNEL_READER_CLOSED   1000
 

Typedefs

typedef struct lbm_char_channel_s lbm_char_channel_t
 

Functions

bool lbm_channel_more (lbm_char_channel_t *chan)
 
int lbm_channel_peek (lbm_char_channel_t *chan, unsigned int n, char *res)
 
bool lbm_channel_read (lbm_char_channel_t *chan, char *res)
 
bool lbm_channel_drop (lbm_char_channel_t *chan, unsigned int n)
 
bool lbm_channel_comment (lbm_char_channel_t *chan)
 
void lbm_channel_set_comment (lbm_char_channel_t *chan, bool comment)
 
void lbm_channel_reader_close (lbm_char_channel_t *chan)
 
bool lbm_channel_reader_is_closed (lbm_char_channel_t *chan)
 
bool lbm_channel_is_empty (lbm_char_channel_t *chan)
 
bool lbm_channel_is_full (lbm_char_channel_t *chan)
 
int lbm_channel_write (lbm_char_channel_t *chan, char c)
 
void lbm_channel_writer_close (lbm_char_channel_t *chan)
 
unsigned int lbm_channel_row (lbm_char_channel_t *chan)
 
unsigned int lbm_channel_column (lbm_char_channel_t *chan)
 
void lbm_create_string_char_channel (lbm_string_channel_state_t *st, lbm_char_channel_t *chan, char *str)
 
void lbm_create_string_char_channel_size (lbm_string_channel_state_t *st, lbm_char_channel_t *chan, char *str, unsigned int size)
 
void lbm_create_buffered_char_channel (lbm_buffered_channel_state_t *st, lbm_char_channel_t *chan)
 

Typedef Documentation

◆ lbm_char_channel_t

Struct describing the interface to a character channel.

Function Documentation

◆ lbm_channel_column()

unsigned int lbm_channel_column ( lbm_char_channel_t chan)

Obtain current column from a channel.

Parameters
chanThe channel to query.

◆ lbm_channel_comment()

bool lbm_channel_comment ( lbm_char_channel_t chan)

Comment mode. Check if a channel is currently in comment mode.

Parameters
chanThe channel.
Returns
true if the channel is in comment mode, false otherwise.

◆ lbm_channel_drop()

bool lbm_channel_drop ( lbm_char_channel_t chan,
unsigned int  n 
)

Drop n characters from a channel.

Parameters
chanThe channel to drop characters from.
nThe number of characters to drop.
Returns
true on successfully dropping n characters, false otherwise.

◆ lbm_channel_is_empty()

bool lbm_channel_is_empty ( lbm_char_channel_t chan)

Check if a channel is empty. Data cannot be read from an empty channel.

Parameters
chanChannel to query.
Returns
True if empty, false otherwise.

◆ lbm_channel_is_full()

bool lbm_channel_is_full ( lbm_char_channel_t chan)

Check if a channel is full. Data cannot be written into a full channel.

Parameters
chanChannel to query.
Returns
True if channel is full, false otherwise.

◆ lbm_channel_more()

bool lbm_channel_more ( lbm_char_channel_t chan)

Check if there are more characters comming on a character channel. This returns false if the sender has closed the send side of the channel.

Parameters
chanThe channel.
Returns
True if sender end is still open false if closed.

◆ lbm_channel_peek()

int lbm_channel_peek ( lbm_char_channel_t chan,
unsigned int  n,
char *  res 
)

Peek into a character channel.

Parameters
chanThe channel to peek into.
nThe position to peek at.
resPointer to a character that will hold the result.
Returns
  • CHANNEL_SUCCESS: successfully peeked.
  • CHANNEL_MORE: The data you try to peek at has not yet arrived into the channel.
  • CHANNEL_END: The sender side is closed and you are peeking outside of valid data.

◆ lbm_channel_read()

bool lbm_channel_read ( lbm_char_channel_t chan,
char *  res 
)

Read a character from the head of the channel.

Parameters
chanThe channel to read from.
resThe resulting character is stored here.
Returns
true on success, otherwise false.

◆ lbm_channel_reader_close()

void lbm_channel_reader_close ( lbm_char_channel_t chan)

Close a channel reader side.

Parameters
chanChannel to close the reader side of.

◆ lbm_channel_reader_is_closed()

bool lbm_channel_reader_is_closed ( lbm_char_channel_t chan)

Check if the reader side of channel is closed.

Parameters
chanChannel to query.
Returns
True if closed, false otherwise.

◆ lbm_channel_row()

unsigned int lbm_channel_row ( lbm_char_channel_t chan)

Obtain current row number from a channel.

Parameters
chanThe channel to query.
Returns
The current row as seen by the calls to "read".

◆ lbm_channel_set_comment()

void lbm_channel_set_comment ( lbm_char_channel_t chan,
bool  comment 
)

Enter into or exit from comment mode.

Parameters
chanChannel to change mode of.
commentTrue to enter into comment mode and false to exit.

◆ lbm_channel_write()

int lbm_channel_write ( lbm_char_channel_t chan,
char  c 
)

Write a character onto the end of a channel.

Parameters
chanChannel to write to.
cCharacter to place onto the channel.
Returns
  • CHANNEL_SUCCESS: Successfully wrote.
  • CHANNEL_READER_CLOSED: The reader end is closed, you should abort writing.
  • CHANNEL_FULL: The channel is full and cannot accept the character. Try again later.

◆ lbm_channel_writer_close()

void lbm_channel_writer_close ( lbm_char_channel_t chan)

Close the writer side of a channel. \ param chan The channel to close the writer side of.

◆ lbm_create_buffered_char_channel()

void lbm_create_buffered_char_channel ( lbm_buffered_channel_state_t st,
lbm_char_channel_t chan 
)

Create a buffered channel that can be read from and written to.

Parameters
stPointer to lbm_buffered_channel_state_t.
chanPointer to lbm_char_channel_t.

◆ lbm_create_string_char_channel()

void lbm_create_string_char_channel ( lbm_string_channel_state_t st,
lbm_char_channel_t chan,
char *  str 
)

Create a channel from a string. This channel can be read from but not written to.

Parameters
stPointer to lbm_string_channel_state.
chanPointer to lbm_char_channel_t.
strThe string to base the channel contents upon.