| 8256 | } |
| 8257 | |
| 8258 | void |
| 8259 | xo_set_version_h (xo_handle_t *xop, const char *version) |
| 8260 | { |
| 8261 | xop = xo_default(xop); |
| 8262 | |
| 8263 | if (version == NULL || strchr(version, '"') != NULL) |
| 8264 | return; |
| 8265 | |
| 8266 | if (!xo_style_is_encoding(xop)) |
| 8267 | return; |
| 8268 | |
| 8269 | switch (xo_style(xop)) { |
| 8270 | case XO_STYLE_XML: |
| 8271 | /* For XML, we record this as an attribute for the first tag */ |
| 8272 | xo_attr_h(xop, "version", "%s", version); |
| 8273 | break; |
| 8274 | |
| 8275 | case XO_STYLE_JSON: |
| 8276 | /* |
| 8277 | * For JSON, we record the version string in our handle, and emit |
| 8278 | * it in xo_emit_top. |
| 8279 | */ |
| 8280 | xop->xo_version = xo_strndup(version, -1); |
| 8281 | break; |
| 8282 | |
| 8283 | case XO_STYLE_ENCODER: |
| 8284 | xo_encoder_handle(xop, XO_OP_VERSION, NULL, version, 0); |
| 8285 | break; |
| 8286 | } |
| 8287 | } |
| 8288 | |
| 8289 | /* |
| 8290 | * Set the version number for the API content being carried through |
no test coverage detected