int dynamic_RESERVED_PRELOAD_SETUP(int cnt, struct fmt_main *pFmt) { char Type[20]; int len; sprintf(Type, "dynamic_%d:", cnt); len = strlen(Type); if (cnt < 0 || cnt > 1000) return 0; if (cnt >= ARRAY_COUNT(Setups) || strncmp(Type, Setups[cnt].szFORMAT_NAME, len)) { int j,bGood=0; len=strlen(Type); for (j = 0; j < ARRAY_COUNT(Setups); ++j) { if (!strncmp(Type, Setups[j].szFORMAT_NAME, len)) { bGood = 1; break; } } if (!bGood) return 0; return dynamic_SETUP(&Setups[j], pFmt); } return dynamic_SETUP(&Setups[cnt], pFmt); }
int dynamic_LOAD_PARSER_FUNCTIONS(int which, struct fmt_main *pFmt) { int ret, cnt; struct cfg_line *gen_line; nPreloadCnt = 0; nFuncCnt = 0; if (!dynamic_LOAD_PARSER_SIGNATURE(which)) { #ifdef HAVE_MPI if (mpi_id == 0) #endif fprintf(stderr, "Could not find section [List.Generic:dynamic_%d] in the john.ini/conf file\n", which); error(); } // Setup the 'default' format name sprintf(SetupName, "$dynamic_%d$", which); sprintf(SetupNameID, "dynamic_%d", which); Setup.szFORMAT_NAME = str_alloc_copy(SetupName); // allocate (and set null) enough file pointers cnt = Count_Items("Func="); Setup.pFuncs = mem_alloc_tiny((cnt+1)*sizeof(DYNAMIC_primitive_funcp), MEM_ALIGN_WORD); memset(Setup.pFuncs, 0, (cnt+1)*sizeof(DYNAMIC_primitive_funcp)); // allocate (and set null) enough Preloads cnt = Count_Items("Test="); cnt += Count_Items("TestU="); cnt += Count_Items("TestA="); Setup.pPreloads = mem_alloc_tiny((cnt+1)*sizeof(struct fmt_tests), MEM_ALIGN_WORD); memset(Setup.pPreloads, 0, (cnt+1)*sizeof(struct fmt_tests)); // allocate (and set null) enough constants (if we have 8, we still need a null to specify the end of the list) cnt = Count_Items("CONST"); Setup.pConstants = mem_alloc_tiny((cnt+1)*sizeof(DYNAMIC_Constants), MEM_ALIGN_WORD); memset(Setup.pConstants, 0, (cnt+1)*sizeof(DYNAMIC_Constants)); Setup.flags = 0; Setup.startFlags = 0; Setup.SaltLen = 0; Setup.MaxInputLen = 0; // Ok, now 'grind' through the data I do know know how to use // the config stuff too much, so will grind for now, and later // go back over this, and do it 'right', if there is a right way gen_line = gen_source->head; while (gen_line) { if (!dynamic_LOAD_PARSER_FUNCTIONS_LoadLINE(gen_line)) { #ifdef HAVE_MPI if (mpi_id == 0) #endif fprintf(stderr, "Error parsing section [List.Generic:dynamic_%d]\nError in line %d file is %s\n", which, gen_line->number, gen_line->cfg_name); error(); } gen_line = gen_line->next; } ret = dynamic_SETUP(&Setup, pFmt); return ret; }