home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume7 / nstrings.bsd / limits.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-06-03  |  1.2 KB  |  58 lines

  1. static char * sccsid = "@(#)  limits.c  (v6.2 5/19/89)";
  2.  
  3. # include "strings.h"
  4.  
  5. # ifdef I_SPECIAL
  6.  
  7. #    ifdef sun
  8. #        include <sys/exec.h>
  9. #    endif sun
  10. #    include <a.out.h>
  11.  
  12. get_limits (fd, first, last)
  13. int fd;
  14. LSEEK_TYPE * first, * last;
  15. /*
  16.  * Have a look into the input file open under fd.
  17.  * If we think it is an object file, than get the start and
  18.  * size of initialized data and set
  19.  * *first : address where examination of file will start
  20.  * *last  : first address which will not be examined.
  21.  */
  22. {
  23.     register int i;
  24.     struct exec e;
  25.     LSEEK_TYPE l;
  26.  
  27.     *first = (LSEEK_TYPE)0;
  28.     *last = (LSEEK_TYPE)(-1);
  29.     if (lseek (fd, (LSEEK_TYPE)0, 0) != (LSEEK_TYPE)0) {
  30. # ifdef DEBUG
  31.         fprintf (prot, "Input not seekable\n");
  32. # endif
  33.         return;
  34.     }
  35.     i = read (fd, (char*)(&e), sizeof (e));
  36.     if (i != sizeof(e)) {
  37. # ifdef DEBUG
  38.         fprintf (prot, "file too small\n");
  39. # endif
  40.         return;
  41.     }
  42.     if (N_BADMAG(e)) {
  43. # ifdef DEBUG
  44.         fprintf (prot, "bad magic\n");
  45. # endif
  46.         return;
  47.     }
  48.     l = N_TXTOFF(e) + e.a_text;
  49. # ifdef DEBUG
  50.     fprintf (prot, "start of initialized data at %ld\n", (long)i);
  51.     fprintf (prot, "length = %1ld\n", (long)(e.a_data));
  52. # endif
  53.     *first = l;
  54.     *last = l + e.a_data;
  55. }
  56.  
  57. # endif I_SPECIAL
  58.