summaryrefslogtreecommitdiff
path: root/apps/tagdb/file.h
diff options
context:
space:
mode:
authorNiels Laukens <niobos@rockbox.org>2005-07-06 11:03:20 +0000
committerNiels Laukens <niobos@rockbox.org>2005-07-06 11:03:20 +0000
commitd1c294c17de95615b7af428da938b686830b42df (patch)
tree950080f5b6c9503c090df6e4f0929f13eae8891e /apps/tagdb/file.h
parent5e9f52f6d1f3356bc6df75a675e1a2d5cdbf9d77 (diff)
downloadrockbox-d1c294c17de95615b7af428da938b686830b42df.zip
rockbox-d1c294c17de95615b7af428da938b686830b42df.tar.gz
rockbox-d1c294c17de95615b7af428da938b686830b42df.tar.bz2
rockbox-d1c294c17de95615b7af428da938b686830b42df.tar.xz
Initial import of tagdb
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7039 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/tagdb/file.h')
-rw-r--r--apps/tagdb/file.h84
1 files changed, 84 insertions, 0 deletions
diff --git a/apps/tagdb/file.h b/apps/tagdb/file.h
new file mode 100644
index 0000000..d2538a7
--- /dev/null
+++ b/apps/tagdb/file.h
@@ -0,0 +1,84 @@
+#ifndef __FILE_H__
+#define __FILE_H__
+
+#include "config.h"
+#include <stdio.h>
+#include <stdint.h>
+
+struct file_entry {
+ char* name; // song name
+
+ uint32_t hash;
+ uint32_t song; // pointer to song
+ uint32_t rundb; // pointer to rundb
+
+ struct file_size {
+ uint32_t name_len; // must be mulitple of 4
+ } size;
+ unsigned char flag; // flags
+};
+
+struct file_entry* new_file_entry(const uint32_t name_len);
+/* Creates a new file_entry with the specified sizes
+ * Returns a pointer to the structure on success,
+ * NULL on failure
+ */
+
+int file_entry_destruct(struct file_entry *e);
+/* Destructs the given file_entry and free()'s it's memory
+ * returns 0 on success, 1 on failure
+ */
+
+inline int file_entry_resize(struct file_entry *e, const uint32_t name_len);
+/* Change the size of the entry
+ * returns 0 on succes, 1 on failure
+ */
+
+int file_entry_serialize(FILE *fd, const struct file_entry *e);
+/* Serializes the entry in the file at the current position
+ * returns 0 on success, 1 on failure
+ */
+
+int file_entry_unserialize(struct file_entry* *e, FILE *fd);
+/* Unserializes an entry from file into a new structure
+ * The address of the structure is saved into *e
+ * returns 0 on success
+ * 1 on malloc() failure
+ * 2 on fread() failure
+ */
+
+int file_entry_write(FILE *fd, struct file_entry *e, struct file_size *s);
+/* Writes the entry to file in the final form
+ * returns 0 (0) on success, 1 (1) on failure
+ */
+
+inline int file_entry_compare(const struct file_entry *a, const struct file_entry *b);
+/* Compares 2 entries
+ * When a < b it returns <0
+ * a = b 0
+ * a > b >0
+ */
+
+struct file_size* new_file_size();
+/* Creates a new size structure
+ * returns a pointer to the structure on success,
+ * NULL on failure
+ */
+
+inline uint32_t file_size_get_length(const struct file_size *size);
+/* Calculates the length of the entry when written by file_entry_write()
+ * returns the length on success, 0xffffffff on failure
+ */
+
+inline int file_size_max(struct file_size *s, const struct file_entry *e);
+/* Updates the file_size structure to contain the maximal lengths of either
+ * the original entry in s, or the entry e
+ * returns 0 on success, 1 on failure
+ */
+
+int file_size_destruct(struct file_size *s);
+/* destructs the file_size structure
+ * returns 0 on success, 1 on failure
+ */
+
+#endif