/*
 ascii codes viewer 1.1
 This program is programmed by freax
 http://users.pandora.be/skatan

 Changelog
 ---------
 1.1.1 :
 Added : Some problem codes (on my system) when using the program in xterm
 
 1.1
 Changed : everything
 Added : The user can choose how much colums he/she wants 
         by using a parameter.
 problems : If you can't do (256 / number of colums), 
            not all codes are printed to the output.
         
 1.0
 Program created ... it is ALIFE !!!
 but it's source looks like hell 


 if  you  abuse  your  computer  by  using  Microsoft   products ,
 this   program   might   blow  up   your  screen , your  harddisk
 controller   could  perform  a  headcrash  , your  keyboard could
 get  mad at you  and could start shooting his keys in your  eyes,
 your harddisk  led  could start flikkering all the  time  meaning
 that all your  harddisk  data is being formatted, your wife could
 start yelling at you and she could start saying that shes leaving
 with the kids  because  you are a fake computer nerd and that she
 found a linux nerd;which are generallty known to be better in sex
 then windows users because they don't have stress  when  they are
 behind their computer..and worse of all  you  could  get  a  blue
 screen  of  death  saying  that you  will  have  to  reboot  your
 system  afther you finally made an uptime of two hours. So if you
 have  any problems at all while using this tool: cool, but  I  am
 not responsible.
 
 ahum.. so
 to install :
        # gcc -o /usr/bin/ascii ascii-version.c
        # chmod 111 /usr/bin/ascii
        # echo "look mom, I compiled a program on my own"
 to use :
        $ ascii | more
    

 ahum, so this is the source code.. 

*/

int main(int argc, char **argv)
{
	int nr_of_col,nr_of_lines,cur_line,cur_col,t_for_line,ch;

	if (argc > 1) nr_of_col = atoi(argv[1]);
	else nr_of_col = 9;
	if (nr_of_col == 0) exit(0);
	t_for_line = 256 / nr_of_col;
	for (cur_line=0; cur_line < t_for_line; ++cur_line) 
	{
		for (cur_col=0; cur_col < nr_of_col; ++cur_col) 
		{
  			ch = cur_line+(cur_col*t_for_line);
  			if ( (ch<=32) || (ch==155) || (ch==127) || (ch==160) || (ch==132) 
     				|| (ch==133) || (ch==136) || ( (ch>=140)&&(ch<=144) )
     				|| ( (ch>=150)&&(ch<=159) ) ) 
     			printf("%3d%1c%1c%3c",ch,':',' ',' ');
 			else printf("%3d%1c%1c%3c",ch,':',ch,' ');

		}
	printf("\n");
	}
	return 0;
}
