Grassroots Infrastructure
The Grassroots Infrastructure is a suite of computing tools to help users and developers use scientific data infrastructure that can easily be interconnected.
Utility Library

General purpose code. More...

Data Structures

struct  User
 A datatype to store user credentials. More...
 
struct  UserGroup
 A datatype to store user credentials. More...
 
struct  ByteBuffer
 A datatype to allow an automatically growing buffer for appending data to. More...
 
struct  DataListNode
 A ListNode for LinkedLists that also stores arbitrary blocks of data. More...
 
struct  DoubleListNode
 A ListNode for LinkedLists that also stores an double value. More...
 
struct  HashBucket
 A datatype for holding a key-value pair along with the hashed value of the key. More...
 
struct  HashTable
 A container using HashBuckets to allow for fast lookup of key-value pairs. More...
 
struct  IntListNode
 A ListNode for LinkedLists that also stores an integer value. More...
 
struct  ListItem
 A doubly-linked node that points to its predecessor and successor. More...
 
struct  LinkedList
 A doubly-linked list that can be traversed in either direction. More...
 
struct  Iterator
 A datatype for abstracting out the method of moving from one entry in a LinkedList to the next. More...
 
struct  StringIntPair
 A datatype for holding a key-value pair where the key is a c-style string and the value is an unsigned integer. More...
 
struct  StringIntPairArray
 A datatype for storing a set of StringIntPairs. More...
 
struct  StringListNode
 A ListNode for LinkedLists that also stores a string value. More...
 
struct  DataResource
 A datatype representing a URI. More...
 
struct  FileOutputStream
 An OutputStream that writes to user-specified files. More...
 
struct  FileInformation
 A datatype to hold a collection of metadata about a file. More...
 
struct  OutputStream
 An datatype to abstract out the process of writing log and error messages to the appropriate processes and places on a given Server. More...
 
struct  JsonNode
 A datatype for storing a json_t on a LinkedList. More...
 
struct  FieldNode
 A datatype for storing a value as a string along with the datatype to convert it to. More...
 
struct  RegExp
 The module used for performing regular expressions. More...
 
struct  SchemaVersion
 This is a datatype to store the versioning details for the Grassroots JSON schema that is being used. More...
 
struct  Plugin
 A Plugin is a dynamically-loaded component to provide a piece of functionality. More...
 
struct  PluginListNode
 A ListNode for LinkedLists that also stores a plugin value. More...
 
class  AllocFailure
 A class used for memory allocation failures. More...
 

Macros

#define STM_LEVEL_NONE   (0)
 The Stream levels to use. More...
 
#define STM_LEVEL_SEVERE   (1024)
 A severe, probably terminal error. More...
 
#define STM_LEVEL_WARNING   (1025)
 A recoverable error where some functionality may be reduced. More...
 
#define STM_LEVEL_INFO   (1026)
 An general information message. More...
 
#define STM_LEVEL_FINE   (1027)
 A fine level message. More...
 
#define STM_LEVEL_FINER   (1028)
 A more finely-grained level message. More...
 
#define STM_LEVEL_FINEST   (1029)
 An even more finely-grained level message. More...
 
#define STM_LEVEL_ALL   (0xFFFFFFFF)
 Print all messages. More...
 
#define UUID_STRING_BUFFER_SIZE   (37)
 The number of bytes required to store a c-style string representation of a UUID. More...
 
#define UUID_RAW_SIZE   (16)
 The number of bytes required to store the raw data of a UUID. More...
 

Enumerations

enum  MEM_FLAG { MF_ALREADY_FREED, MF_DEEP_COPY, MF_SHALLOW_COPY, MF_SHADOW_USE }
 An enum specifying the particular status of a piece of dynamically allocated memory for a particular object. More...
 
enum  FileLocation { FILE_LOCATION_LOCAL, FILE_LOCATION_REMOTE, FILE_LOCATION_IRODS, FILE_LOCATION_UNKNOWN }
 An enum specifying whether a file is located on a local or remote filesystem. More...
 
enum  PluginStatus { PS_UNSET, PS_LOADED, PS_UNAVAILABLE, PS_CLOSING }
 The current status of a Plugin. More...
 
enum  PluginNature {
  PN_UNKNOWN = -1, PN_SERVICE, PN_CLIENT, PN_HANDLER,
  PN_JOBS_MANAGER, PN_SERVERS_MANAGER, PN_NUM_TYPES
}
 The type of module that the Plugin contains. More...
 
enum  Operation {
  OP_NONE = -1, OP_LIST_ALL_SERVICES, OP_GET_SCHEMA_VERSION, OP_LIST_INTERESTED_SERVICES,
  OP_GET_NAMED_SERVICES, OP_GET_SERVICE_RESULTS, OP_GET_RESOURCE, OP_SERVER_STATUS,
  OP_GET_SERVICE_INFO, OP_NUM_OPERATIONS
}
 The various Operations that a Server can perform. More...
 
enum  OperationStatus {
  OS_LOWER_LIMIT = -4, OS_FAILED = -3, OS_FAILED_TO_START = -2, OS_ERROR = -1,
  OS_IDLE = 0, OS_PENDING, OS_STARTED, OS_FINISHED,
  OS_PARTIALLY_SUCCEEDED, OS_SUCCEEDED, OS_CLEANED_UP, OS_UPPER_LIMIT,
  OS_NUM_STATUSES = OS_UPPER_LIMIT - OS_LOWER_LIMIT + 1
}
 The current status of an Operation. More...
 

Functions

HashTableGetHashTableOfStrings (const uint32 initial_capacity, const uint8 load_percentage)
 Create a HashTable where both the keys and values are strings. More...
 
HashTableGetHashTableOfStringInts (const uint32 initial_capacity, const uint8 load_percentage)
 Create a HashTable where the keys are strings and the values are uint32. More...
 
bool CompareStringHashBuckets (const void *const bucket_key_p, const void *const key_p)
 Compare the keys of two StringHashBuckets. More...
 
int CompareKeysAlphabetically (const void *v0_p, const void *v1_p)
 Compare two strings alphabetically. More...
 
OutputStreamerModule * AllocateStreamer (const ConfigurationManager *const config_manager_p)
 Allocate an OutputStreamerModule for writing log and error messages to named output files. More...
 
void DeallocateStreamer (OutputStreamerModule *streamer_p)
 Free an OutputStreamerModule. More...
 
char * GetFilenameOnly (const char *const full_path_to_file_s)
 Get the filename only from a given path. More...
 
char * GetPathOnly (const char *const full_path_to_file_s)
 Get the path to the parent directory only from a given path. More...
 
char * MakeFilename (const char *const path_s, const char *const filename_s)
 Construct a filename. More...
 
bool DeterminePathAndFile (const char *const full_path_s, char **const path_ss, char **const filename_ss)
 Extract the parent path and filename only from a given path. More...
 
char * SetFileExtension (const char *const filename_s, const char *const extension_s, bool replace_flag)
 Generate a new filename by adding an extension to a filename. More...
 
void UsePlatformFileSeparator (char *value_s)
 Replace any occurrences of // in a string with the platform-specific file separator. More...
 
bool IsPathValid (const char *const path_s)
 Check whether a given file/directory exists. More...
 
bool IsPathAbsolute (const char *const path_s)
 Check whether a given path is absolute. More...
 
LinkedListGetMatchingFiles (const char *const pattern_s, const bool full_path_flag)
 Get files that match a given pattern. More...
 
char GetFileSeparatorChar (void)
 Get the platform-specific file separator. More...
 
const char * GetCurrentDirectoryString (void)
 Get the platform-specific string for the current directory. More...
 
const char * GetParentDirectory (void)
 Get the platform-specific string for the parent directory. More...
 
const char * GetPluginPattern (void)
 Get the platform-specific string for the a plugin. More...
 
bool EnsureDirectoryExists (const char *const path_s)
 Makes sure that a given directory path exists. More...
 
bool CopyToNewFile (const char *const src_filename_s, const char *const dest_filename_s, void(*callback_fn)(void))
 Copy the content of one file to another. More...
 
bool SetCurrentWorkingDirectory (const char *const path_s)
 Set the current working directory. More...
 
char * GetCurrentWorkingDirectory (void)
 Get the current working directory. More...
 
char * GetHomeDirectory (void)
 Get the current user's home directory. More...
 
bool IsDirectory (const char *const path_s)
 Check whether the given path refers to a directory. More...
 
bool RemoveFile (const char *const path_s)
 Delete a file. More...
 
bool DoesFileExist (const char *const path_s)
 Check if a file/directory exists. More...
 
bool InitDefaultOutputStream (void)
 Initialise the default OutputStreams ready for use. More...
 
FileLocation GetFileLocation (const char *const filename_s)
 Determine whether a file is on the local filesystem or not. More...
 
char * CopyFileToLocalFilesystem (const char *const filename_s)
 Copy a file to the local filesystem. More...
 
char * CopyFileChunkToLocalFilesystem (const char *const filename_s, size_t offset, size_t chunk_size)
 Copy a file chunk to the local filesystem. More...
 
char * GetIntAsString (int value)
 Get a newly allocated char * with the given value. More...
 
char * GetUnsignedIntAsString (uint32 value)
 Get a newly allocated char * with the given value. More...
 
void WriteToLog (const char *log_ident_s, const int log_level, const char *message_s,...)
 Write a logging message to the given logfile. More...
 
int PrintJSON (FILE *out_f, const json_t *const json_p, const char *const prefix_s)
 Print a json fragment to a FILE pointer. More...
 
const char * GetJSONString (const json_t *json_p, const char *const key_s)
 Get the value for a given key in a json_t object. More...
 
char * GetCopiedJSONString (const json_t *json_p, const char *const key_s)
 Get the newly-allocated value for a given key in a json_t object. More...
 
bool GetJSONInteger (const json_t *json_p, const char *const key_s, json_int_t *value_p)
 Get the integer value for a given key in a json_t object. More...
 
bool GetJSONLong (const json_t *json_p, const char *const key_s, long *value_p)
 Get the long value for a given key in a json_t object. More...
 
