libtld 2.0.14
A library to determine the Top-Level Domain name of any Internet URI.
Functions | Variables
validate_tld.cpp File Reference

Command line tool to validate TLDs. More...

#include "libtld/tld.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
Include dependency graph for validate_tld.cpp:

Go to the source code of this file.

Functions

void check_uri (char const *uri)
 Check the parameter as a URI.
 
void list ()
 List the default schemes accepted.
 
int main (int argc, char *argv[])
 The validate tools.
 
void usage ()
 Print out the help of the tld tool.
 

Variables

int err_count = 0
 Number of errors so we know whether to exit with 0 or 1.
 
const char * schemes
 List of schemes that we more or less support (some schemes have extensions using the semi-colon that we do not support yet.)
 
char const * user_schemes = nullptr
 Hold a list of schemes as defined by the end user.
 
int verbose = 0
 Whether the user asked for verbosity, false by default.
 

Detailed Description

This tool is used to verify URIs and emails on the command line and in scripts.

Definition in file validate_tld.cpp.

Function Documentation

◆ check_uri()

void check_uri ( char const *  uri)

This function verifies that the URI is valid.

Parameters
[in]uriThe URI to be checked.

Definition at line 70 of file validate_tld.cpp.

References err_count, tld_info::f_category, tld_info::f_country, tld_info::f_offset, tld_info::f_status, tld_info::f_tld, tld_email_list::parse(), schemes, tld_check_uri(), TLD_RESULT_SUCCESS, user_schemes, and verbose.

Referenced by main().

◆ list()

void list ( )

This function lists all the schemes defined in the schemes variable.

Definition at line 125 of file validate_tld.cpp.

References schemes.

Referenced by main(), PHP_FUNCTION(), tld_email_count(), tld_email_free(), tld_email_next(), tld_email_parse(), and tld_email_rewind().

◆ main()

int main ( int  argc,
char *  argv[] 
)

The parameters can include any number of URIs and emails. The system must be told what's what using a protocol. For emails, use the name "mail".

Parameters
[in]argcNumber of command line arguments passed in.
[in]argvThe arguments passed in.
Returns
The tool returns 0 on success meaning that all the URIs and emails are valid, 1 otherwise.

Definition at line 172 of file validate_tld.cpp.

References check_uri(), err_count, LIBTLD_VERSION, list(), tld_version(), usage(), user_schemes, and verbose.

◆ usage()

void usage ( )

This function prints out the help information about the validate_tld tool. The function does not return.

Definition at line 147 of file validate_tld.cpp.

Referenced by main().

Variable Documentation

◆ err_count

int err_count = 0

Definition at line 38 of file validate_tld.cpp.

Referenced by check_uri(), and main().

◆ schemes

const char* schemes
Initial value:
= "afp,adiumxtra,aw,beshare,bolo,cap,coap,crid,dns,feed,file,"
"finger,fish,ftp,ftps,git,gopher,http,https,icap,imap,"
"ipp,irc,irc6,ircs,mumble,mupdate,mysql,nfs,nntp,"
"opaquelocktoken,pop,psql,psyc,rmi,rsync,rtmp,rtsp,rtspu,"
"sftp,shttp,sieve,smb,snmp,soap.beep,soap.beeps,soldat,"
"ssh,teamspeak,telnet,tftp,tip,udp,unreal,ut2004,vemmi,"
"ventrilo,wais,webcal,wyciwyg,z39.50r,z39.50s"

This list of schemes comes from http://en.wikipedia.org/wiki/URI_scheme and is likely not 100% valid, but it should cover a pretty large number of schemes expected to work with our system.

Note
The documentation does not show you all the schemes. Check out the source to see all the schemes currently included.

Definition at line 53 of file validate_tld.cpp.

Referenced by check_uri(), and list().

◆ user_schemes

char const* user_schemes = nullptr

Definition at line 62 of file validate_tld.cpp.

Referenced by check_uri(), and main().

◆ verbose

int verbose = 0

Definition at line 41 of file validate_tld.cpp.

Referenced by check_uri(), and main().

This document is part of the Snap! Websites Project.

Copyright by Made to Order Software Corp.