Fixed indentation in configfile.c, tty.c, options.c

This commit is contained in:
Robert Snell 2022-07-10 18:14:29 -04:00
parent 1c29aac9fa
commit f459a462c5
4 changed files with 46 additions and 48 deletions

View file

@ -131,7 +131,7 @@ static int data_handler(void *user, const char *section, const char *name,
else if ( !strcmp(name, "upcase")) else if ( !strcmp(name, "upcase"))
{ {
option.upcase = true; option.upcase = true;
} }
else if (!strcmp(name, "dtr-pulse-duration")) else if (!strcmp(name, "dtr-pulse-duration"))
{ {
option.dtr_pulse_duration = atoi(value); option.dtr_pulse_duration = atoi(value);

View file

@ -97,7 +97,7 @@ void print_help(char *argv[])
printf(" -c, --color 0..255|none|list Colorize tio text (default: 15)\n"); printf(" -c, --color 0..255|none|list Colorize tio text (default: 15)\n");
printf(" -S, --socket <socket> Redirect I/O to file or network socket\n"); printf(" -S, --socket <socket> Redirect I/O to file or network socket\n");
printf(" -x, --hexadecimal Enable hexadecimal mode\n"); printf(" -x, --hexadecimal Enable hexadecimal mode\n");
printf(" -U, --upcase Translate lower case alpha to upper case\n"); printf(" -U, --upcase Translate lower case alpha to upper case\n");
printf(" -v, --version Display version\n"); printf(" -v, --version Display version\n");
printf(" -h, --help Display help\n"); printf(" -h, --help Display help\n");
printf("\n"); printf("\n");
@ -208,8 +208,8 @@ void options_parse(int argc, char *argv[])
{"stopbits", required_argument, 0, 's' }, {"stopbits", required_argument, 0, 's' },
{"parity", required_argument, 0, 'p' }, {"parity", required_argument, 0, 'p' },
{"output-delay", required_argument, 0, 'o' }, {"output-delay", required_argument, 0, 'o' },
{"eol-delay", required_argument, 0, 'O' }, {"eol-delay", required_argument, 0, 'O' },
{"upcase", no_argument, 0, 'U' }, {"upcase", no_argument, 0, 'U' },
{"dtr-pulse-duration", required_argument, 0, OPT_DTR_PULSE_DURATION }, {"dtr-pulse-duration", required_argument, 0, OPT_DTR_PULSE_DURATION },
{"no-autoconnect", no_argument, 0, 'n' }, {"no-autoconnect", no_argument, 0, 'n' },
{"local-echo", no_argument, 0, 'e' }, {"local-echo", no_argument, 0, 'e' },
@ -274,9 +274,9 @@ void options_parse(int argc, char *argv[])
option.output_delay = string_to_long(optarg); option.output_delay = string_to_long(optarg);
break; break;
case 'O': case 'O':
option.eol_delay = string_to_long(optarg); option.eol_delay = string_to_long(optarg);
break; break;
case OPT_DTR_PULSE_DURATION: case OPT_DTR_PULSE_DURATION:
option.dtr_pulse_duration = string_to_long(optarg); option.dtr_pulse_duration = string_to_long(optarg);
@ -353,9 +353,9 @@ void options_parse(int argc, char *argv[])
option.hex_mode = true; option.hex_mode = true;
break; break;
case 'U': case 'U':
option.upcase = true; option.upcase = true;
break; break;
case 'v': case 'v':
printf("tio v%s\n", VERSION); printf("tio v%s\n", VERSION);
@ -384,7 +384,7 @@ void options_parse(int argc, char *argv[])
/* Assume first non-option is the tty device name */ /* Assume first non-option is the tty device name */
if (strcmp(option.tty_device, "")) if (strcmp(option.tty_device, ""))
optind++; optind++;
else if (optind < argc) else if (optind < argc)
option.tty_device = argv[optind++]; option.tty_device = argv[optind++];

View file

@ -152,11 +152,11 @@ ssize_t tty_write(int fd, const void *buffer, size_t count)
// Write byte by byte with output delay // Write byte by byte with output delay
for (size_t i=0; i<count; i++) for (size_t i=0; i<count; i++)
{ {
// convert alpha to upper case // convert alpha to upper case
if ( option.upcase ) if ( option.upcase )
{ {
*(unsigned char*)buffer = toupper(*(unsigned char*)buffer); *(unsigned char*)buffer = toupper(*(unsigned char*)buffer);
} }
ssize_t retval = write(fd, buffer, 1); ssize_t retval = write(fd, buffer, 1);
if (retval < 0) if (retval < 0)
{ {
@ -165,15 +165,15 @@ ssize_t tty_write(int fd, const void *buffer, size_t count)
break; break;
} }
bytes_written += retval; bytes_written += retval;
if ( option.eol_delay && *(unsigned char*)buffer == '\r' ) if ( option.eol_delay && *(unsigned char*)buffer == '\r' )
{ {
delay( option.eol_delay ); delay( option.eol_delay );
} }
fsync(fd); fsync(fd);
if ( option.output_delay ) if ( option.output_delay )
{ {
delay(option.output_delay); delay(option.output_delay);
} }
} }
} }
else else
@ -184,14 +184,14 @@ ssize_t tty_write(int fd, const void *buffer, size_t count)
tty_flush(fd); tty_flush(fd);
} }
// convert lower case to upper case, in situ // convert lower case to upper case, in situ
if ( option.upcase ) if ( option.upcase )
{ {
for ( size_t i = 0; i<count; i++ ) for ( size_t i = 0; i<count; i++ )
{ {
*((unsigned char*)buffer+i) = toupper(*((unsigned char*)buffer+i)); *((unsigned char*)buffer+i) = toupper(*((unsigned char*)buffer+i));
} }
} }
// Copy bytes to tty write buffer // Copy bytes to tty write buffer
memcpy(tty_buffer_write_ptr, buffer, count); memcpy(tty_buffer_write_ptr, buffer, count);
tty_buffer_write_ptr += count; tty_buffer_write_ptr += count;
@ -287,7 +287,7 @@ void handle_command_sequence(char input_char, char previous_char, char *output_c
tio_printf(" ctrl-t s Show statistics"); tio_printf(" ctrl-t s Show statistics");
tio_printf(" ctrl-t t Send ctrl-t key code"); tio_printf(" ctrl-t t Send ctrl-t key code");
tio_printf(" ctrl-t T Toggle line timestamp mode"); tio_printf(" ctrl-t T Toggle line timestamp mode");
tio_printf(" ctrl-t U Toggle upcase"); tio_printf(" ctrl-t U Toggle upcase");
tio_printf(" ctrl-t v Show version"); tio_printf(" ctrl-t v Show version");
break; break;
@ -397,16 +397,16 @@ void handle_command_sequence(char input_char, char previous_char, char *output_c
} }
break; break;
case KEY_U: case KEY_U:
if ( option.upcase == true ) if ( option.upcase == true )
{ {
option.upcase = false; option.upcase = false;
} }
else else
{ {
option.upcase = true; option.upcase = true;
} }
break; break;
case KEY_V: case KEY_V:
tio_printf("tio v%s", VERSION); tio_printf("tio v%s", VERSION);
@ -631,9 +631,9 @@ void tty_configure(void)
} }
else if ( strcmp("mark", option.parity) == 0) else if ( strcmp("mark", option.parity) == 0)
{ {
tio.c_cflag &= ~PARENB; tio.c_cflag &= ~PARENB;
tio.c_cflag |= PARODD; tio.c_cflag |= PARODD;
tio.c_cflag |= CMSPAR; tio.c_cflag |= CMSPAR;
} }
else else
{ {

View file

@ -1,2 +0,0 @@
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