XMMS2
Macros | Typedefs | Enumerations | Functions
s4.h File Reference
#include <stdint.h>

Macros

#define S4_COND_PARENT   1
 
#define S4_FETCH_PARENT   1
 
#define S4_FETCH_DATA   2
 

Typedefs

typedef struct s4_St s4_t
 
typedef struct s4_val_St s4_val_t
 
typedef struct s4_sourcepref_St s4_sourcepref_t
 
typedef struct s4_condition_St s4_condition_t
 
typedef int(* check_function_t )(s4_condition_t *cond, void *data)
 
typedef int(* filter_function_t )(const s4_val_t *value, s4_condition_t *data)
 
typedef int(* combine_function_t )(s4_condition_t *cond, check_function_t func, void *check_data)
 
typedef void(* free_func_t )(void *)
 
typedef struct s4_fetchspec_St s4_fetchspec_t
 
typedef struct s4_result_St s4_result_t
 
typedef struct s4_resultrow_St s4_resultrow_t
 
typedef struct s4_resultset_St s4_resultset_t
 
typedef struct s4_order_entry_St s4_order_entry_t
 
typedef struct s4_order_St s4_order_t
 
typedef struct s4_pattern_St s4_pattern_t
 
typedef struct s4_transaction_St s4_transaction_t
 

Enumerations

enum  s4_open_flag_t { S4_NEW = 1 << 0, S4_EXISTS = 1 << 1, S4_MEMORY = 1 << 2 }
 Flags for s4_open. More...
 
enum  s4_transaction_flag_t { S4_TRANS_READONLY = 1 << 0 }
 Flags for s4_begin. More...
 
enum  s4_errno_t {
  S4E_NOERROR, S4E_EXISTS, S4E_NOENT, S4E_OPEN,
  S4E_MAGIC, S4E_VERSION, S4E_INCONS, S4E_LOGOPEN,
  S4E_LOGREDO, S4E_DEADLOCK, S4E_EXECUTE, S4E_LOGFULL,
  S4E_READONLY
}
 Error codes. More...
 
enum  s4_cmp_mode_t { S4_CMP_BINARY, S4_CMP_CASELESS, S4_CMP_COLLATE }
 
enum  s4_filter_type_t {
  S4_FILTER_EQUAL, S4_FILTER_NOTEQUAL, S4_FILTER_GREATER, S4_FILTER_SMALLER,
  S4_FILTER_GREATEREQ, S4_FILTER_SMALLEREQ, S4_FILTER_MATCH, S4_FILTER_EXISTS,
  S4_FILTER_TOKEN, S4_FILTER_CUSTOM
}
 
enum  s4_combine_type_t { S4_COMBINE_AND, S4_COMBINE_OR, S4_COMBINE_NOT, S4_COMBINE_CUSTOM }
 
enum  s4_order_direction_t { S4_ORDER_ASCENDING, S4_ORDER_DESCENDING }
 

Functions

s4_val_ts4_val_new_string (const char *str)
 Creates a new string value. More...
 
s4_val_ts4_val_new_int (int32_t i)
 Creates a new integer value. More...
 
s4_val_ts4_val_copy (const s4_val_t *val)
 Copies a value. More...
 
void s4_val_free (s4_val_t *val)
 Frees a value. More...
 
int s4_val_is_str (const s4_val_t *val)
 Checks is a value is a string value. More...
 
int s4_val_is_int (const s4_val_t *val)
 Checks is a value is an integer value. More...
 
int s4_val_get_str (const s4_val_t *val, const char **str)
 Tries to get the string in a string value. More...
 
int s4_val_get_int (const s4_val_t *val, int32_t *i)
 Tries to get the integer in an integer value. More...
 
int s4_val_get_collated_str (const s4_val_t *val, const char **str)
 Tries to get the normalized string in a string value. More...
 
int s4_val_get_casefolded_str (const s4_val_t *val, const char **str)
 Tries to get the normalized string in a string value. More...
 
int s4_val_cmp (const s4_val_t *v1, const s4_val_t *v2, s4_cmp_mode_t mode)
 Compares two values. More...
 
s4_ts4_open (const char *name, const char **indices, int flags)
 Opens an S4 database. More...
 
