53const char *
schemes = 
"afp,adiumxtra,aw,beshare,bolo,cap,coap,crid,dns,feed,file," 
   54                      "finger,fish,ftp,ftps,git,gopher,http,https,icap,imap," 
   55                      "ipp,irc,irc6,ircs,mumble,mupdate,mysql,nfs,nntp," 
   56                      "opaquelocktoken,pop,psql,psyc,rmi,rsync,rtmp,rtsp,rtspu," 
   57                      "sftp,shttp,sieve,smb,snmp,soap.beep,soap.beeps,soldat," 
   58                      "ssh,teamspeak,telnet,tftp,tip,udp,unreal,ut2004,vemmi," 
   59                      "ventrilo,wais,webcal,wyciwyg,z39.50r,z39.50s";
 
   73    if(strncasecmp(uri, 
"mailto:", 7) == 0)
 
   76        result = mail.
parse(uri + 7, 0);
 
   86            std::cout << 
"URI:      " << uri << std::endl;                                      
 
   87            std::cout << 
"Category: " << 
static_cast<int>(info.
f_category) << std::endl;        
 
   88            std::cout << 
"Status:   " << 
static_cast<int>(info.
f_status) << std::endl;          
 
   91                std::cout << 
"Country:  " << info.
f_country << std::endl;                       
 
   93            if(info.
f_tld != 
nullptr)
 
   97                char const * e(strchr(info.
f_tld, 
':'));
 
  100                    e = strchr(info.
f_tld, 
'/');
 
  104                    std::cout << 
"TLD:      " << info.
f_tld << std::endl;                       
 
  108                    std::cout << 
"TLD:      " << std::string(info.
f_tld, e - info.
f_tld) << std::endl; 
 
  110                std::cout << 
"Offset:   " << info.
f_offset << std::endl;                        
 
  116        std::cerr << 
"error: URI \"" << uri << 
"\" is not considered valid." << std::endl;
 
 
  127    for(
const char *s(
schemes); *s != 
'\0'; ++s)
 
 
  149    printf(
"Usage: validate_tld [-<opts>] <uri> | <email>\n");
 
  150    printf(
"Where <uri> or <email> are URIs starting with a valid scheme.\n");
 
  151    printf(
"The <email> scheme is mailto:.\n");
 
  152    printf(
"Where -<opts> are:\n");
 
  153    printf(
"  -h | --help               print out this help screen\n");
 
  154    printf(
"  -l | --list               print the default list of schemes\n");
 
  155    printf(
"  -s | --schemes <list>     set the list of schemes with user's defined schemes\n");
 
  156    printf(
"                            the list is a comma separate set of scheme names\n");
 
  157    printf(
"  -v | --verbose            request some verbosity of the tool's work\n");
 
 
  172int main(
int argc, 
char *argv[])
 
  178        for(
int i(1); i < argc; ++i)
 
  180            if(argv[i][0] == 
'-')
 
  182                if(strcmp(argv[i], 
"-h") == 0 || strcmp(argv[i], 
"--help") == 0)
 
  187                else if(strcmp(argv[i], 
"-l") == 0 || strcmp(argv[i], 
"--list") == 0)
 
  192                else if(strcmp(argv[i], 
"--version") == 0)
 
  201                else if(strcmp(argv[i], 
"-s") == 0 || strcmp(argv[i], 
"--schemes") == 0)
 
  206                        fprintf(stderr, 
"error: the --schemes option requires a list of comma separated schemes.\n");
 
  210                else if(strcmp(argv[i], 
"-v") == 0 || strcmp(argv[i], 
"--verbose") == 0)
 
  224            fprintf(stderr, 
"error: no URI was specified on the command line.\n");
 
  230    catch(std::exception 
const& e) 
 
  238        std::cerr << 
"exception: " << e.what() << std::endl; 
 
 
The C++ side of the email list implementation.
tld_result parse(const std::string &emails, int flags)
Parse a new list of emails.
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.
The public header of the libtld library.
#define LIBTLD_VERSION
The version of the library as a string.
LIBTLD_EXPORT const char * tld_version()
Return the version of the library.
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.
@ TLD_RESULT_SUCCESS
Success! The TLD of the specified URI is valid.
int verbose
Whether the user asked for verbosity, false by default.
int main(int argc, char *argv[])
The validate tools.
void usage()
Print out the help of the tld tool.
char const  * user_schemes
Hold a list of schemes as defined by the end user.
int err_count
Number of errors so we know whether to exit with 0 or 1.
void list()
List the default schemes accepted.
const char * schemes
List of schemes that we more or less support (some schemes have extensions using the semi-colon that ...
void check_uri(char const *uri)
Check the parameter as a URI.