home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / file39a.zip / src / notes.os2 < prev    next >
Text File  |  1993-04-11  |  19KB  |  579 lines

  1. This file, NOTES.OS2, contains various messages and remarks on the OS/2 port,
  2. and some magicfile suggestions by John Adams and Gisbert W. Selke. The email
  3. messages have been edited slightly for brevity and clarity.
  4.  
  5. General notes:
  6. 1. Versions were compiled with Microsoft C 6.00A and EMX/gcc 0.8f. 
  7.  
  8. 2. Some of the original code assumed 32-bit integers. The magic structure
  9. was changed in order to reduce the memory requirement. EMX and MSC changes
  10. can be found by searching for OS2, EMX, and MSC. Bugs in the original
  11. sources can be found by searching for the word "bugfix".
  12.  
  13. 3. MSC stat() is broken on directory names--see Stat() in fsmagic.c.
  14. MSC utime() works as documented, but is still broken.
  15.  
  16. 4. Use spawn instead of fork in EMX/gcc. No pipes in MSDOS; use tempfil.
  17.  
  18. 5. Add apptype.c, which uses DosQ[uery]AppType to determine the type
  19. of executable. If apptype.c has the filename, then apptype can determine
  20. the file type (see apptype.c for one special bug). 
  21.  
  22. However, when the program is reading from stdin (or from a pipe due to "-z"
  23. unwinding), then apptype only sees the part of the file provided by the
  24. program (HOWMANY bytes).  In this case, DosQ[uery]AppType may not be able to
  25. distinguish, for example, a DOS exe from an OS/2 exe.
  26.  
  27. 6. The usual problems with binary vs text files, EOL, and directory 
  28. separators must be handled. strtol in EMX and MSC libs returns LONG_MAX
  29. on overflow--use strtoul with sign check or the supplied localsrc/strtol.c
  30.  
  31.  
  32. =============================================================================
  33.  
  34. To: Darrel R Hankerson <hankedr@mail.auburn.edu>
  35. Cc: darwin@cs.toronto.edu
  36. Subject: Re: file ported to OS/2 1.x--2.x 
  37. In-Reply-To: Your message of Mon, 05 Apr 93 07:39:25 -0500.
  38. Date:     Mon, 5 Apr 1993 10:51:49 -0400
  39. From: ian@sq.com
  40.  
  41. On Mon, 5 Apr 1993 07:39:25 -0400  Darrel R Hankerson wrote:
  42.  
  43. >I have nearly finished a port of [file v3 patchlevel5]
  44. >for OS/2 1.x--2.x.
  45. Glad to see it's been made available for OS/2. Thanks!
  46.  
  47. >The main changes are:
  48. > 1. Change fork() to spawn() (needed for 1.x).
  49. > 2. Add API calls to determine executable type.
  50. > 3. malloc() the magic->desc to reduce memory usage (needed for 1.x).
  51.  
  52. Yes, I'd like to get the source changes back. HOWEVER time has not
  53. stood still; I am now distributing version 3.9, and would rather not
  54. have version 3.[5] circulating. If you have your diffs as patch files,
  55. would it be possible for you to get the lastest (by ftp from
  56. ftp.cs.toronto.edu in /pub/darwin/file), apply and test them again, and
  57. then send the new version both to me (for baseline source) and also:
  58.  
  59. >... upload this as "file3[9].zip" (with context diff's and suitable
  60. >documentation) to the main OS/2 sites...
  61. Then we'd all be distributing the same version...
  62.  
  63. [The current version given in] patchlevel.h now says:
  64.  #define FILE_VERSION_MAJOR    3
  65.  #define patchlevel        9
  66.  
  67. Actually, when I get your OS/2 changes in, it'll be 3.10!
  68.  
  69.  
  70. You also mentioned some
  71. >Minor magic-file problems:
  72. which I'll track down.
  73.  
  74. >The porting was made easier by the excellent form of the sources. Your
  75. >program is a fine piece of work.
  76.  
  77. Thanks for the feedback!
  78.  
  79. Ian Darwin        Free Fine File(1) FTPable From Ftp.cs.toronto.edu
  80. ian@sq.com        cd /pub/darwin/file; get README.FTP -; binary;
  81. Toronto, Canada        mget dist.*
  82.  
  83.  
  84. =============================================================================
  85.  
  86. Date: Tue, 6 Apr 93 09:20:50 CDT
  87. From: Darrel R Hankerson <hankedr>
  88. To: ian@sq.com
  89. Cc: darwin@cs.toronto.edu
  90. In-Reply-To: ian@sq.com's message of Mon, 5 Apr 1993 10:51:49 -0400 <m0nfsWp-0003bFC@sq.com>
  91. Subject: file ported to OS/2 1.x--2.x 
  92.  
  93. [...] I do see a few new buglets in 3.9:
  94.  
  95. 1. In ascmagic.c, you've changed the check for the esc. But there are only 
  96. nbytes of valid data, right?
  97.  
  98. #ifdef OS2                      /* bugfix, not OS/2 specific */
  99.         s = (unsigned char*) memcpy(nbuf, buf, nbytes);
  100.         has_escapes = (memchr(s, '\033', nbytes) != NULL);
  101. #else
  102.         s = (unsigned char*) memcpy(nbuf, buf, HOWMANY);
  103.         has_escapes = (memchr(s, '\033', HOWMANY) != NULL);
  104. #endif
  105.  
  106. This reminds me of another question: In compress.c, would it make more
  107. sense to always read HOMANY bytes from the pipe (as uncompress will give back
  108. more bytes than the orig buffer)? 
  109.  
  110.  
  111. 2. print.c has not been updated to include the additional typ's:
  112.  
  113. #ifdef OS2              /* bugfix, not OS/2 specific */
  114.                 (m->type >= 0 && m->type < sizeof(typ) ?
  115. #else
  116.                 (m->type >= 0 && m->type < 7 ?
  117. #endif
  118.  
  119. You will see the bug if you try "file -c"
  120.  
  121.  
  122. I have working 32-bit OS/2, 16-bit OS/2, and MSDOS versions. I've
  123. added the API calls (in OS/2 versions) to determine the executable
  124. type (can't do this with magic entries).
  125.  
  126. Notes:
  127. 1. OS/2 1.x can't fork()--added code to use pipes and spawn.
  128.  
  129. 2. OS/2 2.x doesn't really like to fork; do spawn.
  130.  
  131. 3. MSDOS can't pipe; added tmpnam code.
  132.  
  133. 4. The 16-bit versions require some changes:
  134.    (a) a few int's need to be unsigned
  135.    (b) a few "%d" in printf need to be "%ld"
  136.    (c) change magic->desc to a pointer and malloc as needed. We need the
  137.        room. More changes here are probably desired, as the current magic
  138.        file has over 900 valid entries and MAXMAGIS=1000 is near the max for
  139.        the 16-bit version. I did have some problems changing 
  140.        mag->value.s to pointer when I played with 3.5. This would give more
  141.        room, but I have not modified 3.9 in this area.
  142.   
  143. 5. OS/2 and MSDOS programs need to handle the "traditional" EOL "\r\n" in 
  144. addition to "\n".  A minor change to softmagic.c (in 2 places) is needed.
  145. As an example, 
  146.  
  147. #ifdef OS2                              /* handle both "\r\n" and "\n" */
  148.                 (void) printf_eol(m->desc, p->s);
  149. #else
  150.                 if ((rt=strchr(p->s, '\n')) != NULL)
  151.                         *rt = '\0';
  152.                 (void) printf(m->desc, p->s);
  153.                 if (rt)
  154.                         *rt = '\n';
  155. #endif
  156.  
  157. printf_eol is suitably defined. Without this change, the printout will
  158. be incorrect for the tst files c.misc*.
  159.  
  160.  
  161. 6. OS/2 and MSDOS programs need to handle both '/' and '\\' as directory
  162. separators. Some minor changes are required. MSC stat() is partially broken
  163. on dir names, minor change added. 
  164.  
  165. --Darrel Hankerson hankedr@mail.auburn.edu or hank@ducvax.auburn.edu
  166.  
  167.  
  168. =============================================================================
  169.  
  170. Date: Sat, 27 Mar 93 22:36:16 CST
  171. From: Darrel R Hankerson <hankedr>
  172. To: mattes@iema.e-technik.uni-stuttgart.de
  173. Subject: How to recognise 16-bit apps
  174.  
  175. DH said:
  176. >> Proposal: Maybe we need a working "file" program with a flexible approach
  177. >> to magic entries. Mattes' apptype could be part of this project.
  178.  
  179. EM said:
  180. > I can provide the code required for identifying the emx version (and
  181. > whether a program is an emx program or isn't), if you need it.  A
  182. > "file"-like approach cannot be used for identifying the type of an
  183. > .exe file -- the NE and LX headers can be almost anywhere.
  184.  
  185. I would like to add the code you mention. I also plan to add the "apptype"
  186. code. 
  187.  
  188. 1. Do you have any suggestions on the way the output should look?
  189.  
  190. 2. How can I identify EMX .o and .obj files?
  191.  
  192. 3. Where can I get an extensive list of magic entries?
  193.  
  194. --Darrel Hankerson hankedr@mail.auburn.edu or hank@ducvax.auburn.edu
  195.  
  196.  
  197. =============================================================================
  198.  
  199. From: Eberhard Mattes <mattes@azu.informatik.uni-stuttgart.de>
  200. Date: Fri, 2 Apr 93 14:03:24 +0200
  201. To: hankedr@mail.auburn.edu
  202. In-Reply-To: Darrel R Hankerson's message of Sat, 27 Mar 93 22:36:16 CST <9303280436.AA04246@ducserv>
  203. Subject: How to recognise 16-bit apps
  204.  
  205. > 1. Do you have any suggestions on the way the output should look?
  206.  
  207. It should be `machine readable'.
  208.  
  209. > 2. How can I identify EMX .o and .obj files?
  210.  
  211. Use the standard i386 Unix magic entry for .o files (0407).  .obj
  212. files start with a THEADR record (a byte of 0x80, followed by two
  213. bytes indicating the length of the record).
  214.  
  215. > 3. Where can I get an extensive list of magic entries?
  216.  
  217. Try one of the Unix "file" programs.  I think I've seen a list for all
  218. the TeX file types somewhere, but they're probably included now in the
  219. Unix "file" programs.  TFM files are a bit hard -- there is no magic
  220. word.  You have to add up several values from the beginning of the
  221. file and compare to some other values.
  222.  
  223. Yours,
  224.   Eberhard Mattes (mattes@azu.informatik.uni-stuttgart.de)
  225.  
  226.  
  227. =============================================================================
  228.  
  229. From: Eberhard Mattes <mattes@azu.informatik.uni-stuttgart.de>
  230. Date: Tue, 6 Apr 93 16:53:19 +0200
  231. To: hankedr@mail.auburn.edu
  232. In-Reply-To: Darrel R Hankerson's message of Fri, 2 Apr 93 23:26:11 CST 
  233. Subject: How to recognise 16-bit apps
  234.  
  235. > I added the ideas from the apptype program. I noticed that the api call
  236. > has somewhat of a bug: The file "blob.com" will be called a DOS exe, unless
  237. > it is an OS/2 program (e.g., a text file "blob.com" will be called a DOS
  238. > exe). 
  239.  
  240. Moreover, it reports the type of the (new and very bug ridden) Win
  241. Emacs as "OS/2 executable".
  242.  
  243. > I have not received your code to identify the EMX version. I will add this,
  244. > should you find time to do this.
  245.  
  246. I haven't sent it yet :-)
  247.  
  248. Yours,
  249.   Eberhard Mattes (mattes@azu.informatik.uni-stuttgart.de)
  250.  
  251.  
  252. =============================================================================
  253.  
  254. Date: Mon, 29 Mar 1993 09:40:45 +0100
  255. From: ccaajpa@ucl.ac.uk (John Paul Adams)
  256. To: hankedr@mail.auburn.edu
  257. Subject: Re: magic file entries needed
  258.  
  259. In article <1993Mar28.030820.21367@news.duc.auburn.edu> you write:
  260. >Some time ago, someone posted a collection of magic file entries (these
  261. >are used by "file" to determine the kind of file). I think they were posted
  262. >here, as they included some entries for various kinds of image files, but
  263. >I could be wrong.
  264.  
  265. I have saved variuos snippets of the network and sorted them out into quite
  266. a nice magic file, though there have been many ideas posted to the network
  267. that don't work on our IBM RS6000 machine, so have not been included. I
  268. would be interested if you have any entries that do not appear on my list,
  269. especially MPEG.
  270.  
  271. Thanks,
  272. John Adams,
  273. J.Adams@uk.ac.ucl
  274.  
  275. -------------------------- my magic files starts here --------------------
  276.  
  277. ##### This file is a collection of formats of files that can be used with
  278. ##### the "file" command for determining what kind of file a file is.
  279. ##### This extends to systems files, file archives and graphics formats.
  280. ##### They are spread into these three sections. The data has been gathered
  281. ##### from a number of sources, mainly from Usenet postings in the pixutils
  282. ##### groups.
  283.  
  284. #####
  285. ##   
  286. ##  AIX SYSTEM FILES
  287. ##  ================
  288. ##  These have been collected from the AIX 3.1 and AIX 3.2 /etc/magic files
  289. ##  and possibly will not run under other computers.
  290. ##   
  291. #####
  292.  
  293. 0    short        070707        cpio archive
  294. 0    string        070707        ASCII cpio archive
  295. 0    short        017436        packed text
  296. 0    string        <aiaff>        archive
  297. 0    string        Rast        RST format font raster
  298. 0    short        0x01df        executable (RISC System/6000 V3.2) or object module
  299. >12    long        >0        not stripped
  300. 0    short        0x0103        executable (RT Version 2) or obj module
  301. >2    byte        0x50        pure
  302. >28    long        >0        not stripped
  303. >6    short        >0        - version %ld
  304. 0    short        0x0104        shared library
  305. 0    short        0x0105        ctab data
  306. 0    short        0xfe04        structured file
  307. 0    string        0xabcdef    message catalog
  308.  
  309. #####
  310. ##   
  311. ##  GENERAL UNIX SYSTEM FILES
  312. ##  =========================
  313. ##  These are generally accepted Unix types that should work on any
  314. ##  Unix system.
  315. ##   
  316. #####
  317.  
  318. 0    short        017037        packed
  319. 0    short        8093        compressed
  320. 0    short        0433        curses-scrdump
  321. 0    short        0434        curses-scrdump
  322. 0    string        %!        PostScript
  323.  
  324. #####
  325. ##   
  326. ##  ARCHIVE FORMATS
  327. ##  ===============
  328. ##  These are a general collection of archivers and stuffers, not only
  329. ##  Unix ones, but those that have come from DOS, Mac and other systems.
  330. ##   
  331. #####
  332.  
  333. #################
  334. ##             ##
  335. ##  DOS FILES  ##
  336. ##  =========  ##
  337. ##             ##
  338. #################
  339.  
  340. 0    string        MZ            MS-DOS executable
  341.  
  342. ###########
  343. ##       ##
  344. ##  ARC  ##
  345. ##  ===  ##
  346. ##       ##
  347. ###########
  348.  
  349. 0    string        \032\010        Arc archive
  350. 0    short        0x1a08            Arc archive
  351. 0    short        0x081a            Arc archive
  352.  
  353. #################
  354. ##             ##
  355. ##  LHARC/LHA  ##
  356. ##  =========  ##
  357. ##             ##
  358. #################
  359.  
  360. 2    string        -lh0-            Lharc 1.x archive
  361. 2    string        -lh1-            Lharc 1.x archive
  362. 2    string        -lz4-            Lharc 1.x archive
  363. 2    string        -lz5-            Lharc 1.x archive
  364. #    [never seen any but the last:]
  365. 2    string        -lzs-            LHa 2.x? archive [lzs]
  366. 2    string        -lh -            LHa 2.x? archive [lh ]
  367. 2    string        -lhd-            LHa 2.x? archive [lhd]
  368. 2    string        -lh2-            LHa 2.x? archive [lh2]
  369. 2    string        -lh3-            LHa 2.x? archive [lh3]
  370. 2    string        -lh4-            LHa 2.x? archive [lh4]
  371. 2    string        -lh5-            LHa (2.x) archive
  372.  
  373. ###########
  374. ##       ##
  375. ##  ZIP  ##
  376. ##  ===  ##
  377. ##       ##
  378. ###########
  379.  
  380. # [newer, smarter "file" programs]
  381. 0    string        PK\003\004        Zip archive
  382. >4    string        \011            (at least v0.9 to extract)
  383. >4    string        \012            (at least v1.0 to extract)
  384. >4    string        \013            (at least v1.1 to extract)
  385. >4    string        \024            (at least v2.0 to extract)
  386. # [stupid "file" programs, big-endian]
  387. 0       long        0x504b0304        Zip archive
  388. >1    long        0x4b030409        (at least v0.9 to extract)
  389. >1    long        0x4b03040a        (at least v1.0 to extract)
  390. >1    long        0x4b03040b        (at least v1.1 to extract)
  391. >1    long        0x4b030414        (at least v2.0 to extract)
  392. # [stupid "file" programs, little-endian]
  393. 0       long        0x04034b50        Zip archive
  394. >1    long        0x0904034b        (at least v0.9 to extract)
  395. >1    long        0x0a04034b        (at least v1.0 to extract)
  396. >1    long        0x0b04034b        (at least v1.1 to extract)
  397. >1    long        0x1404034b        (at least v2.0 to extract)
  398.  
  399. ###########
  400. ##       ##
  401. ##  ZOO  ##
  402. ##  ===  ##
  403. ##       ##
  404. ###########
  405.  
  406. # [GRR:  don't know if all of these versions exist, or if some missing...]
  407. 0    string        ZOO             Zoo archive
  408. >4    string        1.00            (v%4s)
  409. >4    string        1.10            (v%4s)
  410. >4    string        1.20            (v%4s)
  411. >4    string        1.30            (v%4s)
  412. >4    string        1.40            (v%4s)
  413. >4    string        1.50            (v%4s)
  414. >4    string        1.60            (v%4s)
  415. >4    string        1.70            (v%4s)
  416. >4    string        1.71            (v%4s)
  417. >4    string        2.00            (v%4s)
  418. >4    string        2.01            (v%4s)
  419. >4    string        2.10            (v%4s)
  420. # [newer, smarter "file" programs]
  421. >32    string        \001\000        (modify: v1.0+)
  422. >32    string        \001\004        (modify: v1.4+)
  423. >32    string        \002\000        (modify: v2.0+)
  424. >70    string        \001\000        (extract: v1.0+)
  425. >70    string        \002\001        (extract: v2.1+)
  426. # [stupid "file" programs, big-endian]
  427. >32    short        0x0100            (modify: v1.0+)
  428. >32    short        0x0104            (modify: v1.4+)
  429. >32    short        0x0200            (modify: v2.0+)
  430. >70    short        0x0100            (extract: v1.0+)
  431. >70    short        0x0201            (extract: v2.1+)
  432. # [stupid "file" programs, little-endian]
  433. >32    short        0x0001            (modify: v1.0+)
  434. >32    short        0x0401            (modify: v1.4+)
  435. >32    short        0x0002            (modify: v2.0+)
  436. >70    short        0x0001            (extract: v1.0+)
  437. >70    short        0x0102            (extract: v2.1+)
  438. # [GRR:  the following are alternate identifiers]
  439. #20    long        0xdca7c4fd        Zoo archive
  440. #20    long        0xc4fddca7        Zoo archive
  441.  
  442. ################
  443. ##            ##
  444. ##  COMPRESS  ##
  445. ##  ========  ##
  446. ##            ##
  447. ################
  448.  
  449. # [newer, smarter "file" programs]
  450. # [GRR:  are the upper three bits (block size) ever different from 100?]
  451. 0    string        \037\235        compress'd file
  452. >2    string        \211            (9 bits)
  453. >2    string        \212            (10 bits)
  454. >2    string        \213            (11 bits)
  455. >2    string        \214            (12 bits)
  456. >2    string        \215            (13 bits)
  457. >2    string        \216            (14 bits)
  458. >2    string        \217            (15 bits)
  459. >2    string        \220            (16 bits)
  460. # [stupid "file" programs, big-endian]
  461. 0    short        0x1f9d            compress'd file
  462. >1    short        0x9d89            (9 bits)
  463. >1    short        0x9d8a            (10 bits)
  464. >1    short        0x9d8b            (11 bits)
  465. >1    short        0x9d8c            (12 bits)
  466. >1    short        0x9d8d            (13 bits)
  467. >1    short        0x9d8e            (14 bits)
  468. >1    short        0x9d8f            (15 bits)
  469. >1    short        0x9d90            (16 bits)
  470. # [stupid "file" programs, little-endian]
  471. 0    short        0x9d1f            compress'd file
  472. >1    short        0x899d            (9 bits)
  473. >1    short        0x8a9d            (10 bits)
  474. >1    short        0x8b9d            (11 bits)
  475. >1    short        0x8c9d            (12 bits)
  476. >1    short        0x8d9d            (13 bits)
  477. >1    short        0x8e9d            (14 bits)
  478. >1    short        0x8f9d            (15 bits)
  479. >1    short        0x909d            (16 bits)
  480.  
  481. ############
  482. ##        ##
  483. ##  BTOA  ##
  484. ##  ====  ##
  485. ##        ##
  486. ############
  487.  
  488. 0    string        xbtoa            btoa'd file
  489.  
  490. ################
  491. ##            ##
  492. ##  UUDECODE  ##
  493. ##  ========  ##
  494. ##            ##
  495. ################
  496.  
  497. 0    string        begin            uuencoded file
  498.  
  499. #####
  500. ##   
  501. ##  GRAPHICS FORMATS
  502. ##  ================
  503. ##  The ever increasing number of formats makes this section quite
  504. ##  large and the most useful of the collection
  505. ##   
  506. #####
  507.  
  508. ###########
  509. ##       ##
  510. ##  GIF  ##
  511. ##  ===  ##
  512. ##       ##
  513. ###########
  514.  
  515. 0    string        GIF            GIF image archive 
  516. >3    string        87a            - version %3s
  517. >3    string        87A            - version %3s
  518. >3    string        89a            - version %3s
  519. >3    string        89A            - version %3s
  520.  
  521. ############
  522. ##        ##
  523. ##  JPEG  ##
  524. ##  ====  ##
  525. ##        ##
  526. ############
  527.  
  528. 0    long        0xffd8ffe0        JPEG image, big endian
  529. 0    long        0xe0ffd8ff        JPEG image, little endian
  530. 0    string        hsi1            HSI1 image (wrapper for JPEG?)
  531. 6    string        JFIF            JPEG JFIF
  532.  
  533. ####################
  534. ##                ##
  535. ##  PBM+ FORMATS  ##
  536. ##  ============  ##
  537. ##                ##
  538. ####################
  539.  
  540. 0    string        P1            PBM file
  541. 0    string        P2            PGM file
  542. 0    string        P3            PPM file
  543. 0    string        P4            PBM "rawbits" file
  544. 0    string        P5            PGM "rawbits" file
  545. 0    string        P6            PPM "rawbits" file
  546.  
  547. ##############################
  548. ##                          ##
  549. ##  OTHER GRAPHICS FORMATS  ##
  550. ##  ======================  ##
  551. ##                          ##
  552. ##############################
  553.  
  554. 0    string        \361\0\100\273        CMU window manager bitmap
  555. 0    string        \131\246\152\225    Sun rasterfile
  556. 0    string        yz            MGR bitmap
  557. 0    string        \115\115        TIFF file, big-endian
  558. 0    string        \111\111        TIFF file, little-endian
  559. 8    string        ILBM            IFF ILBM file
  560. 0    string        This\040is\040a\040BitMap\040file    Lisp Machine bit-array-file
  561. 0    string        !!            Bennet Yee's "face" format
  562. 0    long        0xf7020183        DVI
  563. 0    string        \0\0\1\263        MPEG Paris
  564.  
  565. #####
  566. ##   
  567. ##  SOUND FORMATS
  568. ##  =============
  569. ##  A few different sound formats from different machines.
  570. ##   
  571. #####
  572.  
  573. 0    string        .snd            Sun Audio
  574.  
  575. ##### Here endeth the list.
  576. ##### Last Updated 10th December 1992.
  577. ##### John Adams, User Services, University College London.
  578. ##### J.Adams@ucl.ac.uk     (J.Adams@uk.ac.ucl for JANET users)
  579.