SF.net SVN: jrpm: [18] trunk/src/java/com/jguild/jrpm/io/RPMLead.java
[email protected] Tue, 07 Nov 2006 15:42:36 -0800
| Newsgroups | gmane.comp.java.jrpm.devel |
|---|---|
| Message-ID | <[email protected]> |
Revision: 18
http://svn.sourceforge.net/jrpm/?rev=18&view=rev
Author: ymenager
Date: 2006-11-07 15:42:24 -0800 (Tue, 07 Nov 2006)
Log Message:
-----------
Removed failure when os is unknown due some IBM doing just that in some of their AIX packages
Modified Paths:
--------------
trunk/src/java/com/jguild/jrpm/io/RPMLead.java
Modified: trunk/src/java/com/jguild/jrpm/io/RPMLead.java
===================================================================
--- trunk/src/java/com/jguild/jrpm/io/RPMLead.java 2006-11-07 23:39:45 UTC (rev 17)
+++ trunk/src/java/com/jguild/jrpm/io/RPMLead.java 2006-11-07 23:42:24 UTC (rev 18)
@@ -1,201 +1,195 @@
-/*
- * jGuild Project: jRPM
- * Released under the Apache License ( http://www.apache.org/LICENSE )
- */
-package com.jguild.jrpm.io;
-
-import com.jguild.jrpm.io.constant.LeadArchitecture;
-import com.jguild.jrpm.io.constant.LeadOS;
-import com.jguild.jrpm.io.constant.LeadSignature;
-import com.jguild.jrpm.io.constant.LeadType;
-import com.jguild.jrpm.io.datatype.*;
-
-import java.util.logging.Logger;
-import java.util.logging.Level;
-
-import java.io.DataInputStream;
-import java.io.IOException;
-
-
-/**
- * The Java Version of the C struct for the lead.
- * <p/>
- * <code><pre>C struct :
- * struct rpmlead {
- * unsigned char magic[4];
- * unsigned char major, minor;
- * short type; (2 byte)
- * short archnum; (2 byte)
- * char name[66];
- * short osnum; (2 byte)
- * short signature_type; (2 byte)
- * char reserved[16];
- * } ;</pre></code>
- *
- * @version $Id: RPMLead.java,v 1.6 2003/10/20 16:32:11 mkuss Exp $
- */
-public class RPMLead {
- private static final Logger logger = RPMFile.logger;
- private LeadArchitecture arch;
- private LeadOS os;
- private LeadSignature sigType;
- private LeadType type;
- private String name;
- private int major;
- private int minor;
-
- protected RPMLead(DataInputStream inputStream)
- throws IOException {
- if (logger.isLoggable(Level.FINER)) {
- logger.finer("Start Reading Lead");
- }
-
- try {
- check(inputStream.readUnsignedByte() == 0xED);
- check(inputStream.readUnsignedByte() == 0xAB);
- check(inputStream.readUnsignedByte() == 0xEE);
- check(inputStream.readUnsignedByte() == 0xDB);
- major = inputStream.readUnsignedByte();
-
- if (logger.isLoggable(Level.FINER)) {
- logger.finer("major: " + major);
- }
-
- minor = inputStream.readUnsignedByte();
-
- if (logger.isLoggable(Level.FINER)) {
- logger.finer("minor: " + minor);
- }
-
- type = LeadType.getLeadType(inputStream.readUnsignedShort());
-
- if (logger.isLoggable(Level.FINER)) {
- logger.finer("type: " + type.getName());
- }
-
- arch = LeadArchitecture.getLeadArchitecture(inputStream.readUnsignedShort());
-
- if (logger.isLoggable(Level.FINER)) {
- logger.finer("arch: " + arch.getName());
- }
-
- byte[] nameBuf = new byte[66];
-
- inputStream.readFully(nameBuf);
- name = RPMUtil.cArrayToString(nameBuf, 0);
-
- if (logger.isLoggable(Level.FINER)) {
- logger.finer("name: " + name);
- }
-
- os = LeadOS.getLeadOS(inputStream.readUnsignedShort());
-
- if (logger.isLoggable(Level.FINER)) {
- logger.finer("os: " + os.getName());
- }
-
- sigType = LeadSignature.getLeadSignature(inputStream.readUnsignedShort());
-
- if (logger.isLoggable(Level.FINER)) {
- logger.finer("sigType: " + sigType.getName());
- }
-
- inputStream.skipBytes(16);
-
- check(major < 5);
- check(!type.equals(LeadType.UNKNOWN));
-
- // Ignore os and arch for source rpms
- if (!type.equals(LeadType.SOURCE)) {
- check(!os.equals(LeadOS.UNKNOWN));
- check(!arch.equals(LeadArchitecture.UNKNOWN));
- }
-
- check(!sigType.equals(LeadType.UNKNOWN));
- } finally {
- if (logger.isLoggable(Level.FINER)) {
- logger.finer("Finished Reading Lead");
- }
- }
- }
-
- /**
- * Get the architecture of a rpm
- *
- * @return the architecture
- */
- public LeadArchitecture getArchitecture() {
- return arch;
- }
-
- /**
- * Get the major number of the rpm version a rpm is build for
- *
- * @return The major number
- */
- public int getMajorVersion() {
- return major;
- }
-
- /**
- * Get the minor number of the rpm version a rpm is build for
- *
- * @return The minor number
- */
- public int getMinorVersion() {
- return minor;
- }
-
- /**
- * Get the name of this rpm. This field has a maximum length of 65
- * characters + one for the ending \0 for c strings.
- *
- * @return The name
- */
- public String getName() {
- return name;
- }
-
- /**
- * Get the operation system a rpm is build for
- *
- * @return The operation system
- */
- public LeadOS getOperationSystem() {
- return os;
- }
-
- /**
- * Get the type of signature this rpm provides
- *
- * @return The signature
- */
- public LeadSignature getSignatureType() {
- return sigType;
- }
-
- /**
- * Get the size of this structure in bytes (as defined for a rpm file)
- *
- * @return The size (96 bytes)
- */
- public final long getSize() {
- return 96;
- }
-
- /**
- * Get the type of a rpm file (binary or source)
- *
- * @return The type
- */
- public LeadType getType() {
- return type;
- }
-
- private static final void check(boolean test)
- throws IOException {
- if (!test) {
- throw new IOException("Corrupted archive");
- }
- }
-}
+/*
+ * jGuild Project: jRPM
+ * Released under the Apache License ( http://www.apache.org/LICENSE )
+ */
+package com.jguild.jrpm.io;
+
+import com.jguild.jrpm.io.constant.LeadArchitecture;
+import com.jguild.jrpm.io.constant.LeadOS;
+import com.jguild.jrpm.io.constant.LeadSignature;
+import com.jguild.jrpm.io.constant.LeadType;
+import com.jguild.jrpm.io.datatype.*;
+
+import java.util.logging.Logger;
+import java.util.logging.Level;
+
+import java.io.DataInputStream;
+import java.io.IOException;
+
+
+/**
+ * The Java Version of the C struct for the lead.
+ * <p/>
+ * <code><pre>C struct :
+ * struct rpmlead {
+ * unsigned char magic[4];
+ * unsigned char major, minor;
+ * short type; (2 byte)
+ * short archnum; (2 byte)
+ * char name[66];
+ * short osnum; (2 byte)
+ * short signature_type; (2 byte)
+ * char reserved[16];
+ * } ;</pre></code>
+ *
+ * @version $Id: RPMLead.java,v 1.6 2003/10/20 16:32:11 mkuss Exp $
+ */
+public class RPMLead {
+ private static final Logger logger = RPMFile.logger;
+ private LeadArchitecture arch;
+ private LeadOS os;
+ private LeadSignature sigType;
+ private LeadType type;
+ private String name;
+ private int major;
+ private int minor;
+
+ protected RPMLead(DataInputStream inputStream)
+ throws IOException {
+ if (logger.isLoggable(Level.FINER)) {
+ logger.finer("Start Reading Lead");
+ }
+
+ try {
+ check(inputStream.readUnsignedByte() == 0xED);
+ check(inputStream.readUnsignedByte() == 0xAB);
+ check(inputStream.readUnsignedByte() == 0xEE);
+ check(inputStream.readUnsignedByte() == 0xDB);
+ major = inputStream.readUnsignedByte();
+
+ if (logger.isLoggable(Level.FINER)) {
+ logger.finer("major: " + major);
+ }
+
+ minor = inputStream.readUnsignedByte();
+
+ if (logger.isLoggable(Level.FINER)) {
+ logger.finer("minor: " + minor);
+ }
+
+ type = LeadType.getLeadType(inputStream.readUnsignedShort());
+
+ if (logger.isLoggable(Level.FINER)) {
+ logger.finer("type: " + type.getName());
+ }
+
+ arch = LeadArchitecture.getLeadArchitecture(inputStream.readUnsignedShort());
+
+ if (logger.isLoggable(Level.FINER)) {
+ logger.finer("arch: " + arch.getName());
+ }
+
+ byte[] nameBuf = new byte[66];
+
+ inputStream.readFully(nameBuf);
+ name = RPMUtil.cArrayToString(nameBuf, 0);
+
+ if (logger.isLoggable(Level.FINER)) {
+ logger.finer("name: " + name);
+ }
+
+ os = LeadOS.getLeadOS(inputStream.readUnsignedShort());
+
+ if (logger.isLoggable(Level.FINER)) {
+ logger.finer("os: " + os.getName());
+ }
+
+ sigType = LeadSignature.getLeadSignature(inputStream.readUnsignedShort());
+
+ if (logger.isLoggable(Level.FINER)) {
+ logger.finer("sigType: " + sigType.getName());
+ }
+
+ inputStream.skipBytes(16);
+
+ check(major < 5);
+ check(!type.equals(LeadType.UNKNOWN));
+
+ check(!sigType.equals(LeadType.UNKNOWN));
+ } finally {
+ if (logger.isLoggable(Level.FINER)) {
+ logger.finer("Finished Reading Lead");
+ }
+ }
+ }
+
+ /**
+ * Get the architecture of a rpm
+ *
+ * @return the architecture
+ */
+ public LeadArchitecture getArchitecture() {
+ return arch;
+ }
+
+ /**
+ * Get the major number of the rpm version a rpm is build for
+ *
+ * @return The major number
+ */
+ public int getMajorVersion() {
+ return major;
+ }
+
+ /**
+ * Get the minor number of the rpm version a rpm is build for
+ *
+ * @return The minor number
+ */
+ public int getMinorVersion() {
+ return minor;
+ }
+
+ /**
+ * Get the name of this rpm. This field has a maximum length of 65
+ * characters + one for the ending \0 for c strings.
+ *
+ * @return The name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Get the operation system a rpm is build for
+ *
+ * @return The operation system
+ */
+ public LeadOS getOperationSystem() {
+ return os;
+ }
+
+ /**
+ * Get the type of signature this rpm provides
+ *
+ * @return The signature
+ */
+ public LeadSignature getSignatureType() {
+ return sigType;
+ }
+
+ /**
+ * Get the size of this structure in bytes (as defined for a rpm file)
+ *
+ * @return The size (96 bytes)
+ */
+ public final long getSize() {
+ return 96;
+ }
+
+ /**
+ * Get the type of a rpm file (binary or source)
+ *
+ * @return The type
+ */
+ public LeadType getType() {
+ return type;
+ }
+
+ private static final void check(boolean test)
+ throws IOException {
+ if (!test) {
+ throw new IOException("Corrupted archive");
+ }
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642