File: README.xml

package info (click to toggle)
tcllib 1.21%2Bdfsg-1
  • links: PTS
  • area: main
  • in suites: bookworm
  • size: 69,456 kB
  • sloc: tcl: 266,493; ansic: 14,259; sh: 2,936; xml: 1,766; yacc: 1,145; pascal: 881; makefile: 112; perl: 84; f90: 84; python: 33; ruby: 13; php: 11
file content (660 lines) | stat: -rw-r--r-- 19,446 bytes parent folder | download | duplicates (3)
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
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
<?xml version="1.0"?>
<!DOCTYPE rfc SYSTEM "rfc2629.dtd">

<?rfc compact="no"?>
<?rfc toc="yes"?>
<?rfc private="The README file"?>
<?rfc header="README"?>

<rfc>
<front>
<title>Tcl MIME</title>

<author initials="M.T." surname="Rose" fullname="Marshall T. Rose">
<organization>Dover Beach Consulting, Inc.</organization>
<address>
<postal>
<street>POB 255268</street>
<city>Sacramento</city> <region>CA</region> <code>95865-5268</code>
<country>US</country>
</postal>
<phone>+1 916 483 8878</phone>
<facsimile>+1 916 483 8848</facsimile>
<email>mrose@dbc.mtview.ca.us</email>
</address>
</author>

<date month="February" year="2000" />

<abstract><t>Tcl MIME generates and parses MIME body parts.</t></abstract>
</front>

<middle>

<section title="SYNOPSIS">
<figure><artwork><![CDATA[
    package provide mime 1.2
    package provide smtp 1.2
]]></artwork></figure>

<t>Tcl MIME is an implementation of a Tcl package that generates and
parses <xref target="RFC2045">MIME</xref> body parts.</t>

<t>Each MIME part consists of a header
(zero or more key/value pairs),
an empty line,
and a structured body.
A MIME part is either a "leaf" or has (zero or more) subordinates.</t>

<t>MIME defines four keys that may appear in the headers:
<list style="hanging">
<t hangText="   Content-Type:">describes the data contained in the body
("the content");</t>

<t hangText="   Content-Transfer-Encoding:">describes how the content is
encoded for transmission in an ASCII stream;</t>

<t hangText="   Content-Description:">a textual description of the
content; and,</t>

<t hangText="   Content-ID:">a globally-unique identifier for the
content.</t>
</list></t>

<t>Consult <xref target="RFC2046" /> for a list of standard content types.
Further,
consult <xref target="RFC822" /> for a list of several other header keys
(e.g., "To", "cc", etc.)</t>

<figure>
<preamble>A simple example might be:</preamble>
<artwork><![CDATA[
    Date: Sun, 04 July 1999 10:38:25 -0600
    From: Marshall Rose <mrose@dbc.mtview.ca.us>
    To: Andreas Kupries <a.kupries@westend.com>
    cc: dnew@messagemedia.com (Darren New)
    MIME-Version: 1.0
    Content-Type: text/plain; charset="us-ascii"
    Content-Description: a simple example
    Content-ID: <4294407315.931384918.1@dbc.mtview.ca.us>

    Here is the body. In this case, simply plain text.
]]></artwork>
</figure>

<t>In addition to an implementation of the mime package,
Tcl MIME includes an implementation of the smtp package.</t>

<vspace blankLines="1000" />

<section title="Requirements">
<t>This package requires:
<list style="symbols">
<t><eref target="http://www.scriptics.com/software/8.1.html">Tcl/Tk version 8.0.3</eref>
</list>
or later</t>
<t>In addition, this package requires one of the following:</t>
<list style="symbols">
<t><eref target="http://www.oche.de/~akupries/soft/trf/">Trf version 2.0p5</eref>
or later</t>
<t><eref target="http://dev.ajubasolutions.com/software/tcllib/">base 64 version 2.0</eref> or later (included with tcllib)</t>
</list></t>
<t>If it is available, Trf will be used to provide better performance;
if not, Tcl-only equivalent functions, based on the base64 package,
are used.</t>
</section>

