libmu_scm.texi
7.77 KB
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
@c This is part of the GNU Mailutils manual.
@c Copyright (C) 1999,2000,2001,2002 Free Software Foundation, Inc.
@c See file mailutils.texi for copying conditions.
@comment *******************************************************************
The library @file{libmu_scm} provides an interface between Mailutils
and Guile, allowing to access the Mailutils functionality from a
Scheme program. For more information about Guile, refer to
@ref{Top,,Overview,guile,The Guile Reference Manual}. For information
about Scheme programming language, @xref{Top,,,r4rs,Revised(4) Report on
the Algorithmic Language Scheme}.
@menu
Functions Provided by libmu_scm
* Address Functions::
* Mailbox Functions::
* Message Functions::
* MIME Functions::
* Log Functions::
Using libmu_scm
* Direct Linking::
* Dynamic Linking::
@end menu
@node Address Functions
@section Address Functions
@deffn {Scheme Function} mu-address-get-personal ADDRESS NUM
Return personal part of an email address.
@end deffn
@deffn {Scheme Function} mu-address-get-comments ADDRESS NUM
@end deffn
@deffn {Scheme Function} mu-address-get-email ADDRESS NUM
Return email part of an email address.
@end deffn
@deffn {Scheme Function} mu-address-get-domain ADDRESS NUM
Return domain part of an email address
@end deffn
@deffn {Scheme Function} mu-address-get-local ADDRESS NUM
Return local part of an email address.
@end deffn
@deffn {Scheme Function} mu-address-get-count ADDRESS
Return number of parts in email address.
@end deffn
@node Mailbox Functions
@section Mailbox Functions
@deffn {Scheme Function} mu-mailbox-open URL MODE
Opens a mailbox specified by URL.
@end deffn
@deffn {Scheme Function} mu-mailbox-close MBOX
Closes mailbox MBOX
@end deffn
@deffn {Scheme Function} mu-mailbox-get-url MBOX
Returns the URL of the mailbox.
@end deffn
@deffn {Scheme Function} mu-mailbox-get-port MBOX MODE
Returns a port associated with the contents of the MBOX.
MODE is a string defining operation mode of the stream. It may
contain any of the two characters: @samp{r} for reading, @samp{w} for
writing.
@end deffn
@deffn {Scheme Function} mu-mailbox-get-message MBOX MSGNO
Retrieve from MBOX message # MSGNO.
@end deffn
@deffn {Scheme Function} mu-mailbox-messages-count MBOX
Returns number of messages in the mailbox.
@end deffn
@deffn {Scheme Function} mu-mailbox-expunge MBOX
Expunges deleted messages from the mailbox.
@end deffn
@deffn {Scheme Function} mu-mailbox-url MBOX
Returns the URL of the mailbox
@end deffn
@deffn {Scheme Function} mu-mailbox-append-message MBOX MESG
Appends the message to the mailbox
@end deffn
@node Message Functions
@section Message Functions
@deffn {Scheme Function} mu-message-copy MESG
Creates the copy of the given message.
@end deffn
@deffn {Scheme Function} mu-message-set-header MESG HEADER VALUE REPLACE
Sets new VALUE to the header HEADER of the message MESG.
If the HEADER is already present in the message its value
is replaced with the supplied one if the optional REPLACE is
#t. Otherwise new header is created and appended.
@end deffn
@deffn {Scheme Function} mu-message-get-size MESG
Returns the size of the given message.
@end deffn
@deffn {Scheme Function} mu-message-get-lines MESG
Returns number of lines in the given message.
@end deffn
@deffn {Scheme Function} mu-message-get-sender MESG
Returns the sender email address for the message MESG.
@end deffn
@deffn {Scheme Function} mu-message-get-header MESG HEADER
Returns the header value of the HEADER in the MESG.
@end deffn
@deffn {Scheme Function} mu-message-get-header-fields MESG HEADERS
Returns the list of headers in the MESG. If optional HEADERS is
specified it should be a list of header names to restrict return
value to.
@end deffn
@deffn {Scheme Function} mu-message-set-header-fields MESG LIST REPLACE
Set the headers in the message MESG from LIST
LIST is a list of (cons HEADER VALUE)
Optional parameter REPLACE specifies whether the new header
values should replace the headers already present in the
message.
@end deffn
@deffn {Scheme Function} mu-message-delete MESG FLAG
Mark given message as deleted. Optional FLAG allows to toggle deleted mark
The message is deleted if it is #t and undeleted if it is #f
@end deffn
@deffn {Scheme Function} mu-message-get-flag MESG FLAG
Return value of the attribute FLAG.
@end deffn
@deffn {Scheme Function} mu-message-set-flag MESG FLAG VALUE
Set the given attribute of the message. If optional VALUE is #f, the
attribute is unset.
@end deffn
@deffn {Scheme Function} mu-message-get-user-flag MESG FLAG
Returns value of the user attribute FLAG.
@end deffn
@deffn {Scheme Function} mu-message-set-user-flag MESG FLAG VALUE
Set the given user attribute of the message. If optional VALUE is
#f, the attribute is unset.
@end deffn
@deffn {Scheme Function} mu-message-get-port MESG MODE FULL
Returns a port associated with the given MESG. MODE is a string
defining operation mode of the stream. It may contain any of the
two characters: @samp{r} for reading, @samp{w} for writing.
If optional FULL argument specified, it should be a boolean value.
If it is #t then the returned port will allow access to any
part of the message (including headers). If it is #f then the port
accesses only the message body (the default).
@end deffn
@deffn {Scheme Function} mu-message-get-body MESG
Returns the message body for the message MESG.
@end deffn
@deffn {Scheme Function} mu-message-send MESG MAILER
Sends the message MESG. Optional MAILER overrides default
mailer settings in mu-mailer.
@end deffn
@node MIME Functions
@section MIME Functions
@deffn {Scheme Function} mu-mime-create FLAGS MESG
Creates a new MIME object.
@end deffn
@deffn {Scheme Function} mu-mime-multipart? MIME
Returns #t if MIME is a multipart object.
@end deffn
@deffn {Scheme Function} mu-mime-get-num-parts MIME
Returns number of parts in a MIME object.
@end deffn
@deffn {Scheme Function} mu-mime-get-part MIME PART
Returns part number PART from a MIME object.
@end deffn
@deffn {Scheme Function} mu-mime-add-part MIME MESG
Adds MESG to the MIME object.
@end deffn
@deffn {Scheme Function} mu-mime-get-message MIME
Converts MIME object to a message.
@end deffn
@node Log Functions
@section Log Functions
@deffn {Scheme Function} mu-openlog IDENT OPTION FACILITY
Opens a connection to the system logger for Guile program.
@end deffn
@deffn {Scheme Function} mu-logger PRIO TEXT
Generates a log message to be distributed via syslogd.
@end deffn
@deffn {Scheme Function} mu-closelog
Closes the channel to the system logger open by mu-openlog.
@end deffn
@node Direct Linking
@section Direct Linking
If you plan to link your program directly to @file{libguile}, it will
probably make sense to link @file{libmu_scm} directly as well. The
arguments to the program loader may be obtained by running
@example
mailutils-config --link guile
@end example
@noindent
@xref{mailutils-config}, for more information about this utility.
Here is a sample Makefile fragment:
@example
MU_LDFLAGS=`mailutils-config --link guile`
MU_INCLUDES=`mailutils-config --include`
myprog: myprog.c
$(CC) -omyprog $(CFLAGS) $(MU_INCLUDES) myprog.c $(MU_LDFLAGS)
@end example
@node Dynamic Linking
@section Dynamic Linking
Dynamic linking is the preferred method of using @file{libmu_scm}. It
uses Guile ``use-modules'' mechanism. An interface module
@file{mailutils.scm} is provided in order to facilitate using this
method. This module is installed in the package data directory (by
default it is @var{prefix}/share/mailutils). A sample use of
this module is:
@example
(set! %load-path (list "/usr/local/share/mailutils"))
(use-modules (mailutils))
# Now you may use mailutils functions:
(let ((mb (mu-mailbox-open "/var/spool/mail/gray" "r")))
...
@end example
@emph{Note}, that you should explicitly modify the @code{%load-path}
before calling @code{use-modules}, otherwise Guile will not be able to
find @file{mailutils.scm}.