File: libmdn.3.in

package info (click to toggle)
mdnkit 2.4-4
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 4,068 kB
  • ctags: 2,624
  • sloc: ansic: 23,661; sh: 8,010; perl: 1,136; tcl: 674; makefile: 643
file content (571 lines) | stat: -rw-r--r-- 16,171 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
.\" $Id: libmdn.3.in,v 1.5.2.3 2002/02/20 05:27:51 m-kasahr Exp $
.\"
.\" Copyright (c) 2001 Japan Network Information Center.  All rights reserved.
.\"  
.\" By using this file, you agree to the terms and conditions set forth bellow.
.\" 
.\" 			LICENSE TERMS AND CONDITIONS 
.\" 
.\" The following License Terms and Conditions apply, unless a different
.\" license is obtained from Japan Network Information Center ("JPNIC"),
.\" a Japanese association, Kokusai-Kougyou-Kanda Bldg 6F, 2-3-4 Uchi-Kanda,
.\" Chiyoda-ku, Tokyo 101-0047, Japan.
.\" 
.\" 1. Use, Modification and Redistribution (including distribution of any
.\"    modified or derived work) in source and/or binary forms is permitted
.\"    under this License Terms and Conditions.
.\" 
.\" 2. Redistribution of source code must retain the copyright notices as they
.\"    appear in each source code file, this License Terms and Conditions.
.\" 
.\" 3. Redistribution in binary form must reproduce the Copyright Notice,
.\"    this License Terms and Conditions, in the documentation and/or other
.\"    materials provided with the distribution.  For the purposes of binary
.\"    distribution the "Copyright Notice" refers to the following language:
.\"    "Copyright (c) Japan Network Information Center.  All rights reserved."
.\" 
.\" 4. Neither the name of JPNIC may be used to endorse or promote products
.\"    derived from this Software without specific prior written approval of
.\"    JPNIC.
.\" 
.\" 5. Disclaimer/Limitation of Liability: THIS SOFTWARE IS PROVIDED BY JPNIC
.\"    "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
.\"    LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
.\"    PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL JPNIC BE LIABLE
.\"    FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
.\"    CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
.\"    SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
.\"    BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
.\"    WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
.\"    OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
.\"    ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
.\" 
.\" 6. Indemnification by Licensee
.\"    Any person or entities using and/or redistributing this Software under
.\"    this License Terms and Conditions shall defend indemnify and hold
.\"    harmless JPNIC from and against any and all judgements damages,
.\"    expenses, settlement liabilities, cost and other liabilities of any
.\"    kind as a result of use and redistribution of this Software or any
.\"    claim, suite, action, litigation or proceeding by any third party
.\"    arising out of or relates to this License Terms and Conditions.
.\" 
.\" 7. Governing Law, Jurisdiction and Venue
.\"    This License Terms and Conditions shall be governed by and and
.\"    construed in accordance with the law of Japan. Any person or entities
.\"    using and/or redistributing this Software under this License Terms and
.\"    Conditions hereby agrees and consent to the personal and exclusive
.\"    jurisdiction and venue of Tokyo District Court of Japan.
.\"
.TH libmdn 3 "Apr 23, 2001"
.\"
.SH NAME
libmdn, libmdnlite \- Mulitilingual Domain Name Handling Libraries
.\"
.SH SYNOPSIS
.nf
#include <mdn/api.h>

mdn_result_t
\fBmdn_nameinit\fP(void)

mdn_result_t
\fBmdn_encodename\fP(int\ actions,\ const\ char\ *from,\ char\ *to,\ size_t\ tolen)

mdn_result_t
\fBmdn_decodename\fP(int\ actions,\ const\ char\ *from,\ char\ *to,\ size_t\ tolen)

mdn_result_t
\fBmdn_enable\fP(int\ on_off)

char *
\fBmdn_result_tostring\fP(mdn_result_t\ result)

