34#if ( defined(LIBTLD_DLL) || defined(_WINDLL) ) && ( defined(_WINDOWS) || defined(WINDOWS) )
36#define LIBTLD_EXPORT __declspec(dllexport)
38#define LIBTLD_EXPORT __declspec(dllimport)
48#define LIBTLD_VERSION_MAJOR 2
49#define LIBTLD_VERSION_MINOR 0
50#define LIBTLD_VERSION_PATCH 14
51#define LIBTLD_VERSION "2.0.14"
115 const char * f_value;
126#define VALID_URI_ASCII_ONLY 0x0001
127#define VALID_URI_NO_SPACES 0x0002
194 invalid_domain(
const char *what_str =
"this tld object is not currently valid") : runtime_error(what_str) {}
203 void set_domain(
const char *domain_name);
204 void set_domain(
const std::string& domain_name);
207 bool is_valid()
const;
208 std::string domain()
const;
209 std::string sub_domains()
const;
210 std::string full_domain()
const;
211 std::string domain_only()
const;
212 std::string tld_only()
const;
214 std::string country()
const;
216 std::string f_domain = std::string();
228 tld_result parse_group(
const std::string& group);
230 std::string f_group = std::string();
231 std::string f_original_email = std::string();
232 std::string f_fullname = std::string();
233 std::string f_username = std::string();
234 std::string f_domain = std::string();
235 std::string f_email_only = std::string();
236 std::string f_canonicalized_email = std::string();
241 tld_result parse(
const std::string& emails,
int flags);
242 static std::string quote_string(
const std::string& name,
char quote);
251 void parse_all_emails();
253 std::string f_input = std::string();
256 std::string f_last_group = std::string();
257 mutable int f_pos = 0;
Class used to ease the use o the tld() function in C++.
Exception thrown when querying for data of an invalid domain.
invalid_domain(const char *what_str="this tld object is not currently valid")
Initialize the invalid_domain exception.
The C++ side of the email list implementation.
std::vector< tld_email_t > tld_email_list_t
A vector of email details.
const char * f_group
The group this emails was defined in.
const char * f_canonicalized_email
The email including the display name.
const char * f_original_email
The email as read from the source.
const char * f_email_only
The complete email address without display name.
const char * f_username
The user being named in this email address.
const char * f_domain
The domain part of the email address.
const char * f_fullname
The user full or display name.
Set of information returned by the tld() function.
enum tld_category f_category
The category of the TLD.
enum tld_status f_status
The status of the TLD.
int f_offset
The offset to the TLD in the URI string you supplied.
char f_country[48]
The country where this TLD is used.
const char * f_tld
Pointer to the TLD in the URI string you supplied.
LIBTLD_EXPORT char * tld_domain_to_lowercase(const char *domain)
Transform a domain with a TLD to lowercase before processing.
@ TLD_EMAIL_FIELD_TYPE_UNKNOWN
The input does not represent valid emails.
@ TLD_EMAIL_FIELD_TYPE_ADDRESS_LIST
The input represents a mandatory list of mailboxes.
@ TLD_EMAIL_FIELD_TYPE_MAILBOX
The input represents a mailbox.
@ TLD_EMAIL_FIELD_TYPE_ADDRESS_LIST_OPT
The input represents an optional list of email addresses.
@ TLD_EMAIL_FIELD_TYPE_INVALID
The input of email_field_type() was not valid.
@ TLD_EMAIL_FIELD_TYPE_MAILBOX_LIST
The input represents a mailbox list.
LIBTLD_EXPORT void tld_email_free(struct tld_email_list *list)
Free the list of emails.
LIBTLD_EXPORT enum tld_result tld(const char *uri, struct tld_info *info)
Get information about the TLD for the specified URI.
LIBTLD_EXPORT const char * tld_status_to_string(enum tld_status status)
Transform the status to a string.
#define LIBTLD_EXPORT
The export API used by MS-Windows DLLs.
@ TLD_CATEGORY_PROFESSIONALS
Professional TLDs.
@ TLD_CATEGORY_LANGUAGE
Language specific TLDs.
@ TLD_CATEGORY_BRAND
The TLD is owned and represents a brand.
@ TLD_CATEGORY_COUNTRY
A country extension.
@ TLD_CATEGORY_GROUP
Groups specific TLDs.
@ TLD_CATEGORY_TECHNICAL
Technical extensions are considered internal.
@ TLD_CATEGORY_LOCATION
Another region specific TLDs.
@ TLD_CATEGORY_INTERNATIONAL
International TLDs.
@ TLD_CATEGORY_UNDEFINED
The TLD was not found.
@ TLD_CATEGORY_ENTREPRENEURIAL
A private extension.
@ TLD_CATEGORY_REGION
Region specific TLDs.
@ TLD_CATEGORY_CONTACT
The attached TLD has contact information.
LIBTLD_EXPORT void tld_email_rewind(struct tld_email_list *list)
Rewind the reading of the emails.
LIBTLD_EXPORT struct tld_email_list * tld_email_alloc()
Allocate a list of emails object.
LIBTLD_EXPORT const char * tld_version()
Return the version of the library.
LIBTLD_EXPORT int tld_email_count(struct tld_email_list *list)
Return the number of emails found after a parse.
LIBTLD_EXPORT enum tld_result tld_email_parse(struct tld_email_list *list, const char *emails, int flags)
Parse a list of emails in the email list object.
LIBTLD_EXPORT void tld_clear_info(struct tld_info *info)
Clear the info structure.
LIBTLD_EXPORT enum tld_result tld_load_tlds(const char *filename, int fallback)
Load a TLDs file as the file to be used by the tld() function.
LIBTLD_EXPORT const struct tld_file * tld_get_tlds()
Return a pointer to the current list of TLDs.
LIBTLD_EXPORT enum tld_category tld_word_to_category(const char *word, int n)
This is for backward compatibility.
LIBTLD_EXPORT enum tld_result tld_next_tld(struct tld_enumeration_state *state, struct tld_info *info)
Read the next TLD and return its info.
LIBTLD_EXPORT enum tld_result tld_check_uri(const char *uri, struct tld_info *info, const char *protocols, int flags)
Check that a URI is valid.
LIBTLD_EXPORT void tld_free_tlds()
Clear the allocated TLD file.
@ TLD_RESULT_SUCCESS
Success! The TLD of the specified URI is valid.
@ TLD_RESULT_NO_TLD
The input URI has no TLD defined.
@ TLD_RESULT_INVALID
The TLD was found, but it is marked as invalid.
@ TLD_RESULT_BAD_URI
The URI includes characters that are not accepted by the function.
@ TLD_RESULT_NOT_FOUND
The URI has a TLD that could not be determined.
@ TLD_RESULT_NULL
The input URI is empty.
@ TLD_STATUS_EXCEPTION
Special status to indicate an exception which is not directly a TLD.
@ TLD_STATUS_UNDEFINED
Special status to indicate we did not find the TLD.
@ TLD_STATUS_RESERVED
The TLD is reserved so no one can use it.
@ TLD_STATUS_VALID
The TLD is currently valid.
@ TLD_STATUS_INFRASTRUCTURE
These TLDs are reserved for the Internet infrastructure.
@ TLD_STATUS_UNUSED
The TLD was officially assigned but not put to use.
@ TLD_STATUS_DEPRECATED
The TLD was once in use.
@ TLD_STATUS_PROPOSED
The TLD was proposed but not yet accepted.
LIBTLD_EXPORT int tld_email_next(struct tld_email_list *list, struct tld_email *e)
Retrieve the next email.
void list()
List the default schemes accepted.