![]() |
libtld 2.0.14
A library to determine the Top-Level Domain name of any Internet URI.
|
Declaration of the TLD file structures. More...
#include <stdint.h>
#include <iostream>
Go to the source code of this file.
Classes | |
class | auto_free_string |
class | auto_free_tld_file |
struct | tld_description |
[internal] The description of one TLD. More... | |
struct | tld_file |
struct | tld_header |
struct | tld_hunk |
struct | tld_magic |
struct | tld_string_length |
struct | tld_string_offset |
struct | tld_tag |
Macros | |
#define | TLD_DESCRIPTIONS TLD_HUNK('D','E','S','C') |
#define | TLD_FILE_VERSION_MAJOR 1 |
#define | TLD_FILE_VERSION_MINOR 0 |
#define | TLD_HEADER TLD_HUNK('H','E','A','D') |
#define | TLD_HUNK(a, b, c, d) ((uint32_t)((a)|((b)<<8)|((c)<<16)|((d)<<24))) |
#define | TLD_MAGIC TLD_HUNK('R','I','F','F') |
#define | TLD_STRING_LENGTHS TLD_HUNK('S','L','E','N') |
#define | TLD_STRING_OFFSETS TLD_HUNK('S','O','F','F') |
#define | TLD_STRINGS TLD_HUNK('S','T','R','S') |
#define | TLD_TAGS TLD_HUNK('T','A','G','S') |
#define | TLD_TLDS TLD_HUNK('T','L','D','S') |
Functions | |
const struct tld_description * | tld_file_description (struct tld_file const *file, uint32_t id) |
const char * | tld_file_errstr (enum tld_file_error err) |
void | tld_file_free (struct tld_file **file) |
enum tld_file_error | tld_file_load (const char *filename, struct tld_file **file) |
enum tld_file_error | tld_file_load_stream (tld_file **file, std::istream &in) |
const char * | tld_file_string (struct tld_file const *file, uint32_t id, uint32_t *length) |
const struct tld_tag * | tld_file_tag (struct tld_file const *file, uint32_t id) |
char * | tld_file_to_json (struct tld_file const *file) |
The older version of the libtld had a pre-compiled structure within the library. The main problem with that designed is that you can't quickly update the list of domain name TLDs. You have to recompile the whole library, generate a new package, install that new package.
The pros are of course that you only have to deal with one file (.so or .a or similar file for your OS).
Yet, the number of TLDs has been growing and changing a lot back and forth in the last 10 years or so and having a compressed external file will make it a lot faster and a lot easier to update the available TLDs.
The structures found here describe that external file. The basic format is IFF (like a WAVE file, sizes and other numbers will be in the endian of your computer, so watch out on that part).
At time of writing, I have these hunks:
Definition in file tld_file.h.
#define TLD_DESCRIPTIONS TLD_HUNK('D','E','S','C') |
Definition at line 75 of file tld_file.h.
#define TLD_FILE_VERSION_MAJOR 1 |
Definition at line 67 of file tld_file.h.
#define TLD_FILE_VERSION_MINOR 0 |
Definition at line 68 of file tld_file.h.
#define TLD_HEADER TLD_HUNK('H','E','A','D') |
Definition at line 74 of file tld_file.h.
#define TLD_HUNK | ( | a, | |
b, | |||
c, | |||
d | |||
) | ((uint32_t)((a)|((b)<<8)|((c)<<16)|((d)<<24))) |
Definition at line 70 of file tld_file.h.
#define TLD_MAGIC TLD_HUNK('R','I','F','F') |
Definition at line 72 of file tld_file.h.
#define TLD_STRING_LENGTHS TLD_HUNK('S','L','E','N') |
Definition at line 78 of file tld_file.h.
#define TLD_STRING_OFFSETS TLD_HUNK('S','O','F','F') |
Definition at line 77 of file tld_file.h.
#define TLD_STRINGS TLD_HUNK('S','T','R','S') |
Definition at line 79 of file tld_file.h.
#define TLD_TAGS TLD_HUNK('T','A','G','S') |
Definition at line 76 of file tld_file.h.
#define TLD_TLDS TLD_HUNK('T','L','D','S') |
Definition at line 73 of file tld_file.h.
enum tld_file_error |
Definition at line 166 of file tld_file.h.
const char * tld_file_errstr | ( | enum tld_file_error | err | ) |
Definition at line 298 of file tld_file.cpp.
void tld_file_free | ( | struct tld_file ** | file | ) |
Definition at line 490 of file tld_file.cpp.
enum tld_file_error tld_file_load | ( | const char * | filename, |
struct tld_file ** | file | ||
) |
Definition at line 275 of file tld_file.cpp.
enum tld_file_error tld_file_load_stream | ( | tld_file ** | file, |
std::istream & | in | ||
) |
Definition at line 51 of file tld_file.cpp.
This document is part of the Snap! Websites Project.
Copyright by Made to Order Software Corp.