/* convert character to character in hackerz mode */ int hackerz_mode(int c) { switch(c) { case 'o': case 'O': c = '0'; break; case 'a': case 'A': if ((rand() % 10) > 5) c = '@'; else c = '4'; break; case 'e': case 'E': c = '3'; break; case 's': case 'S': switch(rand() % 10) { case 0: c = 'z'; break; case 1: c = 'Z'; break; case 2: c = '$'; break; case 3: c = '5'; break; case 4: c = 'S'; break; } break; case 't': case 'T': c = '+'; break; case 'i': case 'I': case 'l': case 'L': c = '1'; break; case '9': c = 'g'; break; case 'g': case 'G': c = '9'; break; default: if (c >= 'a' && c <= 'z') c = ctoupper(c); else c = ctolower(c); } return c; }
/* construct hotkey string into buf buf must be large enough (MAX_COLORBUF should do) cpos is the cursor position on the display USR_BOLD_HOTKEYS has a complex meaning; if USR_BOLD is set, then BOLD_HOTKEYS means we want faint hotkeys, if BOLD is NOT set, then BOLD_HOTKEYS means we want bold hotkeys Same goes for USR_HOTKEY_BRACKETS; if USR_ANSI is set, then HOTKEY_BRACKETS means we want em if ANSI is not set, then HOTKEY_BRACKETS means we don't want em (This is mainly due to backward compatibility with existing users; their BOLD_HOTKEYS flag will be clear, but you will want them to have bold hotkeys if they log in anyway [The other way to solve this is to use 2 flags {one for ANSI terminals and one for dumb terminals}, I use just 1 and link it to BOLD]) */ void print_hotkey(User *usr, char c, char *buf, int buflen, int *cpos) { int len; if (usr == NULL || buf == NULL || buflen <= 0 || cpos == NULL) return; if (usr->flags & USR_UPPERCASE_HOTKEYS) c = ctoupper(c); buf[0] = 0; len = 0; if (usr->flags & (USR_ANSI|USR_BOLD_HOTKEYS)) { buf[len++] = '\x1b'; buf[len++] = '['; if (usr->flags & USR_BOLD) buf[len++] = (usr->flags & USR_BOLD_HOTKEYS) ? '0' : '1'; else buf[len++] = (usr->flags & USR_BOLD_HOTKEYS) ? '1' : '0'; if (usr->flags & USR_ANSI) len += bufprintf(buf+len, buflen - len, ";%d;%dm", color_table[usr->colors[BACKGROUND]].value+10, color_table[usr->colors[HOTKEY]].value); else buf[len++] = 'm'; } if (((usr->flags & (USR_ANSI|USR_HOTKEY_BRACKETS)) == (USR_ANSI|USR_HOTKEY_BRACKETS)) || ((usr->flags & (USR_ANSI|USR_HOTKEY_BRACKETS)) == 0)) { buf[len++] = '<'; buf[len++] = c; buf[len++] = '>'; (*cpos) += 3; } else { buf[len++] = c; (*cpos)++; } if (usr->flags & (USR_ANSI|USR_BOLD_HOTKEYS)) { buf[len++] = '\x1b'; buf[len++] = '['; if (usr->flags & USR_BOLD) buf[len++] = '1'; else buf[len++] = '0'; if (usr->flags & USR_ANSI) len += bufprintf(buf+len, buflen - len, ";%d;%dm", color_table[usr->colors[BACKGROUND]].value+10, Ansi_Color(usr, usr->color)); else buf[len++] = 'm'; } buf[len] = 0; }
STATIC void makeMacroName( char *buffer, const char *name ) /********************************************************** * convert name to internal form (upcased) * buffer must be at least as large as name * Microsoft and POSIX environment variables are case sensitive */ { assert( IsMacroName( name ) ); if( Glob.compat_nmake || Glob.compat_posix ) { strcpy( buffer, name ); } else { while( (*buffer = ctoupper( *name )) != NULLCHAR ) { ++buffer, ++name; } } }
STATIC const char *GetMacroValueProcess( const char *name ) /********************************************************** * returns: pointer to text of macro (incl. environment vars) */ { char macro[MAX_MAC_NAME]; MACRO *cur; char *env; bool cdrive; bool cwd; bool ctime; bool cdate; bool cyear; char *p; int pos; makeMacroName( macro, name ); // Does assert( IsMacroName( name ) ); if( *macro == ENVVAR_C ) { env = GetEnvExt( macro + 1 ); if( env != NULL ) { return( env ); } cdrive = strcmp( macro + 1, "CDRIVE" ) == 0 || strcmp( macro + 1, "__CDRIVE__" ) == 0; cwd = strcmp( macro + 1, "CWD" ) == 0 || strcmp( macro + 1, "__CWD__" ) == 0; ctime = strcmp( macro + 1, "__CTIME__" ) == 0; cdate = strcmp( macro + 1, "__CDATE__" ) == 0; cyear = strcmp( macro + 1, "__CYEAR__" ) == 0; if( cdrive || cwd ) { if( getcwd( getDirBuf(), _MAX_PATH ) == NULL ) { return( NULL ); } p = strchr( dirBuf, ':' ); if( cdrive ) { if( p != NULL ) { *p = NULLCHAR; } else { dirBuf[0] = NULLCHAR; } } else { /* cwd */ if( p != NULL ) { return( p + 1 ); } } return( dirBuf ); } else if( ctime || cdate || cyear ) { struct tm *tm; tm = localtime( &start_time ); if( ctime ) { FmtStr( getDirBuf(), "%D:%D:%D", tm->tm_hour, tm->tm_min, tm->tm_sec ); } else if( cdate ) { FmtStr( getDirBuf(), "%d-%D-%D", tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday ); } else if( cyear ) { FmtStr( getDirBuf(), "%d", tm->tm_year + 1900 ); } return( dirBuf ); } return( NULL ); } cur = getMacroNode( macro ); if( cur != NULL ) { return( cur->value ); } // If not defined as a macro then get it as a Environment variable if( Glob.compat_nmake || Glob.compat_posix ) { // Check if macro is all caps in NMAKE mode if( Glob.compat_nmake ) { for( pos = 0; macro[pos] != NULLCHAR; ++pos ) { if( macro[pos] != ctoupper( macro[pos] ) ) { return( NULL ); } } } env = GetEnvExt( macro ); if( env != NULL ) { return( env ); } } return( NULL ); }