int s4_close (s4_t *s4)
 Closes an open S4 database. More...
 
void s4_sync (s4_t *s4)
 Writes all changes to disk. More...
 
s4_errno_t s4_errno (void)
 Returns the last error number set. More...
 
void s4_create_uuid (unsigned char uuid[16])
 Creates a new random UUID and saves it in the array passed. More...
 
void s4_get_uuid (s4_t *s4, unsigned char uuid[16])
 Gets the UUID of a S4 database. More...
 
char * s4_get_uuid_string (s4_t *s4)
 Gets the UUID-string of a S4 database. More...
 
s4_sourcepref_ts4_sourcepref_create (const char **sourcepref)
 Creates a new source preferences that can be used when querying. More...
 
void s4_sourcepref_unref (s4_sourcepref_t *sourcepref)
 Decreases the reference of a sourcepref. More...
 
s4_sourcepref_ts4_sourcepref_ref (s4_sourcepref_t *sp)
 Increases the refcount of a sourcepref. More...
 
int s4_sourcepref_get_priority (s4_sourcepref_t *sp, const char *src)
 Gets the priority of a source. More...
 
s4_condition_ts4_cond_new_combiner (s4_combine_type_t type)
 Creates a new combiner. More...
 
s4_condition_ts4_cond_new_custom_combiner (combine_function_t func)
 Creates a new combiner with a user specified combiner function. More...
 
void s4_cond_add_operand (s4_condition_t *cond, s4_condition_t *op)
 Adds and references an operand to a combiner condition. More...
 
s4_condition_ts4_cond_get_operand (s4_condition_t *cond, int op)
 Gets an operand from a combiner condition. More...
 
s4_condition_ts4_cond_new_filter (s4_filter_type_t type, const char *key, const s4_val_t *value, s4_sourcepref_t *sourcepref, s4_cmp_mode_t mode, int flags)
 Creates a new filter condition. More...
 
s4_condition_ts4_cond_new_custom_filter (filter_function_t func, void *userdata, free_func_t free, const char *key, s4_sourcepref_t *sourcepref, s4_cmp_mode_t cmp_mode, int monotonic, int flags)
 Creates a new filter condition with a user specified filter function. More...
 
int s4_cond_is_filter (s4_condition_t *cond)
 Checks if this condition is a filter condition. More...
 
int s4_cond_is_combiner (s4_condition_t *cond)
 Checks if this condition is a combiner condition. More...
 
s4_filter_type_t s4_cond_get_filter_type (s4_condition_t *cond)
 
s4_combine_type_t s4_cond_get_combiner_type (s4_condition_t *cond)
 
int s4_cond_get_flags (s4_condition_t *cond)
 Gets the flags for a condition. More...
 
const char * s4_cond_get_key (s4_condition_t *cond)
 Gets the key for a condition. More...
 
s4_sourcepref_ts4_cond_get_sourcepref (s4_condition_t *cond)
 Gets the source preference that should be used. More...
 
int s4_cond_is_monotonic (s4_condition_t *cond)
 Checks if the condition is a monotonic filter. More...
 
void * s4_cond_get_funcdata (s4_condition_t *cond)
 Returns the data that should be fed to the filter function. More...
 
void s4_cond_update_key (s4_condition_t *cond, s4_t *s4)
 Change the key with a constant key for faster checking. More...
 
int s4_cond_get_cmp_mode (s4_condition_t *cond)
 Gets the comparison mode used by the filter condition. More...
 
void s4_cond_free (s4_condition_t *cond)
 Frees a condition and operands recursively. More...
 
s4_condition_ts4_cond_ref (s4_condition_t *cond)
 Increments the reference count of a condition. More...
 
void s4_cond_unref (s4_condition_t *cond)
 Decrements the reference count of a condition. More...
 
filter_function_t s4_cond_get_filter_function (s4_condition_t *cond)
 Gets the filter function for the condition. More...
 
combine_function_t s4_cond_get_combine_function (s4_condition_t *cond)
 Gets the combine function for the condition. More...
 
s4_fetchspec_ts4_fetchspec_create (void)
 Creates a new fetch specification. More...
 
void s4_fetchspec_add (s4_fetchspec_t *spec, const char *key, s4_sourcepref_t *sourcepref, int flags)
 Adds something to fetch to the fetch specification. More...
 
