switch is_gzip from short to bool

pull/2075/head
Gabriele Gristina 5 years ago
parent 481c752456
commit c2e634c426

@ -999,7 +999,7 @@ typedef struct hc_fp
gzFile gfp;
} f;
short is_gzip;
bool is_gzip;
const char *path;
char *mode;
} HCFILE;

@ -526,8 +526,7 @@ static bool write_kernel_binary (hashcat_ctx_t *hashcat_ctx, char *kernel_file,
return false;
}
// set gzip to false
fp.is_gzip = 0;
fp.is_gzip = false;
// if (lock_file (fp) == -1)
if (lock_file (fp.f.fp) == -1)

@ -1680,8 +1680,7 @@ bool brain_server_write_hash_dump (brain_server_db_hash_t *brain_server_db_hash,
}
else
{
// force gzip to false
fp.is_gzip = 0;
fp.is_gzip = false;
// const size_t nwrite = fwrite (brain_server_db_hash->long_buf, sizeof (brain_server_hash_long_t), brain_server_db_hash->long_cnt, fd);
const size_t nwrite = hc_fwrite (brain_server_db_hash->long_buf, sizeof (brain_server_hash_long_t), brain_server_db_hash->long_cnt, &fp);
@ -1893,8 +1892,7 @@ bool brain_server_write_attack_dump (brain_server_db_attack_t *brain_server_db_a
}
else
{
// force gzip to false
fp.is_gzip = 0;
fp.is_gzip = false;
// storing should not include reserved attacks only finished

@ -123,8 +123,7 @@ int debugfile_init (hashcat_ctx_t *hashcat_ctx)
return -1;
}
// force gzip to false
fp.is_gzip = 0;
fp.is_gzip = false;
// if (lock_file (fp) == -1)
if (lock_file (fp.f.fp) == -1)
@ -143,7 +142,7 @@ int debugfile_init (hashcat_ctx_t *hashcat_ctx)
else
{
HCFILE fp_tmp;
fp_tmp.is_gzip = 0;
fp_tmp.is_gzip = false;
fp_tmp.f.fp = stdout;
// debugfile_ctx->fp = stdout;

@ -203,7 +203,7 @@ int dictstat_write (hashcat_ctx_t *hashcat_ctx)
return -1;
}
fp.is_gzip = 0;
fp.is_gzip = false;
// if (lock_file (fp) == -1)
if (lock_file (fp.f.fp) == -1)

@ -198,7 +198,7 @@ int save_hash (hashcat_ctx_t *hashcat_ctx)
return -1;
}
fp.is_gzip = 0;
fp.is_gzip = false;
// if (lock_file (fp) == -1)
if (lock_file (fp.f.fp) == -1)

@ -54,7 +54,7 @@ void logfile_append (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...)
return;
}
fp.is_gzip = 0;
fp.is_gzip = false;
// lock_file (fp);
lock_file (fp.f.fp);

@ -119,7 +119,7 @@ int loopback_write_open (hashcat_ctx_t *hashcat_ctx)
return -1;
}
fp.is_gzip = 0;
fp.is_gzip = false;
// loopback_ctx->fp = fp;
loopback_ctx->fp = &fp;