bool GetJSONReal (const json_t *json_p, const char *const key_s, double *value_p)
 Get the double value for a given key in a json_t object. More...
 
bool GetJSONBoolean (const json_t *json_p, const char *const key_s, bool *value_p)
 Get the boolean value for a given key in a json_t object. More...
 
bool AddStringArrayToJSON (json_t *parent_p, const char **const values_ss, const char *const child_key_s)
 Create and add an array of c-style strings to a json object. More...
 
char ** GetStringArrayFromJSON (const json_t *const array_p, bool add_terminating_null_flag)
 Created an array of c-style string of StringListNodes from a json array. More...
 
bool AddStringListToJSON (json_t *parent_p, LinkedList *values_p, const char *const child_key_s)
 Create and add a LinkedList of StringListNodes to a json object. More...
 
LinkedListGetStringListFromJSON (const json_t *const array_p)
 Created a LinkedList of StringListNodes from a json array. More...
 
json_t * LoadJSONFile (const char *const filename_s)
 Load a JSON file. More...
 
json_t * ConvertTabularDataToJSON (char *data_s, const char column_delimiter, const char row_delimiter, LinkedList *headers_p)
 Convert a string of tabular data into a JSON array using the given column headings. More...
 
json_t * ConvertTabularDataWithHeadersToJSON (char *data_s, const char column_delimiter, const char row_delimiter, json_type(*get_type_fn)(const char *name_s, const void *const data_p), const void *const type_data_p)
 Convert a string of tabular data into a JSON array. More...
 
LinkedListGetTabularHeaders (char **data_ss, const char column_delimiter, const char row_delimiter, json_type(*get_type_fn)(const char *name_s, const void *const data_p), const void *const type_data_p)
 Get the column headers from the first row of a tabular data variable. More...
 
json_t * ConvertRowToJSON (char *row_s, LinkedList *headers_p, const char delimiter)
 Create a JSON object from a delimited string of data. More...
 
bool AddValidJSONString (json_t *parent_p, const char *const key_s, const char *const value_s)
 Add a string key-value pair to a JSON object only if the value is not NULL. More...
 
int PrintJSONToLog (const uint32 level, const char *filename_s, const int line_number, const json_t *json_p, const char *message_s,...)
 Print a json_t object to the logging stream. More...
 
int PrintJSONToErrors (const uint32 level, const char *filename_s, const int line_number, const json_t *json_p, const char *message_s,...)
 Print a json_t object to the error stream. More...
 
bool IsJSONEmpty (const json_t *json_p)
 Is a json_t NULL or empty? More...
 
void PrintJSONRefCounts (const uint32 log_level, const char *const filename_s, const int line_number, const json_t *const value_p, const char *initial_s)
 Print the reference counts for all of the entries in a json_t object to the logging stream. More...
 
bool SetBooleanFromJSON (const json_t *json_p, bool *value_p)
 Set the boolean value of a JSON object. More...
 
bool SetRealFromJSON (const json_t *json_p, double *value_p)
 Get the real value of a JSON object. More...
 
bool SetIntegerFromJSON (const json_t *json_p, json_int_t *value_p)
 Get the integer value of a JSON object. More...
 
bool SetLongFromJSON (const json_t *json_p, int64 *value_p)
 Get the long value of a JSON object. More...
 
bool SetStringFromJSON (const json_t *json_p, char **value_ss)
 Get the string value of a JSON object. More...
 
bool SetJSONNull (json_t *json_p, const char *const key_s)
 Add a child key to a JSON object where the value is null. More...
 
json_t * GetCompoundJSONObject (const json_t *input_p, const char *const compound_s)
 Get a descendant JSON object from another using a given selector. More...
 
bool CopyJSONKeyStringValuePair (const json_t *src_p, json_t *dest_p, const char *const key_s, bool optional_flag)
 Make a copy of given key-value pair from one JSON object to another. More...
 
bool CopyJSONKeyIntegerValuePair (const json_t *src_p, json_t *dest_p, const char *const key_s, bool optional_flag)
 Make a copy of given key-value pair from one JSON object to another. More...
 
bool DeepCopyValidJSON (const json_t *src_p, json_t **dest_pp)
 Make a deep copy of a source JSON fragment to another. More...
 
bool AddOntologyContextTerm (json_t *root_p, const char *key_s, const char *term_s, const bool add_id_flag)
 Add a "@context" section to a JSON fragment to define a class. More...
 
int CompareDoubles (const double d1, const double d2)
 Compare two doubles taking the epsilon of this computer into account. More...
 
int CompareFloats (const float f1, const float f2)
 Compare two floats taking the epsilon of this computer into account. More...
 
bool GetValidRealNumber (const char **str_pp, double64 *data_p, const char *const alternative_decimal_points_s)
 Since atof, atoi, etc. More...
 
bool GetValidInteger (const char **str_pp, int *answer_p)
 Since atof, atoi, etc. More...
 
bool GetValidLong (const char **str_pp, long *answer_p)
 Since atof, atoi, etc. More...
 
int SortDoubles (const void *v1_p, const void *v2_p)
 Compare two doubles taking the epsilon of this computer into account. More...
 
char * ConvertIntegerToString (const int32 value)
 Get an integer as a string, e.g. More...
 
char * ConvertUnsignedIntegerToString (const uint32 value)
 Get an unsigned integer as a string, e.g. More...
 
char * ConvertLongToString (const int64 value)
 Get an int64 as a string, e.g. More...
 
char * ConvertDoubleToString (const double64 value)
 Get an double as a string, e.g. More...
 
char * ConvertSizeTToString (const size_t value)
 Get an size_t as a string, e.g. More...
 
struct MappedMemory * AllocateSharedMemory (const char *id_s, size_t size, int flags)
 Allocate some memory that can shared between different processes. More...
 
bool FreeSharedMemory (struct MappedMemory *mapped_memory_p)
 Free the shared memory segment for a given id. More...
 
void * OpenSharedMemory (struct MappedMemory *mapped_memory_p, int flags)
 Open a shared memory segment. More...
 
bool CloseSharedMemory (struct MappedMemory *mapped_memory_p, void *value_p)
 Close a shared memory segment. More...
 
const char * GetOperationAsString (const Operation op)
 Get the string-based representation of a given Operation. More...
 
Operation GetOperationFromString (const char *op_s)
 Get the Operation for a given String. More...
 
const char * GetOperationStatusAsString (const OperationStatus status)
 Get the string-based representation of a given OperationStatus. More...
 
OperationStatus GetOperationStatusFromString (const char *status_s)
 Get the OperationStatus for a given String. More...
 
Operation GetOperationFromJSON (const json_t *ops_p)
 Get the Operation from a JSON fragment with a key of either OPERATION_S or OPERATION_ID_S. More...
 
bool InitPlatform (void)
 Initialise the Grassroots system for the operating system that it is running on. More...
 
void ExitPlatform (void)
 Release any operating system-specific resources. More...
 
uint32 Snooze (uint32 milliseconds)
 Sleep the current process. More...
 
char * CopyToNewString (const char *const src_p, const size_t length_to_copy, bool trim)
 Copy a string to a newly created string. More...
 
char * EasyCopyToNewString (const char *const src_s)
 Copy a string to a newly created string. More...
 
void FreeCopiedString (char *str_p)
 Delete a string previously allocated using CopyToNewString. More...
 
bool GetLineFromFile (FILE *in_f, char **buffer_pp)
 Read a line from a file with no buffer overflow issues. More...
 
void FreeLineBuffer (char *buffer_p)
 Free a buffer that has been allocated with GetLineFromFile. More...
 
LinkedListParseStringToStringLinkedList (const char *const format_p, const char *const delimiters_p, const bool treat_whitespace_as_delimiter_flag)
 Parse the format string and sort out into a linked list of tokens. More...
 
LinkedListParseStringToIntLinkedList (const char *const format_p, const char *const delimiters_p)
 Parse the format string and sort out into a linked list of IntListNodes holding the tokens as numbers. More...
 
LinkedListParseStringToDataLinkedList (const char *const format_p, const char *const delimiters_p)
 Parse the format string and sort out into a linked list of IntListNodes holding the tokens as numbers. More...
 
char * ConcatenateStrings (const char *const first_s, const char *const second_s)
 Get a newly created string that is the concatenation of two others. More...
 
void ReplaceCharacter (char *value_s, const char char_to_replace, const char replacement_char)
 Replace all instances of a character by another within a string. More...
 
bool GetKeyValuePair (char *line_p, char **key_pp, char **value_pp, const char comment_identifier)
 Get and make copies of two strings from a line of the format. More...
 
char * GetNextToken (const char **start_pp, const char *delimiters_p, const bool check_for_whitespace_flag, const bool update_position_flag)
 Get a copy of the next word from a buffer. More...
 
void FreeToken (char *token_s)
 Free a c-style string that has been returned by GetNextToken. More...
 
void NullifyTrailingZeroes (char *numeric_string_p)
 Format a string containing a number by removing all of its trailing zeroes, e.g. More...
 
bool IsStringEmpty (const char *value_s)
 Test whether a string is NULL or contains just whitespace. More...
 
int Stricmp (const char *c0_s, const char *c1_s)
 Do a case-insensitive comparison between two strings. More...
 
int Strnicmp (const char *c0_s, const char *c1_s, size_t length)
 Do a case-insensitive comparison between the initial portions of two strings. More...
 
const char * Stristr (const char *value_s, const char *substring_s)
 Find a substring within a string. More...
 
char * Strrstr (const char *haystack_s, const char *needle_s)
 Find the last occurence of a substring within a string. More...
 
bool ReplaceStringValue (char **dest_ss, const char *const src_s)
 Make a copy of a string. More...
 
void ReplaceChars (char *value_s, char old_data, char new_data)
 Replace each instance of a character within a string with another. More...
 
uint32 HashString (const void *const key_p)
 Create a numeric value for suitable for hashing from a given string. More...
 
char * GetFileContentsAsString (FILE *input_f)
 Get the contents of FILE as c-style string. More...
 
