Skip to content

Commit

Permalink
Garble out from pack()
Browse files Browse the repository at this point in the history
  • Loading branch information
mjwoodcock committed Feb 22, 2010
1 parent d30ac6b commit 764aba0
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
7 changes: 7 additions & 0 deletions garble.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,10 @@ ungarble(Byte byte)

return byte;
}

Byte
garble(Byte byte)
{
/* Garble and ungarble are the same thing */
return ungarble(byte);
}
1 change: 1 addition & 0 deletions garble.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
void set_password(char *p);
void init_garble();
Byte ungarble(Byte byte);
Byte garble(Byte byte);

#endif
12 changes: 6 additions & 6 deletions pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,9 @@ write_ncr(ofp, byte, bytecount)

if (bytecount > 1)
{
fputc((int)byte, ofp);
fputc((int)RUNMARK, ofp);
fputc((int)bytecount, ofp);
fputc((int)garble(byte), ofp);
fputc((int)garble(RUNMARK), ofp);
fputc((int)garble(bytecount), ofp);
complen += 3;
for (i = 0; i < bytecount; i++)
{
Expand All @@ -163,14 +163,14 @@ write_ncr(ofp, byte, bytecount)
if (byte == RUNMARK)
{
calccrc(RUNMARK);
fputc((int)RUNMARK, ofp);
fputc(0, ofp);
fputc((int)garble(RUNMARK), ofp);
fputc(garble(0), ofp);
complen += 2;
}
else
{
calccrc(byte);
fputc((int)byte, ofp);
fputc((int)garble(byte), ofp);
complen += 1;
}
}
Expand Down
5 changes: 5 additions & 0 deletions testprog/pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "../nsparkio.h"
#include "../pack.h"
#include "../arcfs.h"
#include "../garble.h"

char **files = NULL;
char *archive = NULL;
Expand All @@ -24,6 +25,8 @@ main(int argc, char *argv[])

memset(&header, 0, sizeof(header));

set_password("james");

if (argc != 4)
{
printf("usage: %s <-p|u> <infile> <outfile>\n", argv[0]);
Expand Down Expand Up @@ -52,6 +55,7 @@ main(int argc, char *argv[])
crcsize = header.origlen;
pack(&header, in, out);
fseek(out, 0, SEEK_SET);
printf("\n");
fwrite(&header, sizeof(header), 1, out);
printf("Original size = %d\n", header.origlen);
printf("Compressed size = %d\n", header.complen);
Expand All @@ -67,6 +71,7 @@ main(int argc, char *argv[])
{
printf("Failed %d\n", r);
}
printf("\n");
}

fclose(in);
Expand Down

0 comments on commit 764aba0

Please sign in to comment.