I added the APOUT_UNIX_VERSION variable, so we can recompile/reassemble
authorwarren.toomey <warren.toomey@44b2186c-a14b-0410-8c95-595313601b93>
Thu, 15 May 2008 03:21:46 +0000 (03:21 +0000)
committerwarren.toomey <warren.toomey@44b2186c-a14b-0410-8c95-595313601b93>
Thu, 15 May 2008 03:21:46 +0000 (03:21 +0000)
V2 source code and then run it, without having to muck with the magic.c.

apout.1
magic.c

diff --git a/apout.1 b/apout.1
index 902365b..135e972 100644 (file)
--- a/apout.1
+++ b/apout.1
@@ -1,7 +1,7 @@
 .\" Copyright Warren Toomey
 .\"
-.\" $Revision: 1.9 $
-.\" $Date: 2002/06/10 12:08:27 $
+.\" $Revision: 1.10 $
+.\" $Date: 2008/05/15 03:20:52 $
 .\"
 .Dd December, 2000
 .Dt APOUT 1
@@ -104,6 +104,17 @@ Note that you must set
 .Ev APOUT_ROOT
 before you can run 
 .Nm apout.
+.Pp
+There is one other optional environment variable:
+.Ev APOUT_UNIX_VERSION.
+This is mainly required for UNIX binaries that use the 0407 header,
+which was used across several versions of UNIX, each with a different set
+of system calls. If APOUT_UNIX_VERSION is set,
+.Nm apout
+will use the given version when it cannot determine which version of UNIX a
+binary belongs to. The available values are "V1", "V2", "V3", "V4", "V5", "V6",
+"V7", "2.9BSD" and "2.11BSD".
+.Pp
 .Sh EMULATED ENVIRONMENT VARIABLES
 Initially, PDP-11 binaries run via
 .Nm apout
diff --git a/magic.c b/magic.c
index e326d56..7368240 100644 (file)
--- a/magic.c
+++ b/magic.c
@@ -6,8 +6,8 @@
  * a.out header. If it matches any of the checksums below, it returns
  * the appropriate environment value. Otherwise, it returns IS_UNKNOWN.
  *
- * $Revision: 1.14 $
- * $Date: 2008/05/06 23:31:53 $
+ * $Revision: 1.15 $
+ * $Date: 2008/05/15 03:20:52 $
  */
 #include "defines.h"
 
@@ -118,6 +118,7 @@ int special_magic(u_int16_t *cptr)
 {
     u_int32_t cksum=0;
     int i;
+    char *unix_version;
 
     if (cptr==NULL) return(IS_UNKNOWN);
                                /* Calculate the checksum */
@@ -129,7 +130,20 @@ int special_magic(u_int16_t *cptr)
       return(S[i].environment);
     }
 
-                               /* None, return 0 */
+                               /* See if user tells us what version to use */
+    if ((unix_version = getenv("APOUT_UNIX_VERSION"))) {
+       if (!strcmp(unix_version, "V1")) return(IS_V1);
+       if (!strcmp(unix_version, "V2")) return(IS_V2);
+       if (!strcmp(unix_version, "V3")) return(IS_V3);
+       if (!strcmp(unix_version, "V4")) return(IS_V4);
+       if (!strcmp(unix_version, "V5")) return(IS_V5);
+       if (!strcmp(unix_version, "V6")) return(IS_V6);
+       if (!strcmp(unix_version, "V7")) return(IS_V7);
+       if (!strcmp(unix_version, "2.9BSD")) return(IS_29BSD);
+       if (!strcmp(unix_version, "2.11BSD")) return(IS_211BSD);
+    }
+
+                       /* We can't tell what version of Unix, give up */
     (void)printf("Apout - unknown magic in header: 0x%x\n",cksum);
     return(IS_UNKNOWN);
 }