report_time("Hash merge done, %d entries", sort_count);
sort_hashes(sort_buffer, sort_count);
report_time("Sort done");
- emit_report(sort_buffer, sort_count);
+ emit_report(NULL, sort_buffer, sort_count);
}
else
{
int hashcount;
struct sorthash_t *obarray;
+ struct shif_t *shiflist;
report_time(NULL);
- obarray = merge_hashes(argc-optind, argv+optind, &hashcount);
+ shiflist = init_merge(argc-optind, argv+optind);
+ obarray = merge_hashes(shiflist, argc-optind, &hashcount);
report_time("Hash merge done, %d entries", hashcount);
sort_hashes(obarray, hashcount);
report_time("Sort done");
- emit_report(obarray, hashcount);
+ emit_report(shiflist, obarray, hashcount);
}
exit(0);
dummy_item;
static struct item *head = &dummy_item;
-struct shif_t
-{
- char *name;
- FILE *fp;
- char *normalization;
- int shred_size;
- char *hash_method;
- char *generator_program;
- int hashcount;
-};
static struct shif_t *shiflist;
struct range_t
head = new;
}
-void hash_intern(const struct hash_t *chunk)
-/* enter a has into the in-core array */
-{
-}
-
-struct sorthash_t *merge_hashes(int argc, char *argv[], int *count)
-/* merge hashes from specified files into an in-code list */
+struct shif_t *init_merge(int argc, char *argv[])
{
struct shif_t *sp;
- struct stat sb;
- long total;
- struct sorthash_t *obarray;
- int hashcount;
/* set up metadata blocks for the hash files */
shiflist = (struct shif_t *)calloc(sizeof(struct shif_t), argc);
}
}
+ return(shiflist);
+}
+
+struct sorthash_t *merge_hashes(struct shif_t *shiflist, int shiflen, int *count)
+/* merge hashes from specified files into an in-code list */
+{
+ struct shif_t *sp;
+ long total;
+ struct sorthash_t *obarray;
+ int hashcount;
+ struct stat sb;
+
/* compute total data to be read, we'll use this for the progress meter */
total = 0;
- for (sp = shiflist; sp < shiflist + argc; sp++)
+ for (sp = shiflist; sp < shiflist + shiflen; sp++)
{
stat(sp->name, &sb);
total += sb.st_size - ftell(sp->fp);
}
-
obarray=(struct sorthash_t *)calloc(sizeof(struct sorthash_t),
total/sizeof(struct hash_t));
if (!obarray)
/* read in all hashes */
hashcount = 0;
- for (sp = shiflist; sp < shiflist + argc; sp++)
+ for (sp = shiflist; sp < shiflist + shiflen; sp++)
{
u_int32_t sectcount;
return(0);
}
-void emit_report(struct sorthash_t *obarray, int hashcount)
+void emit_report(struct shif_t *shif,
+ struct sorthash_t *obarray, int hashcount)
{
struct match_t *hitlist, *sorted, *match;
int i, matchcount;
report_time("Reduction done");
puts("#SHIF-B 1.0");
- printf("Hash-Method: %s\n", shiflist[0].hash_method);
+ printf("Hash-Method: %s\n", shif->hash_method);
puts("Merge-Program: shredcompare 1.0");
- printf("Normalization: %s\n", shiflist[0].normalization);
- printf("Shred-Size: %d\n", shiflist[0].shred_size);
+ printf("Normalization: %s\n", shif->normalization);
+ printf("Shred-Size: %d\n", shif->shred_size);
puts("%%");
/* we go through a little extra effort to emit a sorted list */
char *file;
};
+struct shif_t
+{
+ char *name;
+ FILE *fp;
+ char *normalization;
+ int shred_size;
+ char *hash_method;
+ char *generator_program;
+ int hashcount;
+};
+
/* control bits, meant to be set at startup */
extern int c_only;
extern int rws;
/* shredtree.c functions */
extern char **sorted_file_list(const char *, int *);
extern void shredfile(const char *, void (*hook)(struct hash_t, const char *));
-extern struct sorthash_t *merge_hashes(int argc, char *argv[], int *count);
+extern struct shif_t *init_merge(int argc, char *argv[]);
+extern struct sorthash_t *merge_hashes(struct shif_t *shif, int shiflen,
+ int *count);
extern void sort_hashes(struct sorthash_t *hashlist, int hashcount);
-extern void emit_report(struct sorthash_t *obarray, int hashcount);
+extern void emit_report(struct shif_t *,
+ struct sorthash_t *obarray, int hashcount);
extern void report_time(char *legend, ...);