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.
|
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... | |
Functions | |
HashTable * | GetHashTableOfStrings (const uint32 initial_capacity, const uint8 load_percentage) |
Create a HashTable where both the keys and values are strings. More... | |
HashTable * | GetHashTableOfStringInts (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... | |
LinkedList * | GetMatchingFiles (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... | |
LinkedList * | GetStringListFromJSON (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... | |
LinkedList * | GetTabularHeaders (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... | |
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. More... | |
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. More... | |
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. 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... | |
General purpose code.
#define STM_LEVEL_NONE (0) |
The Stream levels to use.
Do not print a message
#define STM_LEVEL_SEVERE (1024) |
A severe, probably terminal error.
#define STM_LEVEL_WARNING (1025) |
A recoverable error where some functionality may be reduced.
#define STM_LEVEL_INFO (1026) |
An general information message.
#define STM_LEVEL_FINE (1027) |
A fine level message.
#define STM_LEVEL_FINER (1028) |
A more finely-grained level message.
#define STM_LEVEL_FINEST (1029) |
An even more finely-grained level message.
#define STM_LEVEL_ALL (0xFFFFFFFF) |
Print all messages.
#define UUID_STRING_BUFFER_SIZE (37) |
The number of bytes required to store a c-style string representation of a UUID.
#define UUID_RAW_SIZE (16) |
The number of bytes required to store the raw data of a UUID.
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.
enum FileLocation |
enum PluginStatus |
enum PluginNature |
The type of module that the Plugin contains.
Enumerator | |
---|---|
PN_UNKNOWN | Unknown type of Plugin. |
PN_SERVICE | |
PN_CLIENT | The Plugin creates a Client. |
PN_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. |
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.
|
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. |
enum 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 |
HashTable* GetHashTableOfStrings | ( | const uint32 | initial_capacity, |
const uint8 | load_percentage | ||
) |
Create a HashTable where both the keys and values are strings.
initial_capacity | The initial number of HashBuckets for the HashTable. |
load_percentage | The percentage value for how full the HashTable should be allowed to become before it is extended. |
NULL
is there was an error. HashTable* GetHashTableOfStringInts | ( | const uint32 | initial_capacity, |
const uint8 | load_percentage | ||
) |
Create a HashTable where the keys are strings and the values are uint32.
initial_capacity | The initial number of HashBuckets for the HashTable. |
load_percentage | The percentage value for how full the HashTable should be allowed to become before it is extended. |
NULL
is there was an error. bool CompareStringHashBuckets | ( | const void *const | bucket_key_p, |
const void *const | key_p | ||
) |
Compare the keys of two StringHashBuckets.
bucket_key_p | The first string |
key_p | The second string. |
int CompareKeysAlphabetically | ( | const void * | v0_p, |
const void * | v1_p | ||
) |
Compare two strings alphabetically.
v0_p | A const char ** for the first string. |
v1_p | A const char ** for the second string. |
OutputStreamerModule* AllocateStreamer | ( | const ConfigurationManager *const | config_manager_p | ) |
Allocate an OutputStreamerModule for writing log and error messages to named output files.
config_manager_p | The ConfigurationManager used to specify the details of the output filenames. |
NULL
upon error. void DeallocateStreamer | ( | OutputStreamerModule * | streamer_p | ) |
Free an OutputStreamerModule.
streamer_p | The OutputStreamerModule to free. |
char* GetFilenameOnly | ( | const char *const | full_path_to_file_s | ) |
Get the filename only from a given path.
full_path_to_file_s | The full path. |
NULL
. char* GetPathOnly | ( | const char *const | full_path_to_file_s | ) |
Get the path to the parent directory only from a given path.
full_path_to_file_s | The full path. |
NULL
. 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.
path_s | The path to append the filename to. |
filename_s | The filename to append. |
NULL
. 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".
full_path_s | The value to extract the path and filename from. |
path_ss | Pointer 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_ss | Pointer 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 |
true
if the extraction was successful false
otherwise. 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.
filename_s | The filename to add the extension to. |
extension_s | The extension to add. |
replace_flag | If 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. |
NULL
. void UsePlatformFileSeparator | ( | char * | value_s | ) |
Replace any occurrences of // in a string with the platform-specific file separator.
value_s | The string to be amended. |
bool IsPathValid | ( | const char *const | path_s | ) |
Check whether a given file/directory exists.
path_s | The path to check. |
true
if the object referred to by the path exists, false
otherwise. bool IsPathAbsolute | ( | const char *const | path_s | ) |
Check whether a given path is absolute.
path_s | The path to check. |
true
if the path is absolute, false
otherwise. LinkedList* GetMatchingFiles | ( | const char *const | pattern_s, |
const bool | full_path_flag | ||
) |
Get files that match a given pattern.
pattern_s | The path including the pattern. |
full_path_flag | If 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. |
NULL
if no matches could be found. 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.
const char* GetCurrentDirectoryString | ( | void | ) |
Get the platform-specific string for the current directory.
For example .// on Unix, . on Windows.
const char* GetParentDirectory | ( | void | ) |
Get the platform-specific string for the parent directory.
For example ..// on Unix, ..\ on Windows.
const char* GetPluginPattern | ( | void | ) |
Get the platform-specific string for the a plugin.
For example lib*.so on Unix, *.dll on Windows.
bool EnsureDirectoryExists | ( | const char *const | path_s | ) |
Makes sure that a given directory path exists.
path_s | The path to check. It can be an arbitrary number of levels deep. |
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. 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.
src_filename_s | The name of the file to copy from. |
dest_filename_s | The name of the file to copy to. |
callback_fn | An optional callback function for monitoring progress with. |
true
if the copy was successful false
otherwise. bool SetCurrentWorkingDirectory | ( | const char *const | path_s | ) |
Set the current working directory.
path_s | The path to set. |
true
if the change was successful false
otherwise. char* GetCurrentWorkingDirectory | ( | void | ) |
Get the current working directory.
char* GetHomeDirectory | ( | void | ) |
Get the current user's home directory.
NULL
upon error. When no longer needed, this value should be freed using FreeCopiedString (). bool IsDirectory | ( | const char *const | path_s | ) |
Check whether the given path refers to a directory.
path_s | The path to check. |
true
if the path exists and is a directory, false
otherwise. bool RemoveFile | ( | const char *const | path_s | ) |
Delete a file.
path_s | The name of the file to delete. |
true
if the file was deleted successfully, false
otherwise. bool DoesFileExist | ( | const char *const | path_s | ) |
Check if a file/directory exists.
path_s | The name of the file/directory to check. |
true
if it exists, false
otherwise. bool InitDefaultOutputStream | ( | void | ) |
Initialise the default OutputStreams ready for use.
This should be called when starting up a Server.
true
if the initialisation was succesful, false
otherwise. FileLocation GetFileLocation | ( | const char *const | filename_s | ) |
Determine whether a file is on the local filesystem or not.
filename_s | The file to check. |
char* CopyFileToLocalFilesystem | ( | const char *const | filename_s | ) |
Copy a file to the local filesystem.
filename_s | The name of the the source file. |
char* CopyFileChunkToLocalFilesystem | ( | const char *const | filename_s, |
size_t | offset, | ||
size_t | chunk_size | ||
) |
Copy a file chunk to the local filesystem.
filename_s | The name of the the source file. |
offset | The byte offset to start copying from. |
chunk_size | The size of the chunk to copy. |
true
on success, false
on error with errno set to the appropriate value. char* GetIntAsString | ( | int | value | ) |
Get a newly allocated char * with the given value.
value | The value to print into the the newly allocated string. |
NULL
upon error. char* GetUnsignedIntAsString | ( | uint32 | value | ) |
Get a newly allocated char * with the given value.
value | The value to print into the the newly allocated string. |
NULL
upon error. void WriteToLog | ( | const char * | log_ident_s, |
const int | log_level, | ||
const char * | message_s, | ||
... | |||
) |
Write a logging message to the given logfile.
log_ident_s | The logfile identifer to use. If this is NULL then "slog" will be used. |
log_level | One of the levels defined in syslog.h: |
message_s | The string to write using standard c printf syntax. |
int PrintJSON | ( | FILE * | out_f, |
const json_t *const | json_p, | ||
const char *const | prefix_s | ||
) |
Print a json fragment to a FILE pointer.
out_f | The FILE to print to. |
json_p | The json object to print. |
prefix_s | An optional string to precede the json output in the given FILE. |
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.
json_p | The json object to query. |
key_s | The key to search for. |
NULL
if the key does not exist in the given json_t object. 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.
json_p | The json object to query. |
key_s | The key to search for. |
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(). 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.
json_p | The json object to query. |
key_s | The key to search for. |
value_p | Where the corresponding value will be stored if the key exists and relates to an int. |
true
if the value was retrieved successfully, false
otherwise. 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.
json_p | The json object to query. |
key_s | The key to search for. |
value_p | Where the corresponding value will be stored if the key exists and relates to an int. |
true
if the value was retrieved successfully, false
otherwise. 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.
json_p | The json object to query. |
key_s | The key to search for. |
value_p | Where the corresponding value will be stored if the key exists and relates to a double. |
true
if the value was retrieved successfully, false
otherwise. 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.
json_p | The json object to query. |
key_s | The key to search for. |
value_p | Where the corresponding value will be stored if the key exists and relates to a boolean. |
true
if the value was retrieved successfully, false
otherwise. 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.
parent_p | The json_t object to add the array to. |
values_ss | The array of c-style strings with a final element set to NULL. |
child_key_s | The key to use to add the json array to parent_p. |
true
if the json_array was created and added successfully, false
otherwise. 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.
array_p | The json_t array to create the c-style strings array from. |
NULL
if array_p is an empty array or if there was an error. 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.
parent_p | The json_t object to add the array to. |
values_p | The LinkedList of StringListNodes. |
child_key_s | The key to use to add the json array to parent_p. |
true
if the json_array was created and added successfully, false
otherwise. LinkedList* GetStringListFromJSON | ( | const json_t *const | array_p | ) |
Created a LinkedList of StringListNodes from a json array.
array_p | The json_t object to generate the list from. |
NULL
if array_p is an empty array or if there was an error. json_t* LoadJSONFile | ( | const char *const | filename_s | ) |
Load a JSON file.
filename_s | The filename to load. |
NULL
upon errors such as the file being unable to be read or not a JSON file. 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.
data_s | The string of data to convert. |
column_delimiter | The character used to separate the data into columns. |
row_delimiter | The character used to separate the data into rows. |
headers_p | A LinkedList of FieldNodes where specifying the headers for each column of data. |
NULL
upon error. 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.
data_s | The string of data to convert. |
column_delimiter | The character used to separate the data into columns. |
row_delimiter | The character used to separate the data into rows. |
get_type_fn | A 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_p | If get_type_fn needs any extra data, it can be passed in here. |
NULL
upon error. 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.
data_ss | A 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_delimiter | The character used to separate the data into columns. |
row_delimiter | The character used to separate the data into rows. |
get_type_fn | A 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_p | If get_type_fn needs any extra data, it can be passed in here. |
NULL
upon error. json_t* ConvertRowToJSON | ( | char * | row_s, |
LinkedList * | headers_p, | ||
const char | delimiter | ||
) |
Create a JSON object from a delimited string of data.
row_s | The delimited data for a single row. |
headers_p | The LinkedList of FieldNodes defining the column titles. |
delimiter | The column delimiter. |
NULL
upon error. 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.
parent_p | The JSON object that the key-value pair will be added to. |
key_s | The key to use. |
value_s | The value to use. |
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. 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.
json_p | The json_t object to print. |
level | The logging level to use. |
filename_s | The filename of the source file calling this method. |
line_number | The line number in the source file which called this method. |
message_s | A char * using the same format as printf, etc. |
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.
json_p | The json_t object to print. |
level | The logging level to use. |
filename_s | The filename of the source file calling this method. |
line_number | The line number in the source file which called this method. |
message_s | A char * using the same format as printf, etc. |
bool IsJSONEmpty | ( | const json_t * | json_p | ) |
Is a json_t NULL
or empty?
json_p | The json_t object to test. |
true
if the json_t is NULL
, an empty array, an empty object or an empty string, false
otherwise. 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.
value_p | The json_t object to print. |
initial_s | An 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_level | The logging level to use. |
filename_s | The filename of the source file calling this method. |
line_number | The line number in the source file which called this method. |
bool SetBooleanFromJSON | ( | const json_t * | json_p, |
bool * | value_p | ||
) |
Set the boolean value of a JSON object.
json_p | The JSON value to get the boolean value from. |
value_p | Pointer to where the boolean value will be stored if it is successfully retrieved. |
true
if the value was successfully retrieved. If the JSON value is not a boolean type false
will be returned. bool SetRealFromJSON | ( | const json_t * | json_p, |
double * | value_p | ||
) |
Get the real value of a JSON object.
json_p | The JSON value to get the real value from. |
value_p | Pointer to where the real value will be stored if it is successfully retrieved. |
true
if the value was successfully retrieved. If the JSON value is not a real type false
will be returned. bool SetIntegerFromJSON | ( | const json_t * | json_p, |
json_int_t * | value_p | ||
) |
Get the integer value of a JSON object.
json_p | The JSON value to get the integer value from. |
value_p | Pointer to where the integer value will be stored if it is successfully retrieved. |
true
if the value was successfully retrieved. If the JSON value is not a integer type false
will be returned. bool SetLongFromJSON | ( | const json_t * | json_p, |
int64 * | value_p | ||
) |
Get the long value of a JSON object.
json_p | The JSON value to get the long value from. |
value_p | Pointer to where the long value will be stored if it is successfully retrieved. |
true
if the value was successfully retrieved. If the JSON value is not a long type false
will be returned. bool SetStringFromJSON | ( | const json_t * | json_p, |
char ** | value_ss | ||
) |
Get the string value of a JSON object.
json_p | The JSON value to get the boolean value from. |
value_ss | Pointer to where the string value will be copied to if it is successfully retrieved. |
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. bool SetJSONNull | ( | json_t * | json_p, |
const char *const | key_s | ||
) |
Add a child key to a JSON object where the value is null.
json_p | The JSON object to add the vaue to. |
key_s | The key for the child object. |
true
if the value was successfully added, false
otherwise. json_t* GetCompoundJSONObject | ( | const json_t * | input_p, |
const char *const | compound_s | ||
) |
Get a descendant JSON object from another using a given selector.
input_p | The JSON object to get the value from |
compound_s | The 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. |
NULL
if it could not be found. 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.
src_p | The JSON object to get the value from. |
dest_p | The JSON object to copy the values to. |
key_s | The key to search for in the input JSON and uses as the key in the output JSON. |
optional_flag | If 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. |
true
upon success, false
upon failure. 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.
src_p | The JSON object to get the value from. |
dest_p | The JSON object to copy the values to. |
key_s | The key to search for in the input JSON and uses as the key in the output JSON. |
optional_flag | If 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. |
true
upon success, false
upon failure. bool DeepCopyValidJSON | ( | const json_t * | src_p, |
json_t ** | dest_pp | ||
) |
Make a deep copy of a source JSON fragment to another.
src_p | The JSON object to copy. |
dest_pp | A pointer to where the copied JSON fragment will be stored upon success |
true
upon success, false
upon failure. 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" } }
root_p | The JSON fragment to add the ontology term to. |
key_s | The key that the ontology term will have in the given JSON fragment. |
term_s | The term to add. |
add_id_flag | If 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. |
true
upon success, false
upon failure. int CompareDoubles | ( | const double | d1, |
const double | d2 | ||
) |
Compare two doubles taking the epsilon of this computer into account.
d1 | The first double to compare. |
d2 | The second double to compare. |
int CompareFloats | ( | const float | f1, |
const float | f2 | ||
) |
Compare two floats taking the epsilon of this computer into account.
f1 | The first float to compare. |
f2 | The second float to compare. |
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.
str_pp | Pointer to char * where we start getting the number from. |
data_p | Pointer where the number will be stored if the conversion was successful. |
alternative_decimal_points_s | An 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. |
true
if the conversion was successful, false
otherwise. 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.
str_pp | Pointer to char * where we start getting the number from. |
answer_p | Pointer where the number will be stored if the conversion was successful. |
true
if the conversion was successful, false
otherwise. 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.
str_pp | Pointer to char * where we start getting the number from. |
answer_p | Pointer where the number will be stored if the conversion was successful. |
int SortDoubles | ( | const void * | v1_p, |
const void * | v2_p | ||
) |
Compare two doubles taking the epsilon of this computer into account.
v1_p | Pointer to the first double to compare. |
v2_p | Pointer to the second double to compare. |
char* ConvertIntegerToString | ( | const int32 | value | ) |
Get an integer as a string, e.g.
1 would be converted to "1"
value | The value to convert to a string. |
NULL
upon error. This needs to be freed using FreeCopiedString(). char* ConvertUnsignedIntegerToString | ( | const uint32 | value | ) |
Get an unsigned integer as a string, e.g.
1 would be converted to "1"
value | The value to convert to a string. |
NULL
upon error. This needs to be freed using FreeCopiedString(). char* ConvertLongToString | ( | const int64 | value | ) |
Get an int64 as a string, e.g.
1 would be converted to "1"
value | The value to convert to a string. |
NULL
upon error. This needs to be freed using FreeCopiedString(). char* ConvertDoubleToString | ( | const double64 | value | ) |
Get an double as a string, e.g.
1.03 would be converted to "1.03"
value | The value to convert to a string. |
NULL
upon error. This needs to be freed using FreeCopiedString(). char* ConvertSizeTToString | ( | const size_t | value | ) |
Get an size_t as a string, e.g.
1 would be converted to "1"
value | The value to convert to a string. |
NULL
upon error. This needs to be freed using FreeCopiedString(). struct MappedMemory* AllocateSharedMemory | ( | const char * | id_s, |
size_t | size, | ||
int | flags | ||
) |
Allocate some memory that can shared between different processes.
id_s | An identifier that will be used to access the shared memory segment if it is successfully allocated. |
size | The size of the requested segment in bytes. |
flags | The 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. |
bool FreeSharedMemory | ( | struct MappedMemory * | mapped_memory_p | ) |
Free the shared memory segment for a given id.
id | The segment identifier for the shared memory segment to free. |
true
if the memory segment was freed successfully, false
otherwise. void* OpenSharedMemory | ( | struct MappedMemory * | mapped_memory_p, |
int | flags | ||
) |
Open a shared memory segment.
id | The segment identifier for the shared memory segment to open. |
flags | This can be SHM_RDONLY for read-only memory. |
NULL
upon error. bool CloseSharedMemory | ( | struct MappedMemory * | mapped_memory_p, |
void * | value_p | ||
) |
Close a shared memory segment.
value_p | The shared memory segment. |
true
if the memory segment was closed successfully, false
otherwise. const char* GetOperationAsString | ( | const Operation | op | ) |
Get the string-based representation of a given Operation.
op | The Operation to get the string-based representation of. |
Operation GetOperationFromString | ( | const char * | op_s | ) |
Get the Operation for a given String.
op_s | The string to get the Operation for. |
const char* GetOperationStatusAsString | ( | const OperationStatus | status | ) |
Get the string-based representation of a given OperationStatus.
status | The OperationStatus to get the string-based representation of. |
OperationStatus GetOperationStatusFromString | ( | const char * | status_s | ) |
Get the OperationStatus for a given String.
status_s | The string to get the OperationStatus for. |
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.
ops_p | The JSON fragment to get the Operation from. |
OP_NONE
if it could not be retrieved successfully. bool InitPlatform | ( | void | ) |
Initialise the Grassroots system for the operating system that it is running on.
true
if the value was converted successfully, false
otherwise. void ExitPlatform | ( | void | ) |
Release any operating system-specific resources.
uint32 Snooze | ( | uint32 | milliseconds | ) |
Sleep the current process.
milliseconds | The number of milliseconds to sleep for. |
char* CopyToNewString | ( | const char *const | src_p, |
const size_t | length_to_copy, | ||
bool | trim | ||
) |
Copy a string to a newly created string.
src_p | The string to copy. |
length_to_copy | If 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. |
trim | Whether to trim left and right trailing whitespace or not. |
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
.
src_s | he string to copy. |
void FreeCopiedString | ( | char * | str_p | ) |
Delete a string previously allocated using CopyToNewString.
str_p | The string to deallocate. This is checked for being NULL in which case this function becomes a no-op routine. |
bool GetLineFromFile | ( | FILE * | in_f, |
char ** | buffer_pp | ||
) |
Read a line from a file with no buffer overflow issues.
in_f | The File to read from. |
buffer_pp | Pointer to a buffer string where the line will get written to. After being used, *buffer_pp muet be freed. |
void FreeLineBuffer | ( | char * | buffer_p | ) |
Free a buffer that has been allocated with GetLineFromFile.
buffer_p | Pointer to a buffer to be freed. |
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.
format_p | The format string to use. |
delimiters_p | A 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_flag | If TRUE whitespace will be treated as a delimiter. |
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.
format_p | The format string to use. |
delimiters_p | A 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. |
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.
format_p | The format string to use. |
delimiters_p | A 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. |
char* ConcatenateStrings | ( | const char *const | first_s, |
const char *const | second_s | ||
) |
Get a newly created string that is the concatenation of two others.
first_s | The first string to concatenate. |
second_s | The second string to concatenate. |
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.
value_s | The string to be altered. |
char_to_replace | The character to replace. |
replacement_char | The replacement character. |
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
line_p | The string to get the values from. |
key_pp | Pointer to a new string where the key will be stored upon success. |
value_pp | Pointer to a new string where the value will be stored upon success. |
comment_identifier | If the line begins with this charcter then treat the whole line as a comment and do not try to get the key and value. |
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.
start_pp | Address of the buffer to read from. |
delimiters_p | An 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_flag | If this is set to true , then the address pointed to by start_pp will be updated to after the token. |
NULL
if there was an error or no more tokens were available. void FreeToken | ( | char * | token_s | ) |
Free a c-style string that has been returned by GetNextToken.
token_s | The token to free. |
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
numeric_string_p | The string to formatted. |
bool IsStringEmpty | ( | const char * | value_s | ) |
Test whether a string is NULL or contains just whitespace.
value_s | The string to test. |
true
If the string is NULL
or just whitespace, false
otherwise. 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.
c0_s | The first string. |
c1_s | The second string. |
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.
c0_s | The first string. |
c1_s | The second string. |
length | The maximum number of characters in each string to compare. |
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.
value_s | The string to search within. |
substring_s | The string to search for |
NULL
if it was not found. char* Strrstr | ( | const char * | haystack_s, |
const char * | needle_s | ||
) |
Find the last occurence of a substring within a string.
haystack_s | The string to search within. |
needle_s | The string to search for |
NULL
if it was not found. bool ReplaceStringValue | ( | char ** | dest_ss, |
const char *const | src_s | ||
) |
Make a copy of a string.
dest_ss | Pointer to the string where the source string will be copied to. |
src_s | The string to copy. |
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. void ReplaceChars | ( | char * | value_s, |
char | old_data, | ||
char | new_data | ||
) |
Replace each instance of a character within a string with another.
value_s | The string to replace the character in. |
old_data | The character to be replaced. |
new_data | The replacement character. |
uint32 HashString | ( | const void *const | key_p | ) |
Create a numeric value for suitable for hashing from a given string.
key_p | The string to create the hashed value for. |
char* GetFileContentsAsString | ( | FILE * | input_f | ) |
Get the contents of FILE as c-style string.
input_f | The FILE to get the contents of |
NULL
upon error. If this value is not NULL
, it should be freed by calling FreeCopiedString when it is no longer needed. char* GetFileContentsAsStringByFilename | ( | const char * | filename_s | ) |
Get the contents of FILE as c-style string.
filename_s | The filename to get the contents of |
NULL
upon error. If this value is not NULL
, it should be freed by calling FreeCopiedString() when it is no longer needed. char* ConcatenateVarargsStrings | ( | const char * | value_s, |
... | |||
) |
Concatenate a va_list of strings.
value_s | The varargs-style array of NULL terminated strings to append. The final entry in this varargs-array must be a NULL . |
NULL
upon failure. bool DoesStringContainWhitespace | ( | const char * | value_s | ) |
Test whether a given string contains any whitespace characters.
value_s | The string to check. |
true
if the string contains any whitespace characters, false
otherwise. 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.
time_s | The string to convert. |
time_p | The struct tm to store the converted time in. |
offset_p | Where the timezone adjustment will be stored. It's in the form (+/-)hhmm. |
true
if the value was converted successfully, false
otherwise. 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.
time_s | The string to convert. |
time_p | The time_t to store the converted time in. |
true
if the value was converted successfully, false
otherwise. 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.
time_s | The string to convert. |
time_p | The struct tm to store the converted time in. |
offset_p | Where the timezone adjustment will be stored. It's in the form (+/-)hhmm. |
true
if the value was converted successfully, false
otherwise. 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.
time_s | The string to convert. |
time_p | The time_t to store the converted time in. |
true
if the value was converted successfully, false
otherwise. bool GetPresentTime | ( | struct tm * | tm_p | ) |
Get the current time.
tm_p | Where the current time will be stored. |
true
if the time was set successfully, false
otherwise. 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.
time_p | The time to get as a c-style string |
include_time_flag | If 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_p | By 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. |
NULL
upon error.bool SetTimeFromString | ( | struct tm *const | time_p, |
const char * | time_s | ||
) |
Set the time from a string in the ISO 8601 format.
time_p | The time to be set from the string |
time_s | The time to be set as a c-style string or NULL upon error. |
true
if the time was set successfully, false
otherwise. bool SetTimeFromDDMMYYYYString | ( | struct tm *const | time_p, |
const char * | time_s | ||
) |
Set the time from a string of the form DD-MM-YYYY.
time_p | The time to be set from the string |
time_s | The time to be set as a c-style string or NULL upon error. |
true
if the time was set successfully, false
otherwise. void AddIntervalToTime | ( | struct tm * | time_p, |
const int | days | ||
) |
Add a number of days to a time.
time_p | The time to be adjusted. |
days | The number of days to add. |
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.
NULL
upon error. void FreeTime | ( | struct tm * | time_p | ) |
Free a struct tm variable allocated by AllocateTime().
time_p | The struct tm to free. |
void CopyTime | ( | const struct tm * | src_p, |
struct tm * | dest_p | ||
) |
Copy the values from one struct tm to another.
src_p | The struct tm to copy the values from. |
dest_p | The struct tm to copy the values to. |
struct tm* DuplicateTime | ( | const struct tm * | src_p | ) |
Make a deep copy of a struct tm.
src_p | The struct tm to copy. |
NULL
upon error. This will need to be freed with FreeTime(). 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.
year | The 4 digit year value. |
month | The month value ranging from 0 for January to 11 for December. |
month | The day value starting from 1. |
int CompareDates | ( | const struct tm * | time_0_p, |
const struct tm * | time_1_p, | ||
const bool | dates_only_flag | ||
) |
Compare two dates chronologically.
time_0_p | The first time. |
time_1_p | The second time. |
dates_only_flag | If 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. |
char* GetUUIDAsString | ( | const uuid_t | id | ) |
Get the string representation of a uuid_t.
id | The uuid_t to get the string representation of. |
NULL
upon error. void ConvertUUIDToString | ( | const uuid_t | id, |
char * | uuid_s | ||
) |
Convert a uuid_t into a given string buffer.
id | The uuid_t to get the string representation of. |
uuid_s | The buffer to write the representation to. This must be at least UUID_STRING_BUFFER_SIZE bytes long. |
bool ConvertStringToUUID | ( | char * | id_s, |
uuid_t | id | ||
) |
void FreeUUIDString | ( | char * | uuid_s | ) |
Free a string representation of a uuid_t.
uuid_s | The string representation to free. |
bool IsUUIDSet | ( | uuid_t | id | ) |
void InitFileInformation | ( | FileInformation * | info_p | ) |
Initialise a FileInformation ready for use.
info_p | The FileInformation to initialise.. |
void FreeTimeString | ( | char * | time_s | ) |
Free a string previsouly-generated from GetTimeAsString().
time_s | The string to free. |
const uint32 CURRENT_SCHEMA_VERSION_MAJOR = 0 |
The current major revision of the Grassroots schema.
const uint32 CURRENT_SCHEMA_VERSION_MINOR = 10 |
The current minor revision of the Grassroots schema.
const char* SO_RANGE_S = "in" |
The identifier for specifying a search for any value within a given set of values.
const char* SO_EQUALS_S = "=" |
The identifier for equality search operations.
const char* SO_LESS_THAN_S = "<" |
The identifier for "less than" search operations.
const char* SO_LESS_THAN_OR_EQUALS_S = "<=" |
The identifier for "less than or equals" search operations.
const char* SO_GREATER_THAN_S = ">" |
The identifier for "greater than" search operations.
const char* SO_GREATER_THAN_OR_EQUALS_S = ">=" |
The identifier for "greater than or equals" search operations.
const char* SO_NOT_EQUALS_S = "!=" |
The identifier for "not equals" search operations.
const char* SO_LIKE_S = "like" |
The identifier for "like" search operations.
const char* SO_CASE_INSENSITIVE_S = "insensitive" |
The identifier for specifying case-insensitive searches.