comparison tools/fanalyze.c @ 2234:ef1845cb436e

Improve help, cosmetics.
author Matti Hamalainen <ccr@tnsp.org>
date Sat, 15 Jun 2019 06:06:23 +0300
parents ba639902d57c
children 2e656da1b10b
comparison
equal deleted inserted replaced
2233:b39eb8b44f22 2234:ef1845cb436e
1 /* 1 /*
2 * Fanalyze - Analyze similarities between multiple files 2 * Fanalyze - Commandline tool for analyzing similarities between multiple files
3 * Programmed and designed by Matti 'ccr' Hamalainen 3 * Programmed and designed by Matti 'ccr' Hamalainen
4 * (C) Copyright 2018-2019 Tecnic Software productions (TNSP) 4 * (C) Copyright 2018-2019 Tecnic Software productions (TNSP)
5 * 5 *
6 * Please read file 'COPYING' for information on license and distribution. 6 * Please read file 'COPYING' for information on license and distribution.
7 */ 7 */
147 dmPrintBanner(stdout, dmProgName, "[options] <input file #1> <input file #2> [...]"); 147 dmPrintBanner(stdout, dmProgName, "[options] <input file #1> <input file #2> [...]");
148 dmArgsPrintHelp(stdout, optList, optListN, 0); 148 dmArgsPrintHelp(stdout, optList, optListN, 0);
149 149
150 fprintf(stdout, 150 fprintf(stdout,
151 "\n" 151 "\n"
152 "Fanalyze is a simplistic commandline tool to assist analysis of similarities\n"
153 "between multiple files of same format (but different content). It provides\n"
154 "automatic analysis (default operating mode), binary grep functionality (-g)\n"
155 "and offset data display (-o)\n"
156 "\n"
152 "Value lists for grep function can contain wildcard '?' (or '#') which\n" 157 "Value lists for grep function can contain wildcard '?' (or '#') which\n"
153 "matches any value of the specified (or inferred) type. For example:\n" 158 "matches any value of the specified (or inferred) type. For example:\n"
154 "-g 0x0f,7,5,?,5,?,? will match sequence of bytes 0f 07 05 ?? 05 ?? ??\n" 159 "-g 0x0f,7,5,?,5,?,? will match sequence of bytes 0f 07 05 ?? 05 ?? ??\n"
155 "and -g 0xe,0x1001,?,2023:le16 will match le16 value 000e 1001 ???? 07e7\n" 160 "and -g 0xe,0x1001,?,2023:le16 will match le16 value 000e 1001 ???? 07e7\n"
156 ); 161 );
523 { 528 {
524 DMCompElem *compBuf = NULL; 529 DMCompElem *compBuf = NULL;
525 size_t compBufSize = 0, totalSize = 0; 530 size_t compBufSize = 0, totalSize = 0;
526 int res; 531 int res;
527 532
528 dmInitProg("fanalyze", "File format analyzer", "0.4", NULL, NULL); 533 dmInitProg("fanalyze", "Simple tool for file format analysis",
534 "0.4", NULL, NULL);
529 dmVerbosity = 1; 535 dmVerbosity = 1;
530 536
531 dmInitStats(&totalStats); 537 dmInitStats(&totalStats);
532 538
533 // Parse arguments 539 // Parse arguments
680 { 686 {
681 dmErrorMsg("Out of memory. Could not allocate comparision buffer!\n"); 687 dmErrorMsg("Out of memory. Could not allocate comparision buffer!\n");
682 goto out; 688 goto out;
683 } 689 }
684 690
685 // Begin analyzing .. 691 //
692 // Basic file data comparision
693 //
686 dmPrint(2, "Analyzing ..\n"); 694 dmPrint(2, "Analyzing ..\n");
687 for (int nfile = 0; nfile < nsrcFiles; nfile++) 695 for (int nfile = 0; nfile < nsrcFiles; nfile++)
688 { 696 {
689 DMSourceFile *file = &srcFiles[nfile]; 697 DMSourceFile *file = &srcFiles[nfile];
690 698
713 el->data = n; 721 el->data = n;
714 } 722 }
715 } 723 }
716 } 724 }
717 725
726 //
718 // Display results 727 // Display results
728 //
719 for (size_t offs = 0, n = 0; offs < compBufSize; offs++) 729 for (size_t offs = 0, n = 0; offs < compBufSize; offs++)
720 { 730 {
721 DMCompElem *el = &compBuf[offs]; 731 DMCompElem *el = &compBuf[offs];
722 BOOL var = el->variants > 1; 732 BOOL var = el->variants > 1;
723 733