SDDSlib
|
This file provides miscellaneous functions for interacting with SDDS objects. More...
#include "SDDS.h"
#include "SDDS_internal.h"
#include "mdb.h"
#include <ctype.h>
#include <unistd.h>
Go to the source code of this file.
Macros | |
#define | COMMENT_COMMANDS 3 |
Functions | |
int32_t | SDDS_PrintTypedValue (void *data, int64_t index, int32_t type, char *format, FILE *fp, uint32_t mode) |
Prints a data value of a specified type using an optional printf format string. | |
int32_t | SDDS_SprintTypedValue (void *data, int64_t index, int32_t type, const char *format, char *buffer, uint32_t mode) |
Formats a data value of a specified type into a string buffer using an optional printf format string. | |
int32_t | SDDS_SprintTypedValueFactor (void *data, int64_t index, int32_t type, const char *format, char *buffer, uint32_t mode, double factor) |
Reallocates memory to a new size and zero-initializes the additional space. | |
void | SDDS_RegisterProgramName (const char *name) |
Registers the executable program name for use in error messages. | |
int32_t | SDDS_NumberOfErrors () |
Retrieves the number of errors recorded by SDDS library routines. | |
void | SDDS_ClearErrors () |
Clears all recorded error messages from the SDDS error stack. | |
void | SDDS_Bomb (char *message) |
Terminates the program after printing an error message and recorded errors. | |
void | SDDS_Warning (char *message) |
Prints a warning message to stderr . | |
void | SDDS_SetError (char *error_text) |
Records an error message in the SDDS error stack. | |
void | SDDS_SetError0 (char *error_text) |
Internal function to record an error message in the SDDS error stack. | |
void | SDDS_PrintErrors (FILE *fp, int32_t mode) |
Prints recorded error messages to a specified file stream. | |
char ** | SDDS_GetErrorMessages (int32_t *number, int32_t mode) |
Retrieves recorded error messages from the SDDS error stack. | |
uint32_t | SDDS_SetAutoCheckMode (uint32_t newMode) |
Sets the automatic check mode for SDDS dataset validation. | |
int32_t | SDDS_CheckDataset (SDDS_DATASET *SDDS_dataset, const char *caller) |
Validates the SDDS dataset pointer. | |
int32_t | SDDS_CheckTabularData (SDDS_DATASET *SDDS_dataset, const char *caller) |
Validates the consistency of tabular data within an SDDS dataset. | |
void * | SDDS_Calloc (size_t nelem, size_t elem_size) |
Allocates zero-initialized memory for an array of elements. | |
void * | SDDS_Malloc (size_t size) |
Allocates memory of a specified size. | |
void | SDDS_Free (void *mem) |
Free memory previously allocated by SDDS_Malloc. | |
void * | SDDS_Realloc (void *old_ptr, size_t new_size) |
Reallocates memory to a new size. | |
void * | SDDS_Recalloc (void *old_ptr, size_t old_size, size_t new_size) |
Reallocates memory to a new size and zero-initializes the additional space. | |
int32_t | SDDS_VerifyPrintfFormat (const char *string, int32_t type) |
Verifies that a printf format string is compatible with a specified data type. | |
int32_t | SDDS_CopyString (char **target, const char *source) |
Copies a source string to a target string with memory allocation. | |
ASSOCIATE_DEFINITION * | SDDS_GetAssociateDefinition (SDDS_DATASET *SDDS_dataset, char *name) |
Retrieves the definition of a specified associate from the SDDS dataset. | |
ASSOCIATE_DEFINITION * | SDDS_CopyAssociateDefinition (ASSOCIATE_DEFINITION **target, ASSOCIATE_DEFINITION *source) |
Creates a copy of an associate definition. | |
int32_t | SDDS_FreeAssociateDefinition (ASSOCIATE_DEFINITION *source) |
Frees memory allocated for an associate definition. | |
COLUMN_DEFINITION * | SDDS_GetColumnDefinition (SDDS_DATASET *SDDS_dataset, char *name) |
Retrieves the definition of a specified column from the SDDS dataset. | |
COLUMN_DEFINITION * | SDDS_CopyColumnDefinition (COLUMN_DEFINITION **target, COLUMN_DEFINITION *source) |
Creates a copy of a column definition. | |
int32_t | SDDS_FreeColumnDefinition (COLUMN_DEFINITION *source) |
Frees memory allocated for a column definition. | |
PARAMETER_DEFINITION * | SDDS_GetParameterDefinition (SDDS_DATASET *SDDS_dataset, char *name) |
Retrieves the definition of a specified parameter from the SDDS dataset. | |
PARAMETER_DEFINITION * | SDDS_CopyParameterDefinition (PARAMETER_DEFINITION **target, PARAMETER_DEFINITION *source) |
Creates a copy of a parameter definition. | |
int32_t | SDDS_FreeParameterDefinition (PARAMETER_DEFINITION *source) |
Frees memory allocated for a parameter definition. | |
ARRAY_DEFINITION * | SDDS_GetArrayDefinition (SDDS_DATASET *SDDS_dataset, char *name) |
Retrieves the definition of a specified array from the SDDS dataset. | |
ARRAY_DEFINITION * | SDDS_CopyArrayDefinition (ARRAY_DEFINITION **target, ARRAY_DEFINITION *source) |
Creates a copy of an array definition. | |
int32_t | SDDS_FreeArrayDefinition (ARRAY_DEFINITION *source) |
Frees memory allocated for an array definition. | |
int | SDDS_CompareIndexedNames (const void *s1, const void *s2) |
Compares two SORTED_INDEX structures by their name fields. | |
int | SDDS_CompareIndexedNamesPtr (const void *s1, const void *s2) |
Compares two pointers to SORTED_INDEX structures by their name fields. | |
int32_t | SDDS_GetColumnIndex (SDDS_DATASET *SDDS_dataset, char *name) |
Retrieves the index of a named column in the SDDS dataset. | |
int32_t | SDDS_GetParameterIndex (SDDS_DATASET *SDDS_dataset, char *name) |
Retrieves the index of a named parameter in the SDDS dataset. | |
int32_t | SDDS_GetArrayIndex (SDDS_DATASET *SDDS_dataset, char *name) |
Retrieves the index of a named array in the SDDS dataset. | |
int32_t | SDDS_GetAssociateIndex (SDDS_DATASET *SDDS_dataset, char *name) |
Retrieves the index of a named associate in the SDDS dataset. | |
int32_t | SDDS_HasWhitespace (char *string) |
Checks if a string contains any whitespace characters. | |
char * | fgetsSkipComments (SDDS_DATASET *SDDS_dataset, char *s, int32_t slen, FILE *fp, char skip_char) |
Reads a line from a file while skipping comment lines. | |
char * | fgetsSkipCommentsResize (SDDS_DATASET *SDDS_dataset, char **s, int32_t *slen, FILE *fp, char skip_char) |
Reads a line from a file with dynamic buffer resizing while skipping comment lines. | |
char * | fgetsLZMASkipComments (SDDS_DATASET *SDDS_dataset, char *s, int32_t slen, struct lzmafile *lzmafp, char skip_char) |
Reads a line from a LZMA-compressed file while skipping comment lines. | |
char * | fgetsLZMASkipCommentsResize (SDDS_DATASET *SDDS_dataset, char **s, int32_t *slen, struct lzmafile *lzmafp, char skip_char) |
Reads a line from a LZMA-compressed file with dynamic buffer resizing while skipping comment lines. | |
void | SDDS_CutOutComments (SDDS_DATASET *SDDS_dataset, char *s, char cc) |
Removes comments from a string based on a specified comment character. | |
int32_t | SDDS_GetToken (char *s, char *buffer, int32_t buflen) |
Extracts the next token from a string, handling quoted substrings and escape characters. | |
int32_t | SDDS_GetToken2 (char *s, char **st, int32_t *strlength, char *buffer, int32_t buflen) |
Extracts the next token from a string, handling quoted substrings and escape characters, with updated string pointers. | |
int32_t | SDDS_PadToLength (char *string, int32_t length) |
Pads a string with spaces to reach a specified length. | |
void | SDDS_EscapeQuotes (char *s, char quote_char) |
Escapes quote characters within a string by inserting backslashes. | |
void | SDDS_UnescapeQuotes (char *s, char quote_char) |
Removes escape characters from quote characters within a string. | |
void | SDDS_EscapeCommentCharacters (char *string, char cc) |
Escapes comment characters within a string by inserting backslashes. | |
int32_t | SDDS_ZeroMemory (void *mem, int64_t n_bytes) |
Sets a block of memory to zero. | |
int32_t | SDDS_SetMemory (void *mem, int64_t n_elements, int32_t data_type,...) |
Initializes a memory block with a sequence of values based on a specified data type. | |
int32_t | SDDS_GetColumnType (SDDS_DATASET *SDDS_dataset, int32_t index) |
Retrieves the data type of a column in the SDDS dataset by its index. | |
int32_t | SDDS_GetNamedColumnType (SDDS_DATASET *SDDS_dataset, char *name) |
Retrieves the data type of a column in the SDDS dataset by its name. | |
int32_t | SDDS_GetArrayType (SDDS_DATASET *SDDS_dataset, int32_t index) |
Retrieves the data type of an array in the SDDS dataset by its index. | |
int32_t | SDDS_GetNamedArrayType (SDDS_DATASET *SDDS_dataset, char *name) |
Retrieves the data type of an array in the SDDS dataset by its name. | |
int32_t | SDDS_GetParameterType (SDDS_DATASET *SDDS_dataset, int32_t index) |
Retrieves the data type of a parameter in the SDDS dataset by its index. | |
int32_t | SDDS_GetNamedParameterType (SDDS_DATASET *SDDS_dataset, char *name) |
Retrieves the data type of a parameter in the SDDS dataset by its name. | |
int32_t | SDDS_GetTypeSize (int32_t type) |
Retrieves the size in bytes of a specified SDDS data type. | |
char * | SDDS_GetTypeName (int32_t type) |
Retrieves the name of a specified SDDS data type as a string. | |
int32_t | SDDS_IdentifyType (char *typeName) |
Identifies the SDDS data type based on its string name. | |
void | SDDS_RemovePadding (char *s) |
Removes leading and trailing whitespace from a string. | |
int32_t | SDDS_StringIsBlank (char *s) |
Checks if a string is blank (contains only whitespace characters). | |
int32_t | SDDS_ColumnIsOfInterest (SDDS_DATASET *SDDS_dataset, char *name) |
Determines if a specified column is marked as of interest in the dataset. | |
char ** | SDDS_GetColumnNames (SDDS_DATASET *SDDS_dataset, int32_t *number) |
Retrieves the names of all columns in the SDDS dataset. | |
char ** | SDDS_GetParameterNames (SDDS_DATASET *SDDS_dataset, int32_t *number) |
Retrieves the names of all parameters in the SDDS dataset. | |
char ** | SDDS_GetArrayNames (SDDS_DATASET *SDDS_dataset, int32_t *number) |
Retrieves the names of all arrays in the SDDS dataset. | |
char ** | SDDS_GetAssociateNames (SDDS_DATASET *SDDS_dataset, int32_t *number) |
Retrieves the names of all associates in the SDDS dataset. | |
void * | SDDS_CastValue (void *data, int64_t index, int32_t data_type, int32_t desired_type, void *memory) |
Casts a value from one SDDS data type to another. | |
void * | SDDS_AllocateMatrix (int32_t size, int64_t dim1, int64_t dim2) |
Allocates a two-dimensional matrix with zero-initialized elements. | |
void | SDDS_FreeArray (SDDS_ARRAY *array) |
Frees memory allocated for an SDDS array structure. | |
void | SDDS_FreeMatrix (void **ptr, int64_t dim1) |
Frees memory allocated for a two-dimensional matrix. | |
int32_t | SDDS_CopyStringArray (char **target, char **source, int64_t n_strings) |
Copies an array of strings from source to target. | |
int32_t | SDDS_FreeStringArray (char **string, int64_t strings) |
Frees an array of strings by deallocating each individual string. | |
void * | SDDS_MakePointerArrayRecursively (void *data, int32_t size, int32_t dimensions, int32_t *dimension) |
Recursively creates a multi-dimensional pointer array from a contiguous data block. | |
void * | SDDS_MakePointerArray (void *data, int32_t type, int32_t dimensions, int32_t *dimension) |
Creates a multi-dimensional pointer array from a contiguous data block. | |
void | SDDS_FreePointerArray (void **data, int32_t dimensions, int32_t *dimension) |
Frees a multi-dimensional pointer array created by SDDS_MakePointerArray. | |
int32_t | SDDS_ApplyFactorToParameter (SDDS_DATASET *SDDS_dataset, char *name, double factor) |
Applies a scaling factor to a specific parameter in the SDDS dataset. | |
int32_t | SDDS_ApplyFactorToColumn (SDDS_DATASET *SDDS_dataset, char *name, double factor) |
Applies a scaling factor to all elements of a specific column in the SDDS dataset. | |
void | SDDS_EscapeNewlines (char *s) |
Escapes newline characters in a string by replacing them with "\\n". | |
int32_t | SDDS_ForceInactive (SDDS_DATASET *SDDS_dataset) |
Marks an SDDS dataset as inactive. | |
int32_t | SDDS_IsActive (SDDS_DATASET *SDDS_dataset) |
Checks whether an SDDS dataset is currently active. | |
int32_t | SDDS_FileIsLocked (const char *filename) |
Determines if a specified file is locked. | |
int32_t | SDDS_LockFile (FILE *fp, const char *filename, const char *caller) |
Attempts to lock a specified file. | |
int32_t | SDDS_BreakIntoLockedFile (char *filename) |
Attempts to override a locked file by creating a temporary copy. | |
int32_t | SDDS_MatchColumns (SDDS_DATASET *SDDS_dataset, char ***nameReturn, int32_t matchMode, int32_t typeMode,...) |
Matches and retrieves column names from an SDDS dataset based on specified criteria. | |
int32_t | SDDS_MatchParameters (SDDS_DATASET *SDDS_dataset, char ***nameReturn, int32_t matchMode, int32_t typeMode,...) |
Matches and retrieves parameter names from an SDDS dataset based on specified criteria. | |
int32_t | SDDS_MatchArrays (SDDS_DATASET *SDDS_dataset, char ***nameReturn, int32_t matchMode, int32_t typeMode,...) |
Matches and retrieves array names from an SDDS dataset based on specified criteria. | |
char * | SDDS_FindColumn (SDDS_DATASET *SDDS_dataset, int32_t mode,...) |
Finds the first column in the SDDS dataset that matches the specified criteria. | |
char * | SDDS_FindParameter (SDDS_DATASET *SDDS_dataset, int32_t mode,...) |
Finds the first parameter in the SDDS dataset that matches the specified criteria. | |
char * | SDDS_FindArray (SDDS_DATASET *SDDS_dataset, int32_t mode,...) |
Finds the first array in the SDDS dataset that matches the specified criteria. | |
int32_t | SDDS_CheckColumn (SDDS_DATASET *SDDS_dataset, char *name, char *units, int32_t type, FILE *fp_message) |
Checks if a column exists in the SDDS dataset with the specified name, units, and type. | |
int32_t | SDDS_CheckParameter (SDDS_DATASET *SDDS_dataset, char *name, char *units, int32_t type, FILE *fp_message) |
Checks if a parameter exists in the SDDS dataset with the specified name, units, and type. | |
int32_t | SDDS_CheckArray (SDDS_DATASET *SDDS_dataset, char *name, char *units, int32_t type, FILE *fp_message) |
Checks if an array exists in the SDDS dataset with the specified name, units, and type. | |
int32_t | SDDS_PrintCheckText (FILE *fp, char *name, char *units, int32_t type, char *class_name, int32_t error_code) |
Prints detailed error messages related to SDDS entity checks. | |
int32_t | SDDS_DeleteParameterFixedValues (SDDS_DATASET *SDDS_dataset) |
Deletes fixed values from all parameters in the SDDS dataset. | |
int32_t | SDDS_SetDataMode (SDDS_DATASET *SDDS_dataset, int32_t newmode) |
Sets the data mode (ASCII or Binary) for the SDDS dataset. | |
int32_t | SDDS_CheckDatasetStructureSize (int32_t size) |
Verifies that the size of the SDDS_DATASET structure matches the expected size. | |
int32_t | SDDS_ColumnCount (SDDS_DATASET *page) |
Retrieves the number of columns in the SDDS dataset. | |
int32_t | SDDS_ParameterCount (SDDS_DATASET *page) |
Retrieves the number of parameters in the SDDS dataset. | |
int32_t | SDDS_ArrayCount (SDDS_DATASET *page) |
Retrieves the number of arrays in the SDDS dataset. | |
void | SDDS_InterpretEscapes (char *s) |
Interprets and converts escape sequences in a string. | |
uint32_t | SDDS_GetSpecialCommentsModes (SDDS_DATASET *SDDS_dataset) |
Retrieves the current special comments modes set in the SDDS dataset. | |
void | SDDS_ResetSpecialCommentsModes (SDDS_DATASET *SDDS_dataset) |
Resets the special comments modes in the SDDS dataset. | |
void | SDDS_ParseSpecialComments (SDDS_DATASET *SDDS_dataset, char *s) |
Parses and processes special comment commands within the SDDS dataset. | |
int32_t | SDDS_IsBigEndianMachine () |
Determines whether the current machine uses big-endian byte ordering. | |
int32_t | SDDS_VerifyArrayExists (SDDS_DATASET *SDDS_dataset, int32_t mode,...) |
Verifies the existence of an array in the SDDS dataset based on specified criteria. | |
int32_t | SDDS_VerifyColumnExists (SDDS_DATASET *SDDS_dataset, int32_t mode,...) |
Verifies the existence of a column in the SDDS dataset based on specified criteria. | |
int32_t | SDDS_VerifyParameterExists (SDDS_DATASET *SDDS_dataset, int32_t mode,...) |
Verifies the existence of a parameter in the SDDS dataset based on specified criteria. | |
char ** | getMatchingSDDSNames (SDDS_DATASET *dataset, char **matchName, int32_t matches, int32_t *names, short type) |
Retrieves an array of matching SDDS entity names based on specified criteria. | |
SDDS_DATASET * | SDDS_CreateEmptyDataset (void) |
Creates an empty SDDS dataset. | |
Variables | |
static int32_t | n_errors = 0 |
static int32_t | n_errors_max = 0 |
static char ** | error_description = NULL |
static char * | registeredProgramName = NULL |
static uint32_t | AutoCheckMode = 0x0000UL |
static char * | commentCommandName [COMMENT_COMMANDS] |
static uint32_t | commentCommandFlag [COMMENT_COMMANDS] |
This file provides miscellaneous functions for interacting with SDDS objects.
This file provides miscellaneous functions for interacting with SDDS objects.
Definition in file SDDS_utils.c.
#define COMMENT_COMMANDS 3 |
Definition at line 5168 of file SDDS_utils.c.
char * fgetsLZMASkipComments | ( | SDDS_DATASET * | SDDS_dataset, |
char * | s, | ||
int32_t | slen, | ||
struct lzmafile * | lzmafp, | ||
char | skip_char ) |
Reads a line from a LZMA-compressed file while skipping comment lines.
This function reads lines from the specified LZMA-compressed file stream, ignoring lines that begin with the specified skip_char
. It also processes special comment lines that start with !#
by parsing them using SDDS_ParseSpecialComments
.
[in] | SDDS_dataset | Pointer to the SDDS_DATASET structure, used for processing comments. |
[out] | s | Pointer to a character array where the read line will be stored. |
[in] | slen | The maximum number of characters to read into s . |
[in] | lzmafp | Pointer to the lzmafile structure representing the LZMA-compressed file stream. |
[in] | skip_char | Character indicating the start of a comment line. Lines beginning with this character will be skipped. |
s
containing the read line. If the end of the file is reached or an error occurs, returns NULL
.s
by removing comments as determined by SDDS_CutOutComments
.Definition at line 1528 of file SDDS_utils.c.
char * fgetsLZMASkipCommentsResize | ( | SDDS_DATASET * | SDDS_dataset, |
char ** | s, | ||
int32_t * | slen, | ||
struct lzmafile * | lzmafp, | ||
char | skip_char ) |
Reads a line from a LZMA-compressed file with dynamic buffer resizing while skipping comment lines.
This function reads lines from the specified LZMA-compressed file stream, ignoring lines that begin with the specified skip_char
. If a line exceeds the current buffer size, the buffer is dynamically resized to accommodate the entire line. It also processes special comment lines that start with !#
by parsing them using SDDS_ParseSpecialComments
.
[in] | SDDS_dataset | Pointer to the SDDS_DATASET structure, used for processing comments. |
[in,out] | s | Pointer to a pointer to a character array where the read line will be stored. This buffer may be resized if necessary. |
[in,out] | slen | Pointer to an int32_t variable specifying the current size of the buffer *s . This value may be updated if the buffer is resized. |
[in] | lzmafp | Pointer to the lzmafile structure representing the LZMA-compressed file stream. |
[in] | skip_char | Character indicating the start of a comment line. Lines beginning with this character will be skipped. |
*s
containing the read line. If the end of the file is reached or an error occurs, returns NULL
.*s
, including freeing it when no longer needed.Definition at line 1560 of file SDDS_utils.c.
char * fgetsSkipComments | ( | SDDS_DATASET * | SDDS_dataset, |
char * | s, | ||
int32_t | slen, | ||
FILE * | fp, | ||
char | skip_char ) |
Reads a line from a file while skipping comment lines.
This function reads lines from the specified file stream, ignoring lines that begin with the specified skip_char
. It also processes special comment lines that start with !#
by parsing them using SDDS_ParseSpecialComments
.
[in] | SDDS_dataset | Pointer to the SDDS_DATASET structure, used for processing comments. |
[out] | s | Pointer to a character array where the read line will be stored. |
[in] | slen | The maximum number of characters to read into s . |
[in] | fp | Pointer to the FILE stream to read from. |
[in] | skip_char | Character indicating the start of a comment line. Lines beginning with this character will be skipped. |
s
containing the read line. If the end of the file is reached or an error occurs, returns NULL
.s
by removing comments as determined by SDDS_CutOutComments
.Definition at line 1451 of file SDDS_utils.c.
char * fgetsSkipCommentsResize | ( | SDDS_DATASET * | SDDS_dataset, |
char ** | s, | ||
int32_t * | slen, | ||
FILE * | fp, | ||
char | skip_char ) |
Reads a line from a file with dynamic buffer resizing while skipping comment lines.
This function reads lines from the specified file stream, ignoring lines that begin with the specified skip_char
. If a line exceeds the current buffer size, the buffer is dynamically resized to accommodate the entire line. It also processes special comment lines that start with !#
by parsing them using SDDS_ParseSpecialComments
.
[in] | SDDS_dataset | Pointer to the SDDS_DATASET structure, used for processing comments. |
[in,out] | s | Pointer to a pointer to a character array where the read line will be stored. This buffer may be resized if necessary. |
[in,out] | slen | Pointer to an int32_t variable specifying the current size of the buffer s . This value may be updated if the buffer is resized. |
[in] | fp | Pointer to the FILE stream to read from. |
[in] | skip_char | Character indicating the start of a comment line. Lines beginning with this character will be skipped. |
*s
containing the read line. If the end of the file is reached or an error occurs, returns NULL
.*s
, including freeing it when no longer needed.Definition at line 1482 of file SDDS_utils.c.
char ** getMatchingSDDSNames | ( | SDDS_DATASET * | dataset, |
char ** | matchName, | ||
int32_t | matches, | ||
int32_t * | names, | ||
short | type ) |
Retrieves an array of matching SDDS entity names based on specified criteria.
This function processes a list of SDDS entity names (columns, parameters, or arrays) and selects those that match the provided criteria. It supports wildcard matching and exact matching based on the presence of wildcards in the names.
[in] | dataset | Pointer to the SDDS_DATASET structure representing the dataset to be searched. |
[in] | matchName | Array of strings containing the names or patterns to match against the dataset's entities. |
[in] | matches | The number of names/patterns provided in matchName . |
[out] | names | Pointer to an int32_t that will be set to the number of matched names. |
[in] | type | Specifies the type of SDDS entity to match. Valid values are:
|
char **
) containing the names of the matched SDDS entities.NULL
.wild_match
for pattern matching when wildcards are present in the matchName
entries.type
parameter is correctly specified to match the intended SDDS entity class.type
value will cause the function to terminate the program with an error message.Definition at line 5556 of file SDDS_utils.c.
void * SDDS_AllocateMatrix | ( | int32_t | size, |
int64_t | dim1, | ||
int64_t | dim2 ) |
Allocates a two-dimensional matrix with zero-initialized elements.
This function allocates memory for a two-dimensional matrix based on the specified dimensions and element size. Each row of the matrix is individually allocated and initialized to zero.
[in] | size | The size in bytes of each element in the matrix. |
[in] | dim1 | The number of rows in the matrix. |
[in] | dim2 | The number of columns in the matrix. |
NULL
if memory allocation fails.calloc
to ensure that all elements are zero-initialized.SDDS_FreeMatrix
.Definition at line 2739 of file SDDS_utils.c.
int32_t SDDS_ApplyFactorToColumn | ( | SDDS_DATASET * | SDDS_dataset, |
char * | name, | ||
double | factor ) |
Applies a scaling factor to all elements of a specific column in the SDDS dataset.
This function multiplies each value in the specified column by the given factor
. It first retrieves the column's index and verifies that it is of a numeric type. The scaling operation is performed in-place on each element of the column's data array.
[in] | SDDS_dataset | Pointer to the SDDS_DATASET structure representing the dataset. |
[in] | name | A NULL-terminated string specifying the name of the column to scale. |
[in] | factor | The scaling factor to apply to each element of the column. |
1
on successful application of the factor to all elements.0
if the column is not found, is non-numeric, or if the dataset lacks the necessary data array.Definition at line 3123 of file SDDS_utils.c.
int32_t SDDS_ApplyFactorToParameter | ( | SDDS_DATASET * | SDDS_dataset, |
char * | name, | ||
double | factor ) |
Applies a scaling factor to a specific parameter in the SDDS dataset.
This function multiplies the value of a specified parameter by the given factor
. It first retrieves the parameter's index and verifies that it is of a numeric type. The scaling operation is performed in-place on the parameter's data.
[in] | SDDS_dataset | Pointer to the SDDS_DATASET structure representing the dataset. |
[in] | name | A NULL-terminated string specifying the name of the parameter to scale. |
[in] | factor | The scaling factor to apply to the parameter's value. |
1
on successful application of the factor.0
if the parameter is not found, is non-numeric, or if the dataset lacks the necessary data array.Definition at line 3046 of file SDDS_utils.c.
int32_t SDDS_ArrayCount | ( | SDDS_DATASET * | page | ) |
Retrieves the number of arrays in the SDDS dataset.
This function returns the total count of arrays defined in the layout of the provided SDDS dataset.
[in] | page | Pointer to the SDDS_DATASET structure representing the dataset. |
int32_t
) in the dataset.0
if the provided dataset pointer is NULL
.Definition at line 5053 of file SDDS_utils.c.
void SDDS_Bomb | ( | char * | message | ) |
Terminates the program after printing an error message and recorded errors.
This function prints a termination message to stderr
, invokes SDDS_PrintErrors
to display all recorded errors, and then exits the program with a non-zero status.
[in] | message | The termination message to be printed. If NULL , a default message "?" is used. |
Definition at line 342 of file SDDS_utils.c.
int32_t SDDS_BreakIntoLockedFile | ( | char * | filename | ) |
Attempts to override a locked file by creating a temporary copy.
This function tries to break into a locked file by creating a temporary backup and replacing the original file with this backup. The process involves:
.blXXX
suffix, where XXX
ranges from 1000
to 1019
.On Windows systems (_WIN32
defined), the function currently does not support breaking into locked files and will output an error message.
[in] | filename | The path to the locked file that needs to be overridden. |
0
on successful override of the locked file.1
if the operation fails or is not supported on the current platform.cp
and mv
system commands on Unix-like systems.Definition at line 3372 of file SDDS_utils.c.
void * SDDS_Calloc | ( | size_t | nelem, |
size_t | elem_size ) |
Allocates zero-initialized memory for an array of elements.
This function is a wrapper around the standard calloc
function, used by SDDS routines to allocate memory. It ensures that even if the requested number of elements or element size is zero or negative, a minimum of 1 element with a size of 4 bytes is allocated.
[in] | nelem | Number of elements to allocate. |
[in] | elem_size | Size in bytes of each element. |
NULL
.nelem
or elem_size
is less than or equal to zero, the function allocates memory for one element of 4 bytes by default.Definition at line 617 of file SDDS_utils.c.
void * SDDS_CastValue | ( | void * | data, |
int64_t | index, | ||
int32_t | data_type, | ||
int32_t | desired_type, | ||
void * | memory ) |
Casts a value from one SDDS data type to another.
This function converts a value from its original SDDS data type (data_type
) to a desired SDDS data type (desired_type
). It retrieves the value at the specified index
from the data
array and stores the converted value in the provided memory
location.
[in] | data | Pointer to the data array containing the original values. |
[in] | index | The zero-based index of the value to be casted within the data array. |
[in] | data_type | The original SDDS data type of the value. Must be one of the SDDS type constants:
|
[in] | desired_type | The desired SDDS data type to which the value should be casted. Must be one of the SDDS type constants listed above. |
[out] | memory | Pointer to the memory location where the casted value will be stored. |
memory
location containing the casted value on success.NULL
if the casting fails due to invalid data types or other errors.SDDS_STRING
types.memory
location has sufficient space to store the casted value.Definition at line 2628 of file SDDS_utils.c.
int32_t SDDS_CheckArray | ( | SDDS_DATASET * | SDDS_dataset, |
char * | name, | ||
char * | units, | ||
int32_t | type, | ||
FILE * | fp_message ) |
Checks if an array exists in the SDDS dataset with the specified name, units, and type.
This function verifies whether an array with the given name exists within the provided SDDS dataset. Additionally, it can check if the array's units and type match the specified criteria.
[in] | SDDS_dataset | Pointer to the SDDS_DATASET structure representing the dataset to be checked. |
[in] | name | The name of the array to check. |
[in] | units | The units of the array. This parameter may be NULL if units are not to be validated. |
[in] | type | Specifies the expected type of the array. Valid values are:
|
[in] | fp_message | File pointer where error messages will be sent. Typically, this is stderr . |
SDDS_CHECK_OKAY
if the array exists and matches the specified criteria.SDDS_CHECK_NONEXISTENT
if the array does not exist.SDDS_CHECK_WRONGTYPE
if the array exists but does not match the specified type.SDDS_CHECK_WRONGUNITS
if the array exists but does not match the specified units.units
is NULL
, the function does not perform units validation.SDDS_GetArrayInformation
and SDDS_GetArrayType
.SDDS_SetError
if it encounters issues accessing array information.Definition at line 4742 of file SDDS_utils.c.
int32_t SDDS_CheckColumn | ( | SDDS_DATASET * | SDDS_dataset, |
char * | name, | ||
char * | units, | ||
int32_t | type, | ||
FILE * | fp_message ) |
Checks if a column exists in the SDDS dataset with the specified name, units, and type.
This function verifies whether a column with the given name exists in the SDDS dataset and optionally checks if its units and type match the specified criteria.
[in] | SDDS_dataset | Pointer to the SDDS_DATASET structure representing the dataset to be checked. |
[in] | name | The name of the column to check. |
[in] | units | The units of the column. May be NULL if units are not to be checked. |
[in] | type | Specifies the expected type of the column. Valid values are:
|
[in] | fp_message | File pointer where error messages will be sent. Typically, this is stderr . |
SDDS_CHECK_OKAY
if the column exists and matches the specified criteria.SDDS_CHECK_NONEXISTENT
if the column does not exist.SDDS_CHECK_WRONGTYPE
if the column exists but does not match the specified type.SDDS_CHECK_WRONGUNITS
if the column exists but does not match the specified units.units
is NULL
, the function does not check for units.SDDS_GetColumnInformation
and SDDS_GetColumnType
.SDDS_SetError
if it encounters issues accessing column information.Definition at line 4562 of file SDDS_utils.c.
int32_t SDDS_CheckDataset | ( | SDDS_DATASET * | SDDS_dataset, |
const char * | caller ) |
Validates the SDDS dataset pointer.
This function checks whether the provided SDDS_DATASET
pointer is valid (non-NULL). If the check fails, it records an appropriate error message.
[in] | SDDS_dataset | Pointer to the SDDS_DATASET structure to be validated. |
[in] | caller | Name of the calling function, used for error reporting. |
1
if the dataset pointer is valid; otherwise, returns 0
and records an error message.Definition at line 552 of file SDDS_utils.c.
int32_t SDDS_CheckDatasetStructureSize | ( | int32_t | size | ) |
Verifies that the size of the SDDS_DATASET structure matches the expected size.
This function ensures that the size of the SDDS_DATASET
structure used by the program matches the size expected by the SDDS library. This check is crucial to prevent issues related to structure size mismatches, which can occur due to differences in compiler settings or library versions.
[in] | size | The size of the SDDS_DATASET structure as determined by the calling program (typically using sizeof(SDDS_DATASET) ). |
1
if the provided size matches the expected size of the SDDS_DATASET
structure.0
if there is a size mismatch, indicating potential incompatibility issues.Definition at line 4979 of file SDDS_utils.c.
int32_t SDDS_CheckParameter | ( | SDDS_DATASET * | SDDS_dataset, |
char * | name, | ||
char * | units, | ||
int32_t | type, | ||
FILE * | fp_message ) |
Checks if a parameter exists in the SDDS dataset with the specified name, units, and type.
This function verifies whether a parameter with the given name exists in the SDDS dataset and optionally checks if its units and type match the specified criteria.
[in] | SDDS_dataset | Pointer to the SDDS_DATASET structure representing the dataset to be checked. |
[in] | name | The name of the parameter to check. |
[in] | units | The units of the parameter. May be NULL if units are not to be checked. |
[in] | type | Specifies the expected type of the parameter. Valid values are:
|
[in] | fp_message | File pointer where error messages will be sent. Typically, this is stderr . |
SDDS_CHECK_OKAY
if the parameter exists and matches the specified criteria.SDDS_CHECK_NONEXISTENT
if the parameter does not exist.SDDS_CHECK_WRONGTYPE
if the parameter exists but does not match the specified type.SDDS_CHECK_WRONGUNITS
if the parameter exists but does not match the specified units.units
is NULL
, the function does not check for units.SDDS_GetParameterInformation
and SDDS_GetParameterType
.SDDS_SetError
if it encounters issues accessing parameter information.Definition at line 4653 of file SDDS_utils.c.
int32_t SDDS_CheckTabularData | ( | SDDS_DATASET * | SDDS_dataset, |
const char * | caller ) |
Validates the consistency of tabular data within an SDDS dataset.
This function checks the integrity of tabular data in the given SDDS_DATASET
. It verifies that if columns are defined, corresponding row flags and data arrays exist, and that the number of rows matches the column definitions.
[in] | SDDS_dataset | Pointer to the SDDS_DATASET structure to be validated. |
[in] | caller | Name of the calling function, used for error reporting. |
1
if the tabular data is consistent and valid; otherwise, returns 0
and records an error message.AutoCheckMode
includes TABULAR_DATA_CHECKS
.Definition at line 577 of file SDDS_utils.c.
void SDDS_ClearErrors | ( | void | ) |
Clears all recorded error messages from the SDDS error stack.
This function removes all error messages that have been recorded by SDDS library routines, resetting the error count to zero. It should be called after handling or logging the errors to prepare for future error recording.
SDDS_NumberOfErrors
will return zero until new errors are recorded.Definition at line 318 of file SDDS_utils.c.
int32_t SDDS_ColumnCount | ( | SDDS_DATASET * | page | ) |
Retrieves the number of columns in the SDDS dataset.
This function returns the total count of columns defined in the layout of the provided SDDS dataset.
[in] | page | Pointer to the SDDS_DATASET structure representing the dataset. |
int32_t
) in the dataset.0
if the provided dataset pointer is NULL
.Definition at line 5007 of file SDDS_utils.c.
int32_t SDDS_ColumnIsOfInterest | ( | SDDS_DATASET * | SDDS_dataset, |
char * | name ) |
Determines if a specified column is marked as of interest in the dataset.
This function checks whether the column with the given name
is flagged as of interest within the provided SDDS_dataset
. It verifies the dataset's validity and then iterates through the columns to find a match based on the column_flag
array.
[in] | SDDS_dataset | Pointer to the SDDS_DATASET structure representing the dataset. |
[in] | name | A NULL-terminated string specifying the name of the column to check. |
1
if the column is marked as of interest.0
if the column is not marked as of interest or if column_flag
is not set.-1
if the dataset is invalid.Definition at line 2428 of file SDDS_utils.c.
int SDDS_CompareIndexedNames | ( | const void * | s1, |
const void * | s2 ) |
Compares two SORTED_INDEX
structures by their name fields.
This function is used as a comparison callback for sorting functions like qsort
. It compares the name
fields of two SORTED_INDEX
structures lexicographically.
[in] | s1 | Pointer to the first SORTED_INDEX structure. |
[in] | s2 | Pointer to the second SORTED_INDEX structure. |
name
of s1
is found, respectively, to be less than, to match, or be greater than the name
of s2
.Definition at line 1272 of file SDDS_utils.c.
int SDDS_CompareIndexedNamesPtr | ( | const void * | s1, |
const void * | s2 ) |
Compares two pointers to SORTED_INDEX
structures by their name fields.
This function is used as a comparison callback for sorting functions like qsort
. It compares the name
fields of two SORTED_INDEX
structure pointers lexicographically.
[in] | s1 | Pointer to the first SORTED_INDEX* structure. |
[in] | s2 | Pointer to the second SORTED_INDEX* structure. |
name
of *s1
is found, respectively, to be less than, to match, or be greater than the name
of *s2
.Definition at line 1292 of file SDDS_utils.c.
ARRAY_DEFINITION * SDDS_CopyArrayDefinition | ( | ARRAY_DEFINITION ** | target, |
ARRAY_DEFINITION * | source ) |
Creates a copy of an array definition.
This function allocates memory for a new ARRAY_DEFINITION
structure and copies the contents from the source array definition to the target. All string fields are duplicated to ensure independent memory management.
[out] | target | Pointer to a ARRAY_DEFINITION* where the copied definition will be stored. |
[in] | source | Pointer to the ARRAY_DEFINITION structure to be copied. If source is NULL , the target is set to NULL . |
ARRAY_DEFINITION
structure on success. Returns NULL
on failure (e.g., memory allocation failure).SDDS_FreeArrayDefinition
.Definition at line 1208 of file SDDS_utils.c.
ASSOCIATE_DEFINITION * SDDS_CopyAssociateDefinition | ( | ASSOCIATE_DEFINITION ** | target, |
ASSOCIATE_DEFINITION * | source ) |
Creates a copy of an associate definition.
This function allocates memory for a new ASSOCIATE_DEFINITION
structure and copies the contents from the source associate definition to the target. All string fields are duplicated to ensure independent memory management.
[out] | target | Pointer to a ASSOCIATE_DEFINITION* where the copied definition will be stored. |
[in] | source | Pointer to the ASSOCIATE_DEFINITION structure to be copied. If source is NULL , the target is set to NULL . |
ASSOCIATE_DEFINITION
structure on success. Returns NULL
on failure (e.g., memory allocation failure).SDDS_FreeAssociateDefinition
.Definition at line 920 of file SDDS_utils.c.
COLUMN_DEFINITION * SDDS_CopyColumnDefinition | ( | COLUMN_DEFINITION ** | target, |
COLUMN_DEFINITION * | source ) |
Creates a copy of a column definition.
This function allocates memory for a new COLUMN_DEFINITION
structure and copies the contents from the source column definition to the target. All string fields are duplicated to ensure independent memory management.
[out] | target | Pointer to a COLUMN_DEFINITION* where the copied definition will be stored. |
[in] | source | Pointer to the COLUMN_DEFINITION structure to be copied. If source is NULL , the target is set to NULL . |
COLUMN_DEFINITION
structure on success. Returns NULL
on failure (e.g., memory allocation failure).SDDS_FreeColumnDefinition
.Definition at line 1012 of file SDDS_utils.c.
PARAMETER_DEFINITION * SDDS_CopyParameterDefinition | ( | PARAMETER_DEFINITION ** | target, |
PARAMETER_DEFINITION * | source ) |
Creates a copy of a parameter definition.
This function allocates memory for a new PARAMETER_DEFINITION
structure and copies the contents from the source parameter definition to the target. All string fields are duplicated to ensure independent memory management.
[out] | target | Pointer to a PARAMETER_DEFINITION* where the copied definition will be stored. |
[in] | source | Pointer to the PARAMETER_DEFINITION structure to be copied. If source is NULL , the target is set to NULL . |
PARAMETER_DEFINITION
structure on success. Returns NULL
on failure (e.g., memory allocation failure).SDDS_FreeParameterDefinition
.Definition at line 1109 of file SDDS_utils.c.
int32_t SDDS_CopyString | ( | char ** | target, |
const char * | source ) |
Copies a source string to a target string with memory allocation.
This function allocates memory for the target string and copies the contents of the source string into it. If the source string is NULL
, the target string is set to NULL
.
[out] | target | Pointer to a char* variable where the copied string will be stored. Memory is allocated within this function and should be freed by the caller to avoid memory leaks. |
[in] | source | The source string to be copied. If NULL , the target is set to NULL . |
1
on successful copy and memory allocation. Returns 0
on error (e.g., memory allocation failure).Definition at line 856 of file SDDS_utils.c.
int32_t SDDS_CopyStringArray | ( | char ** | target, |
char ** | source, | ||
int64_t | n_strings ) |
Copies an array of strings from source to target.
This function duplicates each string from the source
array into the target
array. It handles memory allocation for each individual string using SDDS_CopyString
.
[in] | target | Pointer to the destination array of strings where the copied strings will be stored. |
[in] | source | Pointer to the source array of strings to be copied. |
[in] | n_strings | The number of strings to copy from the source to the target. |
1
on successful copying of all strings.0
if either source
or target
is NULL
, or if any string copy operation fails.target
array has sufficient space allocated.target
array.Definition at line 2837 of file SDDS_utils.c.
SDDS_DATASET * SDDS_CreateEmptyDataset | ( | void | ) |
Creates an empty SDDS dataset.
This function allocates and initializes an empty SDDS_DATASET
structure. The returned dataset can then be configured and populated with columns, parameters, and arrays as needed.
SDDS_DATASET
structure.NULL
if memory allocation fails.NULL
before using it.Definition at line 5628 of file SDDS_utils.c.
void SDDS_CutOutComments | ( | SDDS_DATASET * | SDDS_dataset, |
char * | s, | ||
char | cc ) |
Removes comments from a string based on a specified comment character.
This function processes a string s
, removing any content that follows the comment character cc
. It also handles special comment lines that start with !#
by parsing them using SDDS_ParseSpecialComments
. The function ensures that quoted sections within the string are preserved and not mistakenly identified as comments.
[in] | SDDS_dataset | Pointer to the SDDS_DATASET structure used for processing special comments. |
[in,out] | s | Pointer to the character array containing the string to process. The string will be modified in place. |
[in] | cc | The comment character indicating the start of a comment. |
Definition at line 1680 of file SDDS_utils.c.
int32_t SDDS_DeleteParameterFixedValues | ( | SDDS_DATASET * | SDDS_dataset | ) |
Deletes fixed values from all parameters in the SDDS dataset.
This function iterates through all parameters in the provided SDDS dataset and removes any fixed values associated with them. It ensures that both the current layout and the original layout of the dataset have their fixed values cleared.
[in] | SDDS_dataset | Pointer to the SDDS_DATASET structure representing the dataset from which fixed values will be deleted. |
1
on successful deletion of all fixed values.0
if the dataset check fails or if saving the layout fails.Definition at line 4883 of file SDDS_utils.c.
void SDDS_EscapeCommentCharacters | ( | char * | string, |
char | cc ) |
Escapes comment characters within a string by inserting backslashes.
This function scans the input string string
and inserts a backslash (\
) before each occurrence of the specified comment character cc
, provided it is not already escaped. This is useful for preparing strings to include comment characters without them being interpreted as actual comments.
[in,out] | string | Pointer to the string in which comment characters will be escaped. The string will be modified in place. |
[in] | cc | The comment character to escape (e.g., # ). |
string
is updated correctly. The caller must ensure that string
has sufficient space to accommodate the additional backslashes.Definition at line 1955 of file SDDS_utils.c.
void SDDS_EscapeNewlines | ( | char * | s | ) |
Escapes newline characters in a string by replacing them with "\\n".
This function modifies the input string s
in place by replacing each newline character (‘’
') with the two-character sequence
'\'and
'n'`. It shifts the subsequent characters in the string to accommodate the additional character introduced by the escape sequence.
[in,out] | s | Pointer to the null-terminated string to be modified. Important: The buffer pointed to by s must have sufficient space to accommodate the additional characters resulting from the escape sequences. Failure to ensure adequate space may lead to buffer overflows. |
Definition at line 3189 of file SDDS_utils.c.
void SDDS_EscapeQuotes | ( | char * | s, |
char | quote_char ) |
Escapes quote characters within a string by inserting backslashes.
This function scans the input string s
and inserts a backslash (\
) before each occurrence of the specified quote_char
, provided it is not already escaped. This is useful for preparing strings for formats that require escaped quotes.
[in,out] | s | Pointer to the string in which quotes will be escaped. The string will be modified in place. |
[in] | quote_char | The quote character to escape (e.g., " ). |
s
is updated correctly. The caller must ensure that s
has sufficient space to accommodate the additional backslashes.Definition at line 1901 of file SDDS_utils.c.
int32_t SDDS_FileIsLocked | ( | const char * | filename | ) |
Determines if a specified file is locked.
This function checks whether the given file is currently locked. If file locking is enabled through the F_TEST
and ALLOW_FILE_LOCKING
macros, it attempts to open the file and apply a test lock using lockf
. The function returns 1
if the file is locked and 0
otherwise.
If file locking is not enabled (i.e., the F_TEST
and ALLOW_FILE_LOCKING
macros are not defined), the function always returns 0
, indicating that the file is not locked.
[in] | filename | The path to the file to be checked for a lock. |
1
if the file is locked.0
if the file is not locked or if file locking is not enabled.F_TEST
and ALLOW_FILE_LOCKING
macros are appropriately defined to enable file locking functionality.Definition at line 3282 of file SDDS_utils.c.
char * SDDS_FindArray | ( | SDDS_DATASET * | SDDS_dataset, |
int32_t | mode, | ||
... ) |
Finds the first array in the SDDS dataset that matches the specified criteria.
This function searches through the arrays of the provided SDDS dataset and returns the name of the first array that matches the given criteria based on the specified mode.
The function supports the following modes:
int32_t type
, char *name1, char *name2, ..., NULL
char *name1, char *name2, ..., NULL
char *name1, char *name2, ..., NULL
char *name1, char *name2, ..., NULL
char *name1, char *name2, ..., NULL
[in] | SDDS_dataset | Pointer to the SDDS_DATASET structure containing the dataset. |
[in] | mode | Specifies the mode for matching arrays. Valid modes are:
|
[in] | ... | Variable arguments depending on mode :
|
NULL
if no matching array is found or if an error occurs (e.g., memory allocation failure).free()
or an appropriate memory deallocation function.mode
.Definition at line 4491 of file SDDS_utils.c.
char * SDDS_FindColumn | ( | SDDS_DATASET * | SDDS_dataset, |
int32_t | mode, | ||
... ) |
Finds the first column in the SDDS dataset that matches the specified criteria.
This function searches through the columns of the provided SDDS dataset and returns the name of the first column that matches the given criteria based on the specified mode.
The function supports the following modes:
int32_t type
, char *name1, char *name2, ..., NULL
char *name1, char *name2, ..., NULL
char *name1, char *name2, ..., NULL
char *name1, char *name2, ..., NULL
char *name1, char *name2, ..., NULL
[in] | SDDS_dataset | Pointer to the SDDS_DATASET structure containing the dataset. |
[in] | mode | Specifies the mode for matching columns. Valid modes are:
|
[in] | ... | Variable arguments depending on mode :
|
NULL
if no matching column is found or if an error occurs (e.g., memory allocation failure).free()
or an appropriate memory deallocation function.mode
.Definition at line 4312 of file SDDS_utils.c.
char * SDDS_FindParameter | ( | SDDS_DATASET * | SDDS_dataset, |
int32_t | mode, | ||
... ) |
Finds the first parameter in the SDDS dataset that matches the specified criteria.
This function searches through the parameters of the provided SDDS dataset and returns the name of the first parameter that matches the given criteria based on the specified mode.
The function supports the following modes:
int32_t type
, char *name1, char *name2, ..., NULL
char *name1, char *name2, ..., NULL
char *name1, char *name2, ..., NULL
char *name1, char *name2, ..., NULL
char *name1, char *name2, ..., NULL
[in] | SDDS_dataset | Pointer to the SDDS_DATASET structure containing the dataset. |
[in] | mode | Specifies the mode for matching parameters. Valid modes are:
|
[in] | ... | Variable arguments depending on mode :
|
NULL
if no matching parameter is found or if an error occurs (e.g., memory allocation failure).free()
or an appropriate memory deallocation function.mode
.Definition at line 4404 of file SDDS_utils.c.
int32_t SDDS_ForceInactive | ( | SDDS_DATASET * | SDDS_dataset | ) |
Marks an SDDS dataset as inactive.
This function forces the provided SDDS dataset to become inactive by setting its file pointer to NULL
. An inactive dataset is typically not associated with any open file operations.
[in] | SDDS_dataset | Pointer to the SDDS_DATASET structure to be marked as inactive. |
1
on successful operation.-1
if a NULL
pointer is passed, indicating an error.Definition at line 3223 of file SDDS_utils.c.
void SDDS_Free | ( | void * | mem | ) |
Free memory previously allocated by SDDS_Malloc.
This function frees memory that wsa previously allocated by SDDS_Malloc.
[in] | mem | Pointer to the memory block. |
Definition at line 655 of file SDDS_utils.c.
void SDDS_FreeArray | ( | SDDS_ARRAY * | array | ) |
Frees memory allocated for an SDDS array structure.
This function deallocates all memory associated with an SDDS_ARRAY
structure, including its data and definition. It handles the freeing of string elements if the array type is SDDS_STRING
and ensures that all pointers are set to NULL
after deallocation to prevent dangling references.
[in] | array | Pointer to the SDDS_ARRAY structure to be freed. |
array
pointer becomes invalid and should not be used.Definition at line 2766 of file SDDS_utils.c.
int32_t SDDS_FreeArrayDefinition | ( | ARRAY_DEFINITION * | source | ) |
Frees memory allocated for an array definition.
This function deallocates all memory associated with an ARRAY_DEFINITION
structure, including its string fields. After freeing, the structure is zeroed out to prevent dangling pointers.
[in] | source | Pointer to the ARRAY_DEFINITION structure to be freed. |
1
on successful deallocation. Returns 0
if the source
is NULL
.source
pointer becomes invalid and should not be used.Definition at line 1238 of file SDDS_utils.c.
int32_t SDDS_FreeAssociateDefinition | ( | ASSOCIATE_DEFINITION * | source | ) |
Frees memory allocated for an associate definition.
This function deallocates all memory associated with an ASSOCIATE_DEFINITION
structure, including its string fields. After freeing, the structure is zeroed out to prevent dangling pointers.
[in] | source | Pointer to the ASSOCIATE_DEFINITION structure to be freed. |
1
on successful deallocation. Returns 0
if the source
is NULL
or if required fields are missing.source
pointer becomes invalid and should not be used.Definition at line 944 of file SDDS_utils.c.
int32_t SDDS_FreeColumnDefinition | ( | COLUMN_DEFINITION * | source | ) |
Frees memory allocated for a column definition.
This function deallocates all memory associated with a COLUMN_DEFINITION
structure, including its string fields. After freeing, the structure is zeroed out to prevent dangling pointers.
[in] | source | Pointer to the COLUMN_DEFINITION structure to be freed. |
1
on successful deallocation. Returns 0
if the source
is NULL
or if required fields are missing.source
pointer becomes invalid and should not be used.Definition at line 1042 of file SDDS_utils.c.
void SDDS_FreeMatrix | ( | void ** | ptr, |
int64_t | dim1 ) |
Frees memory allocated for a two-dimensional matrix.
This function deallocates a two-dimensional matrix by freeing each row individually followed by the matrix pointer itself.
[in] | ptr | Pointer to the two-dimensional matrix to be freed. |
[in] | dim1 | The number of rows in the matrix. |
SDDS_AllocateMatrix
or similar memory allocation functions.Definition at line 2808 of file SDDS_utils.c.
int32_t SDDS_FreeParameterDefinition | ( | PARAMETER_DEFINITION * | source | ) |
Frees memory allocated for a parameter definition.
This function deallocates all memory associated with a PARAMETER_DEFINITION
structure, including its string fields. After freeing, the structure is zeroed out to prevent dangling pointers.
[in] | source | Pointer to the PARAMETER_DEFINITION structure to be freed. |
1
on successful deallocation. Returns 0
if the source
is NULL
or if required fields are missing.source
pointer becomes invalid and should not be used.Definition at line 1139 of file SDDS_utils.c.
void SDDS_FreePointerArray | ( | void ** | data, |
int32_t | dimensions, | ||
int32_t * | dimension ) |
Frees a multi-dimensional pointer array created by SDDS_MakePointerArray.
This function recursively deallocates a multi-dimensional pointer array that was previously created using SDDS_MakePointerArray
or SDDS_MakePointerArrayRecursively
. It ensures that all pointer layers are properly freed to prevent memory leaks.
[in] | data | Pointer to the multi-dimensional pointer array to be freed. |
[in] | dimensions | The number of dimensions in the pointer array. |
[in] | dimension | An array specifying the size of each dimension. |
Definition at line 3012 of file SDDS_utils.c.
int32_t SDDS_FreeStringArray | ( | char ** | string, |
int64_t | strings ) |
Frees an array of strings by deallocating each individual string.
This function iterates through an array of strings, freeing each non-NULL string and setting its pointer to NULL
to prevent dangling references.
[in,out] | string | Array of strings to be freed. |
[in] | strings | The number of elements in the string array. |
1
if the array is successfully freed.0
if the string
pointer is NULL
.NULL
.Definition at line 2865 of file SDDS_utils.c.
ARRAY_DEFINITION * SDDS_GetArrayDefinition | ( | SDDS_DATASET * | SDDS_dataset, |
char * | name ) |
Retrieves the definition of a specified array from the SDDS dataset.
This function searches for an array by its name within the provided SDDS dataset. If found, it creates a copy of the array's definition and returns a pointer to it. The returned pointer should be freed by the caller using SDDS_FreeArrayDefinition
to avoid memory leaks.
[in] | SDDS_dataset | Pointer to the SDDS_DATASET structure representing the dataset. |
[in] | name | A null-terminated string specifying the name of the array to retrieve. |
ARRAY_DEFINITION
structure containing the array's information. On failure (e.g., if the array is not found or a copy fails), returns NULL
and records an error message.ARRAY_DEFINITION
pointer using SDDS_FreeArrayDefinition
.Definition at line 1174 of file SDDS_utils.c.
int32_t SDDS_GetArrayIndex | ( | SDDS_DATASET * | SDDS_dataset, |
char * | name ) |
Retrieves the index of a named array in the SDDS dataset.
This function searches for an array by its name within the provided SDDS dataset and returns its index. The index can then be used with other routines for faster access to the array's data or metadata.
[in] | SDDS_dataset | Pointer to the SDDS_DATASET structure representing the dataset. |
[in] | name | A null-terminated string specifying the name of the array whose index is desired. |
-1
and records an error message.Definition at line 1367 of file SDDS_utils.c.
char ** SDDS_GetArrayNames | ( | SDDS_DATASET * | SDDS_dataset, |
int32_t * | number ) |
Retrieves the names of all arrays in the SDDS dataset.
This function allocates and returns an array of NULL-terminated strings containing the names of the arrays in the provided SDDS_dataset
.
[in] | SDDS_dataset | Pointer to the SDDS_DATASET structure representing the dataset. |
[out] | number | Pointer to an int32_t variable where the number of retrieved array names will be stored. |
NULL
on failure (e.g., if the dataset is invalid or memory allocation fails) and records an error message.SDDS_FreeStringArray
or similar functions.Definition at line 2539 of file SDDS_utils.c.
int32_t SDDS_GetArrayType | ( | SDDS_DATASET * | SDDS_dataset, |
int32_t | index ) |
Retrieves the data type of an array in the SDDS dataset by its index.
This function returns the SDDS data type of the specified array within the dataset. The data type corresponds to one of the predefined SDDS type constants, such as SDDS_LONGDOUBLE
, SDDS_DOUBLE
, SDDS_FLOAT
, etc.
[in] | SDDS_dataset | Pointer to the SDDS_DATASET structure representing the dataset. |
[in] | index | The zero-based index of the array whose data type is to be retrieved. The index should be obtained from SDDS_DefineArray or SDDS_GetArrayIndex . |
int32_t
. On failure (e.g., if the index is out of range or the dataset is invalid), returns 0
and records an error message.Definition at line 2202 of file SDDS_utils.c.
ASSOCIATE_DEFINITION * SDDS_GetAssociateDefinition | ( | SDDS_DATASET * | SDDS_dataset, |
char * | name ) |
Retrieves the definition of a specified associate from the SDDS dataset.
This function searches for an associate by its name within the provided SDDS dataset. If found, it creates a copy of the associate's definition and returns a pointer to it. The returned pointer should be freed by the caller using SDDS_FreeAssociateDefinition
to avoid memory leaks.
[in] | SDDS_dataset | Pointer to the SDDS_DATASET structure representing the dataset. |
[in] | name | A null-terminated string specifying the name of the associate to retrieve. |
ASSOCIATE_DEFINITION
structure containing the associate's information. On failure (e.g., if the associate is not found or a copy fails), returns NULL
and records an error message.ASSOCIATE_DEFINITION
pointer using SDDS_FreeAssociateDefinition
.Definition at line 883 of file SDDS_utils.c.
int32_t SDDS_GetAssociateIndex | ( | SDDS_DATASET * | SDDS_dataset, |
char * | name ) |
Retrieves the index of a named associate in the SDDS dataset.
This function searches for an associate by its name within the provided SDDS dataset and returns its index. The index can then be used with other routines for faster access to the associate's data or metadata.
[in] | SDDS_dataset | Pointer to the SDDS_DATASET structure representing the dataset. |
[in] | name | A null-terminated string specifying the name of the associate whose index is desired. |
-1
and records an error message.Definition at line 1396 of file SDDS_utils.c.
char ** SDDS_GetAssociateNames | ( | SDDS_DATASET * | SDDS_dataset, |
int32_t * | number ) |
Retrieves the names of all associates in the SDDS dataset.
This function allocates and returns an array of NULL-terminated strings containing the names of the associates in the provided SDDS_dataset
.
[in] | SDDS_dataset | Pointer to the SDDS_DATASET structure representing the dataset. |
[out] | number | Pointer to an int32_t variable where the number of retrieved associate names will be stored. |
NULL
on failure (e.g., if the dataset is invalid or memory allocation fails) and records an error message.SDDS_FreeStringArray
or similar functions.Definition at line 2577 of file SDDS_utils.c.
COLUMN_DEFINITION * SDDS_GetColumnDefinition | ( | SDDS_DATASET * | SDDS_dataset, |
char * | name ) |
Retrieves the definition of a specified column from the SDDS dataset.
This function searches for a column by its name within the provided SDDS dataset. If found, it creates a copy of the column's definition and returns a pointer to it. The returned pointer should be freed by the caller using SDDS_FreeColumnDefinition
to avoid memory leaks.
[in] | SDDS_dataset | Pointer to the SDDS_DATASET structure representing the dataset. |
[in] | name | A null-terminated string specifying the name of the column to retrieve. |
COLUMN_DEFINITION
structure containing the column's information. On failure (e.g., if the column is not found or a copy fails), returns NULL
and records an error message.COLUMN_DEFINITION
pointer using SDDS_FreeColumnDefinition
.Definition at line 978 of file SDDS_utils.c.
int32_t SDDS_GetColumnIndex | ( | SDDS_DATASET * | SDDS_dataset, |
char * | name ) |
Retrieves the index of a named column in the SDDS dataset.
This function searches for a column by its name within the provided SDDS dataset and returns its index. The index can then be used with other routines for faster access to the column's data or metadata.
[in] | SDDS_dataset | Pointer to the SDDS_DATASET structure representing the dataset. |
[in] | name | A null-terminated string specifying the name of the column whose index is desired. |
-1
and records an error message.Definition at line 1309 of file SDDS_utils.c.
char ** SDDS_GetColumnNames | ( | SDDS_DATASET * | SDDS_dataset, |
int32_t * | number ) |
Retrieves the names of all columns in the SDDS dataset.
This function allocates and returns an array of NULL-terminated strings containing the names of the columns in the provided SDDS_dataset
. It only includes columns that are flagged as of interest if column_flag
is set.
[in] | SDDS_dataset | Pointer to the SDDS_DATASET structure representing the dataset. |
[out] | number | Pointer to an int32_t variable where the number of retrieved column names will be stored. |
NULL
on failure (e.g., if the dataset is invalid or memory allocation fails) and records an error message.SDDS_FreeStringArray
or similar functions.Definition at line 2460 of file SDDS_utils.c.
int32_t SDDS_GetColumnType | ( | SDDS_DATASET * | SDDS_dataset, |
int32_t | index ) |
Retrieves the data type of a column in the SDDS dataset by its index.
This function returns the SDDS data type of the specified column within the dataset. The data type corresponds to one of the predefined SDDS type constants, such as SDDS_LONGDOUBLE
, SDDS_DOUBLE
, SDDS_FLOAT
, etc.
[in] | SDDS_dataset | Pointer to the SDDS_DATASET structure representing the dataset. |
[in] | index | The zero-based index of the column whose data type is to be retrieved. The index should be obtained from SDDS_DefineColumn or SDDS_GetColumnIndex . |
int32_t
. On failure (e.g., if the index is out of range or the dataset is invalid), returns 0
and records an error message.Definition at line 2153 of file SDDS_utils.c.
char ** SDDS_GetErrorMessages | ( | int32_t * | number, |
int32_t | mode ) |
Retrieves recorded error messages from the SDDS error stack.
This function fetches error messages that have been recorded by SDDS library routines. Depending on the mode
parameter, it can retrieve a single error message or all recorded errors.
[out] | number | Pointer to an int32_t variable where the number of retrieved error messages will be stored. If NULL , the function returns NULL . |
[in] | mode | Flags controlling the retrieval behavior:
|
NULL
if no errors are recorded or if memory allocation fails.Definition at line 480 of file SDDS_utils.c.
int32_t SDDS_GetNamedArrayType | ( | SDDS_DATASET * | SDDS_dataset, |
char * | name ) |
Retrieves the data type of an array in the SDDS dataset by its name.
This function searches for an array by its name within the dataset and returns its SDDS data type. The data type corresponds to one of the predefined SDDS type constants, such as SDDS_LONGDOUBLE
, SDDS_DOUBLE
, SDDS_FLOAT
, etc.
[in] | SDDS_dataset | Pointer to the SDDS_DATASET structure representing the dataset. |
[in] | name | A null-terminated string specifying the name of the array whose data type is to be retrieved. |
int32_t
. On failure (e.g., if the array name is not found or the dataset is invalid), returns 0
and records an error message.SDDS_GetArrayIndex
to find the array's index before retrieving its type.Definition at line 2227 of file SDDS_utils.c.
int32_t SDDS_GetNamedColumnType | ( | SDDS_DATASET * | SDDS_dataset, |
char * | name ) |
Retrieves the data type of a column in the SDDS dataset by its name.
This function searches for a column by its name within the dataset and returns its SDDS data type. The data type corresponds to one of the predefined SDDS type constants, such as SDDS_LONGDOUBLE
, SDDS_DOUBLE
, SDDS_FLOAT
, etc.
[in] | SDDS_dataset | Pointer to the SDDS_DATASET structure representing the dataset. |
[in] | name | A null-terminated string specifying the name of the column whose data type is to be retrieved. |
int32_t
. On failure (e.g., if the column name is not found or the dataset is invalid), returns 0
and records an error message.SDDS_GetColumnIndex
to find the column's index before retrieving its type.Definition at line 2178 of file SDDS_utils.c.
int32_t SDDS_GetNamedParameterType | ( | SDDS_DATASET * | SDDS_dataset, |
char * | name ) |
Retrieves the data type of a parameter in the SDDS dataset by its name.
This function searches for a parameter by its name within the dataset and returns its SDDS data type. The data type corresponds to one of the predefined SDDS type constants, such as SDDS_LONGDOUBLE
, SDDS_DOUBLE
, SDDS_FLOAT
, etc.
[in] | SDDS_dataset | Pointer to the SDDS_DATASET structure representing the dataset. |
[in] | name | A null-terminated string specifying the name of the parameter whose data type is to be retrieved. |
int32_t
. On failure (e.g., if the parameter name is not found or the dataset is invalid), returns 0
and records an error message.SDDS_GetParameterIndex
to find the parameter's index before retrieving its type.Definition at line 2276 of file SDDS_utils.c.
PARAMETER_DEFINITION * SDDS_GetParameterDefinition | ( | SDDS_DATASET * | SDDS_dataset, |
char * | name ) |
Retrieves the definition of a specified parameter from the SDDS dataset.
This function searches for a parameter by its name within the provided SDDS dataset. If found, it creates a copy of the parameter's definition and returns a pointer to it. The returned pointer should be freed by the caller using SDDS_FreeParameterDefinition
to avoid memory leaks.
[in] | SDDS_dataset | Pointer to the SDDS_DATASET structure representing the dataset. |
[in] | name | A null-terminated string specifying the name of the parameter to retrieve. |
PARAMETER_DEFINITION
structure containing the parameter's information. On failure (e.g., if the parameter is not found or a copy fails), returns NULL
and records an error message.PARAMETER_DEFINITION
pointer using SDDS_FreeParameterDefinition
.Definition at line 1075 of file SDDS_utils.c.
int32_t SDDS_GetParameterIndex | ( | SDDS_DATASET * | SDDS_dataset, |
char * | name ) |
Retrieves the index of a named parameter in the SDDS dataset.
This function searches for a parameter by its name within the provided SDDS dataset and returns its index. The index can then be used with other routines for faster access to the parameter's data or metadata.
[in] | SDDS_dataset | Pointer to the SDDS_DATASET structure representing the dataset. |
[in] | name | A null-terminated string specifying the name of the parameter whose index is desired. |
-1
and records an error message.Definition at line 1338 of file SDDS_utils.c.
char ** SDDS_GetParameterNames | ( | SDDS_DATASET * | SDDS_dataset, |
int32_t * | number ) |
Retrieves the names of all parameters in the SDDS dataset.
This function allocates and returns an array of NULL-terminated strings containing the names of the parameters in the provided SDDS_dataset
.
[in] | SDDS_dataset | Pointer to the SDDS_DATASET structure representing the dataset. |
[out] | number | Pointer to an int32_t variable where the number of retrieved parameter names will be stored. |
NULL
on failure (e.g., if the dataset is invalid or memory allocation fails) and records an error message.SDDS_FreeStringArray
or similar functions.Definition at line 2501 of file SDDS_utils.c.
int32_t SDDS_GetParameterType | ( | SDDS_DATASET * | SDDS_dataset, |
int32_t | index ) |
Retrieves the data type of a parameter in the SDDS dataset by its index.
This function returns the SDDS data type of the specified parameter within the dataset. The data type corresponds to one of the predefined SDDS type constants, such as SDDS_LONGDOUBLE
, SDDS_DOUBLE
, SDDS_FLOAT
, etc.
[in] | SDDS_dataset | Pointer to the SDDS_DATASET structure representing the dataset. |
[in] | index | The zero-based index of the parameter whose data type is to be retrieved. The index should be obtained from SDDS_DefineParameter or SDDS_GetParameterIndex . |
int32_t
. On failure (e.g., if the index is out of range or the dataset is invalid), returns 0
and records an error message.Definition at line 2251 of file SDDS_utils.c.
uint32_t SDDS_GetSpecialCommentsModes | ( | SDDS_DATASET * | SDDS_dataset | ) |
Retrieves the current special comments modes set in the SDDS dataset.
This function returns the current set of special comment flags that have been parsed and set within the dataset. These flags indicate the presence of specific configurations such as endianness and fixed row counts.
[in] | SDDS_dataset | Pointer to the SDDS_DATASET structure representing the dataset. |
uint32_t
value representing the combined set of special comment flags.0
if no special comments have been set.SDDS_ParseSpecialComments
.Definition at line 5201 of file SDDS_utils.c.
int32_t SDDS_GetToken | ( | char * | s, |
char * | buffer, | ||
int32_t | buflen ) |
Extracts the next token from a string, handling quoted substrings and escape characters.
This function parses the input string s
to extract the next token, considering quoted substrings and escape characters. If the token is enclosed in double quotes ("
), the function ensures that embedded quotes are handled correctly. After extracting the token, the original string s
is updated to remove the extracted portion.
[in,out] | s | Pointer to the string from which to extract the token. This string will be modified to remove the extracted token. |
[out] | buffer | Pointer to a character array where the extracted token will be stored. |
[in] | buflen | The maximum number of characters to copy into buffer , including the null terminator. |
int32_t
. If no token is found or an error occurs (e.g., buffer overflow), returns -1
.s
is null-terminated. The caller must ensure that buffer
has sufficient space to hold the extracted token.Definition at line 1740 of file SDDS_utils.c.
int32_t SDDS_GetToken2 | ( | char * | s, |
char ** | st, | ||
int32_t * | strlength, | ||
char * | buffer, | ||
int32_t | buflen ) |
Extracts the next token from a string, handling quoted substrings and escape characters, with updated string pointers.
This function parses the input string s
to extract the next token, considering quoted substrings and escape characters. If the token is enclosed in double quotes ("
), the function ensures that embedded quotes are handled correctly. After extracting the token, the original string s
is updated by adjusting the string pointer st
and the remaining string length strlength
.
[in,out] | s | Pointer to the string from which to extract the token. This string will be modified to remove the extracted token. |
[in,out] | st | Pointer to the current position in the string s . This will be updated to point to the next character after the extracted token. |
[in,out] | strlength | Pointer to an int32_t variable representing the remaining length of the string s . This will be decremented by the length of the extracted token. |
[out] | buffer | Pointer to a character array where the extracted token will be stored. |
[in] | buflen | The maximum number of characters to copy into buffer , including the null terminator. |
int32_t
. If no token is found or an error occurs (e.g., buffer overflow), returns -1
.buffer
has sufficient space to hold the extracted token. Additionally, st
and strlength
should accurately reflect the current parsing state of the string.Definition at line 1812 of file SDDS_utils.c.
char * SDDS_GetTypeName | ( | int32_t | type | ) |
Retrieves the name of a specified SDDS data type as a string.
This function returns a dynamically allocated string containing the name of the specified SDDS data type. The name corresponds to the textual representation of the data type, such as "double"
, "float"
, "int32"
, etc.
[in] | type | The SDDS data type for which the name is requested. Must be one of the predefined constants:
|
NULL
.SDDS_Free
.Definition at line 2337 of file SDDS_utils.c.
int32_t SDDS_GetTypeSize | ( | int32_t | type | ) |
Retrieves the size in bytes of a specified SDDS data type.
This function returns the size, in bytes, of the specified SDDS data type. The size corresponds to the memory footprint of the data type when stored in the dataset.
[in] | type | The SDDS data type for which the size is requested. Must be one of the predefined constants:
|
-1
and records an error message.SDDS_type_size
array, which should be properly initialized with the sizes of all supported SDDS data types.Definition at line 2308 of file SDDS_utils.c.
int32_t SDDS_HasWhitespace | ( | char * | string | ) |
Checks if a string contains any whitespace characters.
This function scans through the provided string to determine if it contains any whitespace characters (e.g., space, tab, newline).
[in] | string | Pointer to the null-terminated string to be checked. |
1
if the string contains at least one whitespace character. Returns 0
if no whitespace characters are found or if the input string is NULL
.Definition at line 1422 of file SDDS_utils.c.
int32_t SDDS_IdentifyType | ( | char * | typeName | ) |
Identifies the SDDS data type based on its string name.
This function searches for the SDDS data type that matches the provided string typeName
. It returns the corresponding SDDS data type constant if a match is found.
[in] | typeName | A null-terminated string representing the name of the SDDS data type to identify. |
int32_t
) corresponding to typeName
. On failure (e.g., if typeName
does not match any known data type), returns 0
.typeName
and the names of supported SDDS data types.Definition at line 2360 of file SDDS_utils.c.
void SDDS_InterpretEscapes | ( | char * | s | ) |
Interprets and converts escape sequences in a string.
This function processes a string containing escape sequences and converts them into their corresponding character representations. Supported escape sequences include:
\n
, \t
, \b
, \r
, \f
, \v
, \\
, \', \"
, \a
, \?
\ddd
\!
, \)
The function modifies the input string s
in place, replacing escape sequences with their actual character values.
[in,out] | s | Pointer to the null-terminated string to be processed. The string will be modified in place. |
s
has sufficient buffer space to accommodate the modified characters, especially when dealing with octal escape sequences that may reduce the overall string length.Definition at line 5082 of file SDDS_utils.c.
int32_t SDDS_IsActive | ( | SDDS_DATASET * | SDDS_dataset | ) |
Checks whether an SDDS dataset is currently active.
This function determines the active status of the provided SDDS dataset by verifying if its file pointer is non-NULL
.
[in] | SDDS_dataset | Pointer to the SDDS_DATASET structure to be checked. |
1
if the dataset is active (i.e., the file pointer is non-NULL
).0
if the dataset is inactive (i.e., the file pointer is NULL
).-1
if a NULL
pointer is passed, indicating an error.Definition at line 3250 of file SDDS_utils.c.
int32_t SDDS_IsBigEndianMachine | ( | ) |
Determines whether the current machine uses big-endian byte ordering.
This function checks the byte order of the machine on which the program is running. It returns 1
if the machine is big-endian and 0
if it is little-endian.
1
if the machine is big-endian.0
if the machine is little-endian.int32_t
is 4 bytes in size. If compiled on a system where int32_t
differs in size, the behavior may be incorrect.Definition at line 5283 of file SDDS_utils.c.
int32_t SDDS_LockFile | ( | FILE * | fp, |
const char * | filename, | ||
const char * | caller ) |
Attempts to lock a specified file.
This function tries to acquire a lock on the provided file using the given file pointer. If file locking is enabled via the F_TEST
and ALLOW_FILE_LOCKING
macros, it first tests whether the file can be locked and then attempts to establish an exclusive lock. If locking fails at any step, an error message is set, and the function returns 0
.
If file locking is not enabled, the function assumes that the file is not locked and returns 1
.
[in] | fp | Pointer to the open FILE stream associated with the file to be locked. |
[in] | filename | The path to the file to be locked. Used primarily for error messaging. |
[in] | caller | A string identifying the caller or the context in which the lock is being attempted. This is used in error messages to provide more information about the lock attempt. |
1
if the file lock is successfully acquired or if file locking is not enabled.0
if the file is already locked or if locking fails for another reason.lockf
system call for file locking, which may not be supported on all platforms.Definition at line 3326 of file SDDS_utils.c.
void * SDDS_MakePointerArray | ( | void * | data, |
int32_t | type, | ||
int32_t | dimensions, | ||
int32_t * | dimension ) |
Creates a multi-dimensional pointer array from a contiguous data block.
This function generates a multi-dimensional pointer array that maps to a contiguous block of data. It supports arrays with multiple dimensions by recursively creating pointer layers. The dimensions
parameter specifies the number of dimensions, and the dimension
array provides the size for each dimension.
[in] | data | Pointer to the contiguous data block to be mapped. |
[in] | type | The SDDS data type of the elements in the data block. Must be one of the SDDS type constants:
|
[in] | dimensions | The number of dimensions for the pointer array. |
[in] | dimension | An array specifying the size of each dimension. |
NULL
if the input data is NULL
, the dimension
array is invalid, the type
is unknown, or memory allocation fails.SDDS_MakePointerArrayRecursively
to handle multi-dimensional allocations.SDDS_FreePointerArray
.Definition at line 2971 of file SDDS_utils.c.
void * SDDS_MakePointerArrayRecursively | ( | void * | data, |
int32_t | size, | ||
int32_t | dimensions, | ||
int32_t * | dimension ) |
Recursively creates a multi-dimensional pointer array from a contiguous data block.
This internal function is used to build a multi-dimensional pointer array by recursively allocating pointer layers based on the specified dimensions. It maps the contiguous data block to the pointer structure, facilitating easy access to multi-dimensional data.
[in] | data | Pointer to the data block or intermediate pointer array. |
[in] | size | The size in bytes of each element in the current dimension. |
[in] | dimensions | The number of remaining dimensions to process. |
[in] | dimension | An array specifying the size of each remaining dimension. |
NULL
if the input data is NULL
, the dimension
array is invalid, the size
is non-positive, or memory allocation fails.depth
variable to track recursion depth for error reporting.Definition at line 2900 of file SDDS_utils.c.
void * SDDS_Malloc | ( | size_t | size | ) |
Allocates memory of a specified size.
This function is a wrapper around the standard malloc
function, used by SDDS routines to allocate memory. It ensures that a minimum allocation size is enforced.
[in] | size | Number of bytes to allocate. |
size
is less than or equal to zero, it allocates memory for 4 bytes by default. Returns NULL
if memory allocation fails.NULL
before using it.Definition at line 639 of file SDDS_utils.c.
int32_t SDDS_MatchArrays | ( | SDDS_DATASET * | SDDS_dataset, |
char *** | nameReturn, | ||
int32_t | matchMode, | ||
int32_t | typeMode, | ||
... ) |
Matches and retrieves array names from an SDDS dataset based on specified criteria.
This function selects arrays from the provided SDDS dataset according to the specified matching mode and type mode. It supports various calling conventions depending on the matching criteria.
The function supports the following matching modes:
int32_t n_entries
, char **name
char *names
char *name1, char *name2, ..., NULL
NULL
pointer.char *name
, int32_t logic_mode
name
, using the specified logical mode.char *name
, char *exclude
, int32_t logic_mode
name
, excluding those that match the exclude
pattern, using the specified logical mode.Additionally, the typeMode
parameter allows filtering based on array types, such as numeric, floating, or integer types.
[in] | SDDS_dataset | Pointer to the SDDS_DATASET structure containing the dataset. |
[out] | nameReturn | Pointer to a char** that will be allocated and populated with the names of the matched arrays. The caller is responsible for freeing the allocated memory. |
[in] | matchMode | Specifies the matching mode (e.g., SDDS_NAME_ARRAY , SDDS_NAMES_STRING , etc.). |
[in] | typeMode | Specifies the type matching mode (e.g., FIND_SPECIFIED_TYPE , FIND_NUMERIC_TYPE , FIND_FLOATING_TYPE , FIND_INTEGER_TYPE ). |
[in] | ... | Variable arguments depending on matchMode :
|
-1
if an error occurs (e.g., invalid parameters, memory allocation failure).nameReturn
, which must be freed by the caller using appropriate memory deallocation functions.matchMode
.nameReturn
to avoid memory leaks.Definition at line 4040 of file SDDS_utils.c.
int32_t SDDS_MatchColumns | ( | SDDS_DATASET * | SDDS_dataset, |
char *** | nameReturn, | ||
int32_t | matchMode, | ||
int32_t | typeMode, | ||
... ) |
Matches and retrieves column names from an SDDS dataset based on specified criteria.
This function selects columns from the provided SDDS dataset according to the specified matching mode and type mode. It supports various calling conventions depending on the matching criteria.
The function supports the following matching modes:
int32_t n_entries
, char **name
char *names
char *name1, char *name2, ..., NULL
NULL
pointer.char *name
, int32_t logic_mode
name
, using the specified logical mode.char *name
, char *exclude
, int32_t logic_mode
name
, excluding those that match the exclude
pattern, using the specified logical mode.Additionally, the typeMode
parameter allows filtering based on column types, such as numeric, floating, or integer types.
[in] | SDDS_dataset | Pointer to the SDDS_DATASET structure containing the dataset. |
[out] | nameReturn | Pointer to a char** that will be allocated and populated with the names of the matched columns. The caller is responsible for freeing the allocated memory. |
[in] | matchMode | Specifies the matching mode (e.g., SDDS_NAME_ARRAY , SDDS_NAMES_STRING , etc.). |
[in] | typeMode | Specifies the type matching mode (e.g., FIND_SPECIFIED_TYPE , FIND_NUMERIC_TYPE , FIND_FLOATING_TYPE , FIND_INTEGER_TYPE ). |
[in] | ... | Variable arguments depending on matchMode :
|
-1
if an error occurs (e.g., invalid parameters, memory allocation failure).nameReturn
, which must be freed by the caller using appropriate memory deallocation functions.matchMode
.nameReturn
to avoid memory leaks.Definition at line 3484 of file SDDS_utils.c.
int32_t SDDS_MatchParameters | ( | SDDS_DATASET * | SDDS_dataset, |
char *** | nameReturn, | ||
int32_t | matchMode, | ||
int32_t | typeMode, | ||
... ) |
Matches and retrieves parameter names from an SDDS dataset based on specified criteria.
This function selects parameters from the provided SDDS dataset according to the specified matching mode and type mode. It supports various calling conventions depending on the matching criteria.
The function supports the following matching modes:
int32_t n_entries
, char **name
char *names
char *name1, char *name2, ..., NULL
NULL
pointer.char *name
, int32_t logic_mode
name
, using the specified logical mode.char *name
, char *exclude
, int32_t logic_mode
name
, excluding those that match the exclude
pattern, using the specified logical mode.Additionally, the typeMode
parameter allows filtering based on parameter types, such as numeric, floating, or integer types.
[in] | SDDS_dataset | Pointer to the SDDS_DATASET structure containing the dataset. |
[out] | nameReturn | Pointer to a char** that will be allocated and populated with the names of the matched parameters. The caller is responsible for freeing the allocated memory. |
[in] | matchMode | Specifies the matching mode (e.g., SDDS_NAME_ARRAY , SDDS_NAMES_STRING , etc.). |
[in] | typeMode | Specifies the type matching mode (e.g., FIND_SPECIFIED_TYPE , FIND_NUMERIC_TYPE , FIND_FLOATING_TYPE , FIND_INTEGER_TYPE ). |
[in] | ... | Variable arguments depending on matchMode :
|
-1
if an error occurs (e.g., invalid parameters, memory allocation failure).nameReturn
, which must be freed by the caller using appropriate memory deallocation functions.matchMode
.nameReturn
to avoid memory leaks.Definition at line 3762 of file SDDS_utils.c.
int32_t SDDS_NumberOfErrors | ( | void | ) |
Retrieves the number of errors recorded by SDDS library routines.
This function returns the total number of errors that have been recorded by the SDDS library since the last invocation of SDDS_PrintErrors
.
Definition at line 304 of file SDDS_utils.c.
int32_t SDDS_PadToLength | ( | char * | string, |
int32_t | length ) |
Pads a string with spaces to reach a specified length.
This function appends space characters to the end of the input string string
until it reaches the desired length
. If the original string is longer than the specified length
, the function returns an error without modifying the string.
[in,out] | string | Pointer to the null-terminated string to be padded. |
[in] | length | The target length for the string after padding. |
1
on successful padding. Returns 0
if the input string is NULL
or if the original string length exceeds the specified length
.string
has sufficient space to accommodate the additional padding.Definition at line 1879 of file SDDS_utils.c.
int32_t SDDS_ParameterCount | ( | SDDS_DATASET * | page | ) |
Retrieves the number of parameters in the SDDS dataset.
This function returns the total count of parameters defined in the layout of the provided SDDS dataset.
[in] | page | Pointer to the SDDS_DATASET structure representing the dataset. |
int32_t
) in the dataset.0
if the provided dataset pointer is NULL
.Definition at line 5030 of file SDDS_utils.c.
void SDDS_ParseSpecialComments | ( | SDDS_DATASET * | SDDS_dataset, |
char * | s ) |
Parses and processes special comment commands within the SDDS dataset.
This function interprets special commands embedded within comment strings of the SDDS dataset. Supported special commands include:
big-endian
little-endian
fixed-rowcount
Each recognized command updates the commentFlags
field within the dataset's layout to reflect the presence of these special configurations.
[in,out] | SDDS_dataset | Pointer to the SDDS_DATASET structure representing the dataset. The commentFlags field will be updated based on the parsed commands. |
[in] | s | Pointer to the null-terminated string containing special comment commands to be parsed. |
s
is properly formatted and null-terminated to prevent undefined behavior.Definition at line 5251 of file SDDS_utils.c.
int32_t SDDS_PrintCheckText | ( | FILE * | fp, |
char * | name, | ||
char * | units, | ||
int32_t | type, | ||
char * | class_name, | ||
int32_t | error_code ) |
Prints detailed error messages related to SDDS entity checks.
This function outputs error messages to the specified file pointer based on the provided error code. It is primarily used by functions like SDDS_CheckColumn
, SDDS_CheckParameter
, and SDDS_CheckArray
to report issues during validation checks.
[in] | fp | File pointer where the error messages will be printed. Typically, this is stderr . |
[in] | name | The name of the SDDS entity (e.g., column, parameter, array) being checked. |
[in] | units | The expected units of the SDDS entity. May be NULL if units are not relevant. |
[in] | type | The expected type code of the SDDS entity. This can be a specific type or a general category like SDDS_ANY_NUMERIC_TYPE . |
[in] | class_name | A string representing the class of the SDDS entity (e.g., "column", "parameter", "array"). |
[in] | error_code | The specific error code indicating the type of error encountered. Valid values include:
|
error_code
that was passed as an argument.registeredProgramName
is a globally accessible string containing the name of the program for contextual error messages.fp
, name
, and class_name
are not NULL
to prevent undefined behavior.error_code
values that are not handled in the switch statement will result in a generic error message being printed to stderr
.Definition at line 4830 of file SDDS_utils.c.
void SDDS_PrintErrors | ( | FILE * | fp, |
int32_t | mode ) |
Prints recorded error messages to a specified file stream.
This function outputs the errors that have been recorded by SDDS library routines to the given file stream. Depending on the mode
parameter, it can print a single error, all recorded errors, and optionally terminate the program after printing.
[in] | fp | Pointer to the FILE stream where errors will be printed. Typically stderr . |
[in] | mode | Flags controlling the error printing behavior:
|
mode
includes SDDS_EXIT_PrintErrors
, the program will terminate.Definition at line 432 of file SDDS_utils.c.
int32_t SDDS_PrintTypedValue | ( | void * | data, |
int64_t | index, | ||
int32_t | type, | ||
char * | format, | ||
FILE * | fp, | ||
uint32_t | mode ) |
Prints a data value of a specified type using an optional printf format string.
This function prints a single data value from a data array based on the specified type and index. It supports various data types defined by SDDS constants and allows customization of the output format.
[in] | data | Pointer to the base address of the data array to be printed. |
[in] | index | The index of the item within the data array to be printed. |
[in] | type | The data type of the value to be printed, specified by one of the SDDS constants:
|
[in] | format | (Optional) NULL-terminated string specifying a printf format. If NULL , a default format is used based on the data type. |
[in] | fp | Pointer to the FILE stream where the data will be printed. |
[in] | mode | Flags controlling the printing behavior. Valid values are:
|
1
on success. On failure, returns 0
and records an error message.data
pointer points to an array of the specified type
, and index
is within the bounds of this array.Definition at line 59 of file SDDS_utils.c.
void * SDDS_Realloc | ( | void * | old_ptr, |
size_t | new_size ) |
Reallocates memory to a new size.
This function extends the standard realloc
functionality by zero-initializing any newly allocated memory beyond the original size. It ensures that memory is consistently reallocated and initialized across different build configurations.
[in] | old_ptr | Pointer to the original memory block. If NULL , the function behaves like SDDS_Malloc . |
[in] | new_size | New size in bytes for the memory block. |
new_size
is less than or equal to zero, a minimum of 4 bytes is allocated. Returns NULL
if memory reallocation fails.Definition at line 677 of file SDDS_utils.c.
void * SDDS_Recalloc | ( | void * | old_ptr, |
size_t | old_size, | ||
size_t | new_size ) |
Reallocates memory to a new size and zero-initializes the additional space.
This function reallocates a memory block to a new size, similar to the standard realloc
function. Additionally, it ensures that any newly allocated memory beyond the original size is set to zero. This is particularly useful when extending memory blocks to avoid uninitialized memory usage.
[in] | old_ptr | Pointer to the original memory block. If NULL , the function behaves like SDDS_Calloc . |
[in] | old_size | Size in bytes of the original memory block. |
[in] | new_size | New size in bytes for the memory block. |
new_size
is less than or equal to zero, a minimum of 4 bytes is allocated. Returns NULL
if memory reallocation fails.old_size
to new_size
bytes is set to zero. If old_ptr
is NULL
, the function allocates memory initialized to zero.Definition at line 707 of file SDDS_utils.c.
void SDDS_RegisterProgramName | ( | const char * | name | ) |
Registers the executable program name for use in error messages.
This function stores the name of the executing program, which is included in various error and warning messages generated by the SDDS library routines.
[in] | name | The name of the program. If NULL , the registered program name is cleared. |
Definition at line 288 of file SDDS_utils.c.
void SDDS_RemovePadding | ( | char * | s | ) |
Removes leading and trailing whitespace from a string.
This function trims all leading and trailing whitespace characters from the input string s
. It modifies the string in place, ensuring that any padding spaces are removed while preserving the internal content.
[in,out] | s | Pointer to the null-terminated string to be trimmed. The string will be modified in place. |
isspace
function. If the string consists entirely of whitespace, the function will result in an empty string.Definition at line 2379 of file SDDS_utils.c.
void SDDS_ResetSpecialCommentsModes | ( | SDDS_DATASET * | SDDS_dataset | ) |
Resets the special comments modes in the SDDS dataset.
This function clears all special comment flags that have been set within the dataset. After calling this function, the dataset will no longer have any special configurations related to comments.
[in,out] | SDDS_dataset | Pointer to the SDDS_DATASET structure representing the dataset. The commentFlags field will be reset to 0 . |
Definition at line 5221 of file SDDS_utils.c.
uint32_t SDDS_SetAutoCheckMode | ( | uint32_t | newMode | ) |
Sets the automatic check mode for SDDS dataset validation.
This function updates the auto-check mode, which controls the automatic validation of SDDS datasets during operations. The previous mode is returned.
[in] | newMode | The new auto-check mode to be set. It should be a bitwise combination of the following constants:
|
Definition at line 533 of file SDDS_utils.c.
int32_t SDDS_SetDataMode | ( | SDDS_DATASET * | SDDS_dataset, |
int32_t | newmode ) |
Sets the data mode (ASCII or Binary) for the SDDS dataset.
This function configures the data mode of the SDDS dataset to either ASCII or Binary. When setting to Binary mode with byte swapping (using -SDDS_BINARY
), it adjusts the byte order based on the machine's endianness to ensure compatibility.
[in] | SDDS_dataset | Pointer to the SDDS_DATASET structure representing the dataset whose data mode is to be set. |
[in] | newmode | The desired data mode. Valid values are:
|
1
on successful mode change.0
if the mode is invalid, if the dataset is NULL
, or if the dataset has already been written to and the mode cannot be changed.page_number
is 0
and n_rows_written
is 0
).-SDDS_BINARY
, the function automatically determines the appropriate byte order based on the machine's endianness.newmode
parameter is correctly specified to prevent unintended behavior.Definition at line 4932 of file SDDS_utils.c.
void SDDS_SetError | ( | char * | error_text | ) |
Records an error message in the SDDS error stack.
This function appends an error message to the internal error stack. These errors can later be retrieved and displayed using SDDS_PrintErrors
.
[in] | error_text | The error message to be recorded. If NULL , a warning is printed to stderr . |
Definition at line 379 of file SDDS_utils.c.
void SDDS_SetError0 | ( | char * | error_text | ) |
Internal function to record an error message in the SDDS error stack.
This function appends an error message to the internal error stack without adding additional formatting or line breaks. It is typically called by SDDS_SetError
.
[in] | error_text | The error message to be recorded. If NULL , a warning is printed to stderr . |
Definition at line 395 of file SDDS_utils.c.
int32_t SDDS_SetMemory | ( | void * | mem, |
int64_t | n_elements, | ||
int32_t | data_type, | ||
... ) |
Initializes a memory block with a sequence of values based on a specified data type.
This function sets a block of memory to a sequence of values, starting from a specified initial value and incrementing by a defined delta. The sequence is determined by the data_type
parameter, which specifies the type of each element in the memory block. The function supports various SDDS data types and handles the initialization accordingly.
[in,out] | mem | Pointer to the memory block to be initialized. |
[in] | n_elements | The number of elements to initialize in the memory block. |
[in] | data_type | The SDDS data type of each element. Must be one of the following constants:
|
[in] | ... | Variable arguments specifying the starting value and increment value. The types of these arguments depend on the data_type :
|
1
on successful memory initialization. Returns 0
if an unknown or invalid data_type
is provided.data_type
parameter.Definition at line 2039 of file SDDS_utils.c.
int32_t SDDS_SprintTypedValue | ( | void * | data, |
int64_t | index, | ||
int32_t | type, | ||
const char * | format, | ||
char * | buffer, | ||
uint32_t | mode ) |
Formats a data value of a specified type into a string buffer using an optional printf format string.
This function formats a single data value from a data array into a provided buffer. It is a wrapper for SDDS_SprintTypedValueFactor
with a default scaling factor of 1.0.
[in] | data | Pointer to the base address of the data array containing the value to be formatted. |
[in] | index | The index of the item within the data array to be formatted. |
[in] | type | The data type of the value, specified by one of the SDDS constants:
|
[in] | format | (Optional) NULL-terminated string specifying a printf format. If NULL , a default format is used based on the data type. |
[out] | buffer | Pointer to a character array where the formatted string will be stored. |
[in] | mode | Flags controlling the formatting behavior. Valid values are:
|
1
on success. On failure, returns 0
and records an error message.Definition at line 151 of file SDDS_utils.c.
int32_t SDDS_SprintTypedValueFactor | ( | void * | data, |
int64_t | index, | ||
int32_t | type, | ||
const char * | format, | ||
char * | buffer, | ||
uint32_t | mode, | ||
double | factor ) |
Reallocates memory to a new size and zero-initializes the additional space.
This function extends the standard realloc
functionality by zero-initializing any newly allocated memory beyond the original size. It ensures that memory is consistently reallocated and initialized across different build configurations.
[in] | data | Pointer to the base address of the data array containing the value to be formatted. |
[in] | index | The index of the item within the data array to be formatted. |
[in] | type | The data type of the value, specified by one of the SDDS constants:
|
[in] | format | (Optional) NULL-terminated string specifying a printf format. If NULL , a default format is used based on the data type. |
[out] | buffer | Pointer to a character array where the formatted string will be stored. |
[in] | mode | Flags controlling the formatting behavior. Valid values are:
|
[in] | factor | Scaling factor to be applied to the value before formatting. The value is multiplied by this factor. |
1
on success. On failure, returns 0
and records an error message.SDDS_PRINT_NOQUOTES
is specified in mode
.Definition at line 186 of file SDDS_utils.c.
int32_t SDDS_StringIsBlank | ( | char * | s | ) |
Checks if a string is blank (contains only whitespace characters).
This function determines whether the provided NULL-terminated string s
consists solely of whitespace characters. If the string is NULL
or contains only whitespace, the function returns 1
. If the string contains any non-whitespace characters, it returns 0
.
[in] | s | Pointer to the NULL-terminated string to be checked. |
1
if the string is NULL
or contains only whitespace characters.0
if the string contains any non-whitespace characters.Definition at line 2404 of file SDDS_utils.c.
void SDDS_UnescapeQuotes | ( | char * | s, |
char | quote_char ) |
Removes escape characters from quote characters within a string.
This function scans the input string s
and removes backslashes (\
) that precede the specified quote_char
, effectively unescaping the quotes. This is useful for processing strings that have been prepared with escaped quotes.
[in,out] | s | Pointer to the string in which quotes will be unescaped. The string will be modified in place. |
[in] | quote_char | The quote character to unescape (e.g., " ). |
s
by shifting characters to remove the escape backslashes. It assumes that s
is properly null-terminated.Definition at line 1932 of file SDDS_utils.c.
int32_t SDDS_VerifyArrayExists | ( | SDDS_DATASET * | SDDS_dataset, |
int32_t | mode, | ||
... ) |
Verifies the existence of an array in the SDDS dataset based on specified criteria.
This function searches for an array within the SDDS dataset that matches the given criteria defined by the mode
. It returns the index of the first matching array or -1
if no match is found.
The function supports the following modes:
int32_t type
, char *name
char *name
char *name
char *name
char *name
[in] | SDDS_dataset | Pointer to the SDDS_DATASET structure representing the dataset to be searched. |
[in] | mode | Specifies the mode for matching arrays. Valid modes are:
|
[in] | ... | Variable arguments depending on mode :
|
int32_t
) of the first matched array.-1
if no matching array is found.mode
.Definition at line 5344 of file SDDS_utils.c.
int32_t SDDS_VerifyColumnExists | ( | SDDS_DATASET * | SDDS_dataset, |
int32_t | mode, | ||
... ) |
Verifies the existence of a column in the SDDS dataset based on specified criteria.
This function searches for a column within the SDDS dataset that matches the given criteria defined by the mode
. It returns the index of the first matching column or -1
if no match is found.
The function supports the following modes:
int32_t type
, char *name
char *name
char *name
char *name
char *name
[in] | SDDS_dataset | Pointer to the SDDS_DATASET structure representing the dataset to be searched. |
[in] | mode | Specifies the mode for matching columns. Valid modes are:
|
[in] | ... | Variable arguments depending on mode :
|
int32_t
) of the first matched column.-1
if no matching column is found.mode
.Definition at line 5420 of file SDDS_utils.c.
int32_t SDDS_VerifyParameterExists | ( | SDDS_DATASET * | SDDS_dataset, |
int32_t | mode, | ||
... ) |
Verifies the existence of a parameter in the SDDS dataset based on specified criteria.
This function searches for a parameter within the SDDS dataset that matches the given criteria defined by the mode
. It returns the index of the first matching parameter or -1
if no match is found.
The function supports the following modes:
int32_t type
, char *name
char *name
char *name
char *name
char *name
[in] | SDDS_dataset | Pointer to the SDDS_DATASET structure representing the dataset to be searched. |
[in] | mode | Specifies the mode for matching parameters. Valid modes are:
|
[in] | ... | Variable arguments depending on mode :
|
int32_t
) of the first matched parameter.-1
if no matching parameter is found.mode
.Definition at line 5497 of file SDDS_utils.c.
int32_t SDDS_VerifyPrintfFormat | ( | const char * | string, |
int32_t | type ) |
Verifies that a printf format string is compatible with a specified data type.
This function checks whether the provided printf format string is appropriate for the given SDDS data type. It ensures that the format specifier matches the type, preventing potential formatting errors during data output.
[in] | string | The printf format string to be verified. |
[in] | type | The data type against which the format string is verified. Must be one of the SDDS type constants:
|
1
if the format string is valid for the specified type; otherwise, returns 0
and records an error message.Definition at line 750 of file SDDS_utils.c.
void SDDS_Warning | ( | char * | message | ) |
Prints a warning message to stderr
.
This function outputs a warning message to the specified FILE
stream, typically stderr
. If a program name has been registered using SDDS_RegisterProgramName
, it is included in the warning message.
[in] | message | The warning message to be printed. If NULL , a default message "?" is used. |
Definition at line 362 of file SDDS_utils.c.
int32_t SDDS_ZeroMemory | ( | void * | mem, |
int64_t | n_bytes ) |
Sets a block of memory to zero.
This function zero-initializes a specified number of bytes in a memory block. It is a wrapper around the standard memset
function, providing a convenient way to clear memory.
[in,out] | mem | Pointer to the memory block to be zeroed. |
[in] | n_bytes | The number of bytes to set to zero. |
1
on successful memory zeroing. Returns 0
if the input memory pointer mem
is NULL
.n_bytes
.Definition at line 1985 of file SDDS_utils.c.
|
static |
Definition at line 517 of file SDDS_utils.c.
|
static |
Definition at line 5175 of file SDDS_utils.c.
|
static |
Definition at line 5169 of file SDDS_utils.c.
|
static |
Definition at line 273 of file SDDS_utils.c.
|
static |
Definition at line 271 of file SDDS_utils.c.
|
static |
Definition at line 272 of file SDDS_utils.c.
|
static |
Definition at line 274 of file SDDS_utils.c.