libtld: /home/snapwebsites/snapcpp/contrib/libtld/src/validate_tld.cpp File Reference

libtld  1.5.13
A library to determine the Top-Level Domain name of any URL.
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.


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


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.) More...
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

void check_uri ( char const *  uri)

This function verifies that the URI is valid.

[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().

void list ( )

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

Definition at line 108 of file validate_tld.cpp.

References schemes.

Referenced by email_to_vstring(), main(), PHP_FUNCTION(), and tld_email_free().

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".

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

Definition at line 155 of file validate_tld.cpp.

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

void usage ( )

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

Definition at line 130 of file validate_tld.cpp.

Referenced by main().

Variable Documentation

const char* schemes
Initial value:
= "afp,adiumxtra,aw,beshare,bolo,cap,coap,crid,dns,feed,file,"

This list of schemes comes from and is likely not 100% valid, but it should cover a pretty large number of schemes expected to work with our system.

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().

This document is part of the Snap! Websites Project.

Copyright by Made to Order Software Corp.

Syndicate content

Snap! Websites
An Open Source CMS System in C++

Contact Us Directly