A tool for encrypting and compacting C source code
For example, CMUNGE converts the following C source code:
/*------------------------------------------------------*/
/* dos2unix: Converts DOS text files to Unix ones by */
/* removing the `^M' character at the end of each line. */
/*------------------------------------------------------*/
#include <stdio.h>
main ()
{
int c;
while ((c = getchar()) != EOF)
if (c != '\015') /* ^M */
putchar (c);
}
into:
#include <stdio.h>
main(){int l1;while((l1=getchar())!=EOF)if(l1!='\015')putchar(l1);}
Admittedly this is a very simple example for the sake of brevity.
CMUNGE is really intended to be useful for large codes.
CMUNGE provides facilities for protecting parts of the source code from translation, for preventing the in-lining of selected #include files, and for preventing the renaming of selected identifiers. It creates dictionaries that translate the original identifiers and filenames into the new ones and vice versa, by means of which the user can relate the output code to the original if necessary (albeit not easily!).
The purpose of CMUNGE is to allow C source code to be distributed in a form that is unsuitable for modification or further development while still preserving its portability, with the benefit of making it much more compact (e.g. for my C source code I typically obtain compression factors of 4 - 5 as a result of munging it).
The CMUNGE software comprises 2 C programs and a `csh' (`C shell') driver script. Therefore installation is simply a matter of compiling 2 C programs, which can be done with an ANSI or K & R C compiler. Since the driver program is a `csh' script, it assumes a Unix-like operating system.
cmunge [options] files...
Options:
-I include-dir -- Search directory `include-dir' for #include files.
-d output-dir -- Write the output file(s) to directory
`output-dir'. (Default: current directory.)
-f output-file-rootname
-- Output files have names starting with the
string `output-file-rootname' followed by ".c"
if there is one output file, or "1.c", "2.c",
etc, if there is more than one. E.g. `-f f'
causes the output files to be named "f.c"
or "f1.c", "f2.c", etc. (Default: f).
-l min-output-linelen
-- Make lines of the output file(s) at least
`min-output-linelen' characters long.
(Default: 90.)
-p prefix-letter -- Give the translated C identifiers names
consisting of the letter `prefix-letter'
followed by a number. E.g. `-p l' causes
the translated identifiers to be called
l1, l2, etc. (Default: l).
-v version-string -- Insert string `version-string' as a C comment
in the first line of each output file.
(Default: no comment is written.)
-<anything else> -- Other arguments are passed directly to the
C pre-processor, `cpp'. E.g. argument
`-Dname=def' is passed directly to `cpp'.
files... -- The input C source file(s) to be `munged'.
Spaces are optional between option letters and their accompanying arguments.
CMUNGE was developed by John Merlin in December 1993. It has been used by the author to package the releases of SHPF and IDA, which are quite substantial software packages. CMUNGE was made available on the World Wide Web in August 1998.
I should point out that it has not yet been packaged as well as it should be for a public release. For example, there is no CMUNGE man page as yet (although the cmunge command generates the usage information shown above if it is used incorrectly). Prior to this release it has just been used by the author and his colleagues, but it has been made publicly available now in case it is more widely useful. I will rectify these deficiencies if there is sufficient demand. Please send any comments, questions, etc. to jhm@vcpc.univie.ac.at.