summaryrefslogtreecommitdiffstats
path: root/src/proplist.h
blob: 5af15e3285dfb0f6bbf7cc3199aa55d19372625b (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
#ifndef foocanberraproplisthfoo
#define foocanberraproplisthfoo

/***
  This file is part of libcanberra.

  Copyright 2008 Lennart Poettering

  libcanberra is free software; you can redistribute it and/or modify
  it under the terms of the GNU Lesser General Public License as
  published by the Free Software Foundation, either version 2.1 of the
  License, or (at your option) any later version.

  libcanberra is distributed in the hope that it will be useful, but
  WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public
  License along with libcanberra. If not, If not, see
  <http://www.gnu.org/licenses/>.
***/

#include "canberra.h"
#include "mutex.h"

#define N_HASHTABLE 31

typedef struct ca_prop {
    char *key;
    size_t nbytes;
    struct ca_prop *next_in_slot, *next_item, *prev_item;
} ca_prop;

#define CA_PROP_DATA(p) ((void*) ((char*) (p) + CA_ALIGN(sizeof(ca_prop))))

struct ca_proplist {
    ca_mutex *mutex;

    ca_prop *prop_hashtable[N_HASHTABLE];
    ca_prop *first_item;
};

int ca_proplist_merge(ca_proplist **_a, ca_proplist *b, ca_proplist *c);
ca_bool_t ca_proplist_contains(ca_proplist *p, const char *key);

/* Both of the following two functions are not locked! Need manual locking! */
ca_prop* ca_proplist_get_unlocked(ca_proplist *p, const char *key);
const char* ca_proplist_gets_unlocked(ca_proplist *p, const char *key);

#endif