diff options
author | Niels Laukens <niobos@rockbox.org> | 2005-07-06 11:03:20 +0000 |
---|---|---|
committer | Niels Laukens <niobos@rockbox.org> | 2005-07-06 11:03:20 +0000 |
commit | d1c294c17de95615b7af428da938b686830b42df (patch) | |
tree | 950080f5b6c9503c090df6e4f0929f13eae8891e /apps/tagdb/file.h | |
parent | 5e9f52f6d1f3356bc6df75a675e1a2d5cdbf9d77 (diff) | |
download | rockbox-d1c294c17de95615b7af428da938b686830b42df.tar.gz rockbox-d1c294c17de95615b7af428da938b686830b42df.zip |
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.h | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/apps/tagdb/file.h b/apps/tagdb/file.h new file mode 100644 index 0000000000..d2538a7569 --- /dev/null +++ b/apps/tagdb/file.h | |||
@@ -0,0 +1,84 @@ | |||
1 | #ifndef __FILE_H__ | ||
2 | #define __FILE_H__ | ||
3 | |||
4 | #include "config.h" | ||
5 | #include <stdio.h> | ||
6 | #include <stdint.h> | ||
7 | |||
8 | struct file_entry { | ||
9 | char* name; // song name | ||
10 | |||
11 | uint32_t hash; | ||
12 | uint32_t song; // pointer to song | ||
13 | uint32_t rundb; // pointer to rundb | ||
14 | |||
15 | struct file_size { | ||
16 | uint32_t name_len; // must be mulitple of 4 | ||
17 | } size; | ||
18 | unsigned char flag; // flags | ||
19 | }; | ||
20 | |||
21 | struct file_entry* new_file_entry(const uint32_t name_len); | ||
22 | /* Creates a new file_entry with the specified sizes | ||
23 | * Returns a pointer to the structure on success, | ||
24 | * NULL on failure | ||
25 | */ | ||
26 | |||
27 | int file_entry_destruct(struct file_entry *e); | ||
28 | /* Destructs the given file_entry and free()'s it's memory | ||
29 | * returns 0 on success, 1 on failure | ||
30 | */ | ||
31 | |||
32 | inline int file_entry_resize(struct file_entry *e, const uint32_t name_len); | ||
33 | /* Change the size of the entry | ||
34 | * returns 0 on succes, 1 on failure | ||
35 | */ | ||
36 | |||
37 | int file_entry_serialize(FILE *fd, const struct file_entry *e); | ||
38 | /* Serializes the entry in the file at the current position | ||
39 | * returns 0 on success, 1 on failure | ||
40 | */ | ||
41 | |||
42 | int file_entry_unserialize(struct file_entry* *e, FILE *fd); | ||
43 | /* Unserializes an entry from file into a new structure | ||
44 | * The address of the structure is saved into *e | ||
45 | * returns 0 on success | ||
46 | * 1 on malloc() failure | ||
47 | * 2 on fread() failure | ||
48 | */ | ||
49 | |||
50 | int file_entry_write(FILE *fd, struct file_entry *e, struct file_size *s); | ||
51 | /* Writes the entry to file in the final form | ||
52 | * returns 0 (0) on success, 1 (1) on failure | ||
53 | */ | ||
54 | |||
55 | inline int file_entry_compare(const struct file_entry *a, const struct file_entry *b); | ||
56 | /* Compares 2 entries | ||
57 | * When a < b it returns <0 | ||
58 | * a = b 0 | ||
59 | * a > b >0 | ||
60 | */ | ||
61 | |||
62 | struct file_size* new_file_size(); | ||
63 | /* Creates a new size structure | ||
64 | * returns a pointer to the structure on success, | ||
65 | * NULL on failure | ||
66 | */ | ||
67 | |||
68 | inline uint32_t file_size_get_length(const struct file_size *size); | ||
69 | /* Calculates the length of the entry when written by file_entry_write() | ||
70 | * returns the length on success, 0xffffffff on failure | ||
71 | */ | ||
72 | |||
73 | inline int file_size_max(struct file_size *s, const struct file_entry *e); | ||
74 | /* Updates the file_size structure to contain the maximal lengths of either | ||
75 | * the original entry in s, or the entry e | ||
76 | * returns 0 on success, 1 on failure | ||
77 | */ | ||
78 | |||
79 | int file_size_destruct(struct file_size *s); | ||
80 | /* destructs the file_size structure | ||
81 | * returns 0 on success, 1 on failure | ||
82 | */ | ||
83 | |||
84 | #endif | ||