<section title="Copyrights">
<t>(c) 1999-2000 Marshall T. Rose</t>

<t>Hold harmless the author, and any lawful use is allowed.</t>
</section>
</section>

<section title="SYNTAX">
<figure>
<preamble><xref target="mime_initialize">mime::initialize</xref>
returns a token.
Parameters:</preamble>
<artwork><![CDATA[    ?-canonical type/subtype
        ?-param    {key value}?...
        ?-encoding value?
        ?-header   {key value}?... ?
    (-file name | -string value | -parts {token1 ... tokenN})
]]></artwork>
</figure>

<figure>
<preamble><xref target="mime_finalize">mime::finalize</xref> returns
an empty string.
Parameters:</preamble>
<artwork><![CDATA[    token ?-subordinates "all" | "dynamic" | "none"?
]]></artwork>
</figure>

<figure>
<preamble><xref target="mime_getproperty">mime::getproperty</xref>
returns a string or a list of strings.
Parameters:</preamble>
<artwork><![CDATA[    token ?property | -names?
]]></artwork>
</figure>

<figure>
<preamble><xref target="mime_getheader">mime::getheader</xref> returns
a list of strings.
Parameters:</preamble>
<artwork><![CDATA[    token ?key | -names?
]]></artwork>
</figure>

<figure>
<preamble><xref target="mime_setheader">mime::setheader</xref> returns
a list of strings.
Parameters:</preamble>
<artwork><![CDATA[    token key value ?-mode "write" | "append" | "delete"?
]]></artwork>
</figure>

<figure>
<preamble><xref target="mime_getbody">mime::getbody</xref> returns a string.
Parameters:</preamble>
<artwork><![CDATA[    ?-command callback ?-blocksize octets? ?
]]></artwork>
</figure>

<figure>
<preamble><xref target="mime_copymessage">mime::copymessage</xref>
returns an empty string.
Parameters:</preamble>
<artwork><![CDATA[    token channel
]]></artwork>
</figure>

<figure>
<preamble><xref target="mime_buildmessage">mime::buildmessage</xref>
returns an empty string.
Parameters:</preamble>
<artwork><![CDATA[    token
]]></artwork>
</figure>

<figure>
<preamble><xref target="smtp_sendmessage">smtp::sendmessage</xref>
returns a list.
Parameters:</preamble>
<artwork><![CDATA[    token ?-servers list? ?-ports list?
          ?-queue boolean?     ?-atleastone boolean?
          ?-originator string? ?-recipients string?
          ?-header {key value}?...
]]></artwork>
</figure>

<figure>
<preamble><xref target="mime_parseaddress">mime::parseaddress</xref>
returns a list of serialized arrays.
Parameters:</preamble>
<artwork><![CDATA[    string
]]></artwork>
</figure>

<figure>
<preamble><xref target="mime_parsedatetime">mime::parsedatetime</xref>
returns a string.
Parameters:</preamble>
<artwork><![CDATA[    [string | -now] property
]]></artwork>
</figure>

<figure>
<preamble><xref target="mime_mapencoding">mime::mapencoding</xref>
returns a string.
Parameters:</preamble>
<artwork><![CDATA[    encoding_name
]]></artwork>
</figure>

<figure>
<preamble><xref target="mime_reversemapencoding">mime::reversemapencoding</xref>
returns a string.
Parameters:</preamble>
<artwork><![CDATA[    content_type
]]></artwork>
</figure>

</section>

<section title="SEMANTICS">

<section anchor="mime_initialize" title="mime::initialize">
<t>mime::initialize creates a MIME part:
<list style="symbols">
<t>If the -canonical option is present,
then the body is in canonical (raw) form and is found by consulting
either the -file, -string, or -part option.
<vspace blankLines="1" />
In addition,
both the -param and -header options may occur zero or more times to
specify "Content-Type" parameters (e.g., "charset")
and header keyword/values (e.g., "Content-Disposition"),
respectively.
<vspace blankLines="1" />
Also, -encoding, if present,
specifies the "Content-Transfer-Encoding" when copying the body.</t>