char * GetFileContentsAsStringByFilename (const char *filename_s)
 Get the contents of FILE as c-style string. More...
 
char * ConcatenateVarargsStrings (const char *value_s,...)
 Concatenate a va_list of strings. More...
 
bool DoesStringContainWhitespace (const char *value_s)
 Test whether a given string contains any whitespace characters. More...
 
bool ConvertCompactStringToTime (const char *const time_s, struct tm *time_p, int *offset_p)
 Convert a string that is of the form YYYYMMDD or YYYYMMDDhhmmss into a struct tm. More...
 
bool ConvertCompactStringToEpochTime (const char *const time_s, time_t *time_p)
 Convert a string that is of the form YYYYMMDD or YYYYMMDDhhmmss into a time_t. More...
 
bool ConvertDropboxStringToTime (const char *const time_s, struct tm *time_p, int *offset_p)
 Convert a string that is of the form "Sat, 21 Aug 2010 22:31:20 +0000" ("%a, %d %b %Y %H:%M:%S %z") into a struct tm. More...
 
bool ConvertDropboxStringToEpochTime (const char *const time_s, time_t *time_p)
 Convert a string that is of the form "Sat, 21 Aug 2010 22:31:20 +0000" ("%a, %d %b %Y %H:%M:%S %z") into a time_t. More...
 
bool GetPresentTime (struct tm *tm_p)
 Get the current time. More...
 
char * GetTimeAsString (const struct tm *const time_p, const bool include_time_flag, const char *time_delimiter_p)
 Get a time as a string in the ISO 8601 format. More...
 
bool SetTimeFromString (struct tm *const time_p, const char *time_s)
 Set the time from a string in the ISO 8601 format. More...
 
bool SetTimeFromDDMMYYYYString (struct tm *const time_p, const char *time_s)
 Set the time from a string of the form DD-MM-YYYY. More...
 
void AddIntervalToTime (struct tm *time_p, const int days)
 Add a number of days to a time. More...
 
struct tm * AllocateTime (void)
 Allocate a struct tm variable and set all of its values to 0. More...
 
void FreeTime (struct tm *time_p)
 Free a struct tm variable allocated by AllocateTime(). More...
 
void CopyTime (const struct tm *src_p, struct tm *dest_p)
 Copy the values from one struct tm to another. More...
 
struct tm * DuplicateTime (const struct tm *src_p)
 Make a deep copy of a struct tm. More...
 
void SetDateValuesForTime (struct tm *time_p, const int year, const int month, const int day)
 Set the year, month and day values for a struct tm. More...
 
int CompareDates (const struct tm *time_0_p, const struct tm *time_1_p, const bool dates_only_flag)
 Compare two dates chronologically. More...
 
char * GetUUIDAsString (const uuid_t id)
 Get the string representation of a uuid_t. More...
 
void ConvertUUIDToString (const uuid_t id, char *uuid_s)
 Convert a uuid_t into a given string buffer. More...
 
bool ConvertStringToUUID (char *id_s, uuid_t id)
 Convert the string representation of a uuid_t to a uuid_t. More...
 
void FreeUUIDString (char *uuid_s)
 Free a string representation of a uuid_t. More...
 
bool IsUUIDSet (uuid_t id)
 Test whether a uuid_t contains a valid value. More...
 
void InitFileInformation (FileInformation *info_p)
 Initialise a FileInformation ready for use. More...
 
void FreeTimeString (char *time_s)
 Free a string previsouly-generated from GetTimeAsString(). More...
 

Variables

const uint32 CURRENT_SCHEMA_VERSION_MAJOR = 0
 The current major revision of the Grassroots schema. More...
 
const uint32 CURRENT_SCHEMA_VERSION_MINOR = 10
 The current minor revision of the Grassroots schema. More...
 
const char * SO_RANGE_S = "in"
 The identifier for specifying a search for any value within a given set of values. More...
 
const char * SO_EQUALS_S = "="
 The identifier for equality search operations. More...
 
const char * SO_LESS_THAN_S = "<"
 The identifier for "less than" search operations. More...
 
const char * SO_LESS_THAN_OR_EQUALS_S = "<="
 The identifier for "less than or equals" search operations. More...
 
const char * SO_GREATER_THAN_S = ">"
 The identifier for "greater than" search operations. More...
 
const char * SO_GREATER_THAN_OR_EQUALS_S = ">="
 The identifier for "greater than or equals" search operations. More...
 
const char * SO_NOT_EQUALS_S = "!="
 The identifier for "not equals" search operations. More...
 
const char * SO_LIKE_S = "like"
 The identifier for "like" search operations. More...
 
const char * SO_CASE_INSENSITIVE_S = "insensitive"
 The identifier for specifying case-insensitive searches. More...
 

Detailed Description

General purpose code.

Macro Definition Documentation

◆ STM_LEVEL_NONE

#define STM_LEVEL_NONE   (0)

The Stream levels to use.

Do not print a message

◆ STM_LEVEL_SEVERE

#define STM_LEVEL_SEVERE   (1024)

A severe, probably terminal error.

◆ STM_LEVEL_WARNING

#define STM_LEVEL_WARNING   (1025)

A recoverable error where some functionality may be reduced.

◆ STM_LEVEL_INFO

#define STM_LEVEL_INFO   (1026)

An general information message.

◆ STM_LEVEL_FINE

#define STM_LEVEL_FINE   (1027)

A fine level message.

◆ STM_LEVEL_FINER

#define STM_LEVEL_FINER   (1028)

A more finely-grained level message.

◆ STM_LEVEL_FINEST

#define STM_LEVEL_FINEST   (1029)

An even more finely-grained level message.

◆ STM_LEVEL_ALL

#define STM_LEVEL_ALL   (0xFFFFFFFF)

Print all messages.

◆ UUID_STRING_BUFFER_SIZE

#define UUID_STRING_BUFFER_SIZE   (37)

The number of bytes required to store a c-style string representation of a UUID.

◆ UUID_RAW_SIZE

#define UUID_RAW_SIZE   (16)

The number of bytes required to store the raw data of a UUID.

Enumeration Type Documentation

◆ MEM_FLAG

enum MEM_FLAG

An enum specifying the particular status of a piece of dynamically allocated memory for a particular object.

Its use is to allow many objects to have a pointer to some memory but only one takes care of deallocating it.

Enumerator
MF_ALREADY_FREED 

The memory has already been freed so no action need be taken.

MF_DEEP_COPY 

Make a separate copy of the object pointed at by the source pointer.


MF_SHALLOW_COPY 

Use the pointer value.

We will call free on this used value. Nothing else may free this pointer.

MF_SHADOW_USE 

Use the pointer value.

We will not call free on this used value, another module must free the memory.

◆ FileLocation

An enum specifying whether a file is located on a local or remote filesystem.

Enumerator
FILE_LOCATION_LOCAL 

The file is on a local filesystem.

FILE_LOCATION_REMOTE 

The file is on a remote filesystem.

FILE_LOCATION_IRODS 
FILE_LOCATION_UNKNOWN 

The file location is unknown.

◆ PluginStatus

The current status of a Plugin.

Enumerator
PS_UNSET 

No attempt to load a plugin of this type yet.

PS_LOADED 

Plugin of this type has been loaded successfully.

PS_UNAVAILABLE 

Plugin of this type failed to previously load.

PS_CLOSING 

Plugin is in the process of closing.

◆ PluginNature

The type of module that the Plugin contains.

Enumerator
PN_UNKNOWN 

Unknown type of Plugin.

PN_SERVICE 

The Plugin creates a Service.

PN_CLIENT 

The Plugin creates a Client.

PN_HANDLER 

The Plugin creates a Handler.

PN_JOBS_MANAGER 

The Plugin creates a JobsManager.

PN_SERVERS_MANAGER 

The Plugin creates a ServersManager.

PN_NUM_TYPES 

The number of different PluginTypes.

◆ Operation

enum Operation

The various Operations that a Server can perform.

Enumerator
OP_NONE 

No specified Operation found.

OP_LIST_ALL_SERVICES 

Get list of all available services.

OP_GET_SCHEMA_VERSION 

Get the SchemaVersion that the Server is using.

OP_LIST_INTERESTED_SERVICES 

Query services to see if they can work on file.

OP_GET_NAMED_SERVICES 

Get list of services matching the given names.

OP_GET_SERVICE_RESULTS 

Get results or the status of jobs.

OP_GET_RESOURCE 

Get a requested Resource from the Server.

See also
Resource
OP_SERVER_STATUS 

Get the current status of a Server.

OP_GET_SERVICE_INFO 

Get the information for a given Service such as its name, description, config details, etc.

OP_NUM_OPERATIONS 

The number of available Operations.

◆ OperationStatus

The current status of an Operation.

Each Operation has an OperationStatus detailing its current state. Any value less than zero indicates an error with OS_LOWER_LIMIT and OS_UPPER_LIMIT defining the exclusive boundary values.

Enumerator
OS_LOWER_LIMIT 
OS_FAILED 
OS_FAILED_TO_START 
OS_ERROR 
OS_IDLE 
OS_PENDING 
OS_STARTED 
OS_FINISHED 
OS_PARTIALLY_SUCCEEDED 
OS_SUCCEEDED 
OS_CLEANED_UP 
OS_UPPER_LIMIT 
OS_NUM_STATUSES 

Function Documentation

◆ GetHashTableOfStrings()

HashTable* GetHashTableOfStrings ( const uint32  initial_capacity,
const uint8  load_percentage 
)

Create a HashTable where both the keys and values are strings.

Parameters
initial_capacityThe initial number of HashBuckets for the HashTable.
load_percentageThe percentage value for how full the HashTable should be allowed to become before it is extended.
Returns
The HashTable or NULL is there was an error.

◆ GetHashTableOfStringInts()

HashTable* GetHashTableOfStringInts ( const uint32  initial_capacity,
const uint8  load_percentage 
)

Create a HashTable where the keys are strings and the values are uint32.

Parameters
initial_capacityThe initial number of HashBuckets for the HashTable.
load_percentageThe percentage value for how full the HashTable should be allowed to become before it is extended.
Returns
The HashTable or NULL is there was an error.

