예제 #1
0
        public static SystemUseEntry Parse(byte[] data, int offset, Encoding encoding, SuspExtension extension,
                                           out byte length)
        {
            if (data[offset] == 0)
            {
                // A zero-byte here is invalid and indicates an incorrectly written SUSP field.
                // Return null to indicate to the caller that SUSP parsing is terminated.
                length = 0;

                return(null);
            }

            string name = Utilities.BytesToString(data, offset, 2);

            length = data[offset + 2];
            byte version = data[offset + 3];

            switch (name)
            {
            case "CE":
                return(new ContinuationSystemUseEntry(name, length, version, data, offset));

            case "PD":
                return(new PaddingSystemUseEntry(name, length, version));

            case "SP":
                return(new SharingProtocolSystemUseEntry(name, length, version, data, offset));

            case "ST":
                // Termination entry. There's no point in storing or validating this one.
                // Return null to indicate to the caller that SUSP parsing is terminated.
                return(null);

            case "ER":
                return(new ExtensionSystemUseEntry(name, length, version, data, offset, encoding));

            case "ES":
                return(new ExtensionSelectSystemUseEntry(name, length, version, data, offset));

            case "AA":
            case "AB":
            case "AS":
                // Placeholder support for Apple and Amiga extension records.
                return(new GenericSystemUseEntry(name, length, version, data, offset));

            default:
                if (extension == null)
                {
                    return(new GenericSystemUseEntry(name, length, version, data, offset));
                }

                return(extension.Parse(name, length, version, data, offset, encoding));
            }
        }
        public static SystemUseEntry Parse(byte[] data, int offset, Encoding encoding, SuspExtension extension, out int length)
        {
            string name = Utilities.BytesToString(data, offset, 2);

            length = data[offset + 2];

            switch (name)
            {
            case "CE":
                return(new ContinuationSystemUseEntry(data, offset));

            case "PD":
                return(new PaddingSystemUseEntry(data, offset));

            case "SP":
                return(new SharingProtocolSystemUseEntry(data, offset));

            case "ST":
                return(new TerminatorSystemUseEntry(data, offset));

            case "ER":
                return(new ExtensionSystemUseEntry(data, offset, encoding));

            case "ES":
                return(new ExtensionSelectSystemUseEntry(data, offset));

            default:
                if (extension == null)
                {
                    return(new GenericSystemUseEntry(data, offset));
                }
                else
                {
                    return(extension.Parse(name, data, offset, length, encoding));
                }
            }
        }
예제 #3
0
        public static SystemUseEntry Parse(byte[] data, int offset, Encoding encoding, SuspExtension extension, out int length)
        {
            string name = Utilities.BytesToString(data, offset, 2);
            length = data[offset + 2];

            switch (name)
            {
                case "CE":
                    return new ContinuationSystemUseEntry(data, offset);

                case "PD":
                    return new PaddingSystemUseEntry(data, offset);

                case "SP":
                    return new SharingProtocolSystemUseEntry(data, offset);

                case "ST":
                    return new TerminatorSystemUseEntry(data, offset);

                case "ER":
                    return new ExtensionSystemUseEntry(data, offset, encoding);

                case "ES":
                    return new ExtensionSelectSystemUseEntry(data, offset);

                default:
                    if (extension == null)
                    {
                        return new GenericSystemUseEntry(data, offset);
                    }
                    else
                    {
                        return extension.Parse(name, data, offset, length, encoding);
                    }
            }
        }