// initialize the multi logfile
void multi_log_init()
{
	if (logfile_init(LOGFILE_MULTI_LOG)) {
		multi_log_write_header();

		// initialize our timer info
		Multi_log_open_systime = (int) time(NULL);
		Multi_log_update_systime = Multi_log_open_systime;
	} 
}
Exemple #2
0
main()
{
    logfile_type lf;
    logfile_init(&lf,"logfile.log");
    logfile_print(&lf,"Testando %d",123);
    printf("Espere um tempo e entre com um numero: ");
    getchar();
    logfile_print(&lf,"Testando %d",456);
    logfile_print(&lf,"Testando %d",457);
    logfile_print(&lf,"Testando %d",458);
    logfile_print(&lf,"Testando %d",459);
    logfile_close(&lf);
}
int main(){
	cgi_init();
	cgi_session_start();
	cgi_process_form();
	
	int start = atoi(cgi_param("start"));
	
	char *h = charmalloc(100);
	char *u = charmalloc(100);
	char *p = charmalloc(100);
	char *d = charmalloc(100);
	char *fl = charmalloc(100);

	getvarconf("MYSQL_HOST",&h);
	getvarconf("MYSQL_USER",&u);
	getvarconf("MYSQL_PASS",&p);
	getvarconf("MYSQL_DB",&d);
	
	getvarconf("ACCESSWEBLOG", &fl);
	
	logfile_init(fl);
	
	logerror(__FILE__,__LINE__,"Init ");
	if(start == 1)
	{
		puts("Content-Type: text/plain");
		puts("");
		MYSQL *connect;		
		connect = mysql_init(NULL);		
		if(!mysql_real_connect(connect, h, u, p, d, MYSQL_PORT, NULL, 0))
		{
			logerror(__FILE__,__LINE__,"Error Mysql: %s",mysql_error(connect));
			exit(1);
		}
		long double totaleconomy = 0;
		long double totalhits = 0;
		long double totalcount = 0;
		long double totalsize = 0;
		char pet[350];
		char coma = ' ';
		strcpy(pet,"select domain,COUNT(*) as files,sum(filesize) as size,sum(filesize*requested) as eco, sum(requested) as hits from haarp where deleted=0 and static=0 group by domain order by 1 DESC");	
		if(mysql_query(connect, pet))
		{
			logerror(__FILE__,__LINE__,"%s",mysql_error(connect));
			exit(1);
		}
		double percent;
		MYSQL_RES *res = mysql_store_result(connect);		
		MYSQL_ROW v;
		puts("{ data: [");
		while ( (v = mysql_fetch_row(res)) != NULL ) {
			if(atoi(v[2])) {
				percent=(atof(v[3])*100)/atof(v[2]);
			}
			else
				continue;
			printf("%c{domain : '%s', files: '%s', size : '%s', eco : '%s', hits : '%s', porc :'%0.2lf', active: '%d'}\n",coma,v[0],v[1],v[2],v[3],v[4],percent,getActive(v[0]));
			
			coma = ',';
			totaleconomy += atof(v[3]);
			totalhits += atof(v[4]);
			totalcount += atof(v[1]);
			totalsize += atof(v[2]);
		}
		mysql_close(connect);
		printf("%c{domain: 'Totales', files : '%.2Lf', size : '%.2Lf', eco: '%.2Lf', hits : '%.2Lf', porc : '%.2Lf', active: '1' }\n", coma, totalcount, totalsize, totaleconomy, totalhits, (totaleconomy/totalsize)*100.0);	
		puts("]");
		puts("}");
		return 1;
	}
	if(start == 2) //history HC, max and min date.
	{
		puts("Content-Type: text/plain");
		puts("");		
		int len = strlen(cgi_param("domain"));
		char  * domain = (char *)malloc(sizeof(char)*len+2);
		strcpy(domain,cgi_param("domain"));

		MYSQL *connect;
		connect = mysql_init(NULL);
		if(!mysql_real_connect(connect, h, u, p, d, MYSQL_PORT, NULL, 0))
		{
			printf("{success: false, errors: \"Error, mysql connect\"}");
			logerror(__FILE__,__LINE__,"Error Mysql: %s",mysql_error(connect));
			exit(1);
		}
		char pet[200];
		sprintf(pet,"select date(min(downloaded)), date(max(downloaded)) from haarp where domain=trim('%s')",domain);
		if(mysql_query(connect,pet))
		{
			printf("{success: false, errors: 'Error, mysql connect'}");
			logerror(__FILE__,__LINE__,"Error Mysql: %s",mysql_error(connect));
			exit(1);
		}
		MYSQL_RES * res = mysql_store_result(connect);		
		MYSQL_ROW r = mysql_fetch_row(res);
		printf("{success: true, min: '%s', max : '%s'}",r[0],r[1]);
		mysql_close(connect);
		free(domain);
	}
	if(start == 3) //history HC.
	{
		MYSQL *connect;
		connect = mysql_init(NULL);
		FILE *f = fopen("/tmp/t1","w");		
		puts("Content-Type: text/plain");
		puts("");
		if(!mysql_real_connect(connect, h, u, p, d, MYSQL_PORT, NULL, 0))
		{
			printf("{success :false, errors: 'Error, mysql connect'}");
			logerror(__FILE__,__LINE__,"Error Mysql: %s",mysql_error(connect));
			exit(1);
		}
		int len = strlen(cgi_param("data"));
		char * domain = (char*)malloc(sizeof(char)*(len+2));
		strcpy(domain,cgi_param("data"));
							
		len = strlen(cgi_param("fecha"));
		char * date = (char*)malloc(sizeof(char)*(len+2));
		strcpy(date,cgi_param("fecha"));
		//~ trim(date);		
		
		char pet[200];
		
		sprintf(pet,"select count(*), hour(downloaded) as hora from haarp where domain='%s' and date(downloaded)='%s' group by hora",domain,date);
		if(mysql_query(connect,pet))
		{
			printf("{success: false, errors: 'Error, mysql query'}");
			logerror(__FILE__,__LINE__,"Error Mysql: %s",mysql_error(connect));
			exit(1);
		}		
		MYSQL_RES *res = mysql_store_result(connect);
		MYSQL_ROW r;		
		lfiles_count *primer = NULL;
		lfiles_count *ultimo = NULL;
		while( (r = mysql_fetch_row(res)) != NULL )
		{
			lfiles_count *nodo = (lfiles_count *)malloc(sizeof(lfiles_count)*1);
			nodo->files = atoi(r[0]);
			nodo->hora = atoi(r[1]);
			fprintf(f,"(files) %d\n",nodo->hora);
			nodo->next = NULL;
			if(!primer)
			{
				primer = nodo;
				ultimo = nodo;
			}
			else
			{
				ultimo->next = nodo;
				ultimo = nodo;
			}
		}
		sprintf(pet,"select count(*),hour(last_request) as hora from haarp where domain='%s' and date(last_request)='%s' and requested>0 group by hora;",domain,date);
		if(mysql_query(connect,pet))
		{
			printf("{success: false, errors: 'Error, mysql query'}");
			logerror(__FILE__,__LINE__,"Error Mysql: %s",mysql_error(connect));
			exit(1);
		}
		res = mysql_store_result(connect);
		lfiles_count *primer1 = NULL;
		lfiles_count *ultimo1 = NULL;
		while( (r = mysql_fetch_row(res)) != NULL )
		{
			lfiles_count *nodo = (lfiles_count *)malloc(sizeof(lfiles_count)*1);
			nodo->files = atoi(r[0]);
			nodo->hora = atoi(r[1]);
			fprintf(f,"(hits) %d\n", nodo->hora);
			nodo->next = NULL;
			if(!primer1)
			{
				primer1 = nodo;
				ultimo1 = nodo;
			}
			else
			{
				ultimo1->next = nodo;
				ultimo1 = nodo;
			}
		}
		lfiles_count *nodo = primer;
		puts("{ data: [");
		char p = ' ';	
		int cont = 0;
		while(nodo)
		{
			lfiles_count *nodo1 = primer1;
			int entro = 0;	
			while(nodo1)
			{
				if(nodo->hora > nodo1->hora)
				{
					if(nodo1->hora > cont)
					{
						int i;
						for(i=cont;i<nodo1->hora;i++)
						{
							printf("%c{domain: '%s', cache: 0, hits: 0, date: '%d:00'}\n",p,domain,i);
							p = ',';
						}
						cont = ++i;
					}
					else
						cont++;
					printf("%c{domain: '%s', cache: 0, hits: %d, date: '%d:00'}\n",p,domain,nodo1->files,nodo1->hora);
					p = ',';
					primer1 = nodo1->next;
					free(nodo1);
					nodo1 = primer1;	
					continue;				
				}
				else if( nodo->hora == nodo1->hora )
				{
					if(nodo->hora > cont)
					{
						int i;
						for(i=cont;i<nodo->hora;i++)
						{
							printf("%c{domain: '%s', cache: 0, hits: 0, date: '%d:00'}\n",p,domain,i);
							p = ',';
						}
						cont = ++i;
					}
					else 
						cont++;				
					printf("%c{domain: '%s', cache: %d, hits: %d, date: '%d:00'}\n",p,domain,nodo->files,nodo1->files,nodo->hora);
					p = ',';
					primer1 = nodo1->next;
					free(nodo1);					
					entro = 1;
					break;
				}
				else 
				{
					if(nodo->hora > cont)
					{
						int i;
						for(i=cont;i<nodo->hora;i++)
						{
							printf("%c{domain: '%s', cache: 0, hits: 0, date: '%d:00'}\n",p,domain,i);
							p = ',';
						}
						cont = ++i;
					}
					else
						cont++;
			
					printf("%c{domain: '%s', cache: %d, hits: 0, date: '%d:00'}\n",p,domain,nodo->files,nodo->hora);
					p = ',';
					entro = 1;
					break;
				}
			}
			if(!entro)
			{
				if(nodo->hora > cont)
				{
					int i;
					for(i=cont;i<nodo->hora;i++)
					{
						printf("%c{domain: '%s', cache: 0, hits: 0, date: '%d:00'}\n",p,domain,i);
						p = ',';
					}
					cont = ++i;
				}
				else
					cont++;
				printf("%c{domain: '%s', cache: %d, hits: 0, date: '%d:00'}\n",p,domain,nodo->files,nodo->hora);
				p = ',';
			}
			nodo = nodo->next;
		}
		nodo = primer1;
		while(nodo)
		{

			if(nodo->hora > cont)
			{
				int i;
				for(i=cont;i<nodo->hora;i++)
				{
					printf("%c{domain: '%s', cache: 0, hits: 0, date: '%d:00'}\n",p,domain,i);
					p = ',';
				}
				cont = ++i;
			}
			else			
				cont++;
			printf("%c{domain: '%s', cache: 0, hits: %d, date: '%d:00'}\n",p,domain,nodo->files,nodo->hora);
			p = ',';
			nodo = nodo->next;
		}
		if(cont < 23)
		{
			int i;
			for(i=cont;i<=23;i++)
			{
				printf("%c{domain: '%s', cache: 0, hits: 0, date: '%d:00'}\n",p,domain,i);			
				p = ',';
			}
		}
		mysql_close(connect);
		puts("]}");
	}
	return 1;
}
Exemple #4
0
int main(int argc, char **argv)
{
  int xx, i;
#ifdef STOP_UAC
  int nvpair[2];
#endif
  char buf[520], s[25];
  FILE *f;
#ifndef ENABLE_STRIP
  struct rlimit cdlim;
#endif

  /* Don't allow Eggdrop to run as root. */
  if (((int) getuid() == 0) || ((int) geteuid() == 0))
    fatal("ERROR: Eggdrop will not run as root!", 0);

#ifndef ENABLE_STRIP
  cdlim.rlim_cur = RLIM_INFINITY;
  cdlim.rlim_max = RLIM_INFINITY;
  setrlimit(RLIMIT_CORE, &cdlim);
#endif

#include "patch.h"
  /* Version info! */
  egg_snprintf(ver, sizeof ver, "eggdrop v%s", egg_version);
  egg_snprintf(version, sizeof version,
               "Eggdrop v%s (C) 1997 Robey Pointer (C) 2005 Eggheads",
               egg_version);
  /* Now add on the patchlevel (for Tcl) */
  sprintf(&egg_version[strlen(egg_version)], " %u", egg_numver);
  strcat(egg_version, egg_xtra);

#ifdef STOP_UAC
  nvpair[0] = SSIN_UACPROC;
  nvpair[1] = UAC_NOPRINT;
  setsysinfo(SSI_NVPAIRS, (char *) nvpair, 1, NULL, 0);
#endif

  /* Set up error / signal traps. */
  setup_signal_traps();

  /* Initialize a few variables before main loop. */
  cache_miss = 0;
  cache_hit  = 0;
  chanset    = NULL;
  now        = time(NULL);

  egg_memcpy(&nowtm, localtime(&now), sizeof(struct tm));
  lastmin = nowtm.tm_min;

  /* Initialize random number generator. */
  srandom((unsigned int) (now % (getpid() + getppid())));

  init_mem();
  init_language(1);

  /* Process command line arguments. */
  process_args(argc, argv);

  printf("\n%s\n", version);

  init_dcc_max();
  init_userent();
  logfile_init(0);
  init_bots();
  init_net();
  init_modules();

  if (backgrd)
    bg_prepare_split();

  init_tcl(argc, argv);
  init_language(0);
  help_init();
  traffic_init();
  logfile_init(1);

#ifdef STATIC
  link_statics();
#endif

  strncpyz(s, ctime(&now), sizeof s);
  strcpy(&s[11], &s[20]);
  putlog(LOG_ALL, "*", "--- Loading %s (%s)", ver, s);

  /* Read configuration data. */
  readconfig();

  /* Check for encryption module. */
  if (!encrypt_pass) {
    printf(MOD_NOCRYPT);
    bg_send_quit(BG_ABORT);
    exit(1);
  }

  putlog(LOG_MISC, "*", "=== %s: %d channels, %d users.", botnetnick,
         count_channels(), count_users(userlist));

  if (!pid_file[0])
    egg_snprintf(pid_file, sizeof pid_file, "pid.%s", botnetnick);

  /* Check for pre-existing eggdrop! */
  f = fopen(pid_file, "r");
  if (f != NULL) {
    fgets(s, 10, f);
    xx = atoi(s);
    kill(xx, SIGCHLD); /* Meaningless kill to determine if PID is used. */
    if (errno != ESRCH) {
      printf(EGG_RUNNING1, botnetnick);
      printf(EGG_RUNNING2, pid_file);
      bg_send_quit(BG_ABORT);
      exit(1);
    }
  }

  /* Move into background? */
  if (backgrd) {
#ifndef CYGWIN_HACKS
    bg_do_split();
  }
  else {
#endif
    xx = getpid();
    if (xx != 0) {
      FILE *fp;

      /* Write PID to file. */
      unlink(pid_file);
      fp = fopen(pid_file, "w");
      if (fp != NULL) {
        fprintf(fp, "%u\n", xx);
        if (fflush(fp)) {
          /* Let the bot live since this doesn't appear to be a botchk. */
          printf("Cannot not write to '%s' (PID file).\n", pid_file);
          fclose(fp);
          unlink(pid_file);
        }
        else
          fclose(fp);
      }
      else
        printf("Cannot not write to '%s' (PID file).\n", pid_file);
#ifdef CYGWIN_HACKS
      printf("Launched into the background (PID: %d)\n\n", xx);
#endif
    }
  }

  use_stderr = 0;               /* Stop writing to stderr now */
  if (backgrd) {
    /* Ok, try to disassociate from controlling terminal (finger cross) */
#if defined(HAVE_SETPGID) && !defined(CYGWIN_HACKS)
    setpgid(0, 0);
#endif

    /* Tcl wants the stdin, stdout and stderr file handles kept open. */
    freopen("/dev/null", "r", stdin);
    freopen("/dev/null", "w", stdout);
    freopen("/dev/null", "w", stderr);

#ifdef CYGWIN_HACKS
    FreeConsole();
#endif
  }

  /* Terminal emulating dcc chat */
  if (!backgrd && term_z) {
    int n = new_dcc(&DCC_CHAT, sizeof(struct chat_info));

    dcc[n].addr = iptolong(getmyip());
    dcc[n].sock = STDOUT;
    dcc[n].timeval = now;
    dcc[n].u.chat->con_flags = conmask;
    dcc[n].u.chat->strip_flags = STRIP_ALL;
    dcc[n].status = STAT_ECHO;
    strcpy(dcc[n].nick, "HQ");
    strcpy(dcc[n].host, "llama@console");
    /* HACK: Workaround not to pass literal "HQ" as a non-const arg */
    dcc[n].user = get_user_by_handle(userlist, dcc[n].nick);
    /* Make sure there's an innocuous HQ user if needed */
    if (!dcc[n].user) {
      userlist = adduser(userlist, dcc[n].nick, "none", "-", USER_PARTY);
      dcc[n].user = get_user_by_handle(userlist, dcc[n].nick);
    }
    setsock(STDOUT, 0); /* Entry in net table */
    dprintf(n, "\n### ENTERING DCC CHAT SIMULATION ###\n\n");
    dcc_chatter(n);
  }

  then = now;
  online_since = now;
  autolink_cycle(NULL); /* Hurry and connect to tandem bots. */
  add_help_reference("cmds1.help");
  add_help_reference("cmds2.help");
  add_help_reference("core.help");

  /* Create hooks. */
  add_hook(HOOK_SECONDLY, (Function) core_secondly);
  add_hook(HOOK_MINUTELY, (Function) core_minutely);
  add_hook(HOOK_HOURLY, (Function) core_hourly);
  add_hook(HOOK_REHASH, (Function) event_rehash);
  add_hook(HOOK_PRE_REHASH, (Function) event_prerehash);
  add_hook(HOOK_USERFILE, (Function) event_save);
  add_hook(HOOK_BACKUP, (Function) backupuserfile);
  add_hook(HOOK_DAILY, (Function) event_logfile);
  add_hook(HOOK_DAILY, (Function) traffic_reset);
  add_hook(HOOK_LOADED, (Function) event_loaded);

  call_hook(HOOK_LOADED);

  debug0("main: entering loop");
  while (1) {
    int socket_cleanup = 0;

#ifdef USE_TCL_EVENTS
    /* Process a single Tcl event. */
    Tcl_DoOneEvent(TCL_ALL_EVENTS | TCL_DONT_WAIT);
#endif

    now = time(NULL);
    random();

    /* Every second... */
    if (now != then) {
      call_hook(HOOK_SECONDLY);
      then = now;
    }

    /* Only do this every so often. */
    if (!socket_cleanup) {
      socket_cleanup = 5;

      /* Remove dead dcc entries. */
      dcc_remove_lost();

      /* Check for server or dcc activity. */
      dequeue_sockets();
    }
    else {
      socket_cleanup--;
    }

    /* Free unused structures. */
    garbage_collect();

    xx = sockgets(buf, &i);
    if (xx >= 0) { /* Non-error */
      int idx;

      for (idx = 0; idx < dcc_total; idx++) {
        if (dcc[idx].sock != xx)
          continue;

        if (dcc[idx].type && dcc[idx].type->activity) {
          traffic_update_in(dcc[idx].type, (strlen(buf) + 1)); /* Traffic stats. */
          dcc[idx].type->activity(idx, buf, i);
        }
        else {
          putlog(LOG_MISC, "*", "!!! untrapped dcc activity: type %s, sock %d",
                 dcc[idx].type->name, dcc[idx].sock);
        }

        break;
      }
    }
    else if (xx == -1) { /* EOF */
      int idx;

      if (i == STDOUT && !backgrd)
        fatal("END OF FILE ON TERMINAL", 0);

      for (idx = 0; idx < dcc_total; idx++) {
        if (dcc[idx].sock != i)
          continue;

        if (dcc[idx].type && dcc[idx].type->eof) {
          dcc[idx].type->eof(idx);
        }
        else {
          putlog(LOG_MISC, "*",
                 "*** ATTENTION: DEAD SOCKET (%d) OF TYPE %s UNTRAPPED",
                 i, dcc[idx].type ? dcc[idx].type->name : "*UNKNOWN*");
          killsock(i);
          lostdcc(idx);
        }

        idx = dcc_total + 1;
      }

      if (idx == dcc_total) {
        putlog(LOG_MISC, "*",
               "(@) EOF socket %d, not a dcc socket, not anything.", i);
        close(i);
        killsock(i);
      }
    }
    else if (xx == -2 && errno != EINTR) { /* select() error */
      putlog(LOG_MISC, "*", "* Socket error #%d; recovering.", errno);
      for (i = 0; i < dcc_total; i++) {
        if ((fcntl(dcc[i].sock, F_GETFD, 0) == -1) && (errno == EBADF)) {
          putlog(LOG_MISC, "*",
                 "DCC socket %d (type %d, name '%s') expired -- pfft",
                 dcc[i].sock, dcc[i].type, dcc[i].nick);
          killsock(dcc[i].sock);
          lostdcc(i);
          i--;
        }
      }
    }
    else if (xx == -3) {
      call_hook(HOOK_IDLE);
      socket_cleanup = 0;       /* If we've been idle, cleanup & flush */
    }

    if (do_restart) {
      if (do_restart == -2) {
        rehash();
      }
      else {
        int f = 1;
        module_entry *p;
        Function startfunc;
        char name[256];


        check_tcl_event("prerestart");

        /* Unload as many modules as possible */
        while (f) {
          f = 0;

          for (p = module_list; p != NULL; p = p->next) {
            dependancy *d = dependancy_list;
            int ok = 1;

            while (ok && d) {
              if (d->needed == p)
                ok = 0;

              d = d->next;
            }
            if (ok) {
              strcpy(name, p->name);

              if (module_unload(name, botnetnick) == NULL) {
                f = 1;
                break;
              }
            }
          }
        }

        /* Make sure we don't have any modules left hanging around other than
         * "eggdrop" and the two that are supposed to be.
         */
        for (f = 0, p = module_list; p; p = p->next) {
          if (strcmp(p->name, "eggdrop") && strcmp(p->name, "encryption") &&
              strcmp(p->name, "uptime")) {
            f++;
          }
        }
        if (f != 0) {
          putlog(LOG_MISC, "*", MOD_STAGNANT);
        }

        /* Flush log files to disk. */
        flushlogs();

        /* Clean up Tcl stuff. */
        kill_tcl();

        /* Initialize stuff again. */
        init_tcl(argc, argv);
        init_language(0);
        help_init();
        traffic_init();
        logfile_init(1);

        /* This resets our modules which we didn't unload (encryption and uptime). */
        for (p = module_list; p; p = p->next) {
          if (p->funcs) {
            startfunc = p->funcs[MODCALL_START];
            startfunc(NULL);
          }
        }

        rehash();
        restart_chons();
        call_hook(HOOK_LOADED);
      }

      do_restart = 0;
    }
  }
}
Exemple #5
0
int hashcat_session_init (hashcat_ctx_t *hashcat_ctx, const char *install_folder, const char *shared_folder, int argc, char **argv, const int comptime)
{
  user_options_t *user_options = hashcat_ctx->user_options;

  /**
   * make it a bit more comfortable to use some of the special modes in hashcat
   */

  user_options_session_auto (hashcat_ctx);

  /**
   * event init (needed for logging so should be first)
   */

  const int rc_event_init = event_ctx_init (hashcat_ctx);

  if (rc_event_init == -1) return -1;

  /**
   * status init
   */

  const int rc_status_init = status_ctx_init (hashcat_ctx);

  if (rc_status_init == -1) return -1;

  /**
   * folder
   */

  const int rc_folder_config_init = folder_config_init (hashcat_ctx, install_folder, shared_folder);

  if (rc_folder_config_init == -1) return -1;

  /**
   * pidfile
   */

  const int rc_pidfile_init = pidfile_ctx_init (hashcat_ctx);

  if (rc_pidfile_init == -1) return -1;

  /**
   * restore
   */

  const int rc_restore_init = restore_ctx_init (hashcat_ctx, argc, argv);

  if (rc_restore_init == -1) return -1;

  /**
   * process user input
   */

  user_options_preprocess (hashcat_ctx);

  user_options_extra_init (hashcat_ctx);

  user_options_postprocess (hashcat_ctx);

  /**
   * logfile
   */

  const int rc_logfile_init = logfile_init (hashcat_ctx);

  if (rc_logfile_init == -1) return -1;

  /**
   * cpu affinity
   */

  const int rc_affinity = set_cpu_affinity (hashcat_ctx);

  if (rc_affinity == -1) return -1;

  /**
   * prepare seeding for random number generator, required by logfile and rules generator
   */

  setup_seeding (user_options->rp_gen_seed_chgd, user_options->rp_gen_seed);

  /**
   * To help users a bit
   */

  setup_environment_variables ();

  setup_umask ();

  /**
   * tuning db
   */

  const int rc_tuning_db = tuning_db_init (hashcat_ctx);

  if (rc_tuning_db == -1) return -1;

  /**
   * induction directory
   */

  const int rc_induct_ctx_init = induct_ctx_init (hashcat_ctx);

  if (rc_induct_ctx_init == -1) return -1;

  /**
   * outfile-check directory
   */

  const int rc_outcheck_ctx_init = outcheck_ctx_init (hashcat_ctx);

  if (rc_outcheck_ctx_init == -1) return -1;

  /**
   * outfile itself
   */

  const int rc_outfile_init = outfile_init (hashcat_ctx);

  if (rc_outfile_init == -1) return -1;

  /**
   * potfile init
   * this is only setting path because potfile can be used in read and write mode depending on user options
   * plus it depends on hash_mode, so we continue using it in outer_loop
   */

  const int rc_potfile_init = potfile_init (hashcat_ctx);

  if (rc_potfile_init == -1) return -1;

  /**
   * dictstat init
   */

  const int rc_dictstat_init = dictstat_init (hashcat_ctx);

  if (rc_dictstat_init == -1) return -1;

  /**
   * loopback init
   */

  const int rc_loopback_init = loopback_init (hashcat_ctx);

  if (rc_loopback_init == -1) return -1;

  /**
   * debugfile init
   */

  const int rc_debugfile_init = debugfile_init (hashcat_ctx);

  if (rc_debugfile_init == -1) return -1;

  /**
   * Try to detect if all the files we're going to use are accessible in the mode we want them
   */

  const int rc_user_options_check_files = user_options_check_files (hashcat_ctx);

  if (rc_user_options_check_files == -1) return -1;

  /**
   * Init OpenCL library loader
   */

  const int rc_opencl_init = opencl_ctx_init (hashcat_ctx);

  if (rc_opencl_init == -1) return -1;

  /**
   * Init OpenCL devices
   */

  const int rc_devices_init = opencl_ctx_devices_init (hashcat_ctx, comptime);

  if (rc_devices_init == -1) return -1;

  /**
   * HM devices: init
   */

  const int rc_hwmon_init = hwmon_ctx_init (hashcat_ctx);

  if (rc_hwmon_init == -1) return -1;

  // done

  return 0;
}