◆ CompareStringHashBuckets()

bool CompareStringHashBuckets ( const void *const  bucket_key_p,
const void *const  key_p 
)

Compare the keys of two StringHashBuckets.

Parameters
bucket_key_pThe first string
key_pThe second string.
Returns
Less than zero if the first string is before the second, zero if they are identical strings and greater than zero if the first string is after the second.

◆ CompareKeysAlphabetically()

int CompareKeysAlphabetically ( const void *  v0_p,
const void *  v1_p 
)

Compare two strings alphabetically.

Parameters
v0_pA const char ** for the first string.
v1_pA const char ** for the second string.
Returns
Less than zero if the first string is before the second, zero if they are identical strings and greater than zero if the first string is after the second.

◆ AllocateStreamer()

OutputStreamerModule* AllocateStreamer ( const ConfigurationManager *const  config_manager_p)

Allocate an OutputStreamerModule for writing log and error messages to named output files.

Parameters
config_manager_pThe ConfigurationManager used to specify the details of the output filenames.
Returns
A newly-allocated OutputStreamerModule or NULL upon error.

◆ DeallocateStreamer()

void DeallocateStreamer ( OutputStreamerModule *  streamer_p)

Free an OutputStreamerModule.

Parameters
streamer_pThe OutputStreamerModule to free.

◆ GetFilenameOnly()

char* GetFilenameOnly ( const char *const  full_path_to_file_s)

Get the filename only from a given path.

Parameters
full_path_to_file_sThe full path.
Returns
A newly-allocated string containing the filename only. This will need to be freed with FreeCopiedString() to avoid a memory leak. If there was an error, then this will be NULL.

◆ GetPathOnly()

char* GetPathOnly ( const char *const  full_path_to_file_s)

Get the path to the parent directory only from a given path.

Parameters
full_path_to_file_sThe full path.
Returns
A newly-allocated string containing the full path to the parent directory only. This will need to be freed with FreeCopiedString() to avoid a memory leak. If there was an error, then this will be NULL.

◆ MakeFilename()

char* MakeFilename ( const char *const  path_s,
const char *const  filename_s 
)

Construct a filename.

This will concatenate the path and filename together inserting a platform-specific file separator if needed.

Parameters
path_sThe path to append the filename to.
filename_sThe filename to append.
Returns
A newly-allocated string containing the concatenated value which will need to be freed with FreeCopiedString() to avoid a memory leak. If there was an error, then this will be NULL.

◆ DeterminePathAndFile()

bool DeterminePathAndFile ( const char *const  full_path_s,
char **const  path_ss,
char **const  filename_ss 
)

Extract the parent path and filename only from a given path.

This will extract out the parts of path. For example this would split "foo/bar/my_file" into "foo/bar" and "my_file".

Parameters
full_path_sThe value to extract the path and filename from.
path_ssPointer to where a newly-allocated string containing the extracted path will be stored. This will need to be freed with FreeCopiedString() to avoid a memory leak
filename_ssPointer to where a newly-allocated string containing the extracted filename will be stored. This will need to be freed with FreeCopiedString() to avoid a memory leak
Returns
true if the extraction was successful false otherwise.

◆ SetFileExtension()

char* SetFileExtension ( const char *const  filename_s,
const char *const  extension_s,
bool  replace_flag 
)

Generate a new filename by adding an extension to a filename.

This will create a new filename by adding/replacing an extension on a given filename. The extension will be placed either after the last '.'in the filename or at the end of the filename if this could not be found. This behaviour is also determined by replace_flag.

Parameters
filename_sThe filename to add the extension to.
extension_sThe extension to add.
replace_flagIf this is true then any extension found on the filename will be replaced. If this is false then the extension will get concatenated to the end of the filename.
Returns
A newly-allocated string containing the new value which will need to be freed with FreeCopiedString() to avoid a memory leak. If there was an error, then this will be NULL.

◆ UsePlatformFileSeparator()

void UsePlatformFileSeparator ( char *  value_s)

Replace any occurrences of // in a string with the platform-specific file separator.

Parameters
value_sThe string to be amended.

◆ IsPathValid()

bool IsPathValid ( const char *const  path_s)

Check whether a given file/directory exists.

Parameters
path_sThe path to check.
Returns
true if the object referred to by the path exists, false otherwise.

◆ IsPathAbsolute()

bool IsPathAbsolute ( const char *const  path_s)

Check whether a given path is absolute.

Parameters
path_sThe path to check.
Returns
true if the path is absolute, false otherwise.

◆ GetMatchingFiles()

LinkedList* GetMatchingFiles ( const char *const  pattern_s,
const bool  full_path_flag 
)

Get files that match a given pattern.

Parameters
pattern_sThe path including the pattern.
full_path_flagIf this is true then the full path to matching files will be stored. If it is false then only the local filenames will be stored.
Returns
A LinkedList of StringListNode containing the matching filenames or NULL if no matches could be found.

◆ GetFileSeparatorChar()

char GetFileSeparatorChar ( void  )

Get the platform-specific file separator.

Get the character used between directories in a path e.g // on Unix, Amiga, etc., \ on Windows.

Returns
The separator

◆ GetCurrentDirectoryString()

const char* GetCurrentDirectoryString ( void  )

Get the platform-specific string for the current directory.

For example .// on Unix, . on Windows.

Returns
The string for the current directory.

◆ GetParentDirectory()

const char* GetParentDirectory ( void  )

Get the platform-specific string for the parent directory.

For example ..// on Unix, ..\ on Windows.

Returns
The string for the parent directory.

◆ GetPluginPattern()

const char* GetPluginPattern ( void  )

Get the platform-specific string for the a plugin.

For example lib*.so on Unix, *.dll on Windows.

Returns
The string for the plugin pattern.

◆ EnsureDirectoryExists()

bool EnsureDirectoryExists ( const char *const  path_s)

Makes sure that a given directory path exists.

Parameters
path_sThe path to check. It can be an arbitrary number of levels deep.
Returns
true if the path already exists. If not, the all of directories will attempt to be created. If this succeed then true will be returned, false otherwise.

◆ CopyToNewFile()

bool CopyToNewFile ( const char *const  src_filename_s,
const char *const  dest_filename_s,
void(*)(void)  callback_fn 
)

Copy the content of one file to another.

Parameters
src_filename_sThe name of the file to copy from.
dest_filename_sThe name of the file to copy to.
callback_fnAn optional callback function for monitoring progress with.
Returns
true if the copy was successful false otherwise.

◆ SetCurrentWorkingDirectory()

bool SetCurrentWorkingDirectory ( const char *const  path_s)

Set the current working directory.

Parameters
path_sThe path to set.
Returns
true if the change was successful false otherwise.

◆ GetCurrentWorkingDirectory()

char* GetCurrentWorkingDirectory ( void  )

Get the current working directory.

Returns
The current working directory.

◆ GetHomeDirectory()

char* GetHomeDirectory ( void  )

Get the current user's home directory.

Returns
The current user's home directory or NULL upon error. When no longer needed, this value should be freed using FreeCopiedString ().

◆ IsDirectory()

bool IsDirectory ( const char *const  path_s)

Check whether the given path refers to a directory.

Parameters
path_sThe path to check.
Returns
true if the path exists and is a directory, false otherwise.

◆ RemoveFile()

bool RemoveFile ( const char *const  path_s)

Delete a file.

Parameters
path_sThe name of the file to delete.
Returns
true if the file was deleted successfully, false otherwise.

◆ DoesFileExist()

bool DoesFileExist ( const char *const  path_s)

Check if a file/directory exists.

Parameters
path_sThe name of the file/directory to check.
Returns
true if it exists, false otherwise.

◆ InitDefaultOutputStream()

bool InitDefaultOutputStream ( void  )

Initialise the default OutputStreams ready for use.

This should be called when starting up a Server.

Returns
true if the initialisation was succesful, false otherwise.

◆ GetFileLocation()

FileLocation GetFileLocation ( const char *const  filename_s)

Determine whether a file is on the local filesystem or not.

Parameters
filename_sThe file to check.
Returns
The type of location of the file or FILE_LOCATION_UNKNOWN if it could not be determined.

◆ CopyFileToLocalFilesystem()

char* CopyFileToLocalFilesystem ( const char *const  filename_s)

Copy a file to the local filesystem.

Parameters
filename_sThe name of the the source file.
Returns
true on success, false on error with errno set to the appropriate value.

◆ CopyFileChunkToLocalFilesystem()

char* CopyFileChunkToLocalFilesystem ( const char *const  filename_s,
size_t  offset,
size_t  chunk_size 
)

Copy a file chunk to the local filesystem.

Parameters
filename_sThe name of the the source file.
offsetThe byte offset to start copying from.
chunk_sizeThe size of the chunk to copy.
Returns
true on success, false on error with errno set to the appropriate value.

◆ GetIntAsString()

char* GetIntAsString ( int  value)

Get a newly allocated char * with the given value.

Parameters
valueThe value to print into the the newly allocated string.
Returns
The string with the given value or NULL upon error.

◆ GetUnsignedIntAsString()

char* GetUnsignedIntAsString ( uint32  value)

Get a newly allocated char * with the given value.

Parameters
valueThe value to print into the the newly allocated string.
Returns
The string with the given value or NULL upon error.

◆ WriteToLog()

void WriteToLog ( const char *  log_ident_s,
const int  log_level,
const char *  message_s,
  ... 
)

Write a logging message to the given logfile.

Parameters
log_ident_sThe logfile identifer to use. If this is NULL then "slog" will be used.
log_levelOne of the levels defined in syslog.h:
  • LOG_EMERG: The message says the system is unusable.
  • LOG_ALERT: Action on the message must be taken immediately.
  • LOG_CRIT: The message states a critical condition.
  • LOG_ERR: The message describes an error.
  • LOG_WARNING: The message is a warning.
  • LOG_NOTICE: The message describes a normal but important event.
  • LOG_INFO: The message is purely informational.
  • LOG_DEBUG
