Loading [MathJax]/jax/output/HTML-CSS/config.js
mightymandel
v16
GPU-based Mandelbrot set explorer
mightymandel
INDEX
README
CHANGES
BENCHMARKS
TESTING
HACKING
BUGS
TODO
WINDOWS
CODE
Namespaces
Data Structures
Files
File List
atom.c
atom.h
blob_set.c
blob_set.h
completion.c
completion.h
complex.c
complex.h
config.glsl
crc.c
crc.h
filename.c
filename.h
find_ref.c
find_ref.h
fp32_colour.c
fp32_colour.h
fp32_colour2_frag.glsl
fp32_colour2_vert.glsl
fp32_colour_frag.glsl
fp32_colour_vert.glsl
fp32_complex.glsl
fp32_escaped.c
fp32_escaped.h
fp32_escaped_frag.glsl
fp32_escaped_geom.glsl
fp32_escaped_vert.glsl
fp32_fillc.c
fp32_fillc.h
fp32_fillc_frag.glsl
fp32_fillc_vert.glsl
fp32_init.c
fp32_init.h
fp32_init_vert.glsl
fp32_preamble.glsl
fp32_step.c
fp32_step.h
fp32_step_vert.glsl
fp32_unescaped.c
fp32_unescaped.h
fp32_unescaped_geom.glsl
fp32_unescaped_vert.glsl
fp64_complex.glsl
fp64_escaped.c
fp64_escaped.h
fp64_escaped_frag.glsl
fp64_escaped_geom.glsl
fp64_escaped_vert.glsl
fp64_init.c
fp64_init.h
fp64_init_vert.glsl
fp64_preamble.glsl
fp64_step.c
fp64_step.h
fp64_step_vert.glsl
fp64_unescaped.c
fp64_unescaped.h
fp64_unescaped_geom.glsl
fp64_unescaped_vert.glsl
fpxx_approx.c
fpxx_approx.h
fpxx_approx_vert.glsl
fpxx_escaped.c
fpxx_escaped.h
fpxx_escaped_frag.glsl
fpxx_escaped_geom.glsl
fpxx_escaped_vert.glsl
fpxx_init.c
fpxx_init.h
fpxx_init_frag.glsl
fpxx_init_geom.glsl
fpxx_init_vert.glsl
fpxx_step.c
fpxx_step.h
fpxx_step_vert.glsl
fpxx_unescaped.c
fpxx_unescaped.h
fpxx_unescaped_geom.glsl
fpxx_unescaped_vert.glsl
image.c
image.h
interact.c
interact.h
logging.c
logging.h
metadata.c
metadata.h
mightymandel.c
mightymandel.h
parse.c
parse.h
parse_gif.c
parse_gif.h
parse_kfr.c
parse_kfr.h
parse_mdz_center.c
parse_mdz_center.h
parse_mdz_corners.c
parse_mdz_corners.h
parse_mm.c
parse_mm.h
parse_png.c
parse_png.h
parse_ppar_center.c
parse_ppar_center.h
parse_ppar_corners.c
parse_ppar_corners.h
parse_ppm.c
parse_ppm.h
parse_sft.c
parse_sft.h
png.c
png.h
poll.c
poll.h
record.c
record.h
ref_set.c
ref_set.h
render.c
render.h
shader.c
shader.h
slice.c
slice.h
startup.c
startup.h
stopwatch.c
stopwatch.h
texture.c
texture.h
tiling.c
tiling.h
utility.c
utility.h
version.c
version.h
vram.c
vram.h
zoom.c
zoom.h
Globals
metadata.c
Go to the documentation of this file.
1
// mightymandel -- GPU-based Mandelbrot Set explorer
2
// Copyright (C) 2012,2013,2014,2015 Claude Heiland-Allen
3
// License GPL3+ http://www.gnu.org/licenses/gpl.html
4
5
#include <stdbool.h>
6
#include <stdio.h>
7
#include <stdlib.h>
8
#include <string.h>
9
10
#include "
metadata.h
"
11
12
struct
metadata_node
{
13
struct
metadata_node
*
next
;
14
struct
metadata_node
*
prev
;
15
char
*
key
;
16
char
*
value
;
17
};
18
19
struct
metadata
{
20
struct
metadata_node
head
;
21
struct
metadata_node
tail
;
22
};
23
24
struct
metadata
*
metadata_new
() {
25
struct
metadata
*s = calloc(1,
sizeof
(
struct
metadata
));
26
s->
head
.
next
= &s->
tail
;
27
s->
tail
.
prev
= &s->
head
;
28
return
s;
29
}
30
31
void
metadata_delete
(
struct
metadata
*s) {
32
struct
metadata_node
*n = s->
head
.
next
;
33
while
(n->
next
) {
34
n->
prev
->
next
= n->
next
;
35
n->
next
->
prev
= n->
prev
;
36
struct
metadata_node
*m = n->
next
;
37
free(n->
key
);
38
free(n->
value
);
39
free(n);
40
n = m;
41
}
42
}
43
44
struct
metadata_node
*
metadata_find
(
struct
metadata
*s,
const
char
*
key
) {
45
struct
metadata_node
*n = s->
head
.
next
;
46
while
(n->
next
) {
47
if
(0 == strcmp(n->
key
, key)) {
48
return
n;
49
}
50
n = n->
next
;
51
}
52
return
0;
53
}
54
55
const
char
*
metadata_lookup
(
struct
metadata
*s,
const
char
*
key
) {
56
struct
metadata_node
*n =
metadata_find
(s, key);
57
if
(n) {
58
return
n->
value
;
59
}
60
return
0;
61
}
62
63
void
metadata_update
(
struct
metadata
*s,
const
char
*
key
,
const
char
*
value
) {
64
struct
metadata_node
*n =
metadata_find
(s, key);
65
if
(n) {
66
free(n->
value
);
67
n->
value
= strdup(value);
68
}
else
{
69
n = calloc(1,
sizeof
(
struct
metadata_node
));
70
n->
key
= strdup(key);
71
n->
value
= strdup(value);
72
n->
next
= &s->
tail
;
73
n->
prev
= s->
tail
.
prev
;
74
n->
next
->
prev
= n;
75
n->
prev
->
next
= n;
76
}
77
}
78
79
void
metadata_remove
(
struct
metadata
*s,
const
char
*
key
) {
80
struct
metadata_node
*n =
metadata_find
(s, key);
81
if
(! n) {
82
return
;
83
}
84
n->
prev
->
next
= n->
next
;
85
n->
next
->
prev
= n->
prev
;
86
free(n->
key
);
87
free(n->
value
);
88
free(n);
89
}
90
91
int
metadata_strlen
(
const
struct
metadata
*s,
const
char
*prefix) {
92
int
l = 0;
93
struct
metadata_node
*n = s->
head
.
next
;
94
while
(n->
next
) {
95
l += strlen(prefix) + strlen(n->
key
) + 1 + strlen(n->
value
) + 1;
96
n = n->
next
;
97
}
98
return
l;
99
}
100
101
bool
metadata_string
(
const
struct
metadata
*s,
const
char
*prefix,
char
*
string
,
int
length) {
102
char
*str = string;
103
char
*end =
string
+ length;
104
const
struct
metadata_node
*n = s->
head
.
next
;
105
while
(n->
next
&& str < end) {
106
str += snprintf(str, end - str,
"%s%s %s\n"
, prefix, n->
key
, n->
value
);
107
n = n->
next
;
108
}
109
return
str <= end;
110
}
src
metadata.c
Generated on Mon Jan 19 2015 16:18:12 for mightymandel by
1.8.1.2