File: structmspack__system.html

package info (click to toggle)
libmspack 0.5-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 3,916 kB
  • sloc: sh: 11,332; ansic: 7,879; perl: 131; makefile: 97
file content (396 lines) | stat: -rw-r--r-- 31,799 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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.6"/>
<title>libmspack: mspack_system Struct Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">libmspack
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.6 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li class="current"><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
      <li><a href="classes.html"><span>Data&#160;Structure&#160;Index</span></a></li>
      <li><a href="functions.html"><span>Data&#160;Fields</span></a></li>
    </ul>
  </div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Data Structures</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Macros</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#pub-attribs">Data Fields</a>  </div>
  <div class="headertitle">
<div class="title">mspack_system Struct Reference</div>  </div>
</div><!--header-->
<div class="contents">

<p>A structure which abstracts file I/O and memory management.  
 <a href="structmspack__system.html#details">More...</a></p>

<p><code>#include &lt;<a class="el" href="mspack_8h_source.html">mspack.h</a>&gt;</code></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-attribs"></a>
Data Fields</h2></td></tr>
<tr class="memitem:a1a85cac5eeb55db6a432fe3824aa04a3"><td class="memItemLeft" align="right" valign="top">struct <a class="el" href="structmspack__file.html">mspack_file</a> *(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structmspack__system.html#a1a85cac5eeb55db6a432fe3824aa04a3">open</a> )(struct <a class="el" href="structmspack__system.html">mspack_system</a> *self, const char *filename, int mode)</td></tr>
<tr class="memdesc:a1a85cac5eeb55db6a432fe3824aa04a3"><td class="mdescLeft">&#160;</td><td class="mdescRight">Opens a file for reading, writing, appending or updating.  <a href="#a1a85cac5eeb55db6a432fe3824aa04a3">More...</a><br/></td></tr>
<tr class="separator:a1a85cac5eeb55db6a432fe3824aa04a3"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a266561cea2dcf8ad60a42c2ac88536c2"><td class="memItemLeft" align="right" valign="top">void(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structmspack__system.html#a266561cea2dcf8ad60a42c2ac88536c2">close</a> )(struct <a class="el" href="structmspack__file.html">mspack_file</a> *file)</td></tr>
<tr class="memdesc:a266561cea2dcf8ad60a42c2ac88536c2"><td class="mdescLeft">&#160;</td><td class="mdescRight">Closes a previously opened file.  <a href="#a266561cea2dcf8ad60a42c2ac88536c2">More...</a><br/></td></tr>
<tr class="separator:a266561cea2dcf8ad60a42c2ac88536c2"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ac33dcc54409a7d5da9be475b3938101e"><td class="memItemLeft" align="right" valign="top">int(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structmspack__system.html#ac33dcc54409a7d5da9be475b3938101e">read</a> )(struct <a class="el" href="structmspack__file.html">mspack_file</a> *file, void *buffer, int bytes)</td></tr>
<tr class="memdesc:ac33dcc54409a7d5da9be475b3938101e"><td class="mdescLeft">&#160;</td><td class="mdescRight">Reads a given number of bytes from an open file.  <a href="#ac33dcc54409a7d5da9be475b3938101e">More...</a><br/></td></tr>
<tr class="separator:ac33dcc54409a7d5da9be475b3938101e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ac57fb5944e7726abe2272822fa07a30f"><td class="memItemLeft" align="right" valign="top">int(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structmspack__system.html#ac57fb5944e7726abe2272822fa07a30f">write</a> )(struct <a class="el" href="structmspack__file.html">mspack_file</a> *file, void *buffer, int bytes)</td></tr>
<tr class="memdesc:ac57fb5944e7726abe2272822fa07a30f"><td class="mdescLeft">&#160;</td><td class="mdescRight">Writes a given number of bytes to an open file.  <a href="#ac57fb5944e7726abe2272822fa07a30f">More...</a><br/></td></tr>
<tr class="separator:ac57fb5944e7726abe2272822fa07a30f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a86ceffde52284d3a57d5d555d7484a03"><td class="memItemLeft" align="right" valign="top">int(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structmspack__system.html#a86ceffde52284d3a57d5d555d7484a03">seek</a> )(struct <a class="el" href="structmspack__file.html">mspack_file</a> *file, off_t offset, int mode)</td></tr>
<tr class="memdesc:a86ceffde52284d3a57d5d555d7484a03"><td class="mdescLeft">&#160;</td><td class="mdescRight">Seeks to a specific file offset within an open file.  <a href="#a86ceffde52284d3a57d5d555d7484a03">More...</a><br/></td></tr>
<tr class="separator:a86ceffde52284d3a57d5d555d7484a03"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ae25e8b0ca839867f19041aa20508e548"><td class="memItemLeft" align="right" valign="top">off_t(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structmspack__system.html#ae25e8b0ca839867f19041aa20508e548">tell</a> )(struct <a class="el" href="structmspack__file.html">mspack_file</a> *file)</td></tr>
<tr class="memdesc:ae25e8b0ca839867f19041aa20508e548"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns the current file position (in bytes) of the given file.  <a href="#ae25e8b0ca839867f19041aa20508e548">More...</a><br/></td></tr>
<tr class="separator:ae25e8b0ca839867f19041aa20508e548"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a612c93482eb01d2b97321015716ea24a"><td class="memItemLeft" align="right" valign="top">void(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structmspack__system.html#a612c93482eb01d2b97321015716ea24a">message</a> )(struct <a class="el" href="structmspack__file.html">mspack_file</a> *file, const char *format,...)</td></tr>
<tr class="memdesc:a612c93482eb01d2b97321015716ea24a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Used to send messages from the library to the user.  <a href="#a612c93482eb01d2b97321015716ea24a">More...</a><br/></td></tr>
<tr class="separator:a612c93482eb01d2b97321015716ea24a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ac70dd55eb6eca7a390e5ae143525f36a"><td class="memItemLeft" align="right" valign="top">void *(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structmspack__system.html#ac70dd55eb6eca7a390e5ae143525f36a">alloc</a> )(struct <a class="el" href="structmspack__system.html">mspack_system</a> *self, size_t bytes)</td></tr>
<tr class="memdesc:ac70dd55eb6eca7a390e5ae143525f36a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Allocates memory.  <a href="#ac70dd55eb6eca7a390e5ae143525f36a">More...</a><br/></td></tr>
<tr class="separator:ac70dd55eb6eca7a390e5ae143525f36a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aafe460b1ce55ce69be8c16948250f86c"><td class="memItemLeft" align="right" valign="top">void(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structmspack__system.html#aafe460b1ce55ce69be8c16948250f86c">free</a> )(void *ptr)</td></tr>
<tr class="memdesc:aafe460b1ce55ce69be8c16948250f86c"><td class="mdescLeft">&#160;</td><td class="mdescRight">Frees memory.  <a href="#aafe460b1ce55ce69be8c16948250f86c">More...</a><br/></td></tr>
<tr class="separator:aafe460b1ce55ce69be8c16948250f86c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a22cdc77c82dba0f6c58945c816c2732e"><td class="memItemLeft" align="right" valign="top">void(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structmspack__system.html#a22cdc77c82dba0f6c58945c816c2732e">copy</a> )(void *src, void *dest, size_t bytes)</td></tr>
<tr class="memdesc:a22cdc77c82dba0f6c58945c816c2732e"><td class="mdescLeft">&#160;</td><td class="mdescRight">Copies from one region of memory to another.  <a href="#a22cdc77c82dba0f6c58945c816c2732e">More...</a><br/></td></tr>
<tr class="separator:a22cdc77c82dba0f6c58945c816c2732e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a8c64d1bd9b6b0ac9455cfde19ccb61b2"><td class="memItemLeft" align="right" valign="top">void *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structmspack__system.html#a8c64d1bd9b6b0ac9455cfde19ccb61b2">null_ptr</a></td></tr>
<tr class="memdesc:a8c64d1bd9b6b0ac9455cfde19ccb61b2"><td class="mdescLeft">&#160;</td><td class="mdescRight">A null pointer to mark the end of <a class="el" href="structmspack__system.html" title="A structure which abstracts file I/O and memory management. ">mspack_system</a>.  <a href="#a8c64d1bd9b6b0ac9455cfde19ccb61b2">More...</a><br/></td></tr>
<tr class="separator:a8c64d1bd9b6b0ac9455cfde19ccb61b2"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>A structure which abstracts file I/O and memory management. </p>
<p>The library always uses the <a class="el" href="structmspack__system.html" title="A structure which abstracts file I/O and memory management. ">mspack_system</a> structure for interaction with the file system and to allocate, free and copy all memory. It also uses it to send literal messages to the library user.</p>
<p>When the library is compiled normally, passing NULL to a compressor or decompressor constructor will result in a default <a class="el" href="structmspack__system.html" title="A structure which abstracts file I/O and memory management. ">mspack_system</a> being used, where all methods are implemented with the standard C library. However, all constructors support being given a custom created <a class="el" href="structmspack__system.html" title="A structure which abstracts file I/O and memory management. ">mspack_system</a> structure, with the library user's own methods. This allows for more abstract interaction, such as reading and writing files directly to memory, or from a network socket or pipe.</p>
<p>Implementors of an <a class="el" href="structmspack__system.html" title="A structure which abstracts file I/O and memory management. ">mspack_system</a> structure should read all documentation entries for every structure member, and write methods which conform to those standards. </p>
</div><h2 class="groupheader">Field Documentation</h2>
<a class="anchor" id="ac70dd55eb6eca7a390e5ae143525f36a"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void*(* mspack_system::alloc)(struct <a class="el" href="structmspack__system.html">mspack_system</a> *self, size_t bytes)</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Allocates memory. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">self</td><td>a self-referential pointer to the <a class="el" href="structmspack__system.html" title="A structure which abstracts file I/O and memory management. ">mspack_system</a> structure whose <a class="el" href="structmspack__system.html#ac70dd55eb6eca7a390e5ae143525f36a" title="Allocates memory. ">alloc()</a> method is being called. </td></tr>
    <tr><td class="paramname">bytes</td><td>the number of bytes to allocate </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>a pointer to the requested number of bytes, or NULL if not enough memory is available </dd></dl>
<dl class="section see"><dt>See Also</dt><dd><a class="el" href="structmspack__system.html#aafe460b1ce55ce69be8c16948250f86c" title="Frees memory. ">free()</a> </dd></dl>

</div>
</div>
<a class="anchor" id="a266561cea2dcf8ad60a42c2ac88536c2"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void(* mspack_system::close)(struct <a class="el" href="structmspack__file.html">mspack_file</a> *file)</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Closes a previously opened file. </p>
<p>If any memory was allocated for this particular file handle, it should be freed at this time.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">file</td><td>the file to close </td></tr>
  </table>
  </dd>
</dl>
<dl class="section see"><dt>See Also</dt><dd><a class="el" href="structmspack__system.html#a1a85cac5eeb55db6a432fe3824aa04a3" title="Opens a file for reading, writing, appending or updating. ">open()</a> </dd></dl>

</div>
</div>
<a class="anchor" id="a22cdc77c82dba0f6c58945c816c2732e"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void(* mspack_system::copy)(void *src, void *dest, size_t bytes)</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Copies from one region of memory to another. </p>
<p>The regions of memory are guaranteed not to overlap, are usually less than 256 bytes, and may not be aligned. Please note that the source parameter comes before the destination parameter, unlike the standard C function memcpy().</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">src</td><td>the region of memory to copy from </td></tr>
    <tr><td class="paramname">dest</td><td>the region of memory to copy to </td></tr>
    <tr><td class="paramname">bytes</td><td>the size of the memory region, in bytes </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="aafe460b1ce55ce69be8c16948250f86c"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void(* mspack_system::free)(void *ptr)</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Frees memory. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">ptr</td><td>the memory to be freed. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section see"><dt>See Also</dt><dd><a class="el" href="structmspack__system.html#ac70dd55eb6eca7a390e5ae143525f36a" title="Allocates memory. ">alloc()</a> </dd></dl>

</div>
</div>
<a class="anchor" id="a612c93482eb01d2b97321015716ea24a"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void(* mspack_system::message)(struct <a class="el" href="structmspack__file.html">mspack_file</a> *file, const char *format,...)</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Used to send messages from the library to the user. </p>
<p>Occasionally, the library generates warnings or other messages in plain english to inform the human user. These are informational only and can be ignored if not wanted.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">file</td><td>may be a file handle returned from <a class="el" href="structmspack__system.html#a1a85cac5eeb55db6a432fe3824aa04a3" title="Opens a file for reading, writing, appending or updating. ">open()</a> if this message pertains to a specific open file, or NULL if not related to a specific file. </td></tr>
    <tr><td class="paramname">format</td><td>a printf() style format string. It does NOT include a trailing newline. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section see"><dt>See Also</dt><dd><a class="el" href="structmspack__system.html#a1a85cac5eeb55db6a432fe3824aa04a3" title="Opens a file for reading, writing, appending or updating. ">open()</a> </dd></dl>

</div>
</div>
<a class="anchor" id="a8c64d1bd9b6b0ac9455cfde19ccb61b2"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void* mspack_system::null_ptr</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>A null pointer to mark the end of <a class="el" href="structmspack__system.html" title="A structure which abstracts file I/O and memory management. ">mspack_system</a>. </p>
<p>It must equal NULL.</p>
<p>Should the <a class="el" href="structmspack__system.html" title="A structure which abstracts file I/O and memory management. ">mspack_system</a> structure extend in the future, this NULL will be seen, rather than have an invalid method pointer called. </p>

</div>
</div>
<a class="anchor" id="a1a85cac5eeb55db6a432fe3824aa04a3"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">struct <a class="el" href="structmspack__file.html">mspack_file</a>*(* mspack_system::open)(struct <a class="el" href="structmspack__system.html">mspack_system</a> *self, const char *filename, int mode)</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Opens a file for reading, writing, appending or updating. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">self</td><td>a self-referential pointer to the <a class="el" href="structmspack__system.html" title="A structure which abstracts file I/O and memory management. ">mspack_system</a> structure whose <a class="el" href="structmspack__system.html#a1a85cac5eeb55db6a432fe3824aa04a3" title="Opens a file for reading, writing, appending or updating. ">open()</a> method is being called. If this pointer is required by <a class="el" href="structmspack__system.html#a266561cea2dcf8ad60a42c2ac88536c2" title="Closes a previously opened file. ">close()</a>, <a class="el" href="structmspack__system.html#ac33dcc54409a7d5da9be475b3938101e" title="Reads a given number of bytes from an open file. ">read()</a>, <a class="el" href="structmspack__system.html#ac57fb5944e7726abe2272822fa07a30f" title="Writes a given number of bytes to an open file. ">write()</a>, <a class="el" href="structmspack__system.html#a86ceffde52284d3a57d5d555d7484a03" title="Seeks to a specific file offset within an open file. ">seek()</a> or <a class="el" href="structmspack__system.html#ae25e8b0ca839867f19041aa20508e548" title="Returns the current file position (in bytes) of the given file. ">tell()</a>, it should be stored in the result structure at this time. </td></tr>
    <tr><td class="paramname">filename</td><td>the file to be opened. It is passed directly from the library caller without being modified, so it is up to the caller what this parameter actually represents. </td></tr>
    <tr><td class="paramname">mode</td><td>one of <a class="el" href="mspack_8h.html#a817255b35e433f4adcf907fc97f9b63f" title="mspack_system::open() mode: open existing file for reading. ">MSPACK_SYS_OPEN_READ</a> (open an existing file for reading), <a class="el" href="mspack_8h.html#a77508ef49eff6a98f39a3b5021c5c51f" title="mspack_system::open() mode: open new file for writing ">MSPACK_SYS_OPEN_WRITE</a> (open a new file for writing), <a class="el" href="mspack_8h.html#ae9f356d2f22c7c236b9bdad87b25b18b" title="mspack_system::open() mode: open existing file for writing ">MSPACK_SYS_OPEN_UPDATE</a> (open an existing file for reading/writing from the start of the file) or <a class="el" href="mspack_8h.html#a05310a4221173aabf06ab99d09d7504e" title="mspack_system::open() mode: open existing file for writing ">MSPACK_SYS_OPEN_APPEND</a> (open an existing file for reading/writing from the end of the file) </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>a pointer to a <a class="el" href="structmspack__file.html" title="A structure which represents an open file handle. ">mspack_file</a> structure. This structure officially contains no members, its true contents are up to the <a class="el" href="structmspack__system.html" title="A structure which abstracts file I/O and memory management. ">mspack_system</a> implementor. It should contain whatever is needed for other <a class="el" href="structmspack__system.html" title="A structure which abstracts file I/O and memory management. ">mspack_system</a> methods to operate. Returning the NULL pointer indicates an error condition. </dd></dl>
<dl class="section see"><dt>See Also</dt><dd><a class="el" href="structmspack__system.html#a266561cea2dcf8ad60a42c2ac88536c2" title="Closes a previously opened file. ">close()</a>, <a class="el" href="structmspack__system.html#ac33dcc54409a7d5da9be475b3938101e" title="Reads a given number of bytes from an open file. ">read()</a>, <a class="el" href="structmspack__system.html#ac57fb5944e7726abe2272822fa07a30f" title="Writes a given number of bytes to an open file. ">write()</a>, <a class="el" href="structmspack__system.html#a86ceffde52284d3a57d5d555d7484a03" title="Seeks to a specific file offset within an open file. ">seek()</a>, <a class="el" href="structmspack__system.html#ae25e8b0ca839867f19041aa20508e548" title="Returns the current file position (in bytes) of the given file. ">tell()</a>, <a class="el" href="structmspack__system.html#a612c93482eb01d2b97321015716ea24a" title="Used to send messages from the library to the user. ">message()</a> </dd></dl>

</div>
</div>
<a class="anchor" id="ac33dcc54409a7d5da9be475b3938101e"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int(* mspack_system::read)(struct <a class="el" href="structmspack__file.html">mspack_file</a> *file, void *buffer, int bytes)</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Reads a given number of bytes from an open file. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">file</td><td>the file to read from </td></tr>
    <tr><td class="paramname">buffer</td><td>the location where the read bytes should be stored </td></tr>
    <tr><td class="paramname">bytes</td><td>the number of bytes to read from the file. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>the number of bytes successfully read (this can be less than the number requested), zero to mark the end of file, or less than zero to indicate an error. </dd></dl>
<dl class="section see"><dt>See Also</dt><dd><a class="el" href="structmspack__system.html#a1a85cac5eeb55db6a432fe3824aa04a3" title="Opens a file for reading, writing, appending or updating. ">open()</a>, <a class="el" href="structmspack__system.html#ac57fb5944e7726abe2272822fa07a30f" title="Writes a given number of bytes to an open file. ">write()</a> </dd></dl>

</div>
</div>
<a class="anchor" id="a86ceffde52284d3a57d5d555d7484a03"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int(* mspack_system::seek)(struct <a class="el" href="structmspack__file.html">mspack_file</a> *file, off_t offset, int mode)</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Seeks to a specific file offset within an open file. </p>
<p>Sometimes the library needs to know the length of a file. It does this by seeking to the end of the file with seek(file, 0, MSPACK_SYS_SEEK_END), then calling <a class="el" href="structmspack__system.html#ae25e8b0ca839867f19041aa20508e548" title="Returns the current file position (in bytes) of the given file. ">tell()</a>. Implementations may want to make a special case for this.</p>
<p>Due to the potentially varying 32/64 bit datatype off_t on some architectures, the <a class="el" href="mspack_8h.html#a3a94be2216dd1e835733acb7c4645fca" title="System self-test function, to ensure both library and calling program can use one another...">MSPACK_SYS_SELFTEST</a> macro MUST be used before using the library. If not, the error caused by the library passing an inappropriate stackframe to <a class="el" href="structmspack__system.html#a86ceffde52284d3a57d5d555d7484a03" title="Seeks to a specific file offset within an open file. ">seek()</a> is subtle and hard to trace.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">file</td><td>the file to be seeked </td></tr>
    <tr><td class="paramname">offset</td><td>an offset to seek, measured in bytes </td></tr>
    <tr><td class="paramname">mode</td><td>one of <a class="el" href="mspack_8h.html#a80228888f03f72c392e138373acfc74e" title="mspack_system::seek() mode: seek relative to start of file ">MSPACK_SYS_SEEK_START</a> (the offset should be measured from the start of the file), <a class="el" href="mspack_8h.html#a9b90c177e3582571d0155c4597f85168" title="mspack_system::seek() mode: seek relative to current offset ">MSPACK_SYS_SEEK_CUR</a> (the offset should be measured from the current file offset) or <a class="el" href="mspack_8h.html#a24e4d3889d52558e7f0c703db94270d6" title="mspack_system::seek() mode: seek relative to end of file ">MSPACK_SYS_SEEK_END</a> (the offset should be measured from the end of the file) </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>zero for success, non-zero for an error </dd></dl>
<dl class="section see"><dt>See Also</dt><dd><a class="el" href="structmspack__system.html#a1a85cac5eeb55db6a432fe3824aa04a3" title="Opens a file for reading, writing, appending or updating. ">open()</a>, <a class="el" href="structmspack__system.html#ae25e8b0ca839867f19041aa20508e548" title="Returns the current file position (in bytes) of the given file. ">tell()</a> </dd></dl>

</div>
</div>
<a class="anchor" id="ae25e8b0ca839867f19041aa20508e548"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">off_t(* mspack_system::tell)(struct <a class="el" href="structmspack__file.html">mspack_file</a> *file)</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Returns the current file position (in bytes) of the given file. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">file</td><td>the file whose file position is wanted </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>the current file position of the file </dd></dl>
<dl class="section see"><dt>See Also</dt><dd><a class="el" href="structmspack__system.html#a1a85cac5eeb55db6a432fe3824aa04a3" title="Opens a file for reading, writing, appending or updating. ">open()</a>, <a class="el" href="structmspack__system.html#a86ceffde52284d3a57d5d555d7484a03" title="Seeks to a specific file offset within an open file. ">seek()</a> </dd></dl>

</div>
</div>
<a class="anchor" id="ac57fb5944e7726abe2272822fa07a30f"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int(* mspack_system::write)(struct <a class="el" href="structmspack__file.html">mspack_file</a> *file, void *buffer, int bytes)</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Writes a given number of bytes to an open file. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">file</td><td>the file to write to </td></tr>
    <tr><td class="paramname">buffer</td><td>the location where the written bytes should be read from </td></tr>
    <tr><td class="paramname">bytes</td><td>the number of bytes to write to the file. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>the number of bytes successfully written, this can be less than the number requested. Zero or less can indicate an error where no bytes at all could be written. All cases where less bytes were written than requested are considered by the library to be an error. </dd></dl>
<dl class="section see"><dt>See Also</dt><dd><a class="el" href="structmspack__system.html#a1a85cac5eeb55db6a432fe3824aa04a3" title="Opens a file for reading, writing, appending or updating. ">open()</a>, <a class="el" href="structmspack__system.html#ac33dcc54409a7d5da9be475b3938101e" title="Reads a given number of bytes from an open file. ">read()</a> </dd></dl>

</div>
</div>
<hr/>The documentation for this struct was generated from the following file:<ul>
<li><a class="el" href="mspack_8h_source.html">mspack.h</a></li>
</ul>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.6
</small></address>
</body>
</html>