1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 * Ceph - scalable distributed file system
6 * Copyright (C) 2011 New Dream Network
8 * This is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License version 2.1, as published by the Free Software
11 * Foundation. See file COPYING.
15 #ifndef CEPH_RGW_ESCAPE_H
16 #define CEPH_RGW_ESCAPE_H
22 /* Returns the length of a buffer that would be needed to escape 'buf'
23 * as an XML attrribute
25 int escape_xml_attr_len(const char *buf);
27 /* Escapes 'buf' as an XML attribute. Assumes that 'out' is at least long
28 * enough to fit the output. You can find out the required length by calling
29 * escape_xml_attr_len first.
31 void escape_xml_attr(const char *buf, char *out);
33 /* Returns the length of a buffer that would be needed to escape 'buf'
34 * as an JSON attrribute
36 int escape_json_attr_len(const char *buf, int src_len);
38 /* Escapes 'buf' as an JSON attribute. Assumes that 'out' is at least long
39 * enough to fit the output. You can find out the required length by calling
40 * escape_json_attr_len first.
42 void escape_json_attr(const char *buf, int src_len, char *out);
44 /* Note: we escape control characters. Although the XML spec doesn't actually
45 * require this, Amazon does it in their XML responses.