axmlParser

package module
v0.0.0-...-8e32cc8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 25, 2020 License: MIT Imports: 7 Imported by: 1

README

Android binary manifest XML file parser library for Golang

Build Status

This is a golang port of github.com/xgouchet/AXML.

This package aims to parse an android binary mainfest xml file on an apk file.

Installation

go get gitea.com/lunny/axmlParser

Usage

package main

import (
	"fmt"

	"gitea.com/lunny/axmlParser"
)

func main() {
	listener := new(axmlParser.AppNameListener)
	axmlParser.ParseApk("./myApp.apk", listener)

	fmt.Printf("ActivityName: %v\n", listener.ActivityName)
	fmt.Printf("VersionCode: %v\n", listener.VersionCode)
	fmt.Printf("VersionName: %v\n", listener.VersionName)
}

Documentation

Index

Constants

View Source
const (
	TAG = "CXP"

	WORD_START_DOCUMENT = 0x00080003

	WORD_STRING_TABLE = 0x001C0001
	WORD_RES_TABLE    = 0x00080180

	WORD_START_NS  = 0x00100100
	WORD_END_NS    = 0x00100101
	WORD_START_TAG = 0x00100102
	WORD_END_TAG   = 0x00100103
	WORD_TEXT      = 0x00100104
	WORD_EOS       = 0xFFFFFFFF
	WORD_SIZE      = 4

	TYPE_ID_REF   = 0x01000008
	TYPE_ATTR_REF = 0x02000008
	TYPE_STRING   = 0x03000008
	TYPE_DIMEN    = 0x05000008
	TYPE_FRACTION = 0x06000008
	TYPE_INT      = 0x10000008
	TYPE_FLOAT    = 0x04000008

	TYPE_FLAGS  = 0x11000008
	TYPE_BOOL   = 0x12000008
	TYPE_COLOR  = 0x1C000008
	TYPE_COLOR2 = 0x1D000008
)

Variables

View Source
var (
	DIMEN = []string{"px", "dp", "sp",
		"pt", "in", "mm"}
)

Functions

This section is empty.

Types

type AppNameListener

type AppNameListener struct {
	PackageName  string
	VersionName  string
	VersionCode  string
	ActivityName string
	// contains filtered or unexported fields
}

func (*AppNameListener) CharacterData

func (listener *AppNameListener) CharacterData(data string)

*

  • Receive notification of character data (in a <![CDATA[ ]]> block). *
  • @param data
  • the text data

func (*AppNameListener) EndDocument

func (listener *AppNameListener) EndDocument()

*

  • Receive notification of the end of a document.

func (*AppNameListener) EndElement

func (listener *AppNameListener) EndElement(uri, localName, qName string)

*

  • Receive notification of the end of an element. *
  • @param uri
  • the Namespace URI, or the empty string if the element has no
  • Namespace URI or if Namespace processing is not being
  • performed
  • @param localName
  • the local name (without prefix), or the empty string if
  • Namespace processing is not being performed
  • @param qName
  • the qualified XML name (with prefix), or the empty string if
  • qualified names are not available

func (*AppNameListener) EndPrefixMapping

func (listener *AppNameListener) EndPrefixMapping(prefix, uri string)

*

  • End the scope of a prefix-URI mapping. *
  • @param prefix
  • the prefix that was being mapped. This is the empty string
  • when a default mapping scope ends.
  • @param uri
  • the Namespace URI the prefix is mapped to

func (*AppNameListener) ProcessingInstruction

func (listener *AppNameListener) ProcessingInstruction(target, data string)

*

  • Receive notification of a processing instruction. *
  • @param target
  • the processing instruction target
  • @param data
  • the processing instruction data, or null if none was supplied.
  • The data does not include any whitespace separating it from
  • the target
  • @throws org.xml.sax.SAXException
  • any SAX exception, possibly wrapping another exception

func (*AppNameListener) StartDocument

