36 result = (
struct string *)malloc(
sizeof(
struct string));
37 assert(result != NULL);
38 memset(result, 0,
sizeof(
struct string));
50 result->
length = strlen(s);
52 result->
length = (size_t)l;
55 assert(result->
content != NULL);
80 x = (int32_t)ntohl((uint32_t)x);
81 snprintf(buf,
sizeof(buf),
"%lld", (
long long)x);
95 snprintf(buf,
sizeof(buf),
"%llu", (
unsigned long long)x);
108 x = (int16_t)ntohs((uint16_t)x);
109 snprintf(buf,
sizeof(buf),
"%hd", x);
123 snprintf(buf,
sizeof(buf),
"%hu", x);
136 snprintf(buf,
sizeof(buf),
"%hhd", x);
149 snprintf(buf,
sizeof(buf),
"%hhu", x);
170 assert((l == 0) || (s != NULL));
173 for (i = 0; i < l; i++) {
174 snprintf(buf,
sizeof(buf),
"%02hhx", (uint8_t)s[i]);
187 assert((l == 0) || (s != NULL));
190 for (i = 0; i < l; i++) {
194 snprintf(buf,
sizeof(buf),
"%02hhx", (uint8_t)s[i]);
205 assert(inet_ntop(AF_INET, s, buf,
sizeof(buf)) != NULL);
214 assert(inet_pton(AF_INET, s, a) == 1);
215 snprintf(buf,
sizeof(buf),
"%02hhx%02hhx%02hhx%02hhx",
216 a[0], a[1], a[2], a[3]);
225 assert(inet_ntop(AF_INET6, s, buf,
sizeof(buf)) != NULL);
240 while ((dot = strchr(p,
'.')) != NULL) {
244 if ((len & 0xc0) != 0)
296 assert((l % step) == 0);
343eqString(
const struct string *s,
const struct string *o)
371 assert(
line != NULL);
437 assert(elem != NULL);
438 memset(elem, 0,
sizeof(
struct element));
532 assert(e->
key == NULL);
655 assert(elem != NULL);
656 assert(elem->
key == NULL);
659 for (j = i; j > 0; --j) {
661 assert(elem != NULL);
662 assert(elem->
key == NULL);
682 assert(prev != NULL);
683 assert(prev->
key == NULL);
686 for (j = i; j > 1; --j) {
688 assert(prev != NULL);
689 assert(prev->
key == NULL);
716 assert(elem != NULL);
717 assert(elem->
key == NULL);
720 for (j = i; j > 0; --j) {
722 assert(elem != NULL);
723 assert(elem->
key == NULL);
740 assert(elem->
key == NULL);
768 assert(elem->
key != NULL);
769 if (strcmp(elem->
key, k) == 0)
784 assert(
mapGet(m, k) == NULL);
787 assert(e->
key != NULL);
801 assert(elem->
key != NULL);
802 if (strcmp(elem->
key, k) == 0)
806 assert(elem != NULL);
820 assert(elem->
key != NULL);
821 if (strcmp(elem->
key, k) == 0)
825 return ISC_TF(elem != NULL);
839 assert(elem->
key != NULL);
858 assert(elem->
key != NULL);
871 return "not initialized?";
879 return "(unused) null";
898 if (strcmp(n,
"integer") == 0)
900 if (strcmp(n,
"real") == 0)
902 if (strcmp(n,
"boolean") == 0)
904 if (strcmp(n,
"null") == 0)
906 if (strcmp(n,
"string") == 0)
908 if (strcmp(n,
"list") == 0)
910 if (strcmp(n,
"map") == 0)
944 fprintf(fp,
"false");
962 for (sp = 0; sp <
indent - 2; ++sp)
965 for (sp = 0; sp <
indent; ++sp)
989 assert(elem->
key == NULL);
991 skip_elem = elem->
skip;
1002 addIndent(fp, skip_elem,
indent + 2);
1005 addIndent(fp, skip_elem,
indent + 2);
1009 addIndent(fp, skip,
indent);
1033 assert(elem->
key != NULL);
1035 skip_elem = elem->
skip;
1046 addIndent(fp, skip_elem,
indent + 2);
1049 addIndent(fp, skip_elem,
indent + 2);
1050 fprintf(fp,
"\"%s\": ", elem->
key);
1054 addIndent(fp, skip,
indent);
1067 for (i = 0; i < s->
length; i++) {
1072 fprintf(fp,
"\\\"");
1075 fprintf(fp,
"\\\\");
1093 if ((c >= 0) && (c < 0x20)) {
1094 fprintf(fp,
"\\u%04x", (
unsigned)c & 0xff);
1096 fprintf(fp,
"%c", c);
1110 }
while (e != NULL);
1196 memset(h, 0,
sizeof(
struct handle));
1200 assert(item != NULL);
1201 assert(item->
key != NULL);
1202 h->
key = strdup(item->
key);
1203 assert(h->
key != NULL);
1221 assert(list != NULL);
1223 for (i = 0; i <
listSize(list); i++) {
1225 assert(item != NULL);
struct element * copyList(struct element *l)
void concatString(struct string *s, const struct string *a)
void listPush(struct element *l, struct element *e)
struct comment * createComment(const char *line)
void resetInt(struct element *e, int64_t i)
isc_boolean_t eqString(const struct string *s, const struct string *o)
struct string * makeString(int l, const char *s)
isc_boolean_t boolValue(const struct element *e)
struct element * copy(struct element *e)
struct element * createHexa(struct string *h)
void listRemove(struct element *l, int i)
struct element * createList(void)
struct element * createBool(isc_boolean_t b)
struct string * allocString(void)
struct handle * mapPop(struct element *m)
void resetBool(struct element *e, isc_boolean_t b)
size_t mapSize(const struct element *m)
void appendString(struct string *s, const char *a)
struct string * makeStringArray(int l, const char *s, char fmt)
struct element * listGet(struct element *l, int i)
struct string * stringValue(struct element *e)
struct element * createNull(void)
double doubleValue(const struct element *e)
void resetNull(struct element *e)
void resetDouble(struct element *e, double d)
void resetList(struct element *e)
void concat(struct element *l, struct element *o)
void printString(FILE *fp, const struct string *s)
isc_boolean_t mapContains(const struct element *m, const char *k)
struct element * create(void)
void printMap(FILE *fp, const struct map *m, isc_boolean_t skip, unsigned indent)
void derive(struct handle *src, struct handle *dst)
struct string * quote(struct string *s)
struct string * hexaValue(struct element *s)
struct map * mapValue(struct element *e)
struct element * copyMap(struct element *m)
struct element * createInt(int64_t i)
int name2type(const char *n)
void merge(struct element *m, struct element *o)
void mapSet(struct element *m, struct element *e, const char *k)
struct element * createDouble(double d)
isc_boolean_t skip_to_end(const struct element *e)
void listSet(struct element *l, struct element *e, int i)
size_t listSize(const struct element *l)
void resetString(struct element *e, const struct string *s)
struct list * listValue(struct element *e)
struct element * createMap(void)
void print(FILE *fp, const struct element *e, isc_boolean_t skip, unsigned indent)
struct element * createString(const struct string *s)
void printList(FILE *fp, const struct list *l, isc_boolean_t skip, unsigned indent)
void resetBy(struct element *e, struct element *o)
void mapRemove(struct element *m, const char *k)
struct element * mapGet(struct element *m, const char *k)
int64_t intValue(const struct element *e)
const char * type2name(int t)
void resetMap(struct element *e)
struct string * makeStringExt(int l, const char *s, char fmt)
#define TAILQ_INSERT_AFTER(head, listelm, elm)
#define TAILQ_FOREACH_SAFE(var, head, tvar)
#define TAILQ_INSERT_TAIL(head, elm)
#define TAILQ_FOREACH(var, head)
#define TAILQ_CONCAT(head1, head2)
#define TAILQ_FIRST(head)
#define TAILQ_REMOVE(head, elm)
#define TAILQ_EMPTY(head)
#define TAILQ_INSERT_HEAD(head, elm)
struct string string_value