void s4_fetchspec_free (s4_fetchspec_t *spec)
 Frees a fetchspec. More...
 
s4_fetchspec_ts4_fetchspec_ref (s4_fetchspec_t *spec)
 
void s4_fetchspec_unref (s4_fetchspec_t *spec)
 
int s4_fetchspec_size (s4_fetchspec_t *spec)
 Gets the size of the fetchspec. More...
 
const char * s4_fetchspec_get_key (s4_fetchspec_t *spec, int index)
 Gets the key at a give index. More...
 
s4_sourcepref_ts4_fetchspec_get_sourcepref (s4_fetchspec_t *spec, int index)
 Gets the sourcepref at a give index. More...
 
int s4_fetchspec_get_flags (s4_fetchspec_t *spec, int index)
 
void s4_fetchspec_update_key (s4_t *s4, s4_fetchspec_t *spec)
 
const s4_result_ts4_result_next (const s4_result_t *res)
 Gets the next result. More...
 
const char * s4_result_get_key (const s4_result_t *res)
 Gets the result key. More...
 
const char * s4_result_get_src (const s4_result_t *res)
 Gets the result source. More...
 
const s4_val_ts4_result_get_val (const s4_result_t *res)
 Gets the result value. More...
 
void s4_resultrow_set_col (s4_resultrow_t *row, int col_no, s4_result_t *col)
 Sets a column in a resultrow. More...
 
int s4_resultrow_get_col (const s4_resultrow_t *row, int col_no, const s4_result_t **col)
 Gets the value of a column in a resultrow. More...
 
s4_resultset_ts4_resultset_create (int col_count)
 Creates a new resultset. More...
 
void s4_resultset_add_row (s4_resultset_t *set, const s4_resultrow_t *row)
 Adds a row to a resultset. More...
 
int s4_resultset_get_row (const s4_resultset_t *set, int row_no, const s4_resultrow_t **row)
 Gets a row from a resultset. More...
 
const s4_result_ts4_resultset_get_result (const s4_resultset_t *set, int row, int col)
 Gets a result from a resultset. More...
 
int s4_resultset_get_colcount (const s4_resultset_t *set)
 Gets the column count for a resultset. More...
 
int s4_resultset_get_rowcount (const s4_resultset_t *set)
 Gets the row count for a resultset. More...
 
void s4_resultset_free (s4_resultset_t *set)
 Frees a resultset and all the results in it. More...
 
s4_resultset_ts4_resultset_ref (s4_resultset_t *set)
 
void s4_resultset_unref (s4_resultset_t *set)
 
void s4_resultset_sort (s4_resultset_t *set, s4_order_t *order)
 Sorts a resultset. More...
 
void s4_resultset_shuffle (s4_resultset_t *set)
 Shuffles the resultset into a pseudo-random order. More...
 
s4_order_ts4_order_create (void)
 
s4_order_entry_ts4_order_add_column (s4_order_t *order, s4_cmp_mode_t collation, s4_order_direction_t direction)
 
s4_order_entry_ts4_order_add_random (s4_order_t *order, int seed)
 
void s4_order_entry_add_choice (s4_order_entry_t *entry, int column)
 
void s4_order_free (s4_order_t *order)
 
s4_pattern_ts4_pattern_create (const char *pattern, int normalize)
 Creates a new pattern. More...
 
int s4_pattern_match (const s4_pattern_t *p, const s4_val_t *val)
 Matches a pattern against a value. More...
 
void s4_pattern_free (s4_pattern_t *pattern)
 Frees a pattern created with s4_pattern_create. More...
 
char * s4_string_collate (const char *str)
 Creates a string that orders correctly according to the locale. More...
 
char * s4_string_casefold (const char *str)
 Creates a casefolded version of the string. More...
 
s4_transaction_ts4_begin (s4_t *s4, int flags)
 Starts a new transaction. More...
 
int s4_commit (s4_transaction_t *trans)
 Commits a transaction. More...
 
int s4_abort (s4_transaction_t *trans)
 Aborts a transaction. More...
 
int s4_add (s4_transaction_t *trans, const char *key_a, const s4_val_t *val_a, const char *key_b, const s4_val_t *val_b, const char *src)
 Adds a relationship to the database. More...
 
