#include <stdio.h>
#include <string.h>

main()
{
FILE* swapfile;
FILE* rlifile;
char swapstr[80], tempstr[80];
char *scanstr = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
char *dscanstr = "\x20\x09";
char *ptr,*filler="          ";
int i,c;

    if(swapfile = fopen("SWAPP.SYS","rt"))
    {
         rlifile = fopen("RLISWAPP.SYS","wt");

         while(fgets(swapstr,80,swapfile))
         {
              fputs("r   *   ",rlifile);

              strcpy(tempstr,strpbrk(swapstr,scanstr));

              if( strpbrk(ptr = strpbrk(tempstr,dscanstr),scanstr))
              {
                   fwrite(tempstr,ptr-tempstr,1,rlifile);
                   fwrite(filler,6 - (ptr-tempstr),1,rlifile);
                   fputs("   *   ",rlifile);
                   ptr = strpbrk(ptr,scanstr);
                   fputs(ptr,rlifile);
              }
              else fputs(tempstr,rlifile);
         }
         fclose(swapfile);
         fclose(rlifile);
    }
    else printf("Error: file SWAPP.SYS not found\n");
}