Skip to content

Commit

Permalink
vte: New VTE_dump() utility
Browse files Browse the repository at this point in the history
  • Loading branch information
dridi committed May 7, 2024
1 parent a367c01 commit ae65ef4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/vte.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,5 @@ int VTE_cat(struct vte *, const char *);
int VTE_printf(struct vte *, const char *, ...) v_printflike_(2, 3);
int VTE_finish(struct vte *);
int VTE_format(const struct vte *, VTE_format_f *func, void *priv);
int VTE_dump(const struct vte *, VTE_format_f *func, void *priv);
void VTE_destroy(struct vte **);
17 changes: 17 additions & 0 deletions lib/libvarnish/vte.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,23 @@ VTE_finish(struct vte *vte)
return (-1); \
} while (0)

int
VTE_dump(const struct vte *vte, VTE_format_f *func, void *priv)
{
const char *p;

CHECK_OBJ_NOTNULL(vte, VTE_MAGIC);
AN(func);

if (vte->o_sep <= 0)
return (-1);

p = VSB_data(vte->vsb);
AN(p);
VTE_FORMAT(func, priv, "%s", p);
return (0);
}

int
VTE_format(const struct vte *vte, VTE_format_f *func, void *priv)
{
Expand Down

0 comments on commit ae65ef4

Please sign in to comment.