<t>If the -canonical option is not present,
then the MIME part contained in either the -file or the -string option
is parsed,
dynamically generating subordinates as appropriate.</t>
</list></t>
</section>

<section anchor="mime_finalize" title="mime::finalize">
<t>mime::finalize destroys a MIME part.</t>

<t>If the -subordinates option is present,
it specifies which subordinates should also be destroyed.
The default value is "dynamic".</t>
</section>

<section anchor="mime_getproperty" title="mime::getproperty">
<t>mime::getproperty returns the properties of a MIME part.</t>

<figure>
<preamble>The properties are:</preamble>
<artwork><![CDATA[
    property    value
    ========    =====
    content     the type/subtype describing the content
    encoding    the "Content-Transfer-Encoding"
    params      a list of "Content-Type" parameters
    parts       a list of tokens for the part's subordinates
    size        the approximate size of the content (unencoded)
]]></artwork>
<postamble>The "parts" property is present only if the MIME part has
subordinates.</postamble>
</figure>

<t>If mime::getproperty is invoked with the name of a specific property,
then the corresponding value is returned;
instead,
if -names is specified,
a list of all properties is returned;
otherwise,
a serialized array of properties and values is returned.</t>
</section>

<section anchor="mime_getheader" title="mime::getheader">
<t>mime::getheader returns the header of a MIME part.</t>

<t>A header consists of zero or more key/value pairs.
Each value is a list containing one or more strings.</t>

<t>If mime::getheader is invoked with the name of a specific key,
then a list containing the corresponding value(s) is returned;
instead,
if -names is specified,
a list of all keys is returned;
otherwise,
a serialized array of keys and values is returned.
Note that when a key is specified (e.g., "Subject"),
the list returned usually contains exactly one string;
however,
some keys (e.g., "Received") often occur more than once in the header,
accordingly the list returned usually contains more than one string.</t>
</section>

<section anchor="mime_setheader" title="mime::setheader">
<t>mime::setheader writes, appends to, or deletes the value associated
with a key in the header.</t>

<t>The value for -mode is one of:
<list style="hanging">
<t hangText="   write:"> the key/value is either created or
overwritten (the default);</t>

<t hangText="   append:"> a new value is appended for the key
(creating it as necessary); or,</t>

<t hangText="   delete:"> all values associated with the key are removed
(the "value" parameter is ignored).</t>
</list></t>

<t>Regardless,
mime::setheader returns the previous value associated with the key.</t>
</section>

<section anchor="mime_getbody" title="mime::getbody">
<t>mime::getbody returns the body of a leaf MIME part in canonical form.</t>

<figure>
<preamble>If the -command option is present,
then it is repeatedly invoked with a fragment of the body as this:</preamble>
<artwork><![CDATA[
    uplevel #0 $callback [list "data" $fragment]
]]></artwork>
<postamble>(The -blocksize option,
if present,
specifies the maximum size of each fragment passed to the
callback.)</postamble>
</figure>

<figure>
<preamble>When the end of the body is reached,
the callback is invoked as:</preamble>
<artwork><![CDATA[
    uplevel #0 $callback "end"
]]></artwork>
</figure>

<figure>
<preamble>Alternatively,
if an error occurs,
the callback is invoked as:</preamble>
<artwork><![CDATA[
    uplevel #0 $callback [list "error" reason]
]]></artwork>
</figure>

<t>Regardless,
the return value of the final invocation of the callback is propagated
upwards by mime::getbody.</t>

<t>If the -command option is absent,
then the return value of mime::getbody is a string containing the MIME
part's entire body.</t>
</section>

<section anchor="mime_copymessage" title="mime::copymessage">
<t>mime::copymessage copies the MIME part to the specified channel.</t>

<t>mime::copymessage operates synchronously,
and uses fileevent to allow asynchronous operations to proceed
independently.</t>
</section>

