/* compute total data to be read, we'll use this for the progress meter */
total = 0;
- for (sp = shiflist; sp < shiflist + filecount-1; sp++)
+ for (sp = shiflist; sp < shiflist + filecount; sp++)
{
stat(sp->name, &sb);
total += sb.st_size;
fprintf(stderr, "%ld bytes to be read.\n", total);
/* read in all hashes */
+ for (sp = shiflist; sp < shiflist + filecount; sp++)
+ {
+ }
}
return False
file = file.strip()
# Record count comes right after the filename
- (record_count,) = struct.unpack("!i", fp.read(4))
+ (record_count,) = struct.unpack("!H", fp.read(2))
while record_count > 0:
record_count -= 1
# 4 bytes of start line number + 4 of end line number + 16 of MD5 hash
- (start, end, hashval) = struct.unpack("!ii16s", fp.read(24))
+ (start, end, hashval) = struct.unpack("!HH16s", fp.read(20))
if dict.has_key(hashval):
oldval = dict[hashval]
else:
# Compute amount of data to be read
total = sum(map(filesize, args))
sys.stderr.write("%d bytes of data to be read\n" % total)
+ # Read in the filecounts, though this implementation won't use them.
+ for shif in shiflist:
+ shif.fp.read(struct.calcsize("!i"))
# Read in all hashes
hashdict = bsddb.hashopen(None, 'c')
for shif in shiflist:
extern int optind; /* set by getopt */
int status;
+ u_int32_t netfilecount;
char **place, **list, *dir = ".";
while ((status = getopt(argc, argv, "cd:hs:w")) != EOF)
{
/* the objective -- sort */
qsort(list, filecount, sizeof(char *), stringsort);
+ /* generate the list */
+ netfilecount = htonl(filecount);
+ fwrite(&netfilecount, sizeof(u_int32_t), 1, stdout);
for (place = list; place < list + filecount; place++)
shredfile(*place);
if debug:
sys.stderr.write(`line[0]` + "\n")
m.update(line[0])
- return struct.pack("!ii", startline, linecount) + m.digest()
+ return struct.pack("!HH", startline, linecount) + m.digest()
def shredfile(file):
"Emit shred tuples corresponding to a specified file."
outdata += emit_chunk(display, file, linecount)
chunk_count += 1
# Write the actual data
- sys.stdout.write(file + "\n" + struct.pack("!i", chunk_count) + outdata)
+ sys.stdout.write(file + "\n" + struct.pack("!H", chunk_count) + outdata)
if __name__ == '__main__':
try:
if eligible(fullpath):
filenames.append(fullpath)
filenames.sort()
+ sys.stdout.write(struct.pack("!i", len(filenames)))
for path in filenames:
shredfile(path)
# End