.\" header.tmac. GetData manual macros. .\" .\" Copyright (C) 2016 D. V. Wiebe .\" .\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" .\" .\" This file is part of the GetData project. .\" .\" Permission is granted to copy, distribute and/or modify this document .\" under the terms of the GNU Free Documentation License, Version 1.2 or .\" any later version published by the Free Software Foundation; with no .\" Invariant Sections, with no Front-Cover Texts, and with no Back-Cover .\" Texts. A copy of the license is included in the `COPYING.DOC' file .\" as part of this distribution. .\" Format a function name with optional trailer: func_name()trailer .de FN \" func_name [trailer] .nh .BR \\$1 ()\\$2 .hy .. .\" Format a reference to section 3 of the manual: name(3)trailer .de F3 \" func_name [trailer] .nh .BR \\$1 (3)\\$2 .hy .. .\" Format the header of a list of definitons .de DD \" name alt... .ie "\\$2"" \{ \ .TP 8 .PD .B \\$1 \} .el \{ \ .PP .B \\$1 .PD 0 .DD \\$2 \\$3 \} .. .\" Start a code block: Note: groff defines an undocumented .SC for .\" Bell Labs man legacy reasons. .de SC .fam C .na .nh .. .\" End a code block .de EC .hy .ad .fam .. .\" Format a structure pointer member: struct->member\fRtrailer .de SPM \" struct member trailer .nh .ie "\\$3"" .IB \\$1 ->\: \\$2 .el .IB \\$1 ->\: \\$2\fR\\$3 .hy .. .\" Format a function argument .de ARG \" name trailer .nh .ie "\\$2"" .I \\$1 .el .IR \\$1 \\$2 .hy .. .\" Hyphenation exceptions .hw sarray carray lincom linterp .\" gd_move.3. The gd_move man page. .\" .\" Copyright (C) 2008, 2009, 2010, 2012, 2013, 2014, 2016 D. V. Wiebe .\" .\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" .\" .\" This file is part of the GetData project. .\" .\" Permission is granted to copy, distribute and/or modify this document .\" under the terms of the GNU Free Documentation License, Version 1.2 or .\" any later version published by the Free Software Foundation; with no .\" Invariant Sections, with no Front-Cover Texts, and with no Back-Cover .\" Texts. A copy of the license is included in the `COPYING.DOC' file .\" as part of this distribution. .\" .TH gd_move 3 "25 December 2016" "Version 0.10.0" "GETDATA" .SH NAME gd_move \(em move a Dirfile entry between format specification fragments .SH SYNOPSIS .SC .B #include .HP .BI "int gd_move(DIRFILE *" dirfile ", const char" .BI * field_code ", int " new_fragment ", unsigned int " flags ); .EC .SH DESCRIPTION The .FN gd_move function transfers the field or alias specified by .IR field_code , which should not have a representation suffix, defined in the dirfile specified by .IR dirfile from it's current format specification fragment to the fragment indexed by .IR new_fragment . If the field is already defined in the fragment index by .IR new_fragment , this function does nothing and returns no error. If the new fragment has different affixes, the field will be renamed as part of the move. See .F3 gd_rename for details on field renaming. The field is closed before moving, resulting in it's I/O pointer being reset to the beginning-of-field. The .I flags parameter should be zero or more of the following flags, bitwise or'd together: .DD GD_REN_DANGLE By default, if the move results in a change of name for the field due to differing fragment affixes, .B ALIAS entries pointing to this field will be updated with the field's new name. Specifying this flag prohibits this behaviour, turning these aliases into dangling aliases. If moving the field doesn't rename it, this flag is ignored. .DD GD_REN_DATA If .I field_code specifies a .B RAW field, the binary file associated with the field will be translated to account for the possibly different encoding, endianness, and frame offset of the new format specification fragment. It will also be moved to a new directory, if necessary. If this flag is not specified, no changes will be made to the binary file. If .I field_code specifies a field of type other than .BR RAW , this flag is ignored. If the binary file is translated, and the frame offset of the destination fragment is larger than that of the source fragment, this will result in permanent deletion of data from the database. If the new frame offset is smaller than the old frame offset, the binary file will be padded at the front with zeroes. .DD GD_REN_FORCE Skip updating entries which would be invalid (see .F3 gd_rename for details). By default, an invalid field causes the move to fail. If moving the field doesn't rename it, this flag is ignored. .DD GD_REN_UPDB If moving the field renames it, update entries which use this field as an input to account for the new name (see .F3 gd_rename ). If moving the field doesn't rename it, this flag is ignored. .SH RETURN VALUE On success, .FN gd_move returns zero. On error, a negative-valued error code is returned. Possible error codes are: .DD GD_E_ACCMODE The specified dirfile was opened read-only. .DD GD_E_ALLOC The library was unable to allocate memory. .DD GD_E_BAD_CODE The field specified by .I field_code was not found, or else the move resulted in the field being renamed and the resultant metadata update tried to change a field code into something prohibited by a fragment's affixes. .DD GD_E_BAD_DIRFILE The supplied dirfile was invalid. .DD GD_E_BAD_FIELD_TYPE An attempt was made to move the immutable .I INDEX field. .DD GD_E_BAD_INDEX The .I new_fragment argument did not index a valid format specification fragment. .DD GD_E_IO An I/O error occurred while attempting to translate a binary file. .DD GD_E_PROTECTED The metadata of the source or destination format specification fragments was protected from change, or the binary data of the source or destination fragments was protected from change and binary file translation was requested. .DD GD_E_UNKNOWN_ENCODING The encoding scheme of the source or destination fragment is unknown. .DD GD_E_UNSUPPORTED The encoding scheme of the source or destination fragment does not support binary file translation. .PP The error code is also stored in the .B DIRFILE object and may be retrieved after this function returns by calling .F3 gd_error . A descriptive error string for the error may be obtained by calling .F3 gd_error_string . .SH NOTES A binary file translation occurs out-of-place. As a result, sufficient space must be present on the filesystem for both the binary file before translation and the binary file after translation. .SH HISTORY The .FN dirfile_move function appeared in GetData-0.5.0. It had no .ARG flags parameter. In place of .ARG flags was .B int .IR move_data . Passing a non-zero value for this parameter had the same effect as the .B GD_REN_DATA flag does now. In GetData-0.7.0, this function was renamed to .FN gd_move . In all GetData-0.8.x releases, passing an alias name to this function would move the target of the alias. To move an alias itself, a separate function, .FN gd_move_alias was available. In GetData-0.9.0, .FN gd_move_alias was removed. Also in this release, the .ARG move_data parameter was repaced with the .ARG flags parameter. In GetData-0.10.0, the error return from this function changed from -1 to a negative-valued error code. .SH SEE ALSO .F3 gd_metaflush , .F3 gd_open , .F3 gd_error , .F3 gd_error_string , dirfile(5), dirfile-format(5)