1
0
mirror of https://github.com/hashcat/hashcat.git synced 2024-11-26 18:08:20 +00:00

remove useless gzip handling in main_log_* functions

This commit is contained in:
Gabriele Gristina 2019-06-30 18:16:10 +02:00
parent 818837e665
commit e22e1c29b3

View File

@ -28,24 +28,24 @@
int _dowildcard = -1; int _dowildcard = -1;
#endif #endif
static void main_log_clear_line (MAYBE_UNUSED const size_t prev_len, MAYBE_UNUSED HCFILE *fp) static void main_log_clear_line (MAYBE_UNUSED const size_t prev_len, MAYBE_UNUSED FILE *fp)
{ {
#if defined (_WIN) #if defined (_WIN)
hc_fputc ('\r', fp); fputc ('\r', fp);
for (size_t i = 0; i < prev_len; i++) hc_fputc (' ', fp); for (size_t i = 0; i < prev_len; i++) fputc (' ', fp);
hc_fputc ('\r', fp); fputc ('\r', fp);
#else #else
hc_fprintf(fp, "\033[2K\r"); fputs ("\033[2K\r", fp);
#endif #endif
} }
static void main_log (hashcat_ctx_t *hashcat_ctx, HCFILE *fp, const int loglevel) static void main_log (hashcat_ctx_t *hashcat_ctx, FILE *fp, const int loglevel)
{ {
event_ctx_t *event_ctx = hashcat_ctx->event_ctx; event_ctx_t *event_ctx = hashcat_ctx->event_ctx;
@ -57,19 +57,9 @@ static void main_log (hashcat_ctx_t *hashcat_ctx, HCFILE *fp, const int loglevel
const size_t prev_len = event_ctx->prev_len; const size_t prev_len = event_ctx->prev_len;
if (prev_len) if (prev_len) main_log_clear_line (prev_len, fp);
{
main_log_clear_line (prev_len, fp);
}
if (msg_newline == true) event_ctx->prev_len = (msg_newline == true) ? 0 : msg_len;
{
event_ctx->prev_len = 0;
}
else
{
event_ctx->prev_len = msg_len;
}
// color stuff pre // color stuff pre
@ -98,15 +88,15 @@ static void main_log (hashcat_ctx_t *hashcat_ctx, HCFILE *fp, const int loglevel
switch (loglevel) switch (loglevel)
{ {
case LOGLEVEL_INFO: break; case LOGLEVEL_INFO: break;
case LOGLEVEL_WARNING: hc_fwrite ("\033[33m", 5, 1, fp); break; case LOGLEVEL_WARNING: fwrite ("\033[33m", 5, 1, fp); break;
case LOGLEVEL_ERROR: hc_fwrite ("\033[31m", 5, 1, fp); break; case LOGLEVEL_ERROR: fwrite ("\033[31m", 5, 1, fp); break;
case LOGLEVEL_ADVICE: hc_fwrite ("\033[33m", 5, 1, fp); break; case LOGLEVEL_ADVICE: fwrite ("\033[33m", 5, 1, fp); break;
} }
#endif #endif
// finally, print // finally, print
hc_fwrite ((void *)msg_buf, msg_len, 1, fp); fwrite (msg_buf, msg_len, 1, fp);
// color stuff post // color stuff post
@ -122,9 +112,9 @@ static void main_log (hashcat_ctx_t *hashcat_ctx, HCFILE *fp, const int loglevel
switch (loglevel) switch (loglevel)
{ {
case LOGLEVEL_INFO: break; case LOGLEVEL_INFO: break;
case LOGLEVEL_WARNING: hc_fwrite ("\033[0m", 4, 1, fp); break; case LOGLEVEL_WARNING: fwrite ("\033[0m", 4, 1, fp); break;
case LOGLEVEL_ERROR: hc_fwrite ("\033[0m", 4, 1, fp); break; case LOGLEVEL_ERROR: fwrite ("\033[0m", 4, 1, fp); break;
case LOGLEVEL_ADVICE: hc_fwrite ("\033[0m", 4, 1, fp); break; case LOGLEVEL_ADVICE: fwrite ("\033[0m", 4, 1, fp); break;
} }
#endif #endif
@ -132,17 +122,17 @@ static void main_log (hashcat_ctx_t *hashcat_ctx, HCFILE *fp, const int loglevel
if (msg_newline == true) if (msg_newline == true)
{ {
hc_fwrite (EOL, strlen (EOL), 1, fp); fwrite (EOL, strlen (EOL), 1, fp);
// on error, add another newline // on error, add another newline
if (loglevel == LOGLEVEL_ERROR) if (loglevel == LOGLEVEL_ERROR)
{ {
hc_fwrite (EOL, strlen (EOL), 1, fp); fwrite (EOL, strlen (EOL), 1, fp);
} }
} }
hc_fflush (fp); fflush (fp);
} }
static void main_log_advice (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) static void main_log_advice (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
@ -151,38 +141,22 @@ static void main_log_advice (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUS
if (user_options->advice_disable == true) return; if (user_options->advice_disable == true) return;
HCFILE fp; main_log (hashcat_ctx, stdout, LOGLEVEL_ADVICE);
fp.is_gzip = false;
fp.pfp = stdout;
main_log (hashcat_ctx, &fp, LOGLEVEL_ADVICE);
} }
static void main_log_info (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) static void main_log_info (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
{ {
HCFILE fp; main_log (hashcat_ctx, stdout, LOGLEVEL_INFO);
fp.is_gzip = false;
fp.pfp = stdout;
main_log (hashcat_ctx, &fp, LOGLEVEL_INFO);
} }
static void main_log_warning (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) static void main_log_warning (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
{ {
HCFILE fp; main_log (hashcat_ctx, stdout, LOGLEVEL_WARNING);
fp.is_gzip = false;
fp.pfp = stdout;
main_log (hashcat_ctx, &fp, LOGLEVEL_WARNING);
} }
static void main_log_error (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) static void main_log_error (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
{ {
HCFILE fp; main_log (hashcat_ctx, stderr, LOGLEVEL_ERROR);
fp.is_gzip = false;
fp.pfp = stderr;
main_log (hashcat_ctx, &fp, LOGLEVEL_ERROR);
} }
static void main_outerloop_starting (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) static void main_outerloop_starting (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)