func (listener *AppNameListener) StartDocument()

func (*AppNameListener) StartElement

func (listener *AppNameListener) StartElement(uri, localName, qName string,
	attrs []*Attribute)

*

  • Receive notification of the beginning of an element. *
  • @param uri
  • the Namespace URI, or the empty string if the element has no
  • Namespace URI or if Namespace processing is not being
  • performed
  • @param localName
  • the local name (without prefix), or the empty string if
  • Namespace processing is not being performed
  • @param qName
  • the qualified name (with prefix), or the empty string if
  • qualified names are not available
  • @param atts
  • the attributes attached to the element. If there are no
  • attributes, it shall be an empty Attributes object. The value
  • of this object after startElement returns is undefined

func (*AppNameListener) StartPrefixMapping

func (listener *AppNameListener) StartPrefixMapping(prefix, uri string)

*

  • Begin the scope of a prefix-URI Namespace mapping. *
  • @param prefix
  • the Namespace prefix being declared. An empty string is used
  • for the default element namespace, which has no prefix.
  • @param uri
  • the Namespace URI the prefix is mapped to

func (*AppNameListener) Text

func (listener *AppNameListener) Text(data string)

*

  • Receive notification of text. *
  • @param data
  • the text data

type Attribute

type Attribute struct {
	Name, Prefix, Namespace, Value string
}

type Listener

type Listener interface {
	StartDocument()

	/**
	 * Receive notification of the end of a document.
	 */
	EndDocument()

	/**
	 * Begin the scope of a prefix-URI Namespace mapping.
	 *
	 * @param prefix
	 *            the Namespace prefix being declared. An empty string is used
	 *            for the default element namespace, which has no prefix.
	 * @param uri
	 *            the Namespace URI the prefix is mapped to
	 */
	StartPrefixMapping(prefix, uri string)

	/**
	 * End the scope of a prefix-URI mapping.
	 *
	 * @param prefix
	 *            the prefix that was being mapped. This is the empty string
	 *            when a default mapping scope ends.
	 * @param uri
	 *            the Namespace URI the prefix is mapped to
	 */
	EndPrefixMapping(prefix, uri string)

	/**
	 * Receive notification of the beginning of an element.
	 *
	 * @param uri
	 *            the Namespace URI, or the empty string if the element has no
	 *            Namespace URI or if Namespace processing is not being
	 *            performed
	 * @param localName
	 *            the local name (without prefix), or the empty string if
	 *            Namespace processing is not being performed
	 * @param qName
	 *            the qualified name (with prefix), or the empty string if
	 *            qualified names are not available
	 * @param atts
	 *            the attributes attached to the element. If there are no
	 *            attributes, it shall be an empty Attributes object. The value
	 *            of this object after startElement returns is undefined
	 */
	StartElement(uri, localName, qName string,
		atts []*Attribute)

	/**
	 * Receive notification of the end of an element.
	 *
	 * @param uri
	 *            the Namespace URI, or the empty string if the element has no
	 *            Namespace URI or if Namespace processing is not being
	 *            performed
	 * @param localName
	 *            the local name (without prefix), or the empty string if
	 *            Namespace processing is not being performed
	 * @param qName
	 *            the qualified XML name (with prefix), or the empty string if
	 *            qualified names are not available
	 */
	EndElement(uri, localName, qName string)

	/**
	 * Receive notification of text.
	 *
	 * @param data
	 *            the text data
	 */
	Text(data string)

	/**
	 * Receive notification of character data (in a <![CDATA[ ]]> block).
	 *
	 * @param data
	 *            the text data
	 */
	CharacterData(data string)

	/**
	 * Receive notification of a processing instruction.
	 *
	 * @param target
	 *            the processing instruction target
	 * @param data
	 *            the processing instruction data, or null if none was supplied.
	 *            The data does not include any whitespace separating it from
	 *            the target
	 * @throws org.xml.sax.SAXException
	 *             any SAX exception, possibly wrapping another exception
	 */
	ProcessingInstruction(target, data string)
}

