home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / compress / 4194 < prev    next >
Encoding:
Internet Message Format  |  1992-12-22  |  2.0 KB

  1. Path: sparky!uunet!charon.amdahl.com!amdahl!fadden
  2. From: fadden@uts.amdahl.com (Andy McFadden)
  3. Newsgroups: comp.compression
  4. Subject: Portability issues for archiver authors
  5. Message-ID: <92tI03Lyc5EL00@amdahl.uts.amdahl.com>
  6. Date: 22 Dec 92 00:00:39 GMT
  7. Reply-To: fadden@amdahl.uts.amdahl.com (Andy McFadden)
  8. Organization: Amdahl Corporation, Sunnyvale CA
  9. Lines: 42
  10.  
  11. I'm in the process of porting a whole pile of archiving programs to UTS4.0
  12. (Amdahl's SVR4 implementation).  The most common portability problem is the
  13. use of 8-byte file offsets.
  14.  
  15. This means that our seek prototypes look (more or less) like this:
  16.  
  17.     off_t lseek(int, off_t, int);
  18.     off_t fseek(FILE *, off_t, int);
  19.     off_t ftell(FILE *)
  20.  
  21. where off_t is 8 bytes instead of the usual 4 byte long.
  22.  
  23. (Actually, ANSI specifies that the second argument to fseek() is an unsigned
  24. long, but if you're using ANSI prototypes then the problem will go away by
  25. itself anyway.)
  26.  
  27. Also, the st_size field of struct stat is an off_t.
  28.  
  29. So, I usually wander through and case stuff to off_t; no big deal.  However,
  30. "hpack" had a particularly egregious problem: the author defined LONG as
  31. *unsigned* int, which meant that this:
  32.  
  33.     (off_t) ((LONG) -1)
  34.  
  35. evaluates to 0x00000000ffffffff, which is not at all what was intended.  I
  36. ended up doing (off_t) ((long) (x)), which worked.  Took a little while to
  37. find though.
  38.  
  39. (The other thing that bit me was the case conversion on a static string;
  40. apparently with the OS and compiler I'm using, changing a staticly allocated
  41. string is a no-no... something like functionCall("*").)
  42.  
  43.  
  44. So far the portability award goes to ZIP, which (with ANSI prototypes enabled)
  45. compiled and worked the first time.  UNZIP is next; the lseek calls had to
  46. be tweaked.  ARC was sort of annoying, but I got it to work.  HPACK is dead
  47. last, which is surprising since its primary reason for existence seems to be
  48. archiving across platforms.  Haven't tried ZOO or UNARJ yet.
  49.  
  50. -- 
  51. fadden@uts.amdahl.com (Andy McFadden)
  52. [ Above opinions are mine, Amdahl has nothing to do with them, etc, etc. ]
  53.