home *** CD-ROM | disk | FTP | other *** search
/ Amiga MA Magazine 1998 #6 / amigamamagazinepolishissue1998.iso / coders / biblioteki / c_library / rtlibrary / test.c < prev    next >
C/C++ Source or Header  |  1977-12-31  |  2KB  |  111 lines

  1. #if 0
  2. echo gcc -O2 -Wall -nostdlib -s -o test1 test1.c -I../include -I../../agcc/include -I../../agcc/os-include -L../lib -lrt
  3. gcc -O2 -Wall -nostdlib -s -o test1 test1.c -I../include -I../../include -I../../os-include -L../lib -lrt
  4. exit
  5. #endif
  6. /*
  7.  * $Id: test1.c $
  8.  *
  9.  * Author: Tomi Ollila <too@cs.hut.fi>
  10.  *
  11.  * Created: Wed Feb  1 00:46:16 1995 too
  12.  * Last modified: Wed Feb  1 01:47:36 1995 too
  13.  *
  14.  * HISTORY 
  15.  * $Log: $
  16.  */
  17.  
  18. int start(void);
  19.  
  20. int begin()
  21. {
  22.   return start();
  23. }
  24.  
  25. #include <proto/exec.h>
  26. #include <rt_exec.h>
  27. #include <proto/dos.h>
  28. #include <rt_dos.h>
  29.  
  30. struct ExecBase * SysBase;
  31. struct DosLibrary * DOSBase;
  32.  
  33. int run(struct RT * rt);
  34.  
  35. int start()
  36. {
  37.   struct RT * rt;
  38.   int rv;
  39.   
  40.   SysBase = *(struct ExecBase **)4;
  41.  
  42.   unless (rt = rt_Create(100))
  43.     return 20;
  44.  
  45.   rv = run(rt);
  46.  
  47.   rt_Delete(rt);
  48.   return rv;
  49. }
  50.  
  51. char * tststrs[] = {
  52.   "line 0",
  53.   "line 1",
  54.   "line 2",
  55.   "line 3",
  56.   "line 4",
  57.   "line 5",
  58.   "line 6",
  59.   "line 7"
  60. };
  61.  
  62. void showRemoved(char * ptr)
  63. {
  64.   Printf("%s\n", ptr);
  65. }
  66.  
  67. struct RTNode * addLine(struct RT * rt, char * ptr)
  68. {
  69.   Printf("adding *** %s\n", ptr);
  70.   
  71.   return rt_Add(rt, showRemoved, ptr);
  72. }
  73.  
  74. int run(struct RT * rt)
  75. {
  76.   struct RTNode * sn;
  77.  
  78.   unless (rt_OpenLib(rt, &DOSBase, "dos.library", 37))
  79.     return 20;
  80.       
  81.   
  82.   addLine(rt, tststrs[0]);
  83.   addLine(rt, tststrs[1]);
  84.   addLine(rt, tststrs[2]);
  85.   addLine(rt, tststrs[3]);
  86.   sn = addLine(rt, tststrs[4]);
  87.   addLine(rt, tststrs[5]);
  88.  
  89.   rt_RemNode(rt, sn);
  90.   addLine(rt, tststrs[6]);
  91.   addLine(rt, tststrs[7]);
  92.  
  93.   rt_RemData(rt, tststrs[1]);
  94.  
  95.   rt_RemSome(rt, tststrs[0], RTRF_REMTO|RTRF_DATA);
  96.  
  97.   sn = addLine(rt, tststrs[7]);
  98.  
  99.   addLine(rt, tststrs[6]);
  100.   addLine(rt, tststrs[5]);
  101.   addLine(rt, tststrs[4]);
  102.   addLine(rt, tststrs[3]);
  103.   addLine(rt, tststrs[2]);
  104.   addLine(rt, tststrs[1]);
  105.  
  106.   rt_RemSome(rt, sn, RTRF_REMUNTIL|RTRF_NODE);
  107.   Printf("end\n", 1);
  108.   
  109.   return 0;
  110. }
  111.