Parameters
message_sThe string to write using standard c printf syntax.

◆ PrintJSON()

int PrintJSON ( FILE *  out_f,
const json_t *const  json_p,
const char *const  prefix_s 
)

Print a json fragment to a FILE pointer.

Parameters
out_fThe FILE to print to.
json_pThe json object to print.
prefix_sAn optional string to precede the json output in the given FILE.
Returns
O if successful, less than 0 upon error.

◆ GetJSONString()

const char* GetJSONString ( const json_t *  json_p,
const char *const  key_s 
)

Get the value for a given key in a json_t object.

Parameters
json_pThe json object to query.
key_sThe key to search for.
Returns
The corresponding value or NULL if the key does not exist in the given json_t object.

◆ GetCopiedJSONString()

char* GetCopiedJSONString ( const json_t *  json_p,
const char *const  key_s 
)

Get the newly-allocated value for a given key in a json_t object.

Parameters
json_pThe json object to query.
key_sThe key to search for.
Returns
A newly-allocated copy of the corresponding value or NULL if the key does not exist in the given json_t object or failed to be copied. This value, if valid, should be freed with FreeCopiedString().

◆ GetJSONInteger()

bool GetJSONInteger ( const json_t *  json_p,
const char *const  key_s,
json_int_t *  value_p 
)

Get the integer value for a given key in a json_t object.

Parameters
json_pThe json object to query.
key_sThe key to search for.
value_pWhere the corresponding value will be stored if the key exists and relates to an int.
Returns
true if the value was retrieved successfully, false otherwise.

◆ GetJSONLong()

bool GetJSONLong ( const json_t *  json_p,
const char *const  key_s,
long *  value_p 
)

Get the long value for a given key in a json_t object.

Parameters
json_pThe json object to query.
key_sThe key to search for.
value_pWhere the corresponding value will be stored if the key exists and relates to an int.
Returns
true if the value was retrieved successfully, false otherwise.

◆ GetJSONReal()

bool GetJSONReal ( const json_t *  json_p,
const char *const  key_s,
double *  value_p 
)

Get the double value for a given key in a json_t object.

Parameters
json_pThe json object to query.
key_sThe key to search for.
value_pWhere the corresponding value will be stored if the key exists and relates to a double.
Returns
true if the value was retrieved successfully, false otherwise.

◆ GetJSONBoolean()

bool GetJSONBoolean ( const json_t *  json_p,
const char *const  key_s,
bool *  value_p 
)

Get the boolean value for a given key in a json_t object.

Parameters
json_pThe json object to query.
key_sThe key to search for.
value_pWhere the corresponding value will be stored if the key exists and relates to a boolean.
Returns
true if the value was retrieved successfully, false otherwise.

◆ AddStringArrayToJSON()

bool AddStringArrayToJSON ( json_t *  parent_p,
const char **const  values_ss,
const char *const  child_key_s 
)

Create and add an array of c-style strings to a json object.

Parameters
parent_pThe json_t object to add the array to.
values_ssThe array of c-style strings with a final element set to NULL.
child_key_sThe key to use to add the json array to parent_p.
Returns
true if the json_array was created and added successfully, false otherwise.

◆ GetStringArrayFromJSON()

char** GetStringArrayFromJSON ( const json_t *const  array_p,
bool  add_terminating_null_flag 
)

Created an array of c-style string of StringListNodes from a json array.

Parameters
array_pThe json_t array to create the c-style strings array from.
Returns
The array of c-style strings or NULL if array_p is an empty array or if there was an error.

◆ AddStringListToJSON()

bool AddStringListToJSON ( json_t *  parent_p,
LinkedList values_p,
const char *const  child_key_s 
)

Create and add a LinkedList of StringListNodes to a json object.

Parameters
parent_pThe json_t object to add the array to.
values_pThe LinkedList of StringListNodes.
child_key_sThe key to use to add the json array to parent_p.
Returns
true if the json_array was created and added successfully, false otherwise.

◆ GetStringListFromJSON()

LinkedList* GetStringListFromJSON ( const json_t *const  array_p)

Created a LinkedList of StringListNodes from a json array.

Parameters
array_pThe json_t object to generate the list from.
Returns
The LinkedList of StringListNodes or NULL if array_p is an empty array or if there was an error.

◆ LoadJSONFile()

json_t* LoadJSONFile ( const char *const  filename_s)

Load a JSON file.

Parameters
filename_sThe filename to load.
Returns
The resultant JSON fragment or NULL upon errors such as the file being unable to be read or not a JSON file.

◆ ConvertTabularDataToJSON()

json_t* ConvertTabularDataToJSON ( char *  data_s,
const char  column_delimiter,
const char  row_delimiter,
LinkedList headers_p 
)

Convert a string of tabular data into a JSON array using the given column headings.

Parameters
data_sThe string of data to convert.
column_delimiterThe character used to separate the data into columns.
row_delimiterThe character used to separate the data into rows.
headers_pA LinkedList of FieldNodes where specifying the headers for each column of data.
Returns
The tabular data as a JSON array with each child object containing the data for a row with the keys being the header values or NULL upon error.

◆ ConvertTabularDataWithHeadersToJSON()

json_t* ConvertTabularDataWithHeadersToJSON ( char *  data_s,
const char  column_delimiter,
const char  row_delimiter,
json_type(*)(const char *name_s, const void *const data_p)  get_type_fn,
const void *const  type_data_p 
)

Convert a string of tabular data into a JSON array.

This effectively is a wrapper for calling GetTabularHeaders and ConvertTabularDataToJSON.

Parameters
data_sThe string of data to convert.
column_delimiterThe character used to separate the data into columns.
row_delimiterThe character used to separate the data into rows.
get_type_fnA function used to determine the datatype for each of the header values. If this is NULL, then each value will be treated as a string.
type_data_pIf get_type_fn needs any extra data, it can be passed in here.
Returns
The tabular data as a JSON array with each child object containing the data for a row with the keys being the header values or NULL upon error.

◆ GetTabularHeaders()

LinkedList* GetTabularHeaders ( char **  data_ss,
const char  column_delimiter,
const char  row_delimiter,
json_type(*)(const char *name_s, const void *const data_p)  get_type_fn,
const void *const  type_data_p 
)

Get the column headers from the first row of a tabular data variable.

Parameters
data_ssA pointer to the tabular data. If the headers get retrieved successfully then the value that this points to will get incremented to the first row of data.
column_delimiterThe character used to separate the data into columns.
row_delimiterThe character used to separate the data into rows.
get_type_fnA function used to determine the datatype for each of the header values. If this is NULL, then each value will be treated as a string.
type_data_pIf get_type_fn needs any extra data, it can be passed in here.
Returns
A LinkedList of FieldNodes with each one containing a header value or NULL upon error.

◆ ConvertRowToJSON()

json_t* ConvertRowToJSON ( char *  row_s,
LinkedList headers_p,
const char  delimiter 
)

Create a JSON object from a delimited string of data.

Parameters
row_sThe delimited data for a single row.
headers_pThe LinkedList of FieldNodes defining the column titles.
delimiterThe column delimiter.
Returns
The JSON object containing the data from headers_p as the keys and the data from row_s as the values or NULL upon error.

◆ AddValidJSONString()

bool AddValidJSONString ( json_t *  parent_p,
const char *const  key_s,
const char *const  value_s 
)

Add a string key-value pair to a JSON object only if the value is not NULL.

Parameters
parent_pThe JSON object that the key-value pair will be added to.
key_sThe key to use.
value_sThe value to use.
Returns
true if value_s is not NULL and the key-value pair were added successfully or if value_s is NULL. If value_s points to valid data and the key-value pair fails to get added, false will be returned.

◆ PrintJSONToLog()

int PrintJSONToLog ( const uint32  level,
const char *  filename_s,
const int  line_number,
const json_t *  json_p,
const char *  message_s,
  ... 
)

Print a json_t object to the logging stream.

Parameters
json_pThe json_t object to print.
levelThe logging level to use.
filename_sThe filename of the source file calling this method.
line_numberThe line number in the source file which called this method.
message_sA char * using the same format as printf, etc.
Returns
The number of characters written or a negative number upon error.
See also
PrintLog

◆ PrintJSONToErrors()

int PrintJSONToErrors ( const uint32  level,
const char *  filename_s,
const int  line_number,
const json_t *  json_p,
const char *  message_s,
  ... 
)

Print a json_t object to the error stream.

Parameters
json_pThe json_t object to print.
levelThe logging level to use.
filename_sThe filename of the source file calling this method.
line_numberThe line number in the source file which called this method.
message_sA char * using the same format as printf, etc.
Returns
The number of characters written or a negative number upon error.
See also
PrintErrors

◆ IsJSONEmpty()

bool IsJSONEmpty ( const json_t *  json_p)

Is a json_t NULL or empty?

Parameters
json_pThe json_t object to test.
Returns
true if the json_t is NULL, an empty array, an empty object or an empty string, false otherwise.
See also
IsStringEmpty

◆ PrintJSONRefCounts()

void PrintJSONRefCounts ( const uint32  log_level,
const char *const  filename_s,
const int  line_number,
const json_t *const  value_p,
const char *  initial_s 
)

Print the reference counts for all of the entries in a json_t object to the logging stream.

Parameters
value_pThe json_t object to print.
initial_sAn optional message to print to the log prior to parsing the value's reference counts. If this is NULL, then no message will be printed.
log_levelThe logging level to use.
filename_sThe filename of the source file calling this method.
line_numberThe line number in the source file which called this method.
See also
PrintLog

◆ SetBooleanFromJSON()

bool SetBooleanFromJSON ( const json_t *  json_p,
bool *  value_p 
)

Set the boolean value of a JSON object.

Parameters
json_pThe JSON value to get the boolean value from.
value_pPointer to where the boolean value will be stored if it is successfully retrieved.
Returns
true if the value was successfully retrieved. If the JSON value is not a boolean type false will be returned.

◆ SetRealFromJSON()

bool SetRealFromJSON ( const json_t *  json_p,
double *  value_p 
)

