1 /*
2  * Wireshark - Network traffic analyzer
3  * By Gerald Combs <gerald@wireshark.org>
4  * Copyright 2001 Gerald Combs
5  *
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  */
9 
10 #include "syntax-tree.h"
11 
12 static gpointer
string_new(gpointer string)13 string_new(gpointer string)
14 {
15 	return (gpointer) g_strdup((char*) string);
16 }
17 
18 static gpointer
string_dup(gconstpointer string)19 string_dup(gconstpointer string)
20 {
21 	return (gpointer) g_strdup((const char*) string);
22 }
23 
24 static void
string_free(gpointer value)25 string_free(gpointer value)
26 {
27 	g_free(value);
28 }
29 
30 static char *
string_tostr(const void * data)31 string_tostr(const void *data)
32 {
33 	return g_strdup(data);
34 }
35 
36 
37 void
sttype_register_string(void)38 sttype_register_string(void)
39 {
40 	static sttype_t string_type = {
41 		STTYPE_STRING,
42 		"STRING",
43 		string_new,
44 		string_free,
45 		string_dup,
46 		string_tostr
47 	};
48 
49 	static sttype_t charconst_type = {
50 		STTYPE_CHARCONST,
51 		"CHARCONST",
52 		string_new,
53 		string_free,
54 		string_dup,
55 		string_tostr
56 	};
57 
58 	static sttype_t unparsed_type = {
59 		STTYPE_UNPARSED,
60 		"UNPARSED",
61 		string_new,
62 		string_free,
63 		string_dup,
64 		string_tostr
65 	};
66 
67 	sttype_register(&string_type);
68 	sttype_register(&charconst_type);
69 	sttype_register(&unparsed_type);
70 }
71 
72 /*
73  * Editor modelines  -  https://www.wireshark.org/tools/modelines.html
74  *
75  * Local variables:
76  * c-basic-offset: 8
77  * tab-width: 8
78  * indent-tabs-mode: t
79  * End:
80  *
81  * vi: set shiftwidth=8 tabstop=8 noexpandtab:
82  * :indentSize=8:tabSize=8:noTabs=false:
83  */
84