@ -163,7 +163,7 @@ static void main_log_advice (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUS
if (user_options->advice_disable == true) return;
HCFILE fp;
fp.is_gzip = 0;
fp.is_gzip = false;
fp.f.fp = stdout;
// main_log (hashcat_ctx, stdout, LOGLEVEL_ADVICE);
@ -173,7 +173,7 @@ static void main_log_advice (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUS
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;
fp.is_gzip = 0;
fp.is_gzip = false;
fp.f.fp = stdout;
// main_log (hashcat_ctx, stdout, LOGLEVEL_INFO);
@ -183,7 +183,7 @@ static void main_log_info (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED
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;
fp.is_gzip = 0;
fp.is_gzip = false;
fp.f.fp = stdout;
// main_log (hashcat_ctx, stdout, LOGLEVEL_WARNING);
@ -193,7 +193,7 @@ static void main_log_warning (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNU
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;
fp.is_gzip = 0;
fp.is_gzip = false;
fp.f.fp = stderr;
// main_log (hashcat_ctx, stderr, LOGLEVEL_ERROR);

@ -401,7 +401,7 @@ int outfile_write_open (hashcat_ctx_t *hashcat_ctx)
return -1;
}
fp.is_gzip = 0;
fp.is_gzip = false;
// if (lock_file (fp) == -1)
if (lock_file (fp.f.fp) == -1)

@ -167,7 +167,7 @@ static int write_pidfile (hashcat_ctx_t *hashcat_ctx)
return -1;
}
fp.is_gzip = 0;
fp.is_gzip = false;
hc_fwrite (pd, sizeof (pidfile_data_t), 1, &fp);

@ -222,10 +222,7 @@ int potfile_write_open (hashcat_ctx_t *hashcat_ctx)
return -1;
}
// fp->is_gzip = 0;
potfile_ctx->fp = fp;
// potfile_ctx->fp = &fp;
return 0;
}
@ -530,7 +527,7 @@ int potfile_remove_parse (hashcat_ctx_t *hashcat_ctx)
// workaround for new fgetl
HCFILE fp;
fp.is_gzip = 0;
fp.is_gzip = false;
fp.f.fp = potfile_ctx->fp;
while (!feof (potfile_ctx->fp))

@ -223,7 +223,7 @@ static int write_restore (hashcat_ctx_t *hashcat_ctx)
return -1;
}
fp.is_gzip = 0;
fp.is_gzip = false;
// if (setvbuf (fp, NULL, _IONBF, 0))
if (setvbuf (fp.f.fp, NULL, _IONBF, 0))

