ssize_t sizesm;
} Sizes;
-typedef struct{
+typedef struct {
int crinlf;
int crtolf;
int lfincr;
static int troptions(CRLFOpt *options, const char *str);
static int setroptions();
static inline unsigned int lsbmask(unsigned int n);
-static inline int termchck(const void *term);
+static inline int termchck(const struct TERMIOS_STRUCT *term);
static void interchck();
static void cechck();
static void *writeport(void *unused);
static void sighandl(int signo);
static void die(int code, const char *msg, ...);
-static struct TERMIOS_STRUCT cntrl, origterm = { 0 }, newterm = { 0 };
+static struct TERMIOS_STRUCT cntrl, /* device struct */
+ origterm = { 0 }, /* controlling terminal structs */
+ newterm = { 0 };
static Args bsargs = {DEL, DEL, 0};
static const Args nocrargs = {CR, 0, 0},
nolfargs = {LF, '\0', 0}, /* null-terminator is for use inside `getcmd()` */
lfincrargs = {CR, LF, 1},
- crinlfargs = {LF, CR, -1};
+ crinlfargs = {LF, CR, 0};
+
static struct timespec wts;
-static const unsigned int uintmax = ~(unsigned int)0; /* unsigned -1 to return on error */
+static const unsigned int uintmax = ~(unsigned int)0; /* unsigned -1 used to return an error */
static int interactive = 0;
static char *writebuff = NULL;
static char *readbuff = NULL;
die(1, "failed to lock the device, exiting now\n");
}
}
+
/*
* Baud
*/
cntrl.c_iflag &= ~(ISTRIP | BRKINT);
cntrl.c_cflag &= ~(PARENB | PARODD);
- if (verbose) fprintf(stderr, "setting parity [even: %d, odd: %d]\n", parity & 1, (parity & 2) >> 1);
+ if (verbose) fprintf(stderr, "setting parity [even: %d, odd: %d]\n",\
+ parity & 1, (parity & 2) >> 1);
if (parity == 1)
cntrl.c_cflag |= PARENB;
cntrl.c_cflag |= PARENB | PARODD;
if (settermattr(fd, &cntrl) == -1)
- die(2, "failed to set parity [even: %d, odd: %d]\n", parity & 1, (parity & 2) >> 1);
-
+ die(2, "failed to set parity [even: %d, odd: %d]\n",\
+ parity & 1, (parity & 2) >> 1);
/*
* Flow control
}
inline int
-termchck(const void *term)
+termchck(const struct TERMIOS_STRUCT *term)
{
for (size_t i = 0; i < sizeof(struct TERMIOS_STRUCT); i++)
if (((char*)term)[i] != 0)
}
/* ust kills itself upon receiving a signal so no fancy `nanosleep()` features needed */
nanosleep(&timeout, NULL);
- die(0, "\n[EOF]\n");
+ die(0, "[EOF]\n");
return NULL;
}
}
nanosleep(&ts, NULL);
}
- if (isatty(STDIN_FILENO))
- settermattr(STDIN_FILENO, &origterm);
return NULL;
}