Skip to content

Commit ee63f79

Browse files
Pretty: add the ability to stream out to a generic thing
Instead of always requiring FILE *. This does mean a slight code size increase, since we now have to pass an extra parameter down the function stack, plus we're making indirect calls, but it's worth it. Signed-off-by: Thiago Macieira <[email protected]>
1 parent 36bdbfb commit ee63f79

File tree

3 files changed

+147
-150
lines changed

3 files changed

+147
-150
lines changed

Diff for: src/cbor.h

+7
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,13 @@ enum CborPrettyFlags {
591591
CborPrettyDefaultFlags = CborPrettyIndicateIndetermineLength
592592
};
593593

594+
typedef CborError (*CborStreamFunction)(void *token, const char *fmt, ...)
595+
#ifdef __GNUC__
596+
__attribute__((__format__(printf, 2, 3)))
597+
#endif
598+
;
599+
600+
CBOR_API CborError cbor_value_to_pretty_stream(CborStreamFunction streamFunction, void *token, CborValue *value, int flags);
594601
CBOR_API CborError cbor_value_to_pretty_advance_flags(FILE *out, CborValue *value, int flags);
595602
CBOR_API CborError cbor_value_to_pretty_advance(FILE *out, CborValue *value);
596603
CBOR_INLINE_API CborError cbor_value_to_pretty(FILE *out, const CborValue *value)

0 commit comments

Comments
 (0)