mirror of
https://github.com/hashcat/hashcat.git
synced 2025-04-07 18:25:42 +00:00
Get rid of outfile, outfile_format, outfile_autohex, outfile_check_timer variable in main
This commit is contained in:
parent
32d44a5f3e
commit
f5e5dc8ab3
@ -19,7 +19,7 @@ typedef enum outfile_fmt
|
||||
|
||||
} outfile_fmt_t;
|
||||
|
||||
void outfile_init (outfile_ctx_t *outfile_ctx, char *outfile, const uint outfile_format, const uint outfile_autohex);
|
||||
void outfile_init (outfile_ctx_t *outfile_ctx, const user_options_t *user_options);
|
||||
void outfile_destroy (outfile_ctx_t *outfile_ctx);
|
||||
void outfile_format_plain (outfile_ctx_t *outfile_ctx, const unsigned char *plain_ptr, const uint plain_len);
|
||||
void outfile_write_open (outfile_ctx_t *outfile_ctx);
|
||||
|
@ -102,7 +102,6 @@ extern const int DEFAULT_BENCHMARK_ALGORITHMS_BUF[];
|
||||
|
||||
const int comptime = COMPTIME;
|
||||
|
||||
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
#if defined (_WIN)
|
||||
@ -401,10 +400,6 @@ int main (int argc, char **argv)
|
||||
|
||||
// temporarily start
|
||||
|
||||
char *outfile = NULL;
|
||||
uint outfile_format = OUTFILE_FORMAT;
|
||||
uint outfile_autohex = OUTFILE_AUTOHEX;
|
||||
uint outfile_check_timer = OUTFILE_CHECK_TIMER;
|
||||
uint status = STATUS;
|
||||
uint loopback = LOOPBACK;
|
||||
uint weak_hash_threshold = WEAK_HASH_THRESHOLD;
|
||||
@ -422,10 +417,6 @@ int main (int argc, char **argv)
|
||||
if (1)
|
||||
{
|
||||
loopback = user_options->loopback;
|
||||
outfile_autohex = user_options->outfile_autohex;
|
||||
outfile_check_timer = user_options->outfile_check_timer;
|
||||
outfile_format = user_options->outfile_format;
|
||||
outfile = user_options->outfile;
|
||||
powertune_enable = user_options->powertune_enable;
|
||||
rp_gen_func_max = user_options->rp_gen_func_max;
|
||||
rp_gen_func_min = user_options->rp_gen_func_min;
|
||||
@ -631,7 +622,7 @@ int main (int argc, char **argv)
|
||||
{
|
||||
outfile_check_directory = (char *) mymalloc (HCBUFSIZ_TINY);
|
||||
|
||||
snprintf (outfile_check_directory, HCBUFSIZ_TINY - 1, "%s/%s.%s", session_dir, session, OUTFILES_DIR);
|
||||
snprintf (outfile_check_directory, HCBUFSIZ_TINY - 1, "%s/%s.%s", session_dir, user_options->session, OUTFILES_DIR);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -887,7 +878,7 @@ int main (int argc, char **argv)
|
||||
|
||||
data.outfile_ctx = outfile_ctx;
|
||||
|
||||
outfile_init (outfile_ctx, outfile, outfile_format, outfile_autohex);
|
||||
outfile_init (outfile_ctx, user_options);
|
||||
|
||||
/**
|
||||
* Sanity check for hashfile vs outfile (should not point to the same physical file)
|
||||
@ -2864,7 +2855,7 @@ int main (int argc, char **argv)
|
||||
|
||||
inner_threads_cnt++;
|
||||
|
||||
if (outfile_check_timer != 0)
|
||||
if (user_options->outfile_check_timer != 0)
|
||||
{
|
||||
if (data.outfile_check_directory != NULL)
|
||||
{
|
||||
@ -2879,17 +2870,17 @@ int main (int argc, char **argv)
|
||||
}
|
||||
else
|
||||
{
|
||||
outfile_check_timer = 0;
|
||||
user_options->outfile_check_timer = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
outfile_check_timer = 0;
|
||||
user_options->outfile_check_timer = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
data.outfile_check_timer = outfile_check_timer;
|
||||
data.outfile_check_timer = user_options->outfile_check_timer;
|
||||
|
||||
/**
|
||||
* main loop
|
||||
|
@ -10,9 +10,9 @@
|
||||
#include "hash_management.h"
|
||||
#include "outfile.h"
|
||||
|
||||
void outfile_init (outfile_ctx_t *outfile_ctx, char *outfile, const uint outfile_format, const uint outfile_autohex)
|
||||
void outfile_init (outfile_ctx_t *outfile_ctx, const user_options_t *user_options)
|
||||
{
|
||||
if (outfile == NULL)
|
||||
if (user_options->outfile == NULL)
|
||||
{
|
||||
outfile_ctx->fp = stdout;
|
||||
outfile_ctx->filename = NULL;
|
||||
@ -20,11 +20,11 @@ void outfile_init (outfile_ctx_t *outfile_ctx, char *outfile, const uint outfile
|
||||
else
|
||||
{
|
||||
outfile_ctx->fp = NULL;
|
||||
outfile_ctx->filename = outfile;
|
||||
outfile_ctx->filename = user_options->outfile;
|
||||
}
|
||||
|
||||
outfile_ctx->outfile_format = outfile_format;
|
||||
outfile_ctx->outfile_autohex = outfile_autohex;
|
||||
outfile_ctx->outfile_format = user_options->outfile_format;
|
||||
outfile_ctx->outfile_autohex = user_options->outfile_autohex;
|
||||
}
|
||||
|
||||
void outfile_destroy (outfile_ctx_t *outfile_ctx)
|
||||
@ -37,29 +37,29 @@ void outfile_destroy (outfile_ctx_t *outfile_ctx)
|
||||
|
||||
void outfile_format_plain (outfile_ctx_t *outfile_ctx, const unsigned char *plain_ptr, const uint plain_len)
|
||||
{
|
||||
int needs_hexify = 0;
|
||||
bool needs_hexify = false;
|
||||
|
||||
if (outfile_ctx->outfile_autohex == 1)
|
||||
if (outfile_ctx->outfile_autohex == true)
|
||||
{
|
||||
for (uint i = 0; i < plain_len; i++)
|
||||
{
|
||||
if (plain_ptr[i] < 0x20)
|
||||
{
|
||||
needs_hexify = 1;
|
||||
needs_hexify = true;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (plain_ptr[i] > 0x7f)
|
||||
{
|
||||
needs_hexify = 1;
|
||||
needs_hexify = true;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (needs_hexify == 1)
|
||||
if (needs_hexify == true)
|
||||
{
|
||||
fprintf (outfile_ctx->fp, "$HEX[");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user