Get the real value of a JSON object.

Parameters
json_pThe JSON value to get the real value from.
value_pPointer to where the real value will be stored if it is successfully retrieved.
Returns
true if the value was successfully retrieved. If the JSON value is not a real type false will be returned.

◆ SetIntegerFromJSON()

bool SetIntegerFromJSON ( const json_t *  json_p,
json_int_t *  value_p 
)

Get the integer value of a JSON object.

Parameters
json_pThe JSON value to get the integer value from.
value_pPointer to where the integer value will be stored if it is successfully retrieved.
Returns
true if the value was successfully retrieved. If the JSON value is not a integer type false will be returned.

◆ SetLongFromJSON()

bool SetLongFromJSON ( const json_t *  json_p,
int64 *  value_p 
)

Get the long value of a JSON object.

Parameters
json_pThe JSON value to get the long value from.
value_pPointer to where the long value will be stored if it is successfully retrieved.
Returns
true if the value was successfully retrieved. If the JSON value is not a long type false will be returned.

◆ SetStringFromJSON()

bool SetStringFromJSON ( const json_t *  json_p,
char **  value_ss 
)

Get the string value of a JSON object.

Parameters
json_pThe JSON value to get the boolean value from.
value_ssPointer to where the string value will be copied to if it is successfully retrieved.
Returns
true if the value was successfully retrieved and copied. If the JSON value is not a string type or the memory for copying the string value could not be allocated then false will be returned.

◆ SetJSONNull()

bool SetJSONNull ( json_t *  json_p,
const char *const  key_s 
)

Add a child key to a JSON object where the value is null.

Parameters
json_pThe JSON object to add the vaue to.
key_sThe key for the child object.
Returns
true if the value was successfully added, false otherwise.

◆ GetCompoundJSONObject()

json_t* GetCompoundJSONObject ( const json_t *  input_p,
const char *const  compound_s 
)

Get a descendant JSON object from another using a given selector.

Parameters
input_pThe JSON object to get the value from
compound_sThe selector value using a dot notation. For example "foo.bar" would search for a "bar" child key belonging to a "foo" child object of the input value.
Returns
The found JSON object or NULL if it could not be found.

◆ CopyJSONKeyStringValuePair()

bool CopyJSONKeyStringValuePair ( const json_t *  src_p,
json_t *  dest_p,
const char *const  key_s,
bool  optional_flag 
)

Make a copy of given key-value pair from one JSON object to another.

The value is a string.

Parameters
src_pThe JSON object to get the value from.
dest_pThe JSON object to copy the values to.
key_sThe key to search for in the input JSON and uses as the key in the output JSON.
optional_flagIf true the function will return true if the key was missing in the input object. If false then this will make the function return false when the input object does not contain the key.
Returns
true upon success, false upon failure.

◆ CopyJSONKeyIntegerValuePair()

bool CopyJSONKeyIntegerValuePair ( const json_t *  src_p,
json_t *  dest_p,
const char *const  key_s,
bool  optional_flag 
)

Make a copy of given key-value pair from one JSON object to another.

The value is an integer.

Parameters
src_pThe JSON object to get the value from.
dest_pThe JSON object to copy the values to.
key_sThe key to search for in the input JSON and uses as the key in the output JSON.
optional_flagIf true the function will return true if the key was missing in the input object. If false then this will make the function return false when the input object does not contain the key.
Returns
true upon success, false upon failure.

◆ DeepCopyValidJSON()

bool DeepCopyValidJSON ( const json_t *  src_p,
json_t **  dest_pp 
)

Make a deep copy of a source JSON fragment to another.

Parameters
src_pThe JSON object to copy.
dest_ppA pointer to where the copied JSON fragment will be stored upon success
Returns
true upon success, false upon failure.

◆ AddOntologyContextTerm()

bool AddOntologyContextTerm ( json_t *  root_p,
const char *  key_s,
const char *  term_s,
const bool  add_id_flag 
)

Add a "@context" section to a JSON fragment to define a class.

For example

AddOntologyContextTerm (dest_context_p, "so", "http://schema.org", false)

would result in a "@context" object in the gicen JSON fragment of

"@context": { .... "so:": "http://schema.org/" }

and

AddOntologyContextTerm (dest_context_p, "season", "http://purl.obolibrary.org/obo/PECO_0007027", true)

would result in a "@context" object in the gicen JSON fragment of

"@context": { .... "season": { "@context": "http://purl.obolibrary.org/obo/PECO_0007027", "@type": "@id" } }

Parameters
root_pThe JSON fragment to add the ontology term to.
key_sThe key that the ontology term will have in the given JSON fragment.
term_sThe term to add.
add_id_flagIf this is true then the term will be treated as a specific class instance and will have "@type": "@id" added to the JSON fragment for the term.
Returns
true upon success, false upon failure.

◆ CompareDoubles()

int CompareDoubles ( const double  d1,
const double  d2 
)

Compare two doubles taking the epsilon of this computer into account.

Parameters
d1The first double to compare.
d2The second double to compare.
Returns
-1 if d1 is less than d2, +1 if d1 is greater than d2 and 0 if they are identical.

◆ CompareFloats()

int CompareFloats ( const float  f1,
const float  f2 
)

Compare two floats taking the epsilon of this computer into account.

Parameters
f1The first float to compare.
f2The second float to compare.
Returns
-1 if f1 is less than f2, +1 if f1 is greater than f2 and 0 if they are identical.

◆ GetValidRealNumber()

bool GetValidRealNumber ( const char **  str_pp,
double64 *  data_p,
const char *const  alternative_decimal_points_s 
)

Since atof, atoi, etc.

return 0 on error we need to do our own "number getting" routine that notifies us of any errors.

Parameters
str_ppPointer to char * where we start getting the number from.
data_pPointer where the number will be stored if the conversion was successful.
alternative_decimal_points_sAn array of characters to consider as decimal points which may be the case in different locales. If this is NULL then a "." will be used.
Returns
true if the conversion was successful, false otherwise.

◆ GetValidInteger()

bool GetValidInteger ( const char **  str_pp,
int *  answer_p 
)

Since atof, atoi, etc.

return 0 on error we need to do our own "number getting" routine that notifies us of any errors.

Parameters
str_ppPointer to char * where we start getting the number from.
answer_pPointer where the number will be stored if the conversion was successful.
Returns
true if the conversion was successful, false otherwise.

◆ GetValidLong()

bool GetValidLong ( const char **  str_pp,
long *  answer_p 
)

Since atof, atoi, etc.

return 0 on error we need to do our own "number getting" routine that notifies us of any errors.

Parameters
str_ppPointer to char * where we start getting the number from.
answer_pPointer where the number will be stored if the conversion was successful.
Returns
TRUE if the conversion was successful, FALSE otherwise.

◆ SortDoubles()

int SortDoubles ( const void *  v1_p,
const void *  v2_p 
)

Compare two doubles taking the epsilon of this computer into account.

Parameters
v1_pPointer to the first double to compare.
v2_pPointer to the second double to compare.
Returns
-1 if the first double is less than the second, +1 if the first double is greater than the second and 0 if they are identical.

◆ ConvertIntegerToString()

char* ConvertIntegerToString ( const int32  value)

Get an integer as a string, e.g.

1 would be converted to "1"

Parameters
valueThe value to convert to a string.
Returns
The c-style string or NULL upon error. This needs to be freed using FreeCopiedString().

◆ ConvertUnsignedIntegerToString()

char* ConvertUnsignedIntegerToString ( const uint32  value)

Get an unsigned integer as a string, e.g.

1 would be converted to "1"

Parameters
valueThe value to convert to a string.
Returns
The c-style string or NULL upon error. This needs to be freed using FreeCopiedString().

◆ ConvertLongToString()

char* ConvertLongToString ( const int64  value)

Get an int64 as a string, e.g.

1 would be converted to "1"

Parameters
valueThe value to convert to a string.
Returns
The c-style string or NULL upon error. This needs to be freed using FreeCopiedString().

◆ ConvertDoubleToString()

char* ConvertDoubleToString ( const double64  value)

Get an double as a string, e.g.

1.03 would be converted to "1.03"

Parameters
valueThe value to convert to a string.
Returns
The c-style string or NULL upon error. This needs to be freed using FreeCopiedString().

◆ ConvertSizeTToString()

char* ConvertSizeTToString ( const size_t  value)

Get an size_t as a string, e.g.

1 would be converted to "1"

Parameters
valueThe value to convert to a string.
Returns
The c-style string or NULL upon error. This needs to be freed using FreeCopiedString().

◆ AllocateSharedMemory()

struct MappedMemory* AllocateSharedMemory ( const char *  id_s,
size_t  size,
int  flags 
)

Allocate some memory that can shared between different processes.

Parameters
id_sAn identifier that will be used to access the shared memory segment if it is successfully allocated.
sizeThe size of the requested segment in bytes.
flagsThe permissions for the owner, group and world permissions in standard unix format e.g. 0644 for owner to have read and write permissions whilst everyone else having read permissions.
Returns
The segment identifier for the shared memory segment or -1 upon error.

◆ FreeSharedMemory()

bool FreeSharedMemory ( struct MappedMemory *  mapped_memory_p)

Free the shared memory segment for a given id.

Parameters
idThe segment identifier for the shared memory segment to free.
Returns
true if the memory segment was freed successfully, false otherwise.

◆ OpenSharedMemory()

void* OpenSharedMemory ( struct MappedMemory *  mapped_memory_p,
int  flags 
)

Open a shared memory segment.

Parameters
idThe segment identifier for the shared memory segment to open.
flagsThis can be SHM_RDONLY for read-only memory.
Returns
The pointer to the shared memory to be used or NULL upon error.

◆ CloseSharedMemory()

bool CloseSharedMemory ( struct MappedMemory *  mapped_memory_p,
void *  value_p 
)

Close a shared memory segment.

Parameters
value_pThe shared memory segment.
Returns
true if the memory segment was closed successfully, false otherwise.

◆ GetOperationAsString()

const char* GetOperationAsString ( const Operation  op)

