Initialize the gmime for upstream
[platform/upstream/gmime.git] / docs / reference / html / gmime-streams.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2 <html>
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5 <title>GMime Streams</title>
6 <meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
7 <link rel="home" href="index.html" title="GMime 2.6 Reference Manual">
8 <link rel="up" href="fundamentals.html" title="Part II. GMime Fundamentals">
9 <link rel="prev" href="fundamentals.html" title="Part II. GMime Fundamentals">
10 <link rel="next" href="gmime-filters.html" title="GMime Stream Filters">
11 <meta name="generator" content="GTK-Doc V1.18 (XML mode)">
12 <link rel="stylesheet" href="style.css" type="text/css">
13 </head>
14 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
15 <table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"><tr valign="middle">
16 <td><a accesskey="p" href="fundamentals.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
17 <td><a accesskey="u" href="fundamentals.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
18 <td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
19 <th width="100%" align="center">GMime 2.6 Reference Manual</th>
20 <td><a accesskey="n" href="gmime-filters.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
21 </tr></table>
22 <div class="refentry">
23 <a name="gmime-streams"></a><div class="titlepage"></div>
24 <div class="refnamediv"><table width="100%"><tr>
25 <td valign="top">
26 <h2><span class="refentrytitle">GMime Streams</span></h2>
27 <p>GMime Streams — How to use GMime Streams</p>
28 </td>
29 <td valign="top" align="right"></td>
30 </tr></table></div>
31 <div class="refsect1">
32 <a name="stream-overview"></a><h2>Overview of Streams</h2>
33 <p>Streams are the fundamental method for reading and writing
34     data used by GMime. You'll probably notice that the basic API is 
35     similar to that of the low-level Unix I/O layer (read(), write(), 
36     lseek(), etc) with some additional nicities such as a printf-like 
37     function.</p>
38 <p>The three (3) basic stream types are: GMimeStreamFile,
39     GMimeStreamFs and GMimeStreamMem. You can manipulate all three
40     streams using the GMimeStream interfaces. In addition, some of
41     these streams have extended interfaces to allow more fine grained
42     manipulation.</p>
43 <p>GMimeStreamFile and GMimeStreamFs are very similar in that
44     they are both meant for reading and writing data to the file
45     system (in the form of files). Since GMimeStreamFile is an
46     abstracted layer above the standard libc FILE type, one of the
47     added benefits is buffered I/O. GMimeStreamFs, on the other hand,
48     is an abstracted layer above Unix file descriptors. While a
49     GMimeStreamFs can be used on top of a UNIX socket or pipe, you
50     must be careful because sockets and pipes are not seekable.</p>
51 <p>Unlike the previous 2 stream types, GMimeStreamMem does not
52     interact with the file system at all (except maybe the swap
53     partition/file indirectly). Memory streams are handy when you want
54     reads and writes to be nearly instantaneous and/or if you don't
55     want to create a temporary file on disk.</p>
56 <p>The four (4) advanced stream types are GMimeStreamMmap,
57     GMimeStreamNull, GMimeStreamBuffer and GMimeStreamFilter.</p>
58 <p>Our most simple stream, GMimeStreamNull, is the stream
59     equivalent of /dev/null on Unix systems. The main difference is
60     that GMimeStreamNull records the number of bytes written to it -
61     you may find this useful if you need to know the number of bytes a
62     GMimeObject (for example) will require.</p>
63 <p>GMimeStreamMmap is a memory-mapped stream. This isn't
64     guarenteed to work on all systems since not all systems support
65     the POSIX mmap system call, but for those that do - this might
66     present a faster stream than GMimeStreamFs and/or
67     GMimeStreamFile. You'll have to do some experimentation to know
68     for sure.</p>
69 <p>The GMimeStreamBuffer can be used on top of any other type
70     of stream and has 3 modes: block reads, block writes, and cached
71     reads. Block reads are especially useful if you will be making a
72     lot of small reads from a stream that accesses the file
73     system. Block writes are useful for very much the same reason. The
74     final mode, cached reads, can become memory intensive but can be
75     very helpful when inheriting from a stream that does not support
76     seeking (Note: this mode is the least tested so be careful using
77     it).</p>
78 <p>Our final stream type, GMimeStreamFilter, can also be used
79     on top of another stream. This stream, as you may have guessed,
80     filters reads and writes to its inherited stream. For example, one
81     could write a compression filter and apply it to a
82     GMimeStreamFilter and any further reads or writes would be
83     (un)compressed.</p>
84 </div>
85 </div>
86 <div class="footer">
87 <hr>
88           Generated by GTK-Doc V1.18</div>
89 </body>
90 </html>