/* software buffers */
const size_t wbuffsz = 1024;
const size_t rbuffsz = 1024;

/* scratch-pads for input processing */
const size_t scratchwsz = 256;
const size_t scratchrsz = 256;

/* `nanosleep()` values inside the read and write loops */
const long swritedelay = 0; /* seconds */
const long nswritedelay = 1000000; /* nanoseconds */

/* other time variable names follow the same logic as above */

const long sreaddelay = 0;
const long nsreaddelay = 1000000;

/* `nanosleep()` values for the DTR pulse */
const long spulsedelay = 0;
const long nspulsedelay = 1000000;

/* lock the opened device */
const int exclusive = 1; /*(0|1)*/

/*
 * set the device to blocking mode,
 * on some systems this will stop all threads
 * of a process during read/write, thus rendering
 * ust unusable
 */
const int blocking = 1; /*(0|1)*/

/* escape character for interactive use */
const char escapechar = '~';

/* print additional info to stderr */
int verbose = 0; /*(0|1)*/

/*
 * device name
 *
 * Linux:
 * ttyS*   - any standard serial port
 * ttyUSB* - any USB serial port
 *
 * FreeBSD:
 * cuau* - does not wait for DCD
 * ttyu* - 'dial-in' device, waits for DCD
 * cuaU* - USB variant
 * ttyU* - USB variant
 *
 * OpenBSD:
 * cua*  - does not wait for DCD
 * tty*  - 'dial-in' device, waits for DCD
 * cuaU* - USB variant
 * ttyU* - USB variant
 *
 * NetBSD:
 * dty* - opening does not block, does not wait for DCD
 * tty* - 'dial-in' device, blocks opening until a connection is established
 * ttyU* - USB variant
 */
char line[64] = "/dev/cuau0";

/*
 * baud is usually configurable to standard values only, 
 * custom speed requires both hardware and driver support
 */
unsigned int ispeed = 9600;
unsigned int ospeed = 9600;

/*
 *  data bits: can be 8,7,6 or 5.
 *  9 is not supported
 */
char datab = '8';

/* 
 * stop bits: setting this to 1 enables 2 stop bits for all numbers of data bits
 * except 5 - it's 1.5 in that case 
 */
int stopb = 0; /*(0|1)*/

/* 
 * local echo (half-duplex mode) and canonical mode
 */
int half = 0; /*(0|1)*/
int canonical = 0; /*(0|1)*/


/*
 * CR and LF (NL) translation options
 */
CRLFOpt tropts = { 0 };
CRLFOpt itropts = { 0 };

/*
 * backspace: setting to one makes `^H` the backspace character, `^?` otherwise
 */
int backspace = 0; /*(0|1)*/

/*
 * the minimum of characters input before sending them to the line
 */
int minchars = 1; /*(>=1)*/

/*
 * delay between single characters being sent if the buffer has
 * more than 1 (redirected stdin, writing a file)
 * in nanoseconds
 */
long chardelay = 0;

/*
 * XON/XOFF flow control
 * can be enabled with hardware flow control simultaneously
 */
int soft = 0; /*(0|1)*/

/*
 * hardware flow control
 * 1 - RTS/CTS
 * 2 - DTR/DSR (not supported on some platforms)
 * 3 - DCD
 */
int hard = 0; /*(0|1|2|3)*/ 

/*
 * 1 - even
 * 2 - odd
 */
int parity = 0; /*(0|1|2)*/
