Home | History | Annotate | Download | only in libprop

Lines Matching refs:ctx

54     struct _prop_object_externalize_context *ctx, unsigned char c)
57 _PROP_ASSERT(ctx->poec_capacity != 0);
58 _PROP_ASSERT(ctx->poec_buf != NULL);
59 _PROP_ASSERT(ctx->poec_len <= ctx->poec_capacity);
61 if (ctx->poec_len == ctx->poec_capacity) {
62 char *cp = _PROP_REALLOC(ctx->poec_buf,
63 ctx->poec_capacity + BUF_EXPAND,
68 ctx->poec_capacity = ctx->poec_capacity + BUF_EXPAND;
69 ctx->poec_buf = cp;
72 ctx->poec_buf[ctx->poec_len++] = c;
83 struct _prop_object_externalize_context *ctx, const char *cp)
87 if (_prop_extern_append_char(ctx,
102 struct _prop_object_externalize_context *ctx, uint16_t val)
107 return _prop_extern_append_cstring(ctx, tmpstr);
112 struct _prop_object_externalize_context *ctx, const char *cp)
169 if (_prop_json_extern_append_escu(ctx,
182 if ((esc && _prop_extern_append_char(ctx,
184 _prop_extern_append_char(ctx, ch) == false) {
200 struct _prop_object_externalize_context *ctx, const char *cp)
208 rv = _prop_extern_append_cstring(ctx, "&lt;");
211 rv = _prop_extern_append_cstring(ctx, "&gt;");
214 rv = _prop_extern_append_cstring(ctx, "&amp;");
217 rv = _prop_extern_append_char(ctx, ch);
232 struct _prop_object_externalize_context *ctx, const char *cp)
234 _PROP_ASSERT(ctx->poec_format == PROP_FORMAT_XML ||
235 ctx->poec_format == PROP_FORMAT_JSON);
237 switch (ctx->poec_format) {
239 return _prop_json_extern_append_encoded_cstring(ctx, cp);
242 return _prop_xml_extern_append_encoded_cstring(ctx, cp);
252 struct _prop_object_externalize_context *ctx)
256 for (i = 0; i < ctx->poec_depth; i++) {
257 if (_prop_extern_append_char(ctx, '\t') == false) {
270 struct _prop_object_externalize_context *ctx, const char *trailer)
273 _prop_extern_append_cstring(ctx, trailer) == false) {
276 return _prop_extern_append_char(ctx, '\n');
285 struct _prop_object_externalize_context *ctx,
291 _PROP_ASSERT(ctx->poec_format == PROP_FORMAT_XML ||
292 ctx->poec_format == PROP_FORMAT_JSON);
294 switch (ctx->poec_format) {
297 _prop_extern_append_cstring(ctx, tags->json_open_tag);
301 rv = _prop_extern_append_char(ctx, '<') &&
302 _prop_extern_append_cstring(ctx, tags->xml_tag) &&
304 (_prop_extern_append_char(ctx, ' ') &&
305 _prop_extern_append_cstring(ctx, tagattrs))) &&
306 _prop_extern_append_char(ctx, '>');
319 struct _prop_object_externalize_context *ctx,
324 _PROP_ASSERT(ctx->poec_format == PROP_FORMAT_XML ||
325 ctx->poec_format == PROP_FORMAT_JSON);
327 switch (ctx->poec_format) {
330 _prop_extern_append_cstring(ctx, tags->json_close_tag);
334 rv = _prop_extern_append_char(ctx, '<') &&
335 _prop_extern_append_char(ctx, '/') &&
336 _prop_extern_append_cstring(ctx, tags->xml_tag) &&
337 _prop_extern_append_char(ctx, '>');
350 struct _prop_object_externalize_context *ctx,
355 _PROP_ASSERT(ctx->poec_format == PROP_FORMAT_XML ||
356 ctx->poec_format == PROP_FORMAT_JSON);
358 switch (ctx->poec_format) {
361 _prop_extern_append_cstring(ctx,
366 _prop_extern_append_cstring(ctx,
371 rv = _prop_extern_append_cstring(ctx,
379 rv = _prop_extern_append_char(ctx, '<') &&
380 _prop_extern_append_cstring(ctx, tags->xml_tag) &&
381 _prop_extern_append_char(ctx, '/') &&
382 _prop_extern_append_char(ctx, '>');
398 _prop_extern_append_header(struct _prop_object_externalize_context *ctx)
404 if (ctx->poec_format != PROP_FORMAT_XML) {
408 if (_prop_extern_append_cstring(ctx, _plist_xml_header) == false ||
409 _prop_extern_append_start_tag(ctx,
412 _prop_extern_append_char(ctx, '\n') == false) {
425 _prop_extern_append_footer(struct _prop_object_externalize_context *ctx)
427 if (_prop_extern_end_line(ctx, NULL) == false) {
431 if (ctx->poec_format == PROP_FORMAT_XML) {
432 if (_prop_extern_append_end_tag(ctx,
434 _prop_extern_end_line(ctx, NULL) == false) {
439 return _prop_extern_append_char(ctx, '\0');
449 struct _prop_object_externalize_context *ctx;
451 ctx = _PROP_MALLOC(sizeof(*ctx), M_TEMP);
452 if (ctx != NULL) {
453 ctx->poec_buf = _PROP_MALLOC(BUF_EXPAND, M_TEMP);
454 if (ctx->poec_buf == NULL) {
455 _PROP_FREE(ctx, M_TEMP);
458 ctx->poec_len = 0;
459 ctx->poec_capacity = BUF_EXPAND;
460 ctx->poec_depth = 0;
461 ctx->poec_format = fmt;
463 return ctx;
471 _prop_extern_context_free(struct _prop_object_externalize_context *ctx)
474 _PROP_FREE(ctx, M_TEMP);
486 struct _prop_object_externalize_context *ctx;
496 ctx = _prop_extern_context_alloc(fmt);
497 if (ctx == NULL) {
501 if (_prop_extern_append_header(ctx) == false ||
502 obj->po_type->pot_extern(ctx, obj) == false ||
503 _prop_extern_append_footer(ctx) == false) {
505 _PROP_FREE(ctx->poec_buf, M_TEMP);
509 cp = ctx->poec_buf;
511 _prop_extern_context_free(ctx);