-
Notifications
You must be signed in to change notification settings - Fork 0
/
application_header.go
50 lines (32 loc) · 1.07 KB
/
application_header.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package main
import (
"fmt"
"os"
)
func ExtractApplicationHeader(file *os.File) {
segmentLengthBuffer := make([]byte, 2)
_, err := ReadFunc(file, segmentLengthBuffer)
if err != nil {
fmt.Println(err)
panic(err)
}
segmentLength := BigEUint16(segmentLengthBuffer[0], segmentLengthBuffer[1])
fmt.Printf("Length %d\n", segmentLength)
segmentDataBuffer := make([]byte, segmentLength-2)
_, err = ReadFunc(file, segmentDataBuffer)
if err != nil {
fmt.Println(err)
panic(err)
}
fmt.Printf("Identifier %08x\\%02x\n", segmentDataBuffer[:4], segmentDataBuffer[4:5])
fmt.Printf("Version %d.%d\n",
int(segmentDataBuffer[5:6][0]),
int(segmentDataBuffer[6:7][0]),
)
fmt.Printf("Units %d\n", int(segmentDataBuffer[7:8][0]))
fmt.Printf("X Units %d\n", BigEUint16(segmentDataBuffer[8:10][0], segmentDataBuffer[8:10][1]))
fmt.Printf("Y Units %d\n", BigEUint16(segmentDataBuffer[10:12][0], segmentDataBuffer[10:12][1]))
fmt.Printf("X ThumbNail %d\n", int(segmentDataBuffer[12:13][0]))
fmt.Printf("Y ThumbNail %d\n", int(segmentDataBuffer[13:14][0]))
fmt.Println("")
}