<< Previous | Next >> | |
|
int registry_prep_write( RegistryContext * r, char * basename, ServerContext * context);
Description
- Prepare for updating a registry. This function helps organize registry resources in order to create a robust registry.
- Most applications will use the sequence of functions
registry_prep_write()
registry_write()
registry_finish_write()
- or, more simply, just
registry_update()
- See the function description for
registry_prep_read()
for details concerning the organization of registry files.
- Like
registry_prep_read()
, this function opens an existing presumed non-corrupt registry for reading, and also a new empty registry (the "next" registry) for writing the updated esults, as required byregistry_write()
.Parameters
- r
- RegistryContext struct. This is used to pass information in a consistent manner between the major registry API functions. It may be passed uninitialized to this function.
- basename
- Base name (including path) of the registry. This should NOT include any extension (e.g. ".foo") since the extension is manipulated by this function. In practice, this will need to be a resource name on non-volatile storage, which supports names with extensions. In practice, this limits the appropriate filesystem to FAT filesystem only. For example
- registry_prep_write("/A/myreg", &oldspec, &newspec);
- will select from a set of registry files called
- /A/myreg.1, /A/myreg.2, /A/myreg.3\ of which, normally, only two will exist at any time; one will be opened for reading, and the other will be empty and ready for writing.
- context
- ServerContext structure. E.g. from
http_getContext()
.
Return Value
- <0: general failure, code will be negative of one of the codes in
ERRNO.LIB
.- 0: there is currently no resource of the given name. *oldp will be set to -1 in this case. This is not necessarily an error, since it will be returned if the registry has not yet been created. You can pass *oldp to
registry_write()
in this case, and it will correctly create the new registry without attempting to read the (non-existent) "old" registry.- 1,2,3: An existing presumed non-corrupt resource has been opened, and the open resource handle returned in *oldp. The numeric return code indicates which of the extensions was located. Note that the "new" registry file will be this number plus 1 (except that 4 becomes 1).
Library
- register.lib
See Also
- registry_read, registry_finish_read, registry_prep_read, registry_write, registry_finish_write, registry_enumerate, registry_update, registry_get
Dynamic C Functions | << Previous | Next >> | rabbit.com |