diff --git a/src/configfile.h b/src/configfile.h index 8fbea07..6d0cc30 100644 --- a/src/configfile.h +++ b/src/configfile.h @@ -24,18 +24,18 @@ struct config_t { - const char *user; + const char *user; - char *path; - char *section_name; - char *match; + char *path; + char *section_name; + char *match; - char *tty; - char *flow; - char *parity; - char *log_filename; - char *socket; - char *map; + char *tty; + char *flow; + char *parity; + char *log_filename; + char *socket; + char *map; }; void config_file_print(void); diff --git a/src/error.c b/src/error.c index 43da8dd..dfe32aa 100644 --- a/src/error.c +++ b/src/error.c @@ -38,64 +38,64 @@ static bool in_session = false; void error_enter_session_mode(void) { - in_session = true; + in_session = true; } void error_printf_(const char *format, ...) { - va_list args; - char *line; + va_list args; + char *line; - va_start(args, format); - vasprintf(&line, format, args); + va_start(args, format); + vasprintf(&line, format, args); - if (in_session) - { - if (print_tainted) + if (in_session) { - putchar('\n'); + if (print_tainted) + { + putchar('\n'); + } + ansi_error_printf("[%s] %s", timestamp_current_time(), line); + } + else + { + fprintf(stderr, "%s\n", line); } - ansi_error_printf("[%s] %s", timestamp_current_time(), line); - } - else - { - fprintf(stderr, "%s\n", line); - } - va_end(args); + va_end(args); - print_tainted = false; - free(line); + print_tainted = false; + free(line); } void tio_error_printf(const char *format, ...) { - va_list args; + va_list args; - va_start(args, format); - vsnprintf(error[0], 1000, format, args); - va_end(args); + va_start(args, format); + vsnprintf(error[0], 1000, format, args); + va_end(args); } void tio_error_printf_silent(const char *format, ...) { - va_list args; + va_list args; - va_start(args, format); - vsnprintf(error[1], 1000, format, args); - va_end(args); + va_start(args, format); + vsnprintf(error[1], 1000, format, args); + va_end(args); } void error_exit(void) { - if (error[0][0] != 0) - { - /* Print error */ - error_printf_("Error: %s", error[0]); - } - else if ((error[1][0] != 0) && (option.no_autoconnect)) - { - /* Print silent error */ - error_printf_("Error: %s", error[1]); - } + if (error[0][0] != 0) + { + /* Print error */ + error_printf_("Error: %s", error[0]); + } + else if ((error[1][0] != 0) && (option.no_autoconnect)) + { + /* Print silent error */ + error_printf_("Error: %s", error[1]); + } } diff --git a/src/print.c b/src/print.c index cf130f0..b5ad48c 100644 --- a/src/print.c +++ b/src/print.c @@ -31,45 +31,45 @@ char ansi_format[30]; void print_hex(char c) { - printf("%02x ", (unsigned char) c); + printf("%02x ", (unsigned char) c); } void print_normal(char c) { - putchar(c); + putchar(c); } void print_init_ansi_formatting() { - if (option.color == 256) - { - // Set bold text with no color changes - sprintf(ansi_format, "\e[1m"); - } - else - { - // Set bold text with user defined ANSI color - sprintf(ansi_format, "\e[1;38;5;%dm", option.color); - } + if (option.color == 256) + { + // Set bold text with no color changes + sprintf(ansi_format, "\e[1m"); + } + else + { + // Set bold text with user defined ANSI color + sprintf(ansi_format, "\e[1;38;5;%dm", option.color); + } } void tio_printf_array(const char *array) { - int i = 0, j = 0; + int i = 0, j = 0; - tio_printf(""); + tio_printf(""); - while (array[i]) - { - if (array[i] == '\n') + while (array[i]) { - const char *line = &array[j]; - char *line_copy = strndup(line, i-j); - tio_printf_raw("%s\r", line_copy); - free(line_copy); - j = i; + if (array[i] == '\n') + { + const char *line = &array[j]; + char *line_copy = strndup(line, i-j); + tio_printf_raw("%s\r", line_copy); + free(line_copy); + j = i; + } + i++; } - i++; - } - tio_printf(""); + tio_printf(""); } diff --git a/src/print.h b/src/print.h index e3f6193..c870f17 100644 --- a/src/print.h +++ b/src/print.h @@ -35,72 +35,78 @@ extern char ansi_format[]; #define ansi_printf(format, args...) \ { \ - if (!option.mute) { \ - if (option.color < 0) \ - fprintf (stdout, "\r" format "\r\n", ## args); \ - else \ - fprintf (stdout, "\r%s" format ANSI_RESET "\r\n", ansi_format, ## args); \ - } \ + if (!option.mute) \ + { \ + if (option.color < 0) \ + fprintf (stdout, "\r" format "\r\n", ## args); \ + else \ + fprintf (stdout, "\r%s" format ANSI_RESET "\r\n", ansi_format, ## args); \ + } \ } #define ansi_error_printf(format, args...) \ { \ - if (!option.mute) { \ - if (option.color < 0) \ - fprintf (stderr, "\r" format "\r\n", ## args); \ - else \ - fprintf (stderr, "\r%s" format ANSI_RESET "\r\n", ansi_format, ## args); \ - fflush(stderr); \ - } \ + if (!option.mute) \ + { \ + if (option.color < 0) \ + fprintf (stderr, "\r" format "\r\n", ## args); \ + else \ + fprintf (stderr, "\r%s" format ANSI_RESET "\r\n", ansi_format, ## args); \ + fflush(stderr); \ + } \ } #define ansi_printf_raw(format, args...) \ { \ - if (!option.mute) { \ - if (option.color < 0) \ - fprintf (stdout, format, ## args); \ - else \ - fprintf (stdout, "%s" format ANSI_RESET, ansi_format, ## args); \ - } \ + if (!option.mute) \ + { \ + if (option.color < 0) \ + fprintf (stdout, format, ## args); \ + else \ + fprintf (stdout, "%s" format ANSI_RESET, ansi_format, ## args); \ + } \ } #define tio_warning_printf(format, args...) \ { \ - if (!option.mute) { \ - if (print_tainted) \ - putchar('\n'); \ - if (option.color < 0) \ - fprintf (stdout, "\r[%s] Warning: " format "\r\n", timestamp_current_time(), ## args); \ - else \ - ansi_printf("[%s] Warning: " format, timestamp_current_time(), ## args); \ - } \ + if (!option.mute) \ + { \ + if (print_tainted) \ + putchar('\n'); \ + if (option.color < 0) \ + fprintf (stdout, "\r[%s] Warning: " format "\r\n", timestamp_current_time(), ## args); \ + else \ + ansi_printf("[%s] Warning: " format, timestamp_current_time(), ## args); \ + } \ } #define tio_printf(format, args...) \ { \ - if (!option.mute) { \ - if (print_tainted) \ - putchar('\n'); \ - ansi_printf("[%s] " format, timestamp_current_time(), ## args); \ - print_tainted = false; \ - } \ + if (!option.mute) \ + { \ + if (print_tainted) \ + putchar('\n'); \ + ansi_printf("[%s] " format, timestamp_current_time(), ## args); \ + print_tainted = false; \ + } \ } #define tio_printf_raw(format, args...) \ { \ - if (!option.mute) { \ - if (print_tainted) \ - putchar('\n'); \ - ansi_printf_raw("[%s] " format, timestamp_current_time(), ## args); \ - print_tainted = false; \ - } \ + if (!option.mute) \ + { \ + if (print_tainted) \ + putchar('\n'); \ + ansi_printf_raw("[%s] " format, timestamp_current_time(), ## args); \ + print_tainted = false; \ + } \ } #ifdef DEBUG #define tio_debug_printf(format, args...) \ - fprintf (stdout, "[debug] " format, ## args) + fprintf(stdout, "[debug] " format, ## args) #define tio_debug_printf_raw(format, args...) \ - fprintf (stdout, "" format, ## args) + fprintf(stdout, "" format, ## args) #else #define tio_debug_printf(format, args...) #define tio_debug_printf_raw(format, args...)