The Dink Network

Reply to Re: Decompilers needed

If you don't have an account, just leave the password field blank.
Username:
Password:
Subject:
Antispam: Enter Dink Smallwood's last name (surname) below.
Formatting: :) :( ;( :P ;) :D >( : :s :O evil cat blood
Bold font Italic font hyperlink Code tags
Message:
 
 
March 28th 2008, 06:55 AM
duckdie.gif
The decompiler has been sent to both of you. A little warning, though, it doesn't work on overy computer because I think I accidentally used the wrong parameters when compiling it (sorry). I am unable to recompile it right now (I will try to so soon.

Here's the source code, if anyone's interested :

/* expand.c -- Byte Pair Encoding decompression */
/* Copyright 1996 Philip Gage */

#include <stdio.h>

void decompress (FILE *in, FILE *out)
{ unsigned char stack[16], pair[128][2]; short c, top = 0;
 /* Check for optional pair count and pair table */ if ((c = getc(in)) > 127) fread(pair,2,c-128,in); else putc(c,out);
 for (;  {
 /* Pop byte from stack or read byte from file */ if (top) c = stack[--top]; else if ((c = getc(in)) == EOF) break; /* Push pair on stack or output byte to file */ if (c > 127) { stack[top++] = pair[c-128][1]; stack[top++] = pair[c-128][0]; } else putc(c,out); }
}

int main (int argc, char **argv)
{ FILE *in, *out;
char crap[100];
char crap2[100];

printf("\nDinkC Decompiler V1.00 - Ducklord\n\n");
if (argc > 1)
{
//printf("Char is %c",argv[1][strlen(argv[1])-2]); if (argv[1][strlen(argv[1])-2] != '.')
{  strcpy(crap, argv[1]);
strcat(crap, ".d");
strcpy(crap2, argv[1]);
strcat(crap2, ".c");
} else
{
 strcpy(crap, argv[1]);
strcpy(crap2, argv[1]);
crap2[strlen(crap2)-1] = 'c';

}
}
 if (argc != 2) printf("Usage: decompile crap [.d] (a file called crap.c will be made)\n"); else if ((in=fopen(crap,"rb"))==NULL) printf("Error opening input %s\n",crap); else if ((out=fopen(crap2,"wb"))==NULL) printf("Error opening output %s\n",crap2); else {  printf("Creating %s....", crap2);  decompress(in,out); fclose(out); fclose(in); printf("Done!\n"); 
  } return 0;
}


(As a sidenote, Philip Gage's script required quite a bit of tweaking to make it work .)