home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 15 / AACD15.ISO / AACD / Programming / MultiDesktop / ll / ll.c next >
Encoding:
C/C++ Source or Header  |  1997-03-27  |  2.7 KB  |  150 lines

  1. #include <exec/types.h>
  2. #include <exec/memory.h>
  3. #include <libraries/dos.h>
  4. #include <ctype.h>
  5.  
  6. UBYTE mem[256],buf[256],base[256];
  7.  
  8. struct FileHandle *in,*out,*make,*tmp;
  9.  
  10. BOOL ReadLine()
  11. {
  12.  long i,j;
  13.  
  14.  j=0;
  15.  do
  16.   {
  17.    i=Read(in,&mem[j],1L);
  18.    j++;
  19.   } while((i==1)&&(mem[j-1]!=0xa));
  20.  if(j>1)
  21.   {
  22.    mem[j-1]=0x00;
  23.    return(TRUE);
  24.   }
  25.  return(FALSE);
  26. }
  27.  
  28. void main(argc,argv)
  29.  long   argc;
  30.  UBYTE *argv[];
  31. {
  32.  BOOL bool;
  33.  long i,cmds;
  34.  
  35.  puts("LL Linker-Library-Erstellung  -  Version 1.00");
  36.  
  37.  if(argc!=2)
  38.   {
  39.    puts("Aufruf: LL [CFD-Asm-Datei]");
  40.    exit(0);
  41.   }
  42.  
  43.  in=Open(argv[1],MODE_OLDFILE);
  44.  if(in==NULL)
  45.   {
  46.    printf("Fehler: Kann <%s> nicht öffnen!\n",argv[1]);
  47.    exit(0);
  48.   }
  49.  
  50.  make=Open("t:makeit",MODE_NEWFILE);
  51.  if(make==NULL)
  52.   {
  53.    Close(in);
  54.    puts("Fehler: Kann <t:makeit> nicht erstellen!");
  55.    exit(0);
  56.   }
  57.  
  58.  tmp=Open("t:ll.$$$",MODE_READWRITE);
  59.  if(tmp==NULL)
  60.   {
  61.    Close(in);
  62.    Close(make);
  63.    puts("Fehler: Kann <t:ll.$$$> nicht erstellen!");
  64.    exit(0);
  65.   }
  66.  
  67.  sprintf(&buf,"copy ccs:bin/as t:\ncopy ccs:bin/lb t:\necho \"Assemblieren...\"\n");
  68.  Write(make,&buf,strlen(&buf));
  69.  
  70.  bool=ReadLine();
  71.  strcpy(&base,&mem);
  72.  
  73.  cmds=0;
  74.  strcpy(&buf,"t:lb ram:amiga.lib -a+ ");
  75.  Write(tmp,&buf,strlen(&buf));
  76.  
  77.  do
  78.   {
  79.    bool=ReadLine();
  80.    if(bool)
  81.     {
  82.      if(!(strncmp(&mem,"   XDEF _LVO",12)))
  83.       {
  84.        if(out) Close(out);
  85.        out=NULL;
  86.        if(isupper(mem[12]))
  87.         {
  88.          sprintf(&buf,"t:%s.asm",&mem[12]);
  89.          out=Open(&buf,MODE_NEWFILE);
  90.          if(out==NULL)
  91.           {
  92.            printf("Fehler: Kann <%s> nicht erstellen!\n",&buf);
  93.            bool=FALSE;
  94.           }
  95.          else
  96.           {
  97.            cmds++;
  98.            if(cmds>12)
  99.             {
  100.              cmds=0;
  101.              strcpy(&buf,"\nt:lb ram:amiga.lib -a+ ");
  102.              Write(tmp,&buf,strlen(&buf));
  103.             }
  104.            sprintf(&buf,"t:%s.o",&mem[12]);
  105.            Write(tmp,&buf,strlen(&buf));
  106.            Write(tmp," ",1L);
  107.  
  108.            Write(out,&base,strlen(&base));
  109.            Write(out,"\n",1L);
  110.            Write(out,&mem,strlen(&mem));
  111.            Write(out,"\n",1L);
  112.  
  113.            sprintf(&buf,"t:as >nil: t:%s.asm -C -D\n",&mem[12]);
  114.            Write(make,&buf,strlen(&buf));
  115.           }
  116.         }
  117.       }
  118.      else
  119.       {
  120.        if(out)
  121.         {
  122.          Write(out,&mem,strlen(&mem)); 
  123.          Write(out,"\n",1L);
  124.         }
  125.       }
  126.     }
  127.   } while(bool==TRUE);
  128.  
  129.  strcpy(&buf,"echo \"Anfügen...\"\n");
  130.  Write(make,&buf,strlen(&buf));
  131.  
  132.  Seek(tmp,0,OFFSET_BEGINNING);
  133.  i=Read(tmp,&buf,250);
  134.  while(i>0)
  135.   {
  136.    Write(make,&buf,i);
  137.    i=Read(tmp,&buf,250);
  138.   }  
  139.  
  140.  strcpy(&buf,"\ndel t:#?.o quiet\ndel t:#?.asm quiet\necho \"Fertig.\"\n");
  141.  Write(make,&buf,strlen(&buf));
  142.  
  143.  if(out) Close(out);
  144.  Close(make);
  145.  Close(in);
  146.  Close(tmp);
  147.  DeleteFile("t:ll.$$$");
  148. }
  149.  
  150.