Tcl_RegisterConfig



Tcl_RegisterConfig

NAME
SYNOPSIS
ARGUMENTS
DESCRIPTION
TCL_CONFIG
KEYWORDS

___________________________

NAME

Tcl_RegisterConfig − procedures to register embedded configuration information

SYNOPSIS

#include <tcl.h>

void
Tcl_RegisterConfig
(interp, pkgName, configuration, valEncoding)

ARGUMENTS

Tcl_Interp *interp (in)

Refers to the interpreter the embedded configuration information is registered for. Must not be NULL.

const char *pkgName (in)

Contains the name of the package registering the embedded configuration as ASCII string. This means that this information is in UTF-8 too. Must not be NULL.

Tcl_Config *configuration (in)

Refers to an array of Tcl_Config entries containing the information embedded in the binary library. Must not be NULL. The end of the array is signaled by either a key identical to NULL, or a key referring to the empty string.

const char *valEncoding (in)

Contains the name of the encoding used to store the configuration values as ASCII string. This means that this information is in UTF-8 too. Must not be NULL.

______________

DESCRIPTION

The function described here has its base in TIP 59 and provides extensions with support for the embedding of configuration information into their binary library and the generation of a Tcl-level interface for querying this information.

To embed configuration information into their binary library an extension has to define a non-volatile array of Tcl_Config entries in one if its source files and then call Tcl_RegisterConfig to register that information.

Tcl_RegisterConfig takes four arguments; first, a reference to the interpreter we are registering the information with, second, the name of the package registering its configuration information, third, a pointer to an array of structures, and fourth a string declaring the encoding used by the configuration values.

The string valEncoding contains the name of an encoding known to Tcl. All these names are use only characters in the ASCII subset of UTF-8 and are thus implicitly in the UTF-8 encoding. It is expected that keys are legible English text and therefore using the ASCII subset of UTF-8. In other words, they are expected to be in UTF-8 too. The values associated with the keys can be any string however. For these the contents of valEncoding define which encoding was used to represent the characters of the strings.

Each element of the configuration array refers to two strings containing the key and the value associated with that key. The end of the array is signaled by either an empty key or a key identical to NULL. The function makes no copy of the configuration array. This means that the caller has to make sure that the memory holding this array is never released. This is the meaning behind the word non-volatile used earlier. The easiest way to accomplish this is to define a global static array of Tcl_Config entries. See the file “generic/tclPkgConfig.c” in the sources of the Tcl core for an example.

When called Tcl_RegisterConfig will

(1)

create a namespace having the provided pkgName, if not yet existing.

(2)

create the command pkgconfig in that namespace and link it to the provided information so that the keys from _configuration_ and their associated values can be retrieved through calls to pkgconfig.

The command pkgconfig will provide two subcommands, list and get:

::pkgName::pkgconfig list

Returns a list containing the names of all defined keys.

::pkgName::pkgconfig get key

Returns the configuration value associated with the specified key.

TCL_CONFIG

The Tcl_Config structure contains the following fields:

typedef struct Tcl_Config {
const char* key;
const char* value;
} Tcl_Config;

KEYWORDS

embedding, configuration, binary library






Opportunity


Personal Opportunity - Free software gives you access to billions of dollars of software at no cost. Use this software for your business, personal use or to develop a profitable skill. Access to source code provides access to a level of capabilities/information that companies protect though copyrights. Open source is a core component of the Internet and it is available to you. Leverage the billions of dollars in resources and capabilities to build a career, establish a business or change the world. The potential is endless for those who understand the opportunity.

Business Opportunity - Goldman Sachs, IBM and countless large corporations are leveraging open source to reduce costs, develop products and increase their bottom lines. Learn what these companies know about open source and how open source can give you the advantage.





Free Software


Free Software provides computer programs and capabilities at no cost but more importantly, it provides the freedom to run, edit, contribute to, and share the software. The importance of free software is a matter of access, not price. Software at no cost is a benefit but ownership rights to the software and source code is far more significant.


Free Office Software - The Libre Office suite provides top desktop productivity tools for free. This includes, a word processor, spreadsheet, presentation engine, drawing and flowcharting, database and math applications. Libre Office is available for Linux or Windows.





Free Books


The Free Books Library is a collection of thousands of the most popular public domain books in an online readable format. The collection includes great classical literature and more recent works where the U.S. copyright has expired. These books are yours to read and use without restrictions.


Source Code - Want to change a program or know how it works? Open Source provides the source code for its programs so that anyone can use, modify or learn how to write those programs themselves. Visit the GNU source code repositories to download the source.





Education


Study at Harvard, Stanford or MIT - Open edX provides free online courses from Harvard, MIT, Columbia, UC Berkeley and other top Universities. Hundreds of courses for almost all major subjects and course levels. Open edx also offers some paid courses and selected certifications.


Linux Manual Pages - A man or manual page is a form of software documentation found on Linux/Unix operating systems. Topics covered include computer programs (including library and system calls), formal standards and conventions, and even abstract concepts.