Get the string-based representation of a given Operation.

Parameters
opThe Operation to get the string-based representation of.
Returns
The string-based representation.

◆ GetOperationFromString()

Operation GetOperationFromString ( const char *  op_s)

Get the Operation for a given String.

Parameters
op_sThe string to get the Operation for.
Returns
The Operation or Operation::OP_NONE if the string did not match a valid operation string.

◆ GetOperationStatusAsString()

const char* GetOperationStatusAsString ( const OperationStatus  status)

Get the string-based representation of a given OperationStatus.

Parameters
statusThe OperationStatus to get the string-based representation of.
Returns
The string-based representation.

◆ GetOperationStatusFromString()

OperationStatus GetOperationStatusFromString ( const char *  status_s)

Get the OperationStatus for a given String.

Parameters
status_sThe string to get the OperationStatus for.
Returns
The OperationStatus.

◆ GetOperationFromJSON()

Operation GetOperationFromJSON ( const json_t *  ops_p)

Get the Operation from a JSON fragment with a key of either OPERATION_S or OPERATION_ID_S.

Parameters
ops_pThe JSON fragment to get the Operation from.
Returns
The Operation or OP_NONE if it could not be retrieved successfully.

◆ InitPlatform()

bool InitPlatform ( void  )

Initialise the Grassroots system for the operating system that it is running on.

Returns
true if the value was converted successfully, false otherwise.

◆ ExitPlatform()

void ExitPlatform ( void  )

Release any operating system-specific resources.

◆ Snooze()

uint32 Snooze ( uint32  milliseconds)

Sleep the current process.

Parameters
millisecondsThe number of milliseconds to sleep for.
Returns
0 if the process slept for the required time, or the number of milliseconds remaining if it was interrupted.

◆ CopyToNewString()

char* CopyToNewString ( const char *const  src_p,
const size_t  length_to_copy,
bool  trim 
)

Copy a string to a newly created string.

Parameters
src_pThe string to copy.
length_to_copyIf this is greater than zero, copy this many characters from src_p or its entirety, whichever is smaller. If this is zero or less then all of src_p is copied.
trimWhether to trim left and right trailing whitespace or not.
Returns
A newly allocated copy of the source string or NULL if there was an error. If the string was successfully created, its deallocation must be done with FreeCopiedString() when you are finished with it.

◆ EasyCopyToNewString()

char* EasyCopyToNewString ( const char *const  src_s)

Copy a string to a newly created string.

This calls CopyToNewString() with length_to_copy set to the length of the source string and trim set to false.

Parameters
src_she string to copy.
Returns
A newly allocated copy of the source string or NULL if there was an error. If the string was successfully created, its deallocation must be done with FreeCopiedString() when you are finished with it.

◆ FreeCopiedString()

void FreeCopiedString ( char *  str_p)

Delete a string previously allocated using CopyToNewString.

Parameters
str_pThe string to deallocate. This is checked for being NULL in which case this function becomes a no-op routine.

◆ GetLineFromFile()

bool GetLineFromFile ( FILE *  in_f,
char **  buffer_pp 
)

Read a line from a file with no buffer overflow issues.

Parameters
in_fThe File to read from.
buffer_ppPointer to a buffer string where the line will get written to. After being used, *buffer_pp muet be freed.
Returns
TRUE if the line was read successfully, false if there was an error.

◆ FreeLineBuffer()

void FreeLineBuffer ( char *  buffer_p)

Free a buffer that has been allocated with GetLineFromFile.

Parameters
buffer_pPointer to a buffer to be freed.

◆ ParseStringToStringLinkedList()

LinkedList* ParseStringToStringLinkedList ( const char *const  format_p,
const char *const  delimiters_p,
const bool  treat_whitespace_as_delimiter_flag 
)

Parse the format string and sort out into a linked list of tokens.

Parameters
format_pThe format string to use.
delimiters_pA custom array of characters to use to separate the tokens in format_p. If this NULL then whitespace will be used to delimit the tokens.
treat_whitespace_as_delimiter_flagIf TRUE whitespace will be treated as a delimiter.
Returns
A pointer to a StringLinkedList where each node refers to a token or NULL upon error.

◆ ParseStringToIntLinkedList()

LinkedList* ParseStringToIntLinkedList ( const char *const  format_p,
const char *const  delimiters_p 
)

Parse the format string and sort out into a linked list of IntListNodes holding the tokens as numbers.

Parameters
format_pThe format string to use.
delimiters_pA custom array of characters to use to separate the tokens in format_p. If this NULL then whitespace will be used to delimit the tokens.
Returns
A pointer to a IntLinkedList where each node refers to a token or NULL upon error.

◆ ParseStringToDataLinkedList()

LinkedList* ParseStringToDataLinkedList ( const char *const  format_p,
const char *const  delimiters_p 
)

Parse the format string and sort out into a linked list of IntListNodes holding the tokens as numbers.

Parameters
format_pThe format string to use.
delimiters_pA custom array of characters to use to separate the tokens in format_p. If this NULL then whitespace will be used to delimit the tokens.
Returns
A pointer to a IntLinkedList where each node refers to a token or NULL upon error.

◆ ConcatenateStrings()

char* ConcatenateStrings ( const char *const  first_s,
const char *const  second_s 
)

Get a newly created string that is the concatenation of two others.

Parameters
first_sThe first string to concatenate.
second_sThe second string to concatenate.
Returns
The newly created string or NULL if there was an error.

◆ ReplaceCharacter()

void ReplaceCharacter ( char *  value_s,
const char  char_to_replace,
const char  replacement_char 
)

Replace all instances of a character by another within a string.

Parameters
value_sThe string to be altered.
char_to_replaceThe character to replace.
replacement_charThe replacement character.

◆ GetKeyValuePair()

bool GetKeyValuePair ( char *  line_p,
char **  key_pp,
char **  value_pp,
const char  comment_identifier 
)

Get and make copies of two strings from a line of the format.

key string = value string

Parameters
line_pThe string to get the values from.
key_ppPointer to a new string where the key will be stored upon success.
value_ppPointer to a new string where the value will be stored upon success.
comment_identifierIf the line begins with this charcter then treat the whole line as a comment and do not try to get the key and value.
Returns
TRUE if the key and values were successfully copied, FALSE otherwise.

◆ GetNextToken()

char* GetNextToken ( const char **  start_pp,
const char *  delimiters_p,
const bool  check_for_whitespace_flag,
const bool  update_position_flag 
)

Get a copy of the next word from a buffer.

Parameters
start_ppAddress of the buffer to read from.
delimiters_pAn array of characters that can be used as delimiters. If this is NULL then the behvaiour is determined by check_for_whitespace_flag.
check_for_whitespace_flag
update_position_flagIf this is set to true, then the address pointed to by start_pp will be updated to after the token.
Returns
A copied version of the string or NULL if there was an error or no more tokens were available.
See also
FreeToken

◆ FreeToken()

void FreeToken ( char *  token_s)

Free a c-style string that has been returned by GetNextToken.

Parameters
token_sThe token to free.
See also
GetNextToken

◆ NullifyTrailingZeroes()

void NullifyTrailingZeroes ( char *  numeric_string_p)

Format a string containing a number by removing all of its trailing zeroes, e.g.

7.0000 would become 7 7.5000 would become 7.5

Parameters
numeric_string_pThe string to formatted.

◆ IsStringEmpty()

bool IsStringEmpty ( const char *  value_s)

Test whether a string is NULL or contains just whitespace.

Parameters
value_sThe string to test.
Returns
true If the string is NULL or just whitespace, false otherwise.

◆ Stricmp()

int Stricmp ( const char *  c0_s,
const char *  c1_s 
)

Do a case-insensitive comparison between two strings.

This is a case-insensitive version of the standard ANSI function strcmp.

Parameters
c0_sThe first string.
c1_sThe second string.
Returns
Less than zero if the first string is less than the second, greater than zero if the first string is greater than the second and zero if the strings match.

◆ Strnicmp()

int Strnicmp ( const char *  c0_s,
const char *  c1_s,
size_t  length 
)

Do a case-insensitive comparison between the initial portions of two strings.

This is a case-insensitive version of the standard ANSI function strncmp.

Parameters
c0_sThe first string.
c1_sThe second string.
lengthThe maximum number of characters in each string to compare.
Returns
Less than zero if the first string is less than the second, greater than zero if the first string is greater than the second and zero if the strings match.

◆ Stristr()

const char* Stristr ( const char *  value_s,
const char *  substring_s 
)

Find a substring within a string.

The search is case-insensitive. This is a case-insensitive version of the standard ANSI function strstr.

Parameters
value_sThe string to search within.
substring_sThe string to search for
Returns
The substring within the larger string or NULL if it was not found.

◆ Strrstr()

char* Strrstr ( const char *  haystack_s,
const char *  needle_s 
)

Find the last occurence of a substring within a string.

Parameters
haystack_sThe string to search within.
needle_sThe string to search for
Returns
The substring within the larger string or NULL if it was not found.

◆ ReplaceStringValue()

bool ReplaceStringValue ( char **  dest_ss,
const char *const  src_s 
)

Make a copy of a string.

Parameters
dest_ssPointer to the string where the source string will be copied to.
src_sThe string to copy.
Returns
true if successful, false otherwise. If successful, any string that dest_ss currently points to will be freed prior to pointing at the copy. If the function is unsuccessful then the value pointed to by dest_ss will remain intact.

◆ ReplaceChars()

void ReplaceChars ( char *  value_s,
char  old_data,
char  new_data 
)

Replace each instance of a character within a string with another.

Parameters
value_sThe string to replace the character in.
old_dataThe character to be replaced.
new_dataThe replacement character.

◆ HashString()

uint32 HashString ( const void *const  key_p)

Create a numeric value for suitable for hashing from a given string.

Parameters
key_pThe string to create the hashed value for.
Returns
The hashed value.

◆ GetFileContentsAsString()

char* GetFileContentsAsString ( FILE *  input_f)

Get the contents of FILE as c-style string.

