Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/tcl8.5.2/doc/RegConfig.3 @ 42

Last change on this file since 42 was 25, checked in by landauf, 17 years ago

added tcl to libs

File size: 4.3 KB
Line 
1'\"
2'\" Copyright (c) 2002 Andreas Kupries <andreas_kupries@users.sourceforge.net>
3'\"
4'\" See the file "license.terms" for information on usage and redistribution
5'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
6'\"
7'\" RCS: @(#) $Id: RegConfig.3,v 1.8 2007/12/13 15:22:31 dgp Exp $
8.so man.macros
9.TH Tcl_RegisterConfig 3 8.4 Tcl "Tcl Library Procedures"
10.BS
11'\" Note:  do not modify the .SH NAME line immediately below!
12.SH NAME
13Tcl_RegisterConfig \- procedures to register embedded configuration information
14.SH SYNOPSIS
15.nf
16\fB#include <tcl.h>\fR
17.sp
18void
19\fBTcl_RegisterConfig\fR(\fIinterp, pkgName, configuration, valEncoding\fR)
20.sp
21.SH ARGUMENTS
22.AS Tcl_Interp *configuration
23.AP Tcl_Interp *interp in
24Refers to the interpreter the embedded configuration information is
25registered for. Must not be NULL.
26.AP "const char" *pkgName in
27Contains the name of the package registering the embedded
28configuration as ASCII string. This means that this information is in
29UTF-8 too. Must not be NULL.
30.AP Tcl_Config *configuration in
31Refers to an array of Tcl_Config entries containing the information
32embedded in the binary library. Must not be NULL. The end of the array
33is signaled by either a key identical to NULL, or a key referring to
34the empty string.
35.AP "const char" *valEncoding in
36Contains the name of the encoding used to store the configuration
37values as ASCII string. This means that this information is in UTF-8
38too. Must not be NULL.
39.BE
40
41.SH DESCRIPTION
42.PP
43The function described here has its base in TIP 59 and provides
44extensions with support for the embedding of configuration
45information into their binary library and the generation of a
46Tcl-level interface for querying this information.
47.PP
48To embed configuration information into their binary library an
49extension has to define a non-volatile array of Tcl_Config entries in
50one if its source files and then call \fBTcl_RegisterConfig\fR to
51register that information.
52.PP
53\fBTcl_RegisterConfig\fR takes four arguments; first, a reference to
54the interpreter we are registering the information with, second, the
55name of the package registering its configuration information, third,
56a pointer to an array of structures, and fourth a string declaring the
57encoding used by the configuration values.
58.PP
59The string \fIvalEncoding\fR contains the name of an encoding known to
60Tcl.  All these names are use only characters in the ASCII subset of
61UTF-8 and are thus implicitly in the UTF-8 encoding. It is expected
62that keys are legible English text and therefore using the ASCII
63subset of UTF-8. In other words, they are expected to be in UTF-8
64too. The values associated with the keys can be any string
65however. For these the contents of \fIvalEncoding\fR define which
66encoding was used to represent the characters of the strings.
67.PP
68Each element of the \fIconfiguration\fR array refers to two strings
69containing the key and the value associated with that key. The end of
70the array is signaled by either an empty key or a key identical to
71NULL. The function makes \fBno\fR copy of the \fIconfiguration\fR
72array. This means that the caller has to make sure that the memory
73holding this array is never released. This is the meaning behind the
74word \fBnon-volatile\fR used earlier. The easiest way to accomplish
75this is to define a global static array of Tcl_Config entries. See the file
76.QW generic/tclPkgConfig.c
77in the sources of the Tcl core for an example.
78.PP
79When called \fBTcl_RegisterConfig\fR will
80.IP (1)
81create a namespace having the provided \fIpkgName\fR, if not yet
82existing.
83.IP (2)
84create the command \fBpkgconfig\fR in that namespace and link it to
85the provided information so that the keys from _configuration_ and
86their associated values can be retrieved through calls to
87\fBpkgconfig\fR.
88.PP
89The command \fBpkgconfig\fR will provide two subcommands, \fBlist\fR
90and \fBget\fR:
91.RS
92.TP
93::\fIpkgName\fR::\fBpkgconfig\fR list
94Returns a list containing the names of all defined keys.
95.TP
96::\fIpkgName\fR::\fBpkgconfig\fR get \fIkey\fR
97Returns the configuration value associated with the specified
98\fIkey\fR.
99.RE
100.SH TCL_CONFIG
101.PP
102The \fBTcl_Config\fR structure contains the following fields:
103.PP
104.CS
105typedef struct Tcl_Config {
106    const char* key;
107    const char* value;
108} Tcl_Config;
109.CE
110.\" No cross references yet.
111.\" .SH "SEE ALSO"
112.SH KEYWORDS
113embedding, configuration, bianry library
Note: See TracBrowser for help on using the repository browser.