.\" gd_put_constant.3. The gd_put_constant man page. .\" .\" Copyright (C) 2008, 2009, 2010 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_put_constant 3 "4 November 2010" "Version 0.7.0" "GETDATA" .SH NAME gd_put_constant \(em retrieve a scalar constant from a dirfile database .SH SYNOPSIS .B #include .HP .nh .ad l .BI "int gd_put_constant(DIRFILE *" dirfile ", const char *" field_code , .BI "gd_type_t " data_type ", const void *" data_in ); .hy .ad n .SH DESCRIPTION The .BR gd_put_constant () function queries a dirfile(5) database specified by .I dirfile and sets the .B CONST scalar .I field_code , which may not contain a representation suffix, to the value specified in .IR data_in , which should be of the type indicated by .IR data_type . The .I dirfile argument must point to a valid DIRFILE object previously created by a call to .BR gd_open (3). The .I data_type argument should be one of the following symbols, which indicates the desired return type of the data: .RS .TP 11 .I GD_UINT8 unsigned 8-bit integer .TP .I GD_INT8 signed (two's complement) 8-bit integer .TP .I GD_UINT16 unsigned 16-bit integer .TP .I GD_INT16 signed (two's complement) 16-bit integer .TP .I GD_UINT32 unsigned 32-bit integer .TP .I GD_INT32 signed (two's complement) 32-bit integer .TP .I GD_UINT64 unsigned 64-bit integer .TP .I GD_INT64 signed (two's complement) 64-bit integer .TP .IR GD_FLOAT32 \~or\~ GD_FLOAT IEEE-754 standard 32-bit single precision floating point number .TP .IR GD_FLOAT64 \~or\~ GD_DOUBLE IEEE-754 standard 64-bit double precision floating point number .RE The data type of the supplied value need not be the same as the type of the storage type of the constant in the database. Type conversion will be performed as necessary to return the requested type. The argument .I data_out must point to valid data type of the specified type. Because constant values are stored in the dirfile metadata, the new value of .I field_code won't be written to disk until the dirfile metadata is flushed with .BR gd_metaflush (3), or until the dirfile is closed. .SH RETURN VALUE On success, .BR gd_put_constant () returns zero. On error, it returns -1 and sets the dirfile error to a non-zero value. Possible error values are: .TP 8 .B GD_E_ACCMODE The specified .I dirfile was opened read-only. .TP .B GD_E_BAD_CODE The field specified by .I field_code was not found in the database. .TP .B GD_E_BAD_DIRFILE An invalid .I dirfile was supplied. .TP .B GD_E_BAD_FIELD_TYPE The supplied .I field_code referred to a field of type other than .BR CONST . The caller should use .BR gd_putdata "(3), " gd_put_carray (3), or .BR gd_put_string (3) instead. .TP .B GD_E_BAD_REPR The representation suffix specified in .I field_code was not recognised. .TP .B GD_E_BAD_TYPE An invalid .I data_type was specified. .TP .B GD_E_INTERNAL_ERROR An internal error occurred in the library while trying to perform the task. This indicates a bug in the library. Please report the incident to the maintainer. .TP .B GD_E_PROTECTED The fragment containing the constant was protected from change. .PP The dirfile error may be retrieved by calling .BR gd_error (3). A descriptive error string for the last error encountered may be obtained from a call to .BR gd_error_string (3). .SH SEE ALSO .BR dirfile (5), .BR gd_metaflush (3), .BR gd_get_constant (3), .BR gd_error (3), .BR gd_error_string (3), .BR gd_open (3), .BR gd_put_carray (3), .BR gd_put_string (3), .BR gd_putdata (3)