From: git Date: Sat, 21 Feb 2026 10:14:45 +0000 (-0500) Subject: TERMIOS_STRUCT macro fix X-Git-Url: https://git.datadissipation.net/?a=commitdiff_plain;h=600e7dfa6d742f6300d27ce7f10f29fa0e434d7e;p=ust.git TERMIOS_STRUCT macro fix --- diff --git a/ust.c b/ust.c index 2aa9a24..8ad6dd1 100644 --- a/ust.c +++ b/ust.c @@ -50,7 +50,7 @@ typedef struct { ssize_t sizesm; } Sizes; -typedef struct{ +typedef struct { int crinlf; int crtolf; int lfincr; @@ -70,7 +70,7 @@ static unsigned int strtoui(const char *str, const char *msg, unsigned int min); 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); @@ -82,15 +82,18 @@ static inline ssize_t rmchar(char *buff, ssize_t sread, int *scratch, const Args 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; @@ -174,6 +177,7 @@ openport() die(1, "failed to lock the device, exiting now\n"); } } + /* * Baud */ @@ -190,7 +194,8 @@ openport() 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; @@ -198,8 +203,8 @@ openport() 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 @@ -370,7 +375,7 @@ lsbmask(unsigned int n) } 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) @@ -442,7 +447,7 @@ writeport(void *unused) } /* 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; } @@ -485,8 +490,6 @@ readport(void *unused) } nanosleep(&ts, NULL); } - if (isatty(STDIN_FILENO)) - settermattr(STDIN_FILENO, &origterm); return NULL; }