Parameters
input_fThe FILE to get the contents of
Returns
The newly-allocated c-style string containing the contents of the FILE or NULL upon error. If this value is not NULL, it should be freed by calling FreeCopiedString when it is no longer needed.
See also
FreeCopiedString

◆ GetFileContentsAsStringByFilename()

char* GetFileContentsAsStringByFilename ( const char *  filename_s)

Get the contents of FILE as c-style string.

Parameters
filename_sThe filename to get the contents of
Returns
The newly-allocated c-style string containing the contents of the FILE or NULL upon error. If this value is not NULL, it should be freed by calling FreeCopiedString() when it is no longer needed.
See also
GetFileContentsAsString

◆ ConcatenateVarargsStrings()

char* ConcatenateVarargsStrings ( const char *  value_s,
  ... 
)

Concatenate a va_list of strings.

Parameters
value_sThe varargs-style array of NULL terminated strings to append. The final entry in this varargs-array must be a NULL.
Returns
The newly-allocated string that should be freed with FreeCopiedString() when no longer needed or NULL upon failure.

◆ DoesStringContainWhitespace()

bool DoesStringContainWhitespace ( const char *  value_s)

Test whether a given string contains any whitespace characters.

Parameters
value_sThe string to check.
Returns
true if the string contains any whitespace characters, false otherwise.

◆ ConvertCompactStringToTime()

bool ConvertCompactStringToTime ( const char *const  time_s,
struct tm *  time_p,
int *  offset_p 
)

Convert a string that is of the form YYYYMMDD or YYYYMMDDhhmmss into a struct tm.

Parameters
time_sThe string to convert.
time_pThe struct tm to store the converted time in.
offset_pWhere the timezone adjustment will be stored. It's in the form (+/-)hhmm.
Returns
true if the value was converted successfully, false otherwise.

◆ ConvertCompactStringToEpochTime()

bool ConvertCompactStringToEpochTime ( const char *const  time_s,
time_t *  time_p 
)

Convert a string that is of the form YYYYMMDD or YYYYMMDDhhmmss into a time_t.

Parameters
time_sThe string to convert.
time_pThe time_t to store the converted time in.
Returns
true if the value was converted successfully, false otherwise.

◆ ConvertDropboxStringToTime()

bool ConvertDropboxStringToTime ( const char *const  time_s,
struct tm *  time_p,
int *  offset_p 
)

Convert a string that is of the form "Sat, 21 Aug 2010 22:31:20 +0000" ("%a, %d %b %Y %H:%M:%S %z") into a struct tm.

Parameters
time_sThe string to convert.
time_pThe struct tm to store the converted time in.
offset_pWhere the timezone adjustment will be stored. It's in the form (+/-)hhmm.
Returns
true if the value was converted successfully, false otherwise.

◆ ConvertDropboxStringToEpochTime()

bool ConvertDropboxStringToEpochTime ( const char *const  time_s,
time_t *  time_p 
)

Convert a string that is of the form "Sat, 21 Aug 2010 22:31:20 +0000" ("%a, %d %b %Y %H:%M:%S %z") into a time_t.

Parameters
time_sThe string to convert.
time_pThe time_t to store the converted time in.
Returns
true if the value was converted successfully, false otherwise.

◆ GetPresentTime()

bool GetPresentTime ( struct tm *  tm_p)

Get the current time.

Parameters
tm_pWhere the current time will be stored.
Returns
true if the time was set successfully, false otherwise.

◆ GetTimeAsString()

char* GetTimeAsString ( const struct tm *const  time_p,
const bool  include_time_flag,
const char *  time_delimiter_p 
)

Get a time as a string in the ISO 8601 format.

Parameters
time_pThe time to get as a c-style string
include_time_flagIf this is true then both the date and time will be included in the string in ISO 8601 format. If this is false, then just the date part of the string will be returned.
time_delimiter_pBy default, if the time is requested as part of the string, the hours, minutes and seconds are separated by a ':'. If this value is not NULL then the character it points to will be used instead.
Returns
The time as a c-style string or NULL upon error.
See also
FreeTimeString()

◆ SetTimeFromString()

bool SetTimeFromString ( struct tm *const  time_p,
const char *  time_s 
)

Set the time from a string in the ISO 8601 format.

Parameters
time_pThe time to be set from the string
time_sThe time to be set as a c-style string or NULL upon error.
Returns
true if the time was set successfully, false otherwise.

◆ SetTimeFromDDMMYYYYString()

bool SetTimeFromDDMMYYYYString ( struct tm *const  time_p,
const char *  time_s 
)

Set the time from a string of the form DD-MM-YYYY.

Parameters
time_pThe time to be set from the string
time_sThe time to be set as a c-style string or NULL upon error.
Returns
true if the time was set successfully, false otherwise.

◆ AddIntervalToTime()

void AddIntervalToTime ( struct tm *  time_p,
const int  days 
)

Add a number of days to a time.

Parameters
time_pThe time to be adjusted.
daysThe number of days to add.

◆ AllocateTime()

struct tm* AllocateTime ( void  )

Allocate a struct tm variable and set all of its values to 0.

This value should be freed using FreeTime() to avoid a memory leak.

Returns
The new struct tm or NULL upon error.

◆ FreeTime()

void FreeTime ( struct tm *  time_p)

Free a struct tm variable allocated by AllocateTime().

Parameters
time_pThe struct tm to free.

◆ CopyTime()

void CopyTime ( const struct tm *  src_p,
struct tm *  dest_p 
)

Copy the values from one struct tm to another.

Parameters
src_pThe struct tm to copy the values from.
dest_pThe struct tm to copy the values to.

◆ DuplicateTime()

struct tm* DuplicateTime ( const struct tm *  src_p)

Make a deep copy of a struct tm.

Parameters
src_pThe struct tm to copy.
Returns
The newly-allocated struct tm with the copied values or NULL upon error. This will need to be freed with FreeTime().

◆ SetDateValuesForTime()

void SetDateValuesForTime ( struct tm *  time_p,
const int  year,
const int  month,
const int  day 
)

Set the year, month and day values for a struct tm.

Parameters
yearThe 4 digit year value.
monthThe month value ranging from 0 for January to 11 for December.
monthThe day value starting from 1.

◆ CompareDates()

int CompareDates ( const struct tm *  time_0_p,
const struct tm *  time_1_p,
const bool  dates_only_flag 
)

Compare two dates chronologically.

Parameters
time_0_pThe first time.
time_1_pThe second time.
dates_only_flagIf this is true then only the date, month and year of the two times will be used for comparison. If this is false then the hours, minutes and seconds will be used too.
Returns
Less than zero if the first date is chronologically before the second one, greater than zero if the first date is after the second and zero if the dates are the same.

◆ GetUUIDAsString()

char* GetUUIDAsString ( const uuid_t  id)

Get the string representation of a uuid_t.

Parameters
idThe uuid_t to get the string representation of.
Returns
A newly-allocated string of the id or NULL upon error.
See also
FreeUUIDString.

◆ ConvertUUIDToString()

void ConvertUUIDToString ( const uuid_t  id,
char *  uuid_s 
)

Convert a uuid_t into a given string buffer.

Parameters
idThe uuid_t to get the string representation of.
uuid_sThe buffer to write the representation to. This must be at least UUID_STRING_BUFFER_SIZE bytes long.
See also
UUID_STRING_BUFFER_SIZE

◆ ConvertStringToUUID()

bool ConvertStringToUUID ( char *  id_s,
uuid_t  id 
)

Convert the string representation of a uuid_t to a uuid_t.

Parameters
id_sThe buffer containing the representation.
idThe uuid_t to set.
Returns
true if the uuid_t was set successfully, false otherwise.

◆ FreeUUIDString()

void FreeUUIDString ( char *  uuid_s)

Free a string representation of a uuid_t.

Parameters
uuid_sThe string representation to free.
See also
GetUUIDAsString.

◆ IsUUIDSet()

bool IsUUIDSet ( uuid_t  id)

Test whether a uuid_t contains a valid value.

Parameters
idThe uuid_t to test.
Returns
true if the uuid_t is valid, false otherwise.

◆ InitFileInformation()

void InitFileInformation ( FileInformation info_p)

Initialise a FileInformation ready for use.

Parameters
info_pThe FileInformation to initialise..

◆ FreeTimeString()

void FreeTimeString ( char *  time_s)

Free a string previsouly-generated from GetTimeAsString().

Parameters
time_sThe string to free.
See also
GetTimeAsString()

Variable Documentation

◆ CURRENT_SCHEMA_VERSION_MAJOR

const uint32 CURRENT_SCHEMA_VERSION_MAJOR = 0

The current major revision of the Grassroots schema.

◆ CURRENT_SCHEMA_VERSION_MINOR

const uint32 CURRENT_SCHEMA_VERSION_MINOR = 10

The current minor revision of the Grassroots schema.

◆ SO_RANGE_S

const char* SO_RANGE_S = "in"

The identifier for specifying a search for any value within a given set of values.

◆ SO_EQUALS_S

const char* SO_EQUALS_S = "="

The identifier for equality search operations.

◆ SO_LESS_THAN_S

const char* SO_LESS_THAN_S = "<"

The identifier for "less than" search operations.

◆ SO_LESS_THAN_OR_EQUALS_S

const char* SO_LESS_THAN_OR_EQUALS_S = "<="

The identifier for "less than or equals" search operations.

◆ SO_GREATER_THAN_S

const char* SO_GREATER_THAN_S = ">"

The identifier for "greater than" search operations.

◆ SO_GREATER_THAN_OR_EQUALS_S

const char* SO_GREATER_THAN_OR_EQUALS_S = ">="

The identifier for "greater than or equals" search operations.

◆ SO_NOT_EQUALS_S

const char* SO_NOT_EQUALS_S = "!="

The identifier for "not equals" search operations.

◆ SO_LIKE_S

const char* SO_LIKE_S = "like"

The identifier for "like" search operations.

◆ SO_CASE_INSENSITIVE_S

const char* SO_CASE_INSENSITIVE_S = "insensitive"

The identifier for specifying case-insensitive searches.