X-Git-Url: http://git.bytex64.net/?a=blobdiff_plain;f=database%2Fdatabase.h;h=e60d6099698ab6fcc915e9b317a0f235c8437c54;hb=7a6eb2318ad7e2c245649213780ad14ecc9a64a7;hp=0ef1c7ddc299342245cb6e68ff4c4f6acb277f47;hpb=1cf0f1ebfbd5b5a621af2a49ac0328fd0cec4bf4;p=blerg.git diff --git a/database/database.h b/database/database.h index 0ef1c7d..e60d609 100644 --- a/database/database.h +++ b/database/database.h @@ -1,9 +1,15 @@ +/* Blerg is (C) 2011 The Dominion of Awesome, and is distributed under a + * BSD-style license. Please see the COPYING file for details. + */ #ifndef _DATABASE_H #define _DATABASE_H #include #include +#define VALID_CHAR(c) ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '-' || c == '_') +#define WHITESPACE(c) (c == ' ' || c == '\t' || c == '\n' || c == '\r') + struct record { uint32_t offset; uint16_t length; @@ -13,8 +19,12 @@ struct record { struct meta { uint64_t sequence; + uint64_t subscription_mark; + uint32_t status; }; +#define BLERGMETA_MUTED 0x00000001 + struct blerg { int meta_fd; int index_fd; @@ -28,11 +38,18 @@ struct blerg { int data_size; }; -int blerg_exists(const char *); -struct blerg *blerg_open(const char *); -int blerg_close(struct blerg *); -int blerg_store(struct blerg *, const char *, int); -int blerg_fetch(struct blerg *, int, char **, int *); +#define BLERG_INVALID_RECORD 0xFFFFFFFFFFFFFFFF + +int blerg_exists(const char *name); +struct blerg *blerg_open(const char *name); +int blerg_close(struct blerg *blerg); +uint64_t blerg_store(struct blerg *blerg, const char *data, int length); +int blerg_fetch(struct blerg *blerg, uint64_t record, char **data, int *length); uint64_t blerg_get_record_count(struct blerg *); +time_t blerg_get_timestamp(struct blerg *blerg, uint64_t record); +int blerg_set_subscription_mark(struct blerg *blerg); +uint64_t blerg_get_subscription_mark(struct blerg *blerg); +int blerg_set_mute(struct blerg *blerg, int v); +int blerg_get_mute(struct blerg *blerg); #endif //_DATABASE_H