aboutsummaryrefslogtreecommitdiff
path: root/lib/libXDAAP/daap_contentcodes.h
blob: fb4b3884485e6a09af0c6f5b2538b989e0ab8bc9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/* list of known contentcodes
 *
 * Copyright (c) David Hammerton 2003
 *
 * FIXME: needs to be made per connection.. as some hosts may have
 *        different content codes.
 *
 *
 * Permission is hereby granted, free of charge, to any person
 * obtaining a copy of this software and associated documentation
 * files (the "Software"), to deal in the Software without
 * restriction, including without limitation the rights to use,
 * copy, modify, merge, publish, distribute, sublicense, and/or
 * sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 * OTHER DEALINGS IN THE SOFTWARE.
 *
 */

#ifndef _DAAP_CONTENTCODES_H
#define _DAAP_CONTENTCODES_H

#include "daap.h"

/* FIXME: replace this with a hashed dictionary, rather
 * than this linked list. its slow
 */

typedef struct dmap_ContentCodeContainerTAG dmap_ContentCodeContainer;
struct dmap_ContentCodeContainerTAG
{
    dmap_ContentCode c;
    dmap_ContentCodeContainer *next;
};

typedef struct
{
    char *prefix;
    dmap_ContentCodeContainer *codes;
} dmap_ContentCode_table;

const dmap_ContentCode *dmap_lookupCode(const dmap_ContentCode_table *table,
                                        const char *name);
const dmap_ContentCode *dmap_lookupCodeFromFOURCC(const dmap_ContentCode_table *table,
                                                  const dmap_contentCodeFOURCC fourcc);
/* add actually performs a duplicate test, also.
 * if the duplicate test matches, add will print an ERR if the records arn't
 * the same
 */
void dmap_addCode(dmap_ContentCode_table *table, const char *name,
                  const dmap_contentCodeFOURCC code, const dmap_DataTypes type);


extern dmap_ContentCode_table dmap_table;
extern dmap_ContentCode_table daap_table;
extern dmap_ContentCode_table com_table;

#define dmap_l(str) dmap_lookupCode(&dmap_table, str)
#define dmap_add(str, code, type) dmap_addCode(&dmap_table, str, code, type)

#define daap_l(str) dmap_lookupCode(&daap_table, str)
#define daap_add(str, code, type) dmap_addCode(&daap_table, str, code, type)

#define com_l(str) dmap_lookupCode(&com_table, str)
#define com_add(str, code, type) dmap_addCode(&com_table, str, code, type)

dmap_DataTypes dmap_isCC(const dmap_contentCodeFOURCC fourcc,
                         const dmap_ContentCode *code);


typedef void (*containerHandlerFunc)(dmap_contentCodeFOURCC code,
                                     const int size,
                                     const char *buffer,
                                     void *scopeData);
int dmap_parseContainer(containerHandlerFunc pfnHandler,
                        const int size, const char *buffer,
                        void *scopeData);

/* private structures, get passed around various container parses in daap.c */
typedef struct
{
    dmap_ContentCode c;
} scopeContentCodesDictionary;

#endif /* _DAAP_CONTENTCODES_H */