home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 177.lha / DRes_v1.3 / util / gtd.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-04-28  |  1.2 KB  |  63 lines

  1.  
  2. /*
  3.  *  GTD     -GetTaskData/FreeTaskData tester
  4.  *
  5.  *  Matthew Dillon, 30 Sep 1988
  6.  *
  7.  *  gtd             - show task memlist entries
  8.  *  gtd <name>            - remove an entry
  9.  *  gtd <name> <bytes>        - add/retrieve an entry, display it, then
  10.  *                  store sequential values into the buffer.
  11.  */
  12.  
  13. #include <stdio.h>
  14. #include <local/typedefs.h>
  15. #include <local/xmisc.h>
  16.  
  17. extern int Enable_Abort;
  18. extern char *GetTaskData();
  19.  
  20. main(ac,av)
  21. char *av[];
  22. {
  23.     char *ptr;
  24.     long bytes;
  25.     short i;
  26.     TASK *task = FindTask(NULL);
  27.  
  28.     Enable_Abort = 0;
  29.  
  30.     if (openlibs(DRES_LIB) == 0)
  31.     exit(1);
  32.     if (ac == 1) {
  33.     MEMLIST *ml;
  34.     for (ml = GetHead(&task->tc_MemEntry); ml; ml = GetSucc(ml)) {
  35.         printf("memlist %08lx %ld %s\n", ml, ml->ml_NumEntries,
  36.         ((ml->ml_Node.ln_Name) ? ml->ml_Node.ln_Name : "NULL")
  37.         );
  38.     }
  39.     goto fail;
  40.     }
  41.     bytes = atoi(av[2]);
  42.     printf("%s,%ld :", av[1], bytes);
  43.     fflush(stdout);
  44.     if (ac == 2) {
  45.     printf("result %ld\n", FreeTaskData(av[1]));
  46.     } else {
  47.     ptr = GetTaskData(av[1], bytes);
  48.     if (!ptr) {
  49.         puts("failed");
  50.         goto fail;
  51.     }
  52.     printf("%08lx ", ptr);
  53.     fflush(stdout);
  54.     for (i = 0; i < bytes; ++i) {
  55.         printf("%02x ", ptr[i]);
  56.         ptr[i] = i;
  57.     }
  58.     }
  59. fail:
  60.     closelibs(-1);
  61. }
  62.  
  63.