OSDN Git Service

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