File: rlist.h

package info (click to toggle)
cfengine3 3.24.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 37,552 kB
  • sloc: ansic: 163,161; sh: 10,296; python: 2,950; makefile: 1,744; lex: 784; yacc: 633; perl: 211; pascal: 157; xml: 21; sed: 13
file content (119 lines) | stat: -rw-r--r-- 4,626 bytes parent folder | download | duplicates (2)
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/*
  Copyright 2024 Northern.tech AS

  This file is part of CFEngine 3 - written and maintained by Northern.tech AS.

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

  This program 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 General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA

  To the extent this program is licensed as part of the Enterprise
  versions of CFEngine, the applicable Commercial Open Source License
  (COSL) may apply to this file if you as a licensee so wish it. See
  included file COSL.txt.
*/

#ifndef CFENGINE_RLIST_H
#define CFENGINE_RLIST_H

#include <cf3.defs.h>
#include <writer.h>
#include <json.h>
#include <fncall.h>

/* NOTE: an empty Rlist is simply NULL. */
struct Rlist_
{
    Rval val;
    Rlist *next;
};

RvalType DataTypeToRvalType(DataType datatype);

bool RlistValueIsType(const Rlist *rlist, RvalType type);
char *RvalScalarValue(Rval rval);
FnCall *RvalFnCallValue(Rval rval);
Rlist *RvalRlistValue(Rval rval);
JsonElement *RvalContainerValue(Rval rval);

const char *RvalTypeToString(RvalType type);

Rval RvalNew(const void *item, RvalType type);

/**
 * Get new secret Rval.
 *
 * @note RvalDestroy() not required to be called on the returned value.
 */
Rval RvalNewSecret();

Rval RvalNewRewriter(const void *item, RvalType type, JsonElement *map);
Rval RvalCopy(Rval rval);
Rval RvalCopyRewriter(Rval rval, JsonElement *map);
void RvalDestroy(Rval rval);
JsonElement *RvalToJson(Rval rval);
char *RvalToString(Rval rval);
char *RlistToString(const Rlist *rlist);
void RvalWrite(Writer *writer, Rval rval);
void RvalWriteQuoted(Writer *writer, Rval rval);
void RvalWriteRaw(Writer *writer, Rval rval);
unsigned RvalHash(Rval rval, unsigned seed);

Rlist *RlistCopy(const Rlist *list);
Rlist *RlistCopyRewriter(const Rlist *list, JsonElement *map);
unsigned int RlistHash        (const Rlist *list, unsigned seed);
unsigned int RlistHash_untyped(const void *list, unsigned seed);
void RlistDestroy        (Rlist *list);
void RlistDestroy_untyped(void *rl);
void RlistDestroyEntry(Rlist **liststart, Rlist *entry);
char *RlistScalarValue(const Rlist *rlist);
char *RlistScalarValueSafe(const Rlist *rlist);
FnCall *RlistFnCallValue(const Rlist *rlist);
Rlist *RlistRlistValue(const Rlist *rlist);
Rlist *RlistParseShown(const char *string);
Rlist *RlistParseString(const char *string);
Rlist *RlistKeyIn(Rlist *list, const char *key);
int RlistLen(const Rlist *start);
bool RlistMatchesRegexRlist(const Rlist *list, const Rlist *search);
bool RlistMatchesRegex(const Rlist *list, const char *str);
bool RlistIsInListOfRegex(const Rlist *list, const char *str);
bool RlistIsNullList(const Rlist *list);
bool RlistContainsString(const Rlist *list, const char *string);

Rlist *RlistAppendRval(Rlist **start, Rval rval);

Rlist *RlistPrependScalarIdemp(Rlist **start, const char *scalar);
Rlist *RlistAppendScalarIdemp(Rlist **start, const char *scalar);
Rlist *RlistAppendScalar(Rlist **start, const char *scalar);

Rlist *RlistPrepend(Rlist **start, const void *item, RvalType type);
Rlist *RlistAppend(Rlist **start, const void *item, RvalType type);
Rlist *RlistAppendAllTypes(Rlist **start, const void *item, RvalType type, bool all_types);
Rlist *RlistAppendString(Rlist **start, const char *string);

Rlist *RlistFromSplitString(const char *string, char sep);
Rlist *RlistFromStringSplitLines(const char *string, bool detect_crlf);
Rlist *RlistFromSplitRegex(const char *string, const char *regex, size_t max_entries, bool allow_blanks);
Rlist *RlistFromRegexSplitNoOverflow(const char *string, const char *regex, int max);
Rlist *RlistFromContainer(const JsonElement *container);

void RlistWrite(Writer *writer, const Rlist *list);
Rlist *RlistLast(Rlist *start);
void RlistFilter(Rlist **list, bool (*KeepPredicate)(void *item, void *predicate_data), void *predicate_user_data, void (*DestroyItem)(void *item));
void RlistReverse(Rlist **list);
void ScalarWrite(Writer *w, const char *s, bool quote, bool raw);
void RlistFlatten(EvalContext *ctx, Rlist **list);
bool RlistEqual        (const Rlist *list1, const Rlist *list2);
bool RlistEqual_untyped(const void *list1, const void *list2);


#endif