Skip to content

Commit

Permalink
Added build instructions to README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
ajwans committed Jan 7, 2014
1 parent 31d2fc6 commit dc09aa6
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
20 changes: 19 additions & 1 deletion README.md
Expand Up @@ -3,7 +3,7 @@ libtoml

Fast C parser using Ragel to generate the state machine.

Currently targetted at toml b098bd2.
Currently targetted at toml 4f23be43e4 (minus UTF-8)

Usage
=====
Expand All @@ -13,6 +13,7 @@ Usage

struct toml_node *root;
struct toml_node *node;
char *buf = "[foo]\nbar = 1\n";

toml_init(&root);
toml_parse(toml_root, buf, len);
Expand All @@ -23,6 +24,23 @@ toml_dump(toml_root, stdout);
toml_free(root);
```
Building it
===========
```sh
> autoconf
> ./configure
> make
```

If you want to run the tests

```sh
> ./configure --with-cunit=<path_to_cunit>
> make test
> ./test
```

TODO
====

Expand Down
9 changes: 6 additions & 3 deletions toml.c
Expand Up @@ -11,8 +11,6 @@

#include "toml.h"

typedef void (*toml_node_walker)(struct toml_node *, void *);

int
toml_init(struct toml_node **toml_root)
{
Expand Down Expand Up @@ -200,7 +198,6 @@ _toml_walk(struct toml_node *node, toml_node_walker fn, void *ctx)

list_for_each_safe(&node->value.list, item, next, list) {
_toml_walk(&item->node, fn, ctx);
free(item);
}
break;
}
Expand All @@ -214,6 +211,12 @@ _toml_walk(struct toml_node *node, toml_node_walker fn, void *ctx)
}
}

void
toml_walk(struct toml_node *root, toml_node_walker fn, void *ctx)
{
_toml_walk(root, fn, ctx);
}

void
toml_dump(struct toml_node *toml_root, FILE *output)
{
Expand Down
3 changes: 3 additions & 0 deletions toml.h
Expand Up @@ -41,11 +41,14 @@ struct toml_list_item {
struct toml_node node;
};

typedef void (*toml_node_walker)(struct toml_node *, void *);

int toml_init(struct toml_node **);
int toml_parse(struct toml_node *, char *, int);
struct toml_node *toml_get(struct toml_node *, char *);
void toml_dump(struct toml_node *, FILE *);
void toml_tojson(struct toml_node *, FILE *);
void toml_free(struct toml_node *);
void toml_walk(struct toml_node *, toml_node_walker, void *);

#endif

0 comments on commit dc09aa6

Please sign in to comment.