.\" gd_putdata.3. The gd_putdata 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_putdata 3 "4 November 2010" "Version 0.7.0" "GETDATA" .SH NAME gd_putdata \(em write data to a dirfile database .SH SYNOPSIS .B #include .HP .nh .ad l .BI "size_t gd_putdata(DIRFILE *" dirfile ", const char *" field_code ", off_t" .IB first_frame ", off_t " first_sample ", size_t " num_frames ", size_t" .IB num_samples ", gd_type_t " data_type ", const void *" data_in ); .hy .ad n .SH DESCRIPTION The .BR gd_putdata () function writes data to a dirfile(5) database specified by .I dirfile for the field .IR field_code , which may not contain a representation suffix. It writes .I num_frames frames plus .I num_samples samples to this field, starting .I first_sample samples past frame .IR first_frame . The data is read from the user-supplied buffer .IR data_in, which is has a data type specified by .IR data_type . This interface cannot write to field representations. The .I dirfile argument must point to a valid DIRFILE object previously created by a call to .BR gd_open (3). The first sample written will be .RS .IR first_frame " * " samples_per_frame " + " first_sample .RE as measured from the start of the dirfile, where .I samples_per_frame is the number of samples per frame as returned by .BR gd_spf (3). The number of samples which .BR gd_putdata () attempts to write is, similarly, .RS .IR num_frames " * " samples_per_frame " + " num_samples . .RE Although calling .BR gd_putdata () using both samples and frames is possible, the function is typically called with either .IR num_samples " and " first_sample , or .IR num_frames " and " first_frames , equal to zero. The .I data_type argument should be one of the following symbols, which indicates the type of the input 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 type of the input data need not be the same as the type of the data stored in the database. Type conversion will be performed as necessary to write the appropriate type. The argument .I data_in must point to a valid memory location of containing all the data to be written. .SH RETURN VALUE In all cases, .BR gd_putdata () returns the number of samples (not bytes) successfully written to the database, which may be zero if an error has occurred. If an error has occurred, the dirfile error will be set 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_ALLOC The library was unable to allocate memory. .TP .B GD_E_BAD_CODE The field specified by .IR field_code , or one of the fields it uses for input, 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 Either the field specified by .IR field_code , or one of the fields it uses for input, was of .B MULTIPLY or .B DIVIDE type, or .B LINCOM type with more than one input fields. In this case, .BR gd_putdata () has no knowledge on how to partition the input data. Alternately, the caller may have attempted to write to the implicit INDEX field, which is not possible. .TP .B GD_E_BAD_REPR The representation suffix specified in .I field_code was not recognised, or an attempt was made to write to a field representation, instead of the underlying field. .TP .B GD_E_BAD_TYPE An invalid .I data_type was specified. .TP .B GD_E_DIMENSION A scalar field was found where a vector field was expected. .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_OPEN_LINFILE An error occurred while trying to read a LINTERP table from disk. .TP .B GD_E_PROTECTED The data of the .B RAW field backing .I field_code was protected from change by a /PROTECT directive. .TP .B GD_E_RANGE An attempt was made to write data before the beginning-of-frame marker for .IR field_code , or the raw field it depends on. .TP .B GD_E_RAW_IO An error occurred while trying to open, read from, or write to a file on disk containing a raw field. .TP .B GD_E_RECURSE_LEVEL Too many levels of recursion were encountered while trying to resolve .IR field_code . This usually indicates a circular dependency in field specification in the dirfile. .TP .B GD_E_UNSUPPORTED Reading from dirfiles with the encoding scheme of the specified dirfile is not supported by the library. See .BR dirfile-encoding (5) for details on dirfile encoding schemes. .RE .PP The dirfile error may be retrieved by calling .BR gd_error (3). A descriptive error string for the last error encountered can be obtained from a call to .BR gd_error_string (3). .SH SEE ALSO .BR dirfile (5), .BR dirfile-encoding (5), .BR gd_open (3), .BR gd_error (3), .BR gd_error_string (3), .BR gd_getdata (3), .BR gd_put_carray (3), .BR gd_put_constant (3), .BR gd_spf (3)