int s4_del (s4_transaction_t *trans, const char *key_a, const s4_val_t *val_a, const char *key_b, const s4_val_t *val_b, const char *src)
 Deletes a relationship from the database. More...
 
s4_resultset_ts4_query (s4_transaction_t *trans, s4_fetchspec_t *fs, s4_condition_t *cond)
 Queries an S4 database. More...
 

Macro Definition Documentation

#define S4_COND_PARENT   1
#define S4_FETCH_DATA   2
#define S4_FETCH_PARENT   1

Referenced by xmms_fetch_info_new().

Typedef Documentation

typedef int(* check_function_t)(s4_condition_t *cond, void *data)
typedef int(* combine_function_t)(s4_condition_t *cond, check_function_t func, void *check_data)
typedef int(* filter_function_t)(const s4_val_t *value, s4_condition_t *data)
typedef void(* free_func_t)(void *)
typedef struct s4_condition_St s4_condition_t
typedef struct s4_fetchspec_St s4_fetchspec_t
typedef struct s4_order_entry_St s4_order_entry_t
typedef struct s4_order_St s4_order_t
typedef struct s4_pattern_St s4_pattern_t
typedef struct s4_result_St s4_result_t
typedef struct s4_resultrow_St s4_resultrow_t
typedef struct s4_resultset_St s4_resultset_t
typedef struct s4_sourcepref_St s4_sourcepref_t
typedef struct s4_St s4_t
typedef struct s4_transaction_St s4_transaction_t
typedef struct s4_val_St s4_val_t

Enumeration Type Documentation

Enumerator
S4_CMP_BINARY 

Compare the values byte by byte.

S4_CMP_CASELESS 

Compare casefolded versions of the strings.

S4_CMP_COLLATE 

Compare collated keys (taking locale into account)

Enumerator
S4_COMBINE_AND 
S4_COMBINE_OR 
S4_COMBINE_NOT 
S4_COMBINE_CUSTOM 
enum s4_errno_t

Error codes.

Enumerator
S4E_NOERROR 

No error to report.

S4E_EXISTS 

Tried to open a database with S4_NEW, but the file already exists.

S4E_NOENT 

Tried to open a database with S4_EXISTS, but it did not exist.

S4E_OPEN 

fopen failed when trying to open the database.

errno has more details

S4E_MAGIC 

Magic number was not correct.

Probably not an S4 database

S4E_VERSION 

Version number was incorrect.

S4E_INCONS 

Database is inconsistent.

S4E_LOGOPEN 

Could not open log file.

See errno for more details

S4E_LOGREDO 

Could not redo changes in the log.

Probably corrupted log

S4E_DEADLOCK 

The transaction deadlocked and was aborted.

S4E_EXECUTE 

One of the operations in the transaction failed.

S4E_LOGFULL 

Not enough room in the log for the transaction.

S4E_READONLY 

Tried to use s4_add or s4_del on a read-only transaction.

Enumerator
S4_FILTER_EQUAL 
S4_FILTER_NOTEQUAL 
S4_FILTER_GREATER 
S4_FILTER_SMALLER 
S4_FILTER_GREATEREQ 
S4_FILTER_SMALLEREQ 
S4_FILTER_MATCH 
S4_FILTER_EXISTS 
S4_FILTER_TOKEN 
S4_FILTER_CUSTOM 

Flags for s4_open.

Enumerator
S4_NEW 
S4_EXISTS 
S4_MEMORY 
Enumerator
S4_ORDER_ASCENDING 
S4_ORDER_DESCENDING 

Flags for s4_begin.

Enumerator
S4_TRANS_READONLY 

Function Documentation

char* s4_string_casefold ( const char *  str)

Creates a casefolded version of the string.

Parameters
strThe string to casefold
Returns
A casefolded version of str, free with g_free

Referenced by _string_lookup_casefolded(), and s4_val_get_casefolded_str().

char* s4_string_collate ( const char *  str)

Creates a string that orders correctly according to the locale.

Parameters
strThe string to collate
Returns
A collated version of str, must be freed with g_free

Referenced by _string_lookup_collated(), and s4_val_get_collated_str().