$MAGIC_NUMBER
$MAGIC_NUMBER :
Data file component
This class is responsible for loading the data file and walking the IPV4 Radix Trie to find the properties for a given User-Agent.
readHeader()
The header of the file contains the following data:
2B DA (US-ASCII) 1B File type ID (1: carrier data, 2:some other data.... etc) 2B Header length - the total size of the header including the preceding bytes 2B Length of copyright text ?B Copyright (US-ASCII) "(c) Copyright 2013 - Afilias Technologies Ltd" 24B Creation date (US-ASCII) "2013-08-07T15:36:44+0000" 1B Version, major 1B Version, minor 4B Licence ID 4B CRC-32 - all data after first bucket offset
checkFileTypeGetHeaderLength( $startBytes) : integer
Check the first few bytes to make sure we are opening a Carrier Identification file. Also get the length of the header.
$startBytes |
header length
readBuckets()
Each bucket is comprised of the following. The BucketHandler is responsible for actually parsing the data in each bucket. This method keeps reading until either the end of the file or until all necessary buckets have been read. It will skip buckets with IDs it does not recognise to hopefully future proof the API against possible additions to the data file
Bucket structure:
2B Bucket ID 4B CRC-32 checksum - NOTE: unsigned int! 4B Length of the data ?B Data