<section anchor="mime_buildmessage" title="mime::buildmessage">
<t>mime::buildmessage returns the MIME part as a string.  It is similar
to mime::copymessage, only it returns the data as a return string
instead of writing to a channel.</t>
</section>

<section anchor="smtp_sendmessage" title="smtp::sendmessage">
<t>smtp::sendmessage sends a MIME part to an SMTP server.
(Note that this procedure is in the "smtp" package,
not the "mime" package.)</t>

<t>The options are:
<list style="hanging">
<t hangText="   -servers:">a list of SMTP servers
(the default is "localhost");</t>

<t hangText="   -ports:">a list of SMTP ports
(the default is 25);</t>

<t hangText="   -queue:">indicates that the SMTP server should be
asked to queue the message for later processing;</t>

<t hangText="   -atleastone:">indicates that the SMTP server must find
at least one recipient acceptable for the message to be sent;</t>

<t hangText="   -originator:">a string containing an 822-style address
specification
(if present the header isn't examined for an originator address);</t>

<t hangText="   -recipients:">a string containing one or more 822-style
address specifications
(if present the header isn't examined for recipient addresses); and,</t>

<t hangText="   -header:">a keyword/value pairing
(may occur zero or more times).</t>
</list></t>

<t>If the -originator option is not present,
the originator address is taken from "From" (or "Resent-From");
similarly,
if the -recipients option is not present,
recipient addresses are taken from "To", "cc", and "Bcc" (or
"Resent-To", and so on).
Note that the header key/values supplied by the "-header" option
(not those present in the MIME part)
are consulted.
Regardless,
header key/values are added to the outgoing message as necessary to
ensure that a valid 822-style message is sent.</t>

<t>smtp::sendmessage returns a list indicating which recipients were
unacceptable to the SMTP server.
Each element of the list is another list,
containing the address, an SMTP error code, and a textual diagnostic.
Depending on the -atleastone option and the intended recipients,,
a non-empty list may still indicate that the message was accepted by
the server.</t>
</section>

<section anchor="mime_parseaddress" title="mime::parseaddress">
<t>mime::parseaddr takes a string containing one or more 822-style
address specifications and returns a list of serialized arrays,
one element for each address specified in the argument.</t>

<figure>
<preamble>Each serialized array contains these properties:</preamble>
<artwork><![CDATA[
    property    value
    ========    =====
    address     local@domain
    comment     822-style comment
    domain      the domain part (rhs)
    error       non-empty on a parse error
    group       this address begins a group
    friendly    user-friendly rendering
    local       the local part (lhs)
    memberP     this address belongs to a group
    phrase      the phrase part
    proper      822-style address specification
    route       822-style route specification (obsolete)
]]></artwork>
<postamble>Note that one or more of these properties may be empty.</postamble>
</figure>
</section>

<vspace blankLines="10000" />

<section anchor="mime_parsedatetime" title="mime::parsedatetime">
<t>mime::parsedatetime takes a string containing an 822-style
date-time specification and returns the specified property.</t>

<figure>
<preamble>The list of properties and their ranges are:</preamble>
<artwork><![CDATA[
    property     range
    ========     =====
    hour         0 .. 23
    lmonth       January, February, ..., December
    lweekday     Sunday, Monday, ... Saturday
    mday         1 .. 31
    min          0 .. 59
    mon          1 .. 12
    month        Jan, Feb, ..., Dec
    proper       822-style date-time specification
    rclock       elapsed seconds between then and now
    sec          0 .. 59
    wday         0 .. 6 (Sun .. Mon)
    weekday      Sun, Mon, ..., Sat
    yday         1 .. 366
    year         1900 ...
    zone         -720 .. 720 (minutes east of GMT)
]]></artwork>
</figure>
</section>

<section anchor="mime_mapencoding" title="mime::mapencoding">
<t>mime::mapencoding maps tcl encodings onto the proper names for their
MIME charset type.  This is only done for encodings whose charset types
were known.  The remaining encodings return "" for now.</t>
</section>

<section anchor="mime_reversemapencoding" title="mime::reversemapencoding">
<t>mime::reversemapencoding maps MIME charset types onto tcl encoding names.
Those that are unknown return "".</t>
</section>

</section>

<section title="EXAMPLES">
<figure>
<artwork><![CDATA[
package require mime 1.0
package require smtp 1.0


# create an image

set imageT [mime::initialize -canonical image/gif \
                             -file logo.gif]


# parse a message

set messageT [mime::initialize -file example.msg]


# recursively traverse a message looking for primary recipients

proc traverse {token} {
    set result ""

# depth-first search
    if {![catch { mime::getproperty $token parts } parts]} {
        foreach part $parts {
            set result [concat $result [traverse $part]]
        }
    }

# one value for each line occuring in the header
    foreach value [mime::getheader $token To] {
        foreach addr [mime::parseaddress $value] {
            catch { unset aprops }
            array set aprops $addr
            lappend result $aprops(address)
        }
    }

    return $result
}


# create a multipart containing both, and a timestamp

set multiT [mime::initialize -canonical multipart/mixed
                             -parts [list $imageT $messageT]]




# send it to some friends

smtp::sendmessage $multiT \
      -header [list From "Marshall Rose <mrose@dbc.mtview.ca.us>"] \
      -header [list To "Andreas Kupries <a.kupries@westend.com>"] \
      -header [list cc "dnew@messagemedia.com (Darren New)"] \
      -header [list Subject "test message..."]


# clean everything up

mime::finalize $multiT -subordinates all
]]></artwork>
</figure>
</section>

</middle>

<back>
<references>
<reference anchor="RFC2045">
<front>
<title>Multipurpose Internet Mail Extensions (MIME)
Part One: Format of Internet Message Bodies</title>
<author initials="N." surname="Freed" fullname="Ned Freed">
<organization>Innosoft International, Inc.</organization>
<address>
<email>ned@innosoft.com</email>
</address>
</author>
<author initials="N.S." surname="Borenstein"
        fullname="Nathaniel S. Borenstein">
<organization>First Virtual Holdings, Incorporated</organization>
<address>
<email>nsb@messagemedia.com</email>
</address>
</author>
<date month="November" year="1996"/>
</front>
<seriesInfo name="RFC" value="2045" />
</reference>

<reference anchor="RFC2046">
<front>
<title>Multipurpose Internet Mail Extensions (MIME)
Part Two: Media Types</title>
<author initials="N." surname="Freed" fullname="Ned Freed">
<organization>Innosoft International, Inc.</organization>
<address>
<email>ned@innosoft.com</email>
</address>
</author>
<author initials="N.S." surname="Borenstein"
        fullname="Nathaniel S. Borenstein">
<organization>First Virtual Holdings, Incorporated</organization>
<address>
<email>nsb@messagemedia.com</email>
</address>
</author>
<date month="November" year="1995"/>
</front>
<seriesInfo name="RFC" value="2046" />
</reference>

<reference anchor="RFC822">
<front>
<title>Standard for the format of ARPA Internet Text Messages</title>
<author initials="D." surname="Crocker" fullname="Dave Crocker">
<organization abbrev="UDEL">University of Delaware</organization>
<address>
<email>DCrocker@UDel-Relay</email>
</address>
</author>
<date month="August" year="1982"/>
</front>
<seriesInfo name="RFC" value="822" />
<seriesInfo name="STD" value="11" />
</reference>

</references>

<section title="TODO List">
<t><list style="hanging">
<t hangText="mime::initialize">
<list style="symbols">
<t>well-defined errorCode values</t>

<t>catch nested errors when processing a multipart</t>
</list></t>

</list></t>
</section>

<section title="Acknowledgements">
<t>This package is influenced by the safe-tcl package
(Borenstein and Rose, circa 1993),
and also by <eref target="mailto:dnew@messagemedia.com">Darren New</eref>'s
unpublished package of 1999.</t>

<t>This package makes use of
<eref target="mailto:a.kupries@westend.com">Andreas Kupries</eref>'s
excellent Trf package.</t>
</section>

</back>
</rfc>