@ -618,7 +618,7 @@ bool hc_fopen (HCFILE *fp, const char *path, char *mode)
check[1] = fgetc (fp_tmp);
check[2] = fgetc (fp_tmp);
fp->is_gzip = -1;
fp->is_gzip = false;
if (check[0] == 0x1f && check[1] == 0x8b && check[2] == 0x08)
{
@ -626,15 +626,13 @@ bool hc_fopen (HCFILE *fp, const char *path, char *mode)
if (!(fp->f.gfp = gzopen (path, mode))) return false;
fp->is_gzip = 1;
fp->is_gzip = true;
}
else
{
fp->f.fp = fp_tmp;
rewind (fp->f.fp);
fp->is_gzip = 0;
}
fp->path = path;
@ -647,7 +645,7 @@ size_t hc_fread (void *ptr, size_t size, size_t nmemb, HCFILE *fp)
{
size_t n = 0;
if (fp == NULL || fp->is_gzip == -1) return -1;
if (fp == NULL) return -1;
if (fp->is_gzip)
n = gzfread (ptr, size, nmemb, fp->f.gfp);
@ -661,7 +659,7 @@ size_t hc_fwrite (void *ptr, size_t size, size_t nmemb, HCFILE *fp)
{
size_t n = 0;
if (fp == NULL || fp->is_gzip == -1) return -1;
if (fp == NULL) return -1;
if (fp->is_gzip)
n = gzfwrite (ptr, size, nmemb, fp->f.gfp);
@ -677,7 +675,7 @@ int hc_fseek (HCFILE *fp, off_t offset, int whence)
{
int r = 0;
if (fp == NULL || fp->is_gzip == -1) return -1;
if (fp == NULL) return -1;
if (fp->is_gzip)
r = gzseek (fp->f.gfp, (z_off_t) offset, whence);
@ -689,7 +687,7 @@ int hc_fseek (HCFILE *fp, off_t offset, int whence)
void hc_rewind (HCFILE *fp)
{
if (fp == NULL || fp->is_gzip == -1) return;
if (fp == NULL) return;
if (fp->is_gzip)
gzrewind (fp->f.gfp);
@ -701,7 +699,7 @@ off_t hc_ftell (HCFILE *fp)
{
off_t n = 0;
if (fp == NULL || fp->is_gzip == -1) return -1;
if (fp == NULL) return -1;
if (fp->is_gzip)
n = (off_t) gztell (fp->f.gfp);
@ -715,7 +713,7 @@ int hc_fputc (int c, HCFILE *fp)
{
int r = 0;
if (fp == NULL || fp->is_gzip == -1) return -1;
if (fp == NULL) return -1;
if (fp->is_gzip)
r = gzputc (fp->f.gfp, c);
@ -729,7 +727,7 @@ int hc_fgetc (HCFILE *fp)
{
int r = 0;
if (fp == NULL || fp->is_gzip == -1) return -1;
if (fp == NULL) return -1;
if (fp->is_gzip)
r = gzgetc (fp->f.gfp);
@ -743,7 +741,7 @@ char *hc_fgets (char *buf, int len, HCFILE *fp)
{
char *r = NULL;
if (fp == NULL || fp->is_gzip == -1) return NULL;
if (fp == NULL) return NULL;
if (fp->is_gzip)
r = gzgets (fp->f.gfp, buf, len);
@ -757,7 +755,7 @@ int hc_vfprintf (HCFILE *fp, const char *format, va_list ap)
{
int r = -1;
if (fp == NULL || fp->is_gzip == -1) return -1;
if (fp == NULL) return -1;
if (fp->is_gzip)
r = gzvprintf (fp->f.gfp, format, ap);
@ -772,7 +770,7 @@ int hc_fprintf (HCFILE *fp, const char *format, ...)
va_list ap;
int r = -1;
if (fp == NULL || fp->is_gzip == -1) return -1;
if (fp == NULL) return -1;
va_start (ap, format);
@ -788,7 +786,7 @@ int hc_fprintf (HCFILE *fp, const char *format, ...)
int hc_fscanf (HCFILE *fp, const char *format, void *ptr)
{
if (fp == NULL || fp->is_gzip == -1) return -1;
if (fp == NULL) return -1;
char *buf = (char *) hcmalloc (HCBUFSIZ_TINY);
@ -814,7 +812,7 @@ int hc_fileno (HCFILE *fp)
{
int r = -1;
if (fp == NULL || fp->is_gzip == -1) return -1;
if (fp == NULL) return -1;
if (fp->is_gzip)
{
@ -834,7 +832,7 @@ int hc_feof (HCFILE *fp)
{
int r = -1;
if (fp == NULL || fp->is_gzip == -1) return -1;
if (fp == NULL) return -1;
if (fp->is_gzip)
r = gzeof (fp->f.gfp);
@ -846,7 +844,7 @@ int hc_feof (HCFILE *fp)
void hc_fflush (HCFILE *fp)
{
if (fp == NULL || fp->is_gzip == -1) return;
if (fp == NULL) return;
if (fp->is_gzip)
gzflush (fp->f.gfp, Z_SYNC_FLUSH);
@ -856,7 +854,7 @@ void hc_fflush (HCFILE *fp)
void hc_fclose (HCFILE *fp)
{
if (fp == NULL || fp->is_gzip == -1) return;
if (fp == NULL) return;
if (fp->is_gzip)
gzclose (fp->f.gfp);

@ -62,7 +62,7 @@ int process_stdout (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param,
out_t out;
HCFILE fp_tmp;
fp_tmp.is_gzip = 0;
fp_tmp.is_gzip = false;
fp_tmp.f.fp = stdout;
// out.fp = stdout;
@ -85,7 +85,7 @@ int process_stdout (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param,
return -1;
}
fp.is_gzip = 0;
fp.is_gzip = false;
// if (lock_file (fp) == -1)
if (lock_file (fp.f.fp) == -1)

Loading…
Cancel
Save