]>
git.zerfleddert.de Git - proxmark3-svn/blob - client/tinycbor/cborpretty_stdio.c
1 /****************************************************************************
3 ** Copyright (C) 2017 Intel Corporation
5 ** Permission is hereby granted, free of charge, to any person obtaining a copy
6 ** of this software and associated documentation files (the "Software"), to deal
7 ** in the Software without restriction, including without limitation the rights
8 ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 ** copies of the Software, and to permit persons to whom the Software is
10 ** furnished to do so, subject to the following conditions:
12 ** The above copyright notice and this permission notice shall be included in
13 ** all copies or substantial portions of the Software.
15 ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 ****************************************************************************/
29 static CborError
cbor_fprintf(void *out
, const char *fmt
, ...)
35 n
= vfprintf((FILE *)out
, fmt
, list
);
38 return n
< 0 ? CborErrorIO
: CborNoError
;
42 * \fn CborError cbor_value_to_pretty(FILE *out, const CborValue *value)
44 * Converts the current CBOR type pointed to by \a value to its textual
45 * representation and writes it to the \a out stream. If an error occurs, this
46 * function returns an error code similar to CborParsing.
48 * \sa cbor_value_to_pretty_advance(), cbor_value_to_json_advance()
52 * Converts the current CBOR type pointed to by \a value to its textual
53 * representation and writes it to the \a out stream. If an error occurs, this
54 * function returns an error code similar to CborParsing.
56 * If no error ocurred, this function advances \a value to the next element.
57 * Often, concatenating the text representation of multiple elements can be
58 * done by appending a comma to the output stream in between calls to this
61 * \sa cbor_value_to_pretty(), cbor_value_to_pretty_stream(), cbor_value_to_json_advance()
63 CborError
cbor_value_to_pretty_advance(FILE *out
, CborValue
*value
)
65 return cbor_value_to_pretty_stream(cbor_fprintf
, out
, value
, CborPrettyDefaultFlags
);
69 * Converts the current CBOR type pointed to by \a value to its textual
70 * representation and writes it to the \a out stream. If an error occurs, this
71 * function returns an error code similar to CborParsing.
73 * The textual representation can be controlled by the \a flags parameter (see
74 * CborPrettyFlags for more information).
76 * If no error ocurred, this function advances \a value to the next element.
77 * Often, concatenating the text representation of multiple elements can be
78 * done by appending a comma to the output stream in between calls to this
81 * \sa cbor_value_to_pretty_stream(), cbor_value_to_pretty(), cbor_value_to_json_advance()
83 CborError
cbor_value_to_pretty_advance_flags(FILE *out
, CborValue
*value
, int flags
)
85 return cbor_value_to_pretty_stream(cbor_fprintf
, out
, value
, flags
);