~rdoering/ubuntu/karmic/erlang/fix-535090

« back to all changes in this revision

Viewing changes to lib/erl_interface/doc/src/registry.xml

  • Committer: Bazaar Package Importer
  • Author(s): Sergei Golovan
  • Date: 2009-02-15 16:42:52 UTC
  • mfrom: (3.1.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090215164252-q5x4rcf8a5pbesb1
Tags: 1:12.b.5-dfsg-2
Upload to unstable after lenny is released.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version="1.0" encoding="latin1" ?>
 
2
<!DOCTYPE cref SYSTEM "cref.dtd">
 
3
 
 
4
<cref>
 
5
  <header>
 
6
    <copyright>
 
7
      <year>1998</year>
 
8
      <year>2007</year>
 
9
      <holder>Ericsson AB, All Rights Reserved</holder>
 
10
    </copyright>
 
11
    <legalnotice>
 
12
  The contents of this file are subject to the Erlang Public License,
 
13
  Version 1.1, (the "License"); you may not use this file except in
 
14
  compliance with the License. You should have received a copy of the
 
15
  Erlang Public License along with this software. If not, it can be
 
16
  retrieved online at http://www.erlang.org/.
 
17
 
 
18
  Software distributed under the License is distributed on an "AS IS"
 
19
  basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
 
20
  the License for the specific language governing rights and limitations
 
21
  under the License.
 
22
 
 
23
  The Initial Developer of the Original Code is Ericsson AB.
 
24
    </legalnotice>
 
25
 
 
26
    <title>registry</title>
 
27
    <prepared>Gordon Beaton</prepared>
 
28
    <responsible>Gordon Beaton</responsible>
 
29
    <docno></docno>
 
30
    <approved>Gordon Beaton</approved>
 
31
    <checked>Gordon Beaton</checked>
 
32
    <date>980707</date>
 
33
    <rev>A</rev>
 
34
    <file>registry.sgml</file>
 
35
  </header>
 
36
  <lib>Registry</lib>
 
37
  <libsummary>Store and backup key-value pairs</libsummary>
 
38
  <description>
 
39
    <p>This module provides support for storing key-value
 
40
      pairs in a table known as a registry, backing up registries to
 
41
      Mnesia in an atomic manner, and later restoring the contents of a
 
42
      registry from Mnesia.</p>
 
43
  </description>
 
44
  <funcs>
 
45
    <func>
 
46
      <name><ret>ei_reg *</ret><nametext>ei_reg_open(size)</nametext></name>
 
47
      <fsummary>Create and open a registry</fsummary>
 
48
      <type>
 
49
        <v>int size;</v>
 
50
      </type>
 
51
      <desc>
 
52
        <p>Open (create) a registry. The registry will be
 
53
          initially empty. Use <c><![CDATA[ei_reg_close()]]></c> to close the registry
 
54
          later.
 
55
          </p>
 
56
        <p><c><![CDATA[size]]></c> is the approximate number of objects you intend
 
57
          to store in the registry. Since the registry uses a hash table
 
58
          with collision chaining, there is no absolute upper limit on the
 
59
          number of objects that can be stored in it. However for reasons
 
60
          of efficiency, it is a good idea to choose a number that is
 
61
          appropriate for your needs. It is possible to use
 
62
          <c><![CDATA[ei_reg_resize()]]></c> to change the size later. Note that the
 
63
          number you provide will be increased to the nearest larger prime
 
64
          number.
 
65
          </p>
 
66
        <p>On success, an empty registry will be returned. On failure, NULL
 
67
          will be returned.</p>
 
68
      </desc>
 
69
    </func>
 
70
    <func>
 
71
      <name><ret>int</ret><nametext>ei_reg_resize(reg,newsize)</nametext></name>
 
72
      <fsummary>Resize a registry</fsummary>
 
73
      <type>
 
74
        <v>ei_reg *reg;</v>
 
75
        <v>int newsize;</v>
 
76
      </type>
 
77
      <desc>
 
78
        <p>Change the size of a registry.
 
79
          </p>
 
80
        <p><c><![CDATA[newsize]]></c> is the new size to make the registry. The
 
81
          number will be increased to the nearest larger prime number.
 
82
          </p>
 
83
        <p>On success, the registry will be resized, all contents
 
84
          rehashed, and the function will return 0. On failure, the
 
85
          registry will be left unchanged and the function will return -1.</p>
 
86
      </desc>
 
87
    </func>
 
88
    <func>
 
89
      <name><ret>int</ret><nametext>ei_reg_close(reg)</nametext></name>
 
90
      <fsummary>Close a registry </fsummary>
 
91
      <type>
 
92
        <v>ei_reg *reg;</v>
 
93
      </type>
 
94
      <desc>
 
95
        <p>A registry that has previously been created with
 
96
          <c><![CDATA[ei_reg_open()]]></c> is closed, and all the objects it contains
 
97
          are freed.
 
98
          </p>
 
99
        <p><c><![CDATA[reg]]></c> is the registry to close.
 
100
          </p>
 
101
        <p>The function returns 0.</p>
 
102
      </desc>
 
103
    </func>
 
104
    <func>
 
105
      <name><ret>int</ret><nametext>ei_reg_setival(reg,key,i)</nametext></name>
 
106
      <fsummary>Assign an integer object</fsummary>
 
107
      <type>
 
108
        <v>ei_reg *reg;</v>
 
109
        <v>const char *key;</v>
 
110
        <v>int i;</v>
 
111
      </type>
 
112
      <desc>
 
113
        <p>Create a key-value pair with the specified <c><![CDATA[key]]></c> and integer
 
114
          value <c><![CDATA[i]]></c>. If an object already existed with the same
 
115
          <c><![CDATA[key]]></c>, the new value replaces the old one. If the previous
 
116
          value was a binary or string, it is freed with <c><![CDATA[free()]]></c>.
 
117
          </p>
 
118
        <p><c><![CDATA[reg]]></c> is the registry where the object should be placed.
 
119
          </p>
 
120
        <p><c><![CDATA[key]]></c> is the name of the object.
 
121
          </p>
 
122
        <p><c><![CDATA[i]]></c> is the integer value to assign.
 
123
          </p>
 
124
        <p>The function returns 0 on success, or -1 on failure.</p>
 
125
      </desc>
 
126
    </func>
 
127
    <func>
 
128
      <name><ret>int</ret><nametext>ei_reg_setfval(reg,key,f)</nametext></name>
 
129
      <fsummary>Assign a floating point object</fsummary>
 
130
      <type>
 
131
        <v>ei_reg *reg;</v>
 
132
        <v>const char *key;</v>
 
133
        <v>double f;</v>
 
134
      </type>
 
135
      <desc>
 
136
        <p>Create a key-value pair with the specified <c><![CDATA[key]]></c> and
 
137
          floating point value <c><![CDATA[f]]></c>. If an object already existed with
 
138
          the same <c><![CDATA[key]]></c>, the new value replaces the old one. If the
 
139
          previous value was a binary or string, it is freed with <c><![CDATA[free()]]></c>.
 
140
          </p>
 
141
        <p><c><![CDATA[reg]]></c> is the registry where the object should be placed.
 
142
          </p>
 
143
        <p><c><![CDATA[key]]></c> is the name of the object.
 
144
          </p>
 
145
        <p><c><![CDATA[f]]></c> is the floating point value to assign.
 
146
          </p>
 
147
        <p>The function returns 0 on success, or -1 on failure.</p>
 
148
      </desc>
 
149
    </func>
 
150
    <func>
 
151
      <name><ret>int</ret><nametext>ei_reg_setsval(reg,key,s)</nametext></name>
 
152
      <fsummary>Assign a string object</fsummary>
 
153
      <type>
 
154
        <v>ei_reg *reg;</v>
 
155
        <v>const char *key;</v>
 
156
        <v>const char *s;</v>
 
157
      </type>
 
158
      <desc>
 
159
        <p>Create a key-value pair with the specified <c><![CDATA[key]]></c> whose
 
160
          "value" is the specified string <c><![CDATA[s]]></c>. If an object already
 
161
          existed with the same <c><![CDATA[key]]></c>, the new value replaces the old
 
162
          one. If the previous value was a binary or string, it is freed
 
163
          with <c><![CDATA[free()]]></c>.
 
164
          </p>
 
165
        <p><c><![CDATA[reg]]></c> is the registry where the object should be placed.
 
166
          </p>
 
167
        <p><c><![CDATA[key]]></c> is the name of the object.
 
168
          </p>
 
169
        <p><c><![CDATA[s]]></c> is the string to assign. The string itself
 
170
          must have been created through a single call to <c><![CDATA[malloc()]]></c> or
 
171
          similar function, so that the registry can later delete it if
 
172
          necessary by calling <c><![CDATA[free()]]></c>.
 
173
          </p>
 
174
        <p>The function returns 0 on success, or -1 on failure.</p>
 
175
      </desc>
 
176
    </func>
 
177
    <func>
 
178
      <name><ret>int</ret><nametext>ei_reg_setpval(reg,key,p,size)</nametext></name>
 
179
      <fsummary>Assign a binary object</fsummary>
 
180
      <type>
 
181
        <v>ei_reg *reg;</v>
 
182
        <v>const char *key;</v>
 
183
        <v>const void *p;</v>
 
184
        <v>int size;</v>
 
185
      </type>
 
186
      <desc>
 
187
        <p>Create a key-value pair with the specified <c><![CDATA[key]]></c> whose
 
188
          "value" is the binary object pointed to by <c><![CDATA[p]]></c>. If an
 
189
          object already existed with the same <c><![CDATA[key]]></c>, the new value
 
190
          replaces the old one. If the previous value was a binary or
 
191
          string, it is freed with <c><![CDATA[free()]]></c>.
 
192
          </p>
 
193
        <p><c><![CDATA[reg]]></c> is the registry where the object should be placed.
 
194
          </p>
 
195
        <p><c><![CDATA[key]]></c> is the name of the object.
 
196
          </p>
 
197
        <p><c><![CDATA[p]]></c> is a pointer to the binary object. The object itself
 
198
          must have been created through a single call to <c><![CDATA[malloc()]]></c> or
 
199
          similar function, so that the registry can later delete it if
 
200
          necessary by calling <c><![CDATA[free()]]></c>.
 
201
          </p>
 
202
        <p><c><![CDATA[size]]></c> is the length in bytes of the binary object.
 
203
          </p>
 
204
        <p>The function returns 0 on success, or -1 on failure.</p>
 
205
      </desc>
 
206
    </func>
 
207
    <func>
 
208
      <name><ret>int</ret><nametext>ei_reg_setval(reg,key,flags,v,...)</nametext></name>
 
209
      <fsummary>Assign a value to any object type</fsummary>
 
210
      <type>
 
211
        <v>ei_reg *reg;</v>
 
212
        <v>const char *key;</v>
 
213
        <v>int flags;</v>
 
214
        <v>v (see below)</v>
 
215
      </type>
 
216
      <desc>
 
217
        <p>Create a key-value pair with the specified <c><![CDATA[key]]></c> whose
 
218
          value is specified by <c><![CDATA[v]]></c>. If an object already
 
219
          existed with the same <c><![CDATA[key]]></c>, the new value replaces the old
 
220
          one. If the previous value was a binary or string, it is freed
 
221
          with <c><![CDATA[free()]]></c>. 
 
222
          </p>
 
223
        <p><c><![CDATA[reg]]></c> is the registry where the object should be placed.
 
224
          </p>
 
225
        <p><c><![CDATA[key]]></c> is the name of the object.
 
226
          </p>
 
227
        <p><c><![CDATA[flags]]></c> indicates the type of the object specified by
 
228
          <c><![CDATA[v]]></c>. Flags must be one of EI_INT, EI_FLT, EI_STR and
 
229
          EI_BIN, indicating whether <c><![CDATA[v]]></c> is <c><![CDATA[int]]></c>, <c><![CDATA[double]]></c>,
 
230
          <c><![CDATA[char*]]></c> or <c><![CDATA[void*]]></c>. If <c><![CDATA[flags]]></c> is EI_BIN, then a
 
231
          fifth argument <c><![CDATA[size]]></c> is required, indicating the size
 
232
          in bytes of the object pointed to by <c><![CDATA[v]]></c>.
 
233
          </p>
 
234
        <p>If you wish to store an arbitrary pointer in the registry,
 
235
          specify a <c><![CDATA[size]]></c> of 0. In this case, the object itself will
 
236
          not be transferred by an <c><![CDATA[ei_reg_dump()]]></c> operation, just
 
237
          the pointer value.
 
238
          </p>
 
239
        <p>The function returns 0 on success, or -1 on failure.</p>
 
240
      </desc>
 
241
    </func>
 
242
    <func>
 
243
      <name><ret>int</ret><nametext>ei_reg_getival(reg,key)</nametext></name>
 
244
      <fsummary>Get an integer object</fsummary>
 
245
      <type>
 
246
        <v>ei_reg *reg;</v>
 
247
        <v>const char *key;</v>
 
248
      </type>
 
249
      <desc>
 
250
        <p>Get the value associated with <c><![CDATA[key]]></c> in the
 
251
          registry. The value must be an integer.
 
252
          </p>
 
253
        <p><c><![CDATA[reg]]></c> is the registry where the object will be looked
 
254
          up.
 
255
          </p>
 
256
        <p><c><![CDATA[key]]></c> is the name of the object to look up.
 
257
          </p>
 
258
        <p>On success, the function returns the value associated with <c><![CDATA[key]]></c>.
 
259
          If the object was not found or it was not an integer
 
260
          object, -1 is returned. To avoid problems with in-band error
 
261
          reporting (i.e. if you cannot distinguish between -1 and a
 
262
          valid result) use the more general function <c><![CDATA[ei_reg_getval()]]></c>
 
263
          instead.</p>
 
264
      </desc>
 
265
    </func>
 
266
    <func>
 
267
      <name><ret>double</ret><nametext>ei_reg_getfval(reg,key)</nametext></name>
 
268
      <fsummary>Get a floating point object</fsummary>
 
269
      <type>
 
270
        <v>ei_reg *reg;</v>
 
271
        <v>const char *key;</v>
 
272
      </type>
 
273
      <desc>
 
274
        <p>Get the value associated with <c><![CDATA[key]]></c> in the
 
275
          registry. The value must be a floating point type.
 
276
          </p>
 
277
        <p><c><![CDATA[reg]]></c> is the registry where the object will be looked
 
278
          up.
 
279
          </p>
 
280
        <p><c><![CDATA[key]]></c> is the name of the object to look up.
 
281
          </p>
 
282
        <p>On success, the function returns the value associated with <c><![CDATA[key]]></c>.
 
283
          If the object was not found or it was not a floating point
 
284
          object, -1.0 is returned. To avoid problems with in-band error
 
285
          reporting (i.e. if you cannot distinguish between -1.0 and a
 
286
          valid result) use the more general function <c><![CDATA[ei_reg_getval()]]></c>
 
287
          instead.</p>
 
288
      </desc>
 
289
    </func>
 
290
    <func>
 
291
      <name><ret>const char *</ret><nametext>ei_reg_getsval(reg,key)</nametext></name>
 
292
      <fsummary>Get a string object</fsummary>
 
293
      <type>
 
294
        <v>ei_reg *reg;</v>
 
295
        <v>const char *key;</v>
 
296
      </type>
 
297
      <desc>
 
298
        <p>Get the value associated with <c><![CDATA[key]]></c> in the
 
299
          registry. The value must be a string.
 
300
          </p>
 
301
        <p><c><![CDATA[reg]]></c> is the registry where the object will be looked
 
302
          up.
 
303
          </p>
 
304
        <p><c><![CDATA[key]]></c> is the name of the object to look up.
 
305
          </p>
 
306
        <p>On success, the function returns the value associated with
 
307
          <c><![CDATA[key]]></c>. If the object was not found or it was not a string,
 
308
          NULL is returned. To avoid problems with in-band error
 
309
          reporting (i.e. if you cannot distinguish between NULL and a
 
310
          valid result) use the more general function <c><![CDATA[ei_reg_getval()]]></c>
 
311
          instead.</p>
 
312
      </desc>
 
313
    </func>
 
314
    <func>
 
315
      <name><ret>const void *</ret><nametext>ei_reg_getpval(reg,key,size)</nametext></name>
 
316
      <fsummary>Get a binary object</fsummary>
 
317
      <type>
 
318
        <v>ei_reg *reg;</v>
 
319
        <v>const char *key;</v>
 
320
        <v>int size;</v>
 
321
      </type>
 
322
      <desc>
 
323
        <p>Get the value associated with <c><![CDATA[key]]></c> in the
 
324
          registry. The value must be a binary (pointer) type.
 
325
          </p>
 
326
        <p><c><![CDATA[reg]]></c> is the registry where the object will be looked
 
327
          up.
 
328
          </p>
 
329
        <p><c><![CDATA[key]]></c> is the name of the object to look up.
 
330
          </p>
 
331
        <p><c><![CDATA[size]]></c> will be initialized to contain the length in
 
332
          bytes of the object, if it is found.
 
333
          </p>
 
334
        <p>On success, the function returns the value associated with
 
335
          <c><![CDATA[key]]></c> and indicates its length in <c><![CDATA[size]]></c>.
 
336
          If the object was not found or it was not a binary object,
 
337
          NULL is returned. To avoid problems with in-band error
 
338
          reporting (i.e. if you cannot distinguish between NULL and a
 
339
          valid result) use the more general function <c><![CDATA[ei_reg_getval()]]></c>
 
340
          instead.</p>
 
341
      </desc>
 
342
    </func>
 
343
    <func>
 
344
      <name><ret>int</ret><nametext>ei_reg_getval(reg,key,flags,v,...)</nametext></name>
 
345
      <fsummary>Get any object</fsummary>
 
346
      <type>
 
347
        <v>ei_reg *reg;</v>
 
348
        <v>const char *key;</v>
 
349
        <v>int flags;</v>
 
350
        <v>void *v (see below)</v>
 
351
      </type>
 
352
      <desc>
 
353
        <p>This is a general function for retrieving any kind of
 
354
          object from the registry. 
 
355
          </p>
 
356
        <p><c><![CDATA[reg]]></c> is the registry where the object will be looked
 
357
          up.
 
358
          </p>
 
359
        <p><c><![CDATA[key]]></c> is the name of the object to look up.
 
360
          </p>
 
361
        <p><c><![CDATA[flags]]></c> indicates the type of object that you are
 
362
          looking for. If <c><![CDATA[flags]]></c> is 0, then any kind of object will
 
363
          be returned. If <c><![CDATA[flags]]></c> is one of EI_INT, EI_FLT, EI_STR or
 
364
          EI_BIN, then only values of that kind will be returned. The
 
365
          buffer pointed to by <c><![CDATA[v]]></c> must be large enough to hold the return
 
366
          data, i.e. it must be a pointer to one of <c><![CDATA[int]]></c>,
 
367
          <c><![CDATA[double]]></c>, <c><![CDATA[char*]]></c> or <c><![CDATA[void*]]></c>, respectively. Also,
 
368
          if <c><![CDATA[flags]]></c> is EI_BIN, then a fifth argument <c><![CDATA[int *size]]></c> is required, so that the size of the object can be
 
369
          returned.
 
370
          </p>
 
371
        <p>If the function succeeds, <c><![CDATA[v]]></c> (and <c><![CDATA[size]]></c> if the
 
372
          object is binary) will be initialized with the value associated
 
373
          with <c><![CDATA[key]]></c>, and the function will return one of EI_INT,
 
374
          EI_FLT, EI_STR or EI_BIN, indicating the type of object. On failure the
 
375
          function will return -1 and the arguments will not be updated.</p>
 
376
      </desc>
 
377
    </func>
 
378
    <func>
 
379
      <name><ret>int</ret><nametext>ei_reg_markdirty(reg,key)</nametext></name>
 
380
      <fsummary>Mark an object as dirty </fsummary>
 
381
      <type>
 
382
        <v>ei_reg *reg;</v>
 
383
        <v>const char *key;</v>
 
384
      </type>
 
385
      <desc>
 
386
        <p>Mark a registry object as dirty. This will ensure that
 
387
          it is included in the next backup to Mnesia. Normally this
 
388
          operation will not be necessary since all of the normal registry
 
389
          'set' functions do this automatically. However if you have
 
390
          retrieved the value of a string or binary object from the
 
391
          registry and modified the contents, then the change will be
 
392
          invisible to the registry and the object will be assumed to be
 
393
          unmodified. This function allows you to make such modifications
 
394
          and then let the registry know about them. 
 
395
          </p>
 
396
        <p><c><![CDATA[reg]]></c> is the registry containing the object.
 
397
          </p>
 
398
        <p><c><![CDATA[key]]></c> is the name of the object to mark.
 
399
          </p>
 
400
        <p>The function returns 0 on success, or -1 on failure.</p>
 
401
      </desc>
 
402
    </func>
 
403
    <func>
 
404
      <name><ret>int</ret><nametext>ei_reg_delete(reg,key)</nametext></name>
 
405
      <fsummary>Delete an object from the registry</fsummary>
 
406
      <type>
 
407
        <v>ei_reg *reg;</v>
 
408
        <v>const char *key;</v>
 
409
      </type>
 
410
      <desc>
 
411
        <p>Delete an object from the registry. The object is not
 
412
          actually removed from the registry, it is only marked for later
 
413
          removal so that on subsequent backups to Mnesia, the
 
414
          corresponding object can be removed from the Mnesia table as
 
415
          well. If another object is later created with the same key, the
 
416
          object will be reused. 
 
417
          </p>
 
418
        <p>The object will be removed from the registry after a call to
 
419
          <c><![CDATA[ei_reg_dump()]]></c> or <c><![CDATA[ei_reg_purge()]]></c>.
 
420
          </p>
 
421
        <p><c><![CDATA[reg]]></c> is the registry containing <c><![CDATA[key]]></c>.
 
422
          </p>
 
423
        <p><c><![CDATA[key]]></c> is the object to remove.
 
424
          </p>
 
425
        <p>If the object was found, the function returns 0 indicating
 
426
          success. Otherwise the function returns -1.</p>
 
427
      </desc>
 
428
    </func>
 
429
    <func>
 
430
      <name><ret>int</ret><nametext>ei_reg_stat(reg,key,obuf)</nametext></name>
 
431
      <fsummary>Get object information</fsummary>
 
432
      <type>
 
433
        <v>ei_reg *reg;</v>
 
434
        <v>const char *key;</v>
 
435
        <v>struct ei_reg_stat *obuf;</v>
 
436
      </type>
 
437
      <desc>
 
438
        <p>Return information about an object.
 
439
          </p>
 
440
        <p><c><![CDATA[reg]]></c> is the registry containing the object.
 
441
          </p>
 
442
        <p><c><![CDATA[key]]></c> is the name of the object.
 
443
          </p>
 
444
        <p><c><![CDATA[obuf]]></c> is a pointer to an <c><![CDATA[ei_reg_stat]]></c> structure,
 
445
          defined below:
 
446
          </p>
 
447
        <code type="none"><![CDATA[
 
448
struct ei_reg_stat {
 
449
  int attr;
 
450
  int size;
 
451
};
 
452
        ]]></code>
 
453
        <p>In <c><![CDATA[attr]]></c> the object's attributes are stored as the logical
 
454
          OR of its type (one of EI_INT, EI_FLT, EI_BIN and EI_STR),
 
455
          whether it is marked for deletion (EI_DELET) and whether it has
 
456
          been modified since the last backup to Mnesia (EI_DIRTY). 
 
457
          </p>
 
458
        <p>The <c><![CDATA[size]]></c> field indicates the size in bytes required to store
 
459
          EI_STR (including the terminating 0) and EI_BIN objects, or 0
 
460
          for EI_INT and EI_FLT.
 
461
          </p>
 
462
        <p>The function returns 0 and initializes <c><![CDATA[obuf]]></c> on
 
463
          success, or returns -1 on failure.</p>
 
464
      </desc>
 
465
    </func>
 
466
    <func>
 
467
      <name><ret>int</ret><nametext>ei_reg_tabstat(reg,obuf)</nametext></name>
 
468
      <fsummary>Get registry information</fsummary>
 
469
      <type>
 
470
        <v>ei_reg *reg;</v>
 
471
        <v>struct ei_reg_tabstat *obuf;</v>
 
472
      </type>
 
473
      <desc>
 
474
        <p>Return information about a registry. Using information
 
475
          returned by this function, you can see whether the size of the
 
476
          registry is suitable for the amount of data it contains.
 
477
          </p>
 
478
        <p><c><![CDATA[reg]]></c> is the registry to return information about.
 
479
          </p>
 
480
        <p><c><![CDATA[obuf]]></c> is a pointer to an <c><![CDATA[ei_reg_tabstat]]></c> structure,
 
481
          defined below:
 
482
          </p>
 
483
        <code type="none"><![CDATA[
 
484
struct ei_reg_tabstat {
 
485
  int size;  
 
486
  int nelem; 
 
487
  int npos;  
 
488
  int collisions; 
 
489
};
 
490
        ]]></code>
 
491
        <p>The <c><![CDATA[size]]></c> field indicates the number of hash positions
 
492
          in the registry. This is the number you provided when you
 
493
          created or last resized the registry, rounded up to the nearest
 
494
          prime.
 
495
          </p>
 
496
        <p><c><![CDATA[nelem]]></c> indicates the number of elements stored in the
 
497
          registry. It includes objects that are deleted but not purged.
 
498
          </p>
 
499
        <p><c><![CDATA[npos]]></c> indicates the number of unique positions that are
 
500
          occupied in the registry. 
 
501
          </p>
 
502
        <p><c><![CDATA[collisions]]></c> indicates how many elements are sharing
 
503
          positions in the registry.
 
504
          </p>
 
505
        <p>On success, the function returns 0 and <c><![CDATA[obuf]]></c> is
 
506
          initialized to contain table statistics. On failure, the function
 
507
          returns -1.</p>
 
508
      </desc>
 
509
    </func>
 
510
    <func>
 
511
      <name><ret>int</ret><nametext>ei_reg_dump(fd,reg,mntab,flags)</nametext></name>
 
512
      <fsummary>Back up a registry to Mnesia</fsummary>
 
513
      <type>
 
514
        <v>int fd;</v>
 
515
        <v>ei_reg *reg;</v>
 
516
        <v>const char *mntab;</v>
 
517
        <v>int flags;</v>
 
518
      </type>
 
519
      <desc>
 
520
        <p>Dump the contents of a registry to a Mnesia table in an
 
521
          atomic manner, i.e. either all data will be updated, or none of
 
522
          it will. If any errors are encountered while backing up
 
523
          the data, the entire operation is aborted.
 
524
          </p>
 
525
        <p><c><![CDATA[fd]]></c> is an open connection to Erlang.
 
526
          Mnesia 3.0 or later must be running on the Erlang node.
 
527
          </p>
 
528
        <p><c><![CDATA[reg]]></c> is the registry to back up.
 
529
          </p>
 
530
        <p><c><![CDATA[mntab]]></c> is the name of the Mnesia table where the backed
 
531
          up data should be placed. If the table does not exist, it will
 
532
          be created automatically using configurable defaults. See your
 
533
          Mnesia documentation for information about configuring this
 
534
          behaviour. 
 
535
          </p>
 
536
        <p>If <c><![CDATA[flags]]></c> is 0, the backup will include only those
 
537
          objects which have been created, modified or deleted since the
 
538
          last backup or restore (i.e. an incremental backup). After the
 
539
          backup, any objects that were marked dirty are now clean, and any
 
540
          objects that had been marked for deletion are deleted.
 
541
          </p>
 
542
        <p>Alternatively, setting flags to EI_FORCE will cause a full
 
543
          backup to be done, and EI_NOPURGE will cause the deleted objects
 
544
          to be left in the registry afterwards. These can be bitwise ORed
 
545
          together if both behaviours are desired. If EI_NOPURGE was
 
546
          specified, you can use <c><![CDATA[ei_reg_purge()]]></c> to explicitly remove
 
547
          the deleted items from the registry later. 
 
548
          </p>
 
549
        <p>The function returns 0 on success, or -1 on failure.</p>
 
550
      </desc>
 
551
    </func>
 
552
    <func>
 
553
      <name><ret>int</ret><nametext>ei_reg_restore(fd,reg,mntab)</nametext></name>
 
554
      <fsummary>Restore a registry from Mnesia</fsummary>
 
555
      <type>
 
556
        <v>int fd;</v>
 
557
        <v>ei_reg *reg;</v>
 
558
        <v>const char *mntab;</v>
 
559
      </type>
 
560
      <desc>
 
561
        <p>The contents of a Mnesia table are read into the
 
562
          registry. 
 
563
          </p>
 
564
        <p><c><![CDATA[fd]]></c> is an open connection to Erlang.
 
565
          Mnesia 3.0 or later must be running on the Erlang node.
 
566
          </p>
 
567
        <p><c><![CDATA[reg]]></c> is the registry where the data should be placed.
 
568
          </p>
 
569
        <p><c><![CDATA[mntab]]></c> is the name of the Mnesia table to read data
 
570
          from. 
 
571
          </p>
 
572
        <p>Note that only tables of a certain format can be
 
573
          restored, i.e. those that have been created and backed up to
 
574
          with <c><![CDATA[ei_reg_dump()]]></c>. If the registry was not empty before
 
575
          the operation, then the contents of the table are added to the
 
576
          contents of the registry. If the table contains objects with the
 
577
          same keys as those already in the registry, the registry objects
 
578
          will be overwritten with the new values. If the registry
 
579
          contains objects that were not in the table, they will be
 
580
          unchanged by this operation.
 
581
          </p>
 
582
        <p>After the restore operation, the entire contents of the
 
583
          registry is marked as unmodified. Note that this includes any
 
584
          objects that were modified before the restore and not
 
585
          overwritten by the restore.  
 
586
          </p>
 
587
        <p>The function returns 0 on success, or -1 on failure.</p>
 
588
      </desc>
 
589
    </func>
 
590
    <func>
 
591
      <name><ret>int</ret><nametext>ei_reg_purge(reg)</nametext></name>
 
592
      <fsummary>Remove deleted objects</fsummary>
 
593
      <type>
 
594
        <v>ei_reg *reg;</v>
 
595
      </type>
 
596
      <desc>
 
597
        <p>Remove all objects marked for deletion. When objects
 
598
          are deleted with <c><![CDATA[ei_reg_delete()]]></c> they are not actually
 
599
          removed from the registry, only marked for later removal. This
 
600
          is so that on a subsequent backup to Mnesia, the
 
601
          objects can also be removed from the Mnesia table. If you are
 
602
          not backing up to Mnesia then you may wish to remove the objects
 
603
          manually with this function.
 
604
          </p>
 
605
        <p><c><![CDATA[reg]]></c> is a registry containing objects marked for
 
606
          deletion.
 
607
          </p>
 
608
        <p>The function returns 0 on success, or -1 on failure.</p>
 
609
      </desc>
 
610
    </func>
 
611
  </funcs>
 
612
</cref>
 
613