#include <string.h>#include <stdio.h>#include "defines.h"#include "obfuscate.h"#include "util.h"#include "tree.h"Functions | |
| void | obfuscate_set_mode (bool value) | 
| char * | obfuscate_name (const char *real_name, char prefix) | 
| Gets an obfuscated name for the given actual name.   | |
| void | obfuscate_dealloc () | 
Variables | |
| static tnode * | obf_tree = NULL | 
| static int | obf_curr_id = 1000 | 
| bool | obf_mode | 
| void obfuscate_dealloc | ( | ) | 
Deallocates all memory associated with obfuscation.
References PROFILE, PROFILE_END, and tree_dealloc().
Referenced by main().
00109 { PROFILE(OBFUSCATE_DEALLOC); 00110 00111 tree_dealloc( obf_tree ); 00112 00113 PROFILE_END; 00114 00115 }
| char* obfuscate_name | ( | const char * | real_name, | |
| char | prefix | |||
| ) | 
Gets an obfuscated name for the given actual name.
Looks up the given real name in the obfuscation tree. If it exists, simply return the given name; otherwise, create a new element in the tree to represent this new name.
| real_name | Name of actual object in design | |
| prefix | Character representing the prefix of the obfuscated name | 
References FALSE, free_safe, malloc_safe, obf_curr_id, PROFILE, PROFILE_END, tree_add(), tree_find(), and tnode_s::value.
00070 { PROFILE(OBFUSCATE_NAME); 00071 00072 tnode* obfnode; /* Pointer to obfuscated tree node */ 00073 char* key; /* Temporary name used for searching */ 00074 char tname[30]; /* Temporary name used for sizing obfuscation ID */ 00075 unsigned int rv; /* Return value from snprintf calls */ 00076 unsigned int slen; /* String length */ 00077 00078 /* Create temporary name */ 00079 slen = strlen( real_name ) + 3; 00080 key = (char*)malloc_safe( slen ); 00081 rv = snprintf( key, slen, "%s-%c", real_name, prefix ); 00082 assert( rv < slen ); 00083 00084 /* If the name was not previously obfuscated, create a new obfuscated entry in the tree and return the new name */ 00085 if( (obfnode = tree_find( key, obf_tree )) == NULL ) { 00086 00087 /* Create obfuscated name */ 00088 rv = snprintf( tname, 30, "%c%04d", prefix, obf_curr_id ); 00089 assert( rv < 30 ); 00090 obf_curr_id++; 00091 00092 /* Add the obfuscated name to the tree and get the pointer to the new node */ 00093 obfnode = tree_add( key, tname, FALSE, &obf_tree ); 00094 00095 } 00096 00097 /* Deallocate key string */ 00098 free_safe( key, (strlen( key ) + 1) ); 00099 00100 PROFILE_END; 00101 00102 return( obfnode->value ); 00103 00104 }
| void obfuscate_set_mode | ( | bool | value | ) | 
Sets the global 'obf_mode' variable to the specified value.
| value | Boolean value to set obfuscation mode to | 
References obf_mode, PROFILE, and PROFILE_END.
Referenced by main().
00052 { PROFILE(OBFUSCATE_SET_MODE); 00053 00054 obf_mode = value; 00055 00056 PROFILE_END; 00057 00058 }
int obf_curr_id = 1000 [static] | 
        
Current obfuscation identifier. Incremented by one each time that a new obfuscation occurs.
Referenced by obfuscate_name().
Specifies obfuscation mode.
Referenced by obfuscate_set_mode().
 1.6.3