.\"
.SH OVERVIEW
The
.B libmdn
and
.B libmdnlite
libraries support various manipulations of multilingual domain names,
including:
.RS 2
.IP \- 2
encoding convesion
.IP \- 2
name preparation
.RE
.PP
They are designed according to IDNA framework where each application must
do necessary preparations for the multilingual domain names before passing
them to the resolver.
.PP
To help applications do the preparation, the libraries provide easy-to-use,
high-level interface for the work.
.PP
Both libraries provide almost the same API.
The difference between them is that
.B libmdn
internally uses
.I iconv
function to provide encoding conversion from UTF-8 to the local encoding
(such as iso-8859-1, usually determined by the current locale), and vise
versa.
.B libmdnlite
is lightweight version of libmdn.
It assumes local encoding is UTF-8 so that it never uses
.IR iconv .
.PP
This manual describes only a small subset of the API that the libraries
provide, most important functions for application programmers.
For other API, please refer to the mDNkit's specification document
(which is not yet available) or the header files typically found under
`/usr/local/include/mdn/' on your system.
.\"
.SH DESCRIPTION
.PP
The
.B mdn_nameinit
function initializes the whole library, and reads the default
configuration file
.BR mdn.conf ,
which includes configuration parameters for multilingual domain name
preparation.
If
.B mdn_nameinit
is called more than once, the library initialization will take place
only at the first call while the configuration file will be (re)read
at every call.
.PP
If there are no errors,
.B mdn_nameinit
returns
.BR mdn_success .
Otherwise, the returned value indicates the cause of the error.
See the section ``RETURN VALUES'' below for the error codes.
.PP
Usually you don't have to call this function explicitly because
it is implicitly called when
.B mdn_encodename
or
.B mdn_decodename
is first called without prior calling of
.BR mdn_nameinit .
.\"
.PP
.B mdn_encodename
function performs name preparation and encoding conversion on
the multilingual domain name specified by
.IR from ,
and stores the result to
.IR to ,
whose length is specified by 
.IR tolen .
.I actions
is a bitwise-OR of the following macros, specifying which subprocesses
in the encoding process are to be employed.
.RS 2
.nf
.ft CW
MDN_LOCALCONV     Local encoding <-> UTF-8 conversion
MDN_DELIMMAP      Delimiter mapping
MDN_LOCALMAP      Local mapping
MDN_NAMEPREP      NAMEPREP
                  (inculding unassigned codepoint check)
MDN_IDNCONV       UTF-8 <-> ACE conversion
.ft R
.fi
.RE
.PP
Details of this encoding process can be found in the section ``NAME ENCODING''.
.PP
For ordinary application, also the
.B MDN_ENCODE_APP
macro is provided for the convenience.
It is eqivalent to 
.RS 2
.nf
.ft CW
MDN_LOCALCONV|MDN_DELIMMAP|MDN_LOCALMAP|MDN_NAMEPREP|MDN_IDNCONV
.ft R
.fi
.RE
.PP
in libmdn, and eqivalent to
.RS 2
.nf
.ft CW
MDN_DELIMMAP|MDN_LOCALMAP|MDN_NAMEPREP|MDN_IDNCONV
.ft R
.fi
.RE
.PP
in libmdnlite.
.PP
.B mdn_decodename
function performs the reverse of
.BR mdn_encodename .
It converts the multilingual domain name given by
.IR from ,
which is represented in a special encoding called ACE,
to the application's local codeset and stores into
.IR to ,
whose length is specified by
.IR tolen .
.I actions
specifies which subprocesses in decoding process take place, as in
.BR mdn_encodename ,
except that only \f(CWMDN_IDNCONV\fP, \f(CWMDN_NAMEPREP\fP and
\f(CWMDN_LOCALCONV\fP are allowed.
Details of this decoding process can be found in the section ``NAME DECODING''.
.PP
For ordinary application, also the
.B MDN_DECODE_APP
macro is provided for the convenience.
It is eqivalent to 
.RS 2
.nf
.ft CW
MDN_IDNCONV|MDN_NAMEPREP|MDN_LOCALCONV
.ft R
.fi
.RE
.PP
in libmdn, and eqivalent to
.RS 2
.nf
.ft CW
MDN_IDNCONV|MDN_NAMEPREP
.ft R
.fi
.RE
.PP
in libmdnlite.
.PP
All of the functions above return error code of type
.BR mdn_result_t .
All codes other than
.B mdn_success
indicates some kind of failure.
.B mdn_result_tostring
function takes an error code
.I result
and returns a pointer to the corresponding message string.
.\"
.SH "NAME ENCODING"
Name encoding is a process that transforms the specified
multilingual domain name to a certain string suitable for name
resolution.
The name encoding process consists of the following steps.
.IP "(1) Encoding Conversion (local codeset to UCS)"
Convert the encoding of the given domain name to
Unicode/ISO10646 UTF-8 format string.
.br
This step is performed if
.I actions
given to
.B mdn_encodename
contains
.B MDN_LOCALCONV
or equals to
.BR MDN_ENCODE_APP .
Note that libmdnlite doesn't support this step.
.br
The source encoding must be one of the two encodings below:
.RS 2
.IP \- 2
The application's local encoding (codeset).
.IP \- 2
ACE specified by the configuration file.
.RE
The latter is suppored because name decoding process may produce
ACE strings when its attempt to convert to the local encoding fails.
See the section ``NAME DECODING'' for details.
.IP "(2) Local mapping"
Apply any locale/language-specific mapping.  This process is
further divided into two subprocesses:
.RS 2
.IP "(2-1) Delimiter mapping"
Map certain characters to the domain name delimiter (U+002E).
This step is performed if
.I actions
given to
.B mdn_encodename
contains
.B MDN_DELIMMAP
or equals to
.BR MDN_ENCODE_APP .
.IP "(2-2) Local mapping based on TLD"
Apply character mapping whose rule is determined by the TLD of the name.
.br
This step is performed if
.I actions
given to
.B mdn_encodename
contains
.B MDN_LOCALMAP
or equals to
.BR MDN_ENCODE_APP .
.RE
.IP "(3) NAMEPREP"
Perform name preparation (NAMEPREP), which is a standard process for
name canonicalizaion of multilingual domain names.
.B mdn_encodename
performs mapping, normalization, prohibited character check and
unassigned codepoint check in that order, as NAMEPREP mentions.
.br
This process includes checking of characters which are not allowed in
multilingual domain names.
This step is performed if
.I actions
given to
.B mdn_encodename
contains
.B MDN_NAMEPREP
or equals to
.BR MDN_ENCODE_APP .
.IP "(4) Encoding conversion (UCS to ACE)"
Convert the NAMEPREPed name to a special encoding designed for representing
multilingual domain names.
.br
The encoding is also known as ACE (ASCII Compatible Encoding) since
a string in the encoding is just like a traditional ASCII domain name
consisting of only letters, numbers and hyphens.
This step is performed if
.I actions
given to
.B mdn_encodename
contains
.B MDN_IDNCONV
or equals to
.BR MDN_ENCODE_APP .
.PP
There are many configuration parameters for this process, such as the
ACE or the local mapping rules.  These parameters are read from the
default mDNkit's configuration file,
.BR mdn.conf .
See mdn.conf(5) for details.
.\"
.SH "NAME DECODING"
Name decoding is a reverse process of the name encoding.
It transforms the specified
multilingual domain name in a special encoding suitable for name
resolution to the normal name string in the application's current codeset.
However, name encoding and name decoding are not symmetric.
Name decoding doesn't perform local mapping.
Both name encoding and decoding do NAMEPREP, but decoding does
it to verfiy a name, while encoding does it to normalize a name.
.PP
The name decoding process consists of the following steps.
.IP "(1) Encoding conversion (ACE to UCS)"
Convert the encoding of the given domain name
from a special one designed for representing
multilingual domain names (ACE) to Unicode/ISO10646 UTF-8.
This step is performed if
.I actions
given to
.B mdn_decodename
contains
.B MDN_IDNCONV
or equals to
.BR MDN_DECODE_APP .
.IP "(2) NAMEPREP check"
Perform name preparation (NAMEPREP) as also done in name encoding,
and compare the result of NAMEPREP and the given UCS name.
If the NAMEPREP is failed or the names are different, the given
name is considered as invalid domain name.
It contains a character which is never seen in a NAMEPREPed domain
name.
This step is performed if
.I actions
given to
.B mdn_decodename
contains
.B MDN_NAMEPREP
or equals to
.BR MDN_DECODE_APP .
.IP "(3) Encoding conversion (UCS to local codeset)"
Convert the encoding of the name from UTF-8 to
the application's local codeset.
.br
The local codeset is determined by the application's locale.
However, it is possible that the conversion to the application's
local codeset fails because the name includes some characters
which don't have mappings to the local codeset.
In this case, libmdn tries instead to convert to ACE specified by
the configuration file.  
.br
This step is performed if
.I actions
given to
.B mdn_decodename
contains
.B MDN_LOCALCONV
or equals to
.BR MDN_DECODE_APP .
Note that libmdnlite doesn't support this step.
.PP
The configuration parameters for this process,
are also read from the configuration file
.BR mdn.conf .
.\"
.SH "MDN_DISABLE"
If the
.BR MDN_DISABLE
environ variable is defined at run-time,
the libraries disable mulitilingual domain name support, by default.
In this case,
.B mdn_encodename
and 
.B mdn_decodename
don't encode/decode an input name, but instead they simply ouput a
copy of the input name as the result of encoding/decoding.
.PP
If your application should always enable mulitilingual domain name
support regardless of definition of
.BR MDN_DISABLE ,
call
.RS 4
.nf
.ft CW
mdn_enable(1)
.ft R
.fi
.RE
before performing encoding/decoding. 
.\"
.SH "RETURN VALUES"
Most of the API functions return values of type
.B mdn_result_t
in order to indicate the status of the call.

The following is a complete list of the status codes.  Note that some
of them are never returned by the functions described in this manual.
.TP 15
.SB mdn_success
Not an error.  The call succeeded.
.TP
.SB mdn_notfound
Specified information does not exist.
.TP
.SB mdn_invalid_encoding
The encoding of the specified string is invalid.
.TP
.SB mdn_invalid_syntax
There is a syntax error in the configuration file.
.TP
.SB mdn_invalid_name
The specified name is not valid.
.TP
.SB mdn_invalid_message
The specified DNS message is not valid.
.TP
.SB mdn_invalid_action
The specified action contains invalid flags.
.TP
.SB mdn_invalid_codepoint
The specified Unicode code point value is not valid.
.TP
.SB mdn_buffer_overflow
The specified buffer is too small to hold the result.
.TP
.SB mdn_noentry
The specified key does not exist in the hash table.
.TP
.SB mdn_nomemory
Memory allocation using malloc failed.
.TP
.SB mdn_nofile
The specified file could not be opened.
.TP
.SB mdn_nomapping
Some characters do not have the mapping to the target character set.
.TP
.SB mdn_context_required
Context information is required.
.TP
.SB mdn_prohibited
The specified string contains some prohibited characters.
.TP
.SB mdn_failure
Generic error which is not covered by the above codes.
.\"
.SH EXAMPLES
To get the address of a multilingual domain name in the application's
local codeset, use
.B mdn_encodename
to convert the name to the format suitable for passing to resolver functions.
.RS 4
.nf
.ft CW
mdn_result_t r;
char ace_name[256];
struct hostent *hp;

\&...
r = mdn_encodename(MDN_ENCODE_APP, name, ace_name,
                   sizeof(ace_name));
if (r != mdn_success) {
    fprintf(stderr, "mdn_encodename failed: %s\en",
            mdn_result_tostring(r));
    exit(1);
}

hp = gethostbyname(ace_name);
\&...
.ft R
.fi
.RE
.PP
To decode the multilingual domain name returned from a resolver function,
use
.BR mdn_decodename .
.RS 4
.nf
.ft CW
mdn_result_t r;
char local_name[256];
struct hostent *hp;

\&...
hp = gethostbyname(name);
r = mdn_decodename(MDN_DECODE_APP, hp->h_name, local_name,
                   sizeof(local_name));
if (r != mdn_success) {
    fprintf(stderr, "mdn_decodename failed: %s\en",
            mdn_result_tostring(r));
    exit(1);
}
printf("name: %s\en", local_name);
\&...
.ft R
.fi
.RE
.\"
.SH COMPATIBILITY
.B mdn_encodename
and
.B mdn_decodename
in mDNkit version 2.x prior to 2.4 provide the 
.B MDN_UNASCHECK
process macro for unassigned codepoint check.
However, beginning with mDNkit version 2.4, the 
.B MDN_NAMEPREP
process macro also performs the unassigned check.
.PP
To perform NAMEPREP without the unassigned check on mDNkit 2.4
or later, specify the actions:
.RS 2
.nf
.ft CW
MDN_NAMEPREP^MDN_UNASCHECK
.ft R
.fi
.RE
.PP
instead of
.BR MDN_NAMEPREP .
.SH FILES
.I @sysconfdir@/mdn.conf
.\"
.SH "SEE ALSO"
mdn.conf(5)