type Manifest

type Manifest struct {
	Attrs map[string][]*Attribute
}

type Parser

type Parser struct {

	// Internal
	Namespaces map[string]string
	Data       []byte

	StringsTable                        []string
	ResourcesIds                        []int
	StringsCount, StylesCount, ResCount int
	ParserOffset                        int
	// contains filtered or unexported fields
}

func New

func New(listener Listener) *Parser

func ParseApk

func ParseApk(apkpath string, listener Listener) (*Parser, error)

func ParseAxml

func ParseAxml(axmlpath string, listener Listener) (*Parser, error)

func (*Parser) IsValid

func (parser *Parser) IsValid(header []byte) bool

func (*Parser) Parse

func (parser *Parser) Parse(data []byte) error

type PlainListener

type PlainListener struct {
	Manifest Manifest
}

func (*PlainListener) BuildXml

func (listener *PlainListener) BuildXml(writer io.Writer) error

func (*PlainListener) CharacterData

func (listener *PlainListener) CharacterData(data string)

*

  • Receive notification of character data (in a <![CDATA[ ]]> block). *
  • @param data
  • the text data

func (*PlainListener) EndDocument

func (listener *PlainListener) EndDocument()

*

  • Receive notification of the end of a document.

func (*PlainListener) EndElement

func (listener *PlainListener) EndElement(uri, localName, qName string)

*

  • Receive notification of the end of an element. *
  • @param uri
  • the Namespace URI, or the empty string if the element has no
  • Namespace URI or if Namespace processing is not being
  • performed
  • @param localName
  • the local name (without prefix), or the empty string if
  • Namespace processing is not being performed
  • @param qName
  • the qualified XML name (with prefix), or the empty string if
  • qualified names are not available

func (*PlainListener) EndPrefixMapping

func (listener *PlainListener) EndPrefixMapping(prefix, uri string)

*

  • End the scope of a prefix-URI mapping. *
  • @param prefix
  • the prefix that was being mapped. This is the empty string
  • when a default mapping scope ends.
  • @param uri
  • the Namespace URI the prefix is mapped to

func (*PlainListener) ProcessingInstruction

func (listener *PlainListener) ProcessingInstruction(target, data string)

*

  • Receive notification of a processing instruction. *
  • @param target
  • the processing instruction target
  • @param data
  • the processing instruction data, or null if none was supplied.
  • The data does not include any whitespace separating it from
  • the target
  • @throws org.xml.sax.SAXException
  • any SAX exception, possibly wrapping another exception

func (*PlainListener) StartDocument

func (listener *PlainListener) StartDocument()

func (*PlainListener) StartElement

func (listener *PlainListener) StartElement(uri, localName, qName string,
	attrs []*Attribute)

*

  • Receive notification of the beginning of an element. *
  • @param uri
  • the Namespace URI, or the empty string if the element has no
  • Namespace URI or if Namespace processing is not being
  • performed
  • @param localName
  • the local name (without prefix), or the empty string if
  • Namespace processing is not being performed
  • @param qName
  • the qualified name (with prefix), or the empty string if
  • qualified names are not available
  • @param atts
  • the attributes attached to the element. If there are no
  • attributes, it shall be an empty Attributes object. The value
  • of this object after startElement returns is undefined

func (*PlainListener) StartPrefixMapping

func (listener *PlainListener) StartPrefixMapping(prefix, uri string)

*

  • Begin the scope of a prefix-URI Namespace mapping. *
  • @param prefix
  • the Namespace prefix being declared. An empty string is used
  • for the default element namespace, which has no prefix.
  • @param uri
  • the Namespace URI the prefix is mapped to

func (*PlainListener) Text

func (listener *PlainListener) Text(data string)

*

  • Receive notification of text. *
  • @param data
  • the text data

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL