Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add va_list overload of yajl_gen_config #215

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/api/yajl_gen.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#define __YAJL_GEN_H__

#include <stddef.h>
#include <stdarg.h>

#ifdef __cplusplus
extern "C" {
Expand Down Expand Up @@ -106,6 +107,8 @@ extern "C" {
* \returns zero in case of errors, non-zero otherwise
*/
YAJL_API int yajl_gen_config(yajl_gen g, yajl_gen_option opt, ...);

YAJL_API int yajl_gen_config_v(yajl_gen g, yajl_gen_option opt, va_list ap);

/** allocate a generator handle
* \param allocFuncs an optional pointer to a structure which allows
Expand Down
15 changes: 9 additions & 6 deletions src/yajl_gen.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,17 @@ struct yajl_gen_t
yajl_alloc_funcs alloc;
};

int
yajl_gen_config(yajl_gen g, yajl_gen_option opt, ...)
{
int rv = 1;
int yajl_gen_config(yajl_gen g, yajl_gen_option opt, ...) {
va_list ap;
va_start(ap, opt);
int rv = yajl_gen_config_v(g, opt, ap);
va_end(ap);
return rv;
}

int yajl_gen_config_v(yajl_gen g, yajl_gen_option opt, va_list ap)
{
int rv = 1;

switch(opt) {
case yajl_gen_beautify:
Expand Down Expand Up @@ -87,8 +92,6 @@ yajl_gen_config(yajl_gen g, yajl_gen_option opt, ...)
rv = 0;
}

va_end(ap);

return rv;
}

Expand Down