1
0
mirror of https://github.com/hashcat/hashcat.git synced 2024-11-22 16:18:09 +00:00

Get rid of exit() in hashcat.c

This commit is contained in:
jsteube 2016-10-12 14:56:53 +02:00
parent 690ca0219e
commit 62284f79b1
3 changed files with 9 additions and 5 deletions

View File

@ -6,9 +6,9 @@
#ifndef _HASHCAT_H
#define _HASHCAT_H
int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_folder, int argc, char **argv, const int comptime);
int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_folder, int argc, char **argv, const int comptime);
void hashcat_ctx_init (hashcat_ctx_t *hashcat_ctx, void (*event) (const u32, struct hashcat_ctx *, const void *, const size_t));
int hashcat_ctx_init (hashcat_ctx_t *hashcat_ctx, void (*event) (const u32, struct hashcat_ctx *, const void *, const size_t));
void hashcat_ctx_destroy (hashcat_ctx_t *hashcat_ctx);
#endif // _HASHCAT_H

View File

@ -55,13 +55,13 @@
extern const u32 DEFAULT_BENCHMARK_ALGORITHMS_CNT;
extern const u32 DEFAULT_BENCHMARK_ALGORITHMS_BUF[];
void hashcat_ctx_init (hashcat_ctx_t *hashcat_ctx, void (*event) (const u32, struct hashcat_ctx *, const void *, const size_t))
int hashcat_ctx_init (hashcat_ctx_t *hashcat_ctx, void (*event) (const u32, struct hashcat_ctx *, const void *, const size_t))
{
if (event == NULL)
{
fprintf (stderr, "Event callback function is mandatory\n");
exit (-1);
return -1;
}
hashcat_ctx->event = event;
@ -92,6 +92,8 @@ void hashcat_ctx_init (hashcat_ctx_t *hashcat_ctx, void (*event) (const u32, str
hashcat_ctx->user_options_extra = (user_options_extra_t *) hcmalloc (hashcat_ctx, sizeof (user_options_extra_t));
hashcat_ctx->user_options = (user_options_t *) hcmalloc (hashcat_ctx, sizeof (user_options_t));
hashcat_ctx->wl_data = (wl_data_t *) hcmalloc (hashcat_ctx, sizeof (wl_data_t));
return 0;
}
void hashcat_ctx_destroy (hashcat_ctx_t *hashcat_ctx)

View File

@ -489,7 +489,9 @@ int main (int argc, char **argv)
hashcat_ctx_t *hashcat_ctx = (hashcat_ctx_t *) malloc (sizeof (hashcat_ctx_t));
hashcat_ctx_init (hashcat_ctx, event);
const int rc_hashcat_init = hashcat_ctx_init (hashcat_ctx, event);
if (rc_hashcat_init == -1) return -1;
// initialize the session via getops for commandline use or
// alternatively you can set the user_options directly