Configuration & Integration

Introduction

This documentation contains the following solutions:

The solution is implemented in the programming language "C". It's provided with the user interface in the form of functions of the "C" programming language. The solution can also be integrated into a Python project.


SDK integration into the final product

The SDK is easy enough to integrate into the final software product developed in the C or C++ programming language. It is also possible to integrate it into the final Python solution.

To use the library, you need to get the library sources from repository here, configure the library, build and install it.


Configuring the url2cat library

Necessary utilities to assemble and configure the library:

Necessary libraries (Ubuntu 18 or higher):


Configuration

1. Go to the library source directory

2. Configure the library using the command

cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DURL2CAT_SERVER=yes -DURL2CAT_DATABASE=yes -DURL2CAT_LIBRARY=static -DURL2CAT_LOCALE=en

Or edit according to your needs and run the bash script located in liburl2cat directory - create_build.sh.

To run the script perform:

sudo chmod +x create_build.sh
./create_build.sh
Using the following cmake commands you can configure library functions:
  • URL2CAT_SERVER - request to the SafeDNS server (yes, no)

  • URL2CAT_DATABASE - request to the local database (yes, no)

  • URL2CAT_LIBRARY - library assembling type (static & shared)

  • URL2CAT_MAX_NUMBER_CATEGORY - number of defined categories (Default number: 5)

  • URL2CAT_HASH_TYPE - Hash type (MD5, SHA256, SHA512. Default type - MD5)

  • URL2CAT_HASH_LEN- Hash length (full - hash is not truncated before searching in the database. Half extract the first 8 bytes of the hash. Default length - half)

  • URL2CAT_CACHE - category entry cache size (dynamic / static)

3. Build the project using the command:

cmake --build build

4. Copy the following library files to your project:


Using the library in the project:

Before using the library, needs to initialize it using the s_url2cat_setting structure. The structure has the following fields:

For initialization use the function - url2cat_init(s_url2cat_setting * setting)

To get a category use the function:
url2cat_category(char * url, size_t len_url, s_url2cat_category * * category, size_t * number_category)

where the structure s_url2cat_category has the following fields:

After finishing using the library you will need to deinitialize it with the command: url2cat_deinit()

The database can be updated while the library is running using the command: 
url2cat_database_update(s_url2cat_setting * setting)

A request for recategorization can be sent while the library is running using the command:
url2cat_recategory(char * url, size_t url_size, char * category_name, size_t category_name_size)

 

Examples of integration the solution into simple projects running on "C" can be found in the /example directory.


Revision #11
Created 22 August 2022 11:44:18
Updated 10 February 2023 04:20:35