Contents ----- Copyright Previous Next

Tutorial

The next paragraphs will describe how to actually vahunz a little example program consisting of only a few source files. All terms and techniques will be described when they are used first.

For most options, default values will be used, to make the whole process easier to understand. You can set several options to modify the behavior of Vahunz, but they will not be described in the tutorial, but in the reference section later on.

The Example Sources

The source files used during this tutorial can be found in vahunz/example. To perform all the steps, you will have to open a CLI and set its current directory to vahunz/example.

In the beginning, the example directory contains four files. Three of them are simple ANSI-C source codes: There also is one named Makefile, which is a simple makefile describing how to compile the whole program for make. This will not be touched by Vahunz.

Compiling The Example Program

First, you do not need to compile the example program to continue with this tutorial.

If you really want to, you will need a make-tool and an ANSI-C compiler with a cc-like calling-syntax. By default, the makefile is designed for gcc, but you can easily change the symbol CC to dcc or whatever, if you like.

Any more details would be out of scope.

The program itself does nothing remarkable: it simulates a guy named Sepp and lets him grow older until he dies. The output will look like:

Sepp grows older.
Sepp is 79 years old.
Sepp grows older.
Sepp is 80 years old.
Sepp grows older.
Sepp is 81 years old.
Sepp grows older.
Sepp is 82 years old.
Sepp grows older.
Sepp is 83 years old.

Sepp died.

There are only few variables and functions, and it should be straight forward what is going on, even when you are unfamiliar to C.

Creating the File List

First of all, Vahunz needs to know which source files it should touch. By default, it looks for a file named vahunz.files, which will have to contain all filenames relative to the current directory. Each filename has to be in an own line.

In our case, we can easily create this list by typing:
list >vahunz.files (#?.c|#?.h) lformat="%p%n"
This will create vahunz.files with the following content:
sepp.c
older.c
older.h

Note that the %p in LFORMAT (for "path") would not have been necessary in this case, as there are no files located in any deeper sub-directories. However, it also did not cause any harm, and you should provide it when creating the file list using list.

More complex programs than this simple example often reside within several directories, and then you will need to specify the full path relative to the current directory. And this is exactly what %p does.

Of course you can also create the file list manually, but this will usually take longer and is more error prone.

Creating the Dictionaries

Now it is time to build the dictionaries. That still is easy. Simply invoke Vahunz without any arguments at all by typing into CLI:
vahunz
The output should look like this:
Vahunz - Make source code un-/more readable.
Version 1.1 (23.2.1998), (C) Thomas Aglassinger 1998

reading existing files
  vahunz.files

building dictionaries
  sepp.c
  older.c
  older.h

writting dictionaries

The dictionary has been written to `vahunz.names'
and should be modified now.
Although the program suggest to modify the dictionary right now, we are going to do this a bit later. Therefor, the contents of vahunz.names should look like this:
 EXIT_SUCCESS
 age
 exit
 grow_older
 main
 name
 print_sepp
 printf
 sepp_age
 sepp_name
 stdio
 stdlib

These are all names Vahunz could find within the source files specified in the file list, omitting language specific keywords and names shorter than three characters - these are considered to be already unreadable.

Note that the first column entirely consist of blanks. Do not touch anything yet.

Your First Vahunzation

As the dictionary now exists, Vahunz is ready to transform the files. With the command line option --output you can specify a directory where the vahunzed files should end up. If you do not specify one, t: will be used.

In this tutorial, for some reason it seems convenient to store the vahunzed sources in ram:vahunzed. Therefor enter:

vahunz --output ram:vahunzed

There is no need to create the directory first, as this will be done automatically when the first file is attempted to be written to it.

The interesting part of the output should look like this:
updating dictionaries
  sepp.c
  older.c
  older.h

building vahunzed dictionary in memory
  0 names vahunzed

writting dictionaries

writting vahunzed files
  ram:vahunzed (created)
  ram:vahunzed/sepp.c
  ram:vahunzed/older.c
  ram:vahunzed/older.h

3 files vahunzed.

It tells that all source files have been rescanned and the name list has been updated, in case there would have been any new names since the creation. Of course, there weren't any yet, but its good to know that Vahunz takes care of this.

It then states that "0 names vahunzed" which means all the names are still meaningful. However, if you take a look at for example ram:vahunzed/sepp.c, you will notice that all the comments and indention are gone.

Vahunzing Names

To tell Vahunz to replace a meaningful name by some garbage, you have to mark the first column in vahunz.names with a "+". Load this file in your editor, and modify it so that it looks something like this:

 EXIT_SUCCESS
+age
 exit
+grow_older
 main
+name
+print_sepp
 printf
+sepp_age
+sepp_name
 stdio
 stdlib

Take care that you only change lines with names you have created, and are not a function or constants declared somewhere in the standard library, like for example printf or EXIT_SUCCESS. The same applies to main and stdio, as for obvious reasons the program will not compile anymore when these names are garbled.

Then again, invoke
vahunz --output ram:vahunzed
The output now has changed a bit. Most remarkable, it now tells:
  6 names vahunzed

The 6 apparently corresponds to the number of "+" in vahunz.names. If you now look at ram:vahunzed/sepp.c, you will see that it looks a bit different as before. For example, the original main() was:

int main(void)
{
    while (sepp_age < 83)
    {
        /* Simulate one year in the life of Sepp */
        grow_older(sepp_name, &sepp_age);
        print_sepp();
    }

    /* Announce the bad news */
    printf("\n%s died.\n", sepp_name);

    /* World ends here. */
    exit(EXIT_SUCCESS);
}
The vahunzed version might look like this:
int main(void)
{
while (s2e < 83)
{

z1i(d6t, &s2e);
r0h();
}

printf("\n%s died.\n", d6t);

exit(EXIT_SUCCESS);
}

The names do not necessarily have to look like this, as they are created randomly on every invocation. In this case, for example grow_older has been renamed to z1i.

When creating the names, Vahunz will take care that they do not already exist for another substitute, and are also not used within the names of original source. Usually they will have only three letters, but if there are many names to garble, they can also become longer.

But the best part: you can now copy the Makefile to ram:vahunzed, recompile the program and execute it. You will notice that it still does the same as before.

Using A Dignorary

Maybe you also noticed a files named vahunz.ignore. This one is called dignorary. This strange word is derived from ignore and dictionary, because that's exactly what it is: a dictionary with names to be ignored (or: left untouched) during vahunzation.

Currently, it only consists of two lines
-older
-sepp

Obviously, these are the names of our input files. Vahunz assumes that the user does not want them to be replaced, as a possible import or #include would fail then.

But the main feature is: the user does not see these names when he is browsing the normal dictionary. Load vahunz.names into your editor again, and change it that it looks like this:

-EXIT_SUCCESS
+age
-exit
+grow_older
-main
+name
+print_sepp
-printf
+sepp_age
+sepp_name
-stdio
-stdlib
and invoke Vahunz as before:
vahunz --output ram:vahunzed
You will notice that all lines starting with a hyphen (-) have been moved to vahunz.ignore, and therefor vahunz.names has become much cleaner.

What Next?

This finishes the tutorial. You should now know how to utilize with the basic concepts.

Still, there are some things to left, so you can use Vahunz more efficient: There are some ready dignoraries included in this distribution, so for example you do not have to mark printf manually.

There also exist several command line options, with most of them being discussed in the use-cases or the reference section in the later part of the manual.