#include <time.h>
#include <getopt.h>
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <dos.h>
#include <io.h>
#include <share.h>
#include <alloc.h>
#include <sys\stat.h>
#include <fcntl.h>
#include <string.h>
#include <process.h>
#include <stdarg.h>
#include <conio.h>

void view_file_with_color(char *filename)
{
char ch;
char hexstring[2];
int attrib;
memset(hexstring,0,3);
int fstream = sopen(filename, O_RDONLY, SH_DENYNO);

    while(read(fstream,&ch,1))
    {
        if(ch == '')
        {
            if(read(fstream,&ch,1))
                if(ch == 'b')
                    if(read(fstream,&hexstring,2))
                        {
                            sscanf(hexstring,"%x",&attrib);
                            textattr(attrib);
                        }
        }
        else
          if(ch == 10)
          {
            putch(13);
            putch(10);
          }
        else
            putch(ch);
    }

close(fstream);
}

main(int argc, char *argv[])
{
    view_file_with_color(argv[1]);
}
