Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / common / escape.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3 /*
4  * Ceph - scalable distributed file system
5  *
6  * Copyright (C) 2011 New Dream Network
7  *
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.
12  *
13  */
14
15 #ifndef CEPH_RGW_ESCAPE_H
16 #define CEPH_RGW_ESCAPE_H
17
18 #ifdef __cplusplus
19 extern "C" {
20 #endif
21
22 /* Returns the length of a buffer that would be needed to escape 'buf'
23  * as an XML attrribute
24  */
25 int escape_xml_attr_len(const char *buf);
26
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.
30  */
31 void escape_xml_attr(const char *buf, char *out);
32
33 /* Returns the length of a buffer that would be needed to escape 'buf'
34  * as an JSON attrribute
35  */
36 int escape_json_attr_len(const char *buf, int src_len);
37
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.
41  */
42 void escape_json_attr(const char *buf, int src_len, char *out);
43
44 /* Note: we escape control characters. Although the XML spec doesn't actually
45  * require this, Amazon does it in their XML responses.
46  */
47
48 #ifdef __cplusplus
49 }
50 #endif
51
52 #endif