File: strings.h

package info (click to toggle)
dwarves-dfsg 1.12-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 812 kB
  • sloc: ansic: 14,573; python: 903; makefile: 36
file content (55 lines) | stat: -rw-r--r-- 1,371 bytes parent folder | download
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
#ifndef _STRINGS_H_
#define _STRINGS_H_ 1
/*
  Copyright (C) 2008 Arnaldo Carvalho de Melo <acme@redhat.com>

  This program is free software; you can redistribute it and/or modify it
  under the terms of version 2 of the GNU General Public License as
  published by the Free Software Foundation.
*/

#include "gobuffer.h"

typedef unsigned int strings_t;

struct strings {
	void		*tree;
	struct gobuffer	gb;
};

struct strings *strings__new(void);

void strings__delete(struct strings *strings);

strings_t strings__add(struct strings *strings, const char *str);
strings_t strings__find(struct strings *strings, const char *str);

int strings__cmp(const struct strings *strings, strings_t a, strings_t b);

static inline const char *strings__ptr(const struct strings *strings, strings_t s)
{
	return gobuffer__ptr(&strings->gb, s);
}

static inline const char *strings__entries(const struct strings *strings)
{
	return gobuffer__entries(&strings->gb);
}

static inline unsigned int strings__nr_entries(const struct strings *strings)
{
	return gobuffer__nr_entries(&strings->gb);
}

static inline strings_t strings__size(const struct strings *strings)
{
	return gobuffer__size(&strings->gb);
}

static inline const char *strings__compress(struct strings *strings,
					    unsigned int *size)
{
	return gobuffer__compress(&strings->gb, size);
}

#endif /* _STRINGS_H_ */