summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYehuda Sadeh <yehuda@inktank.com>2013-02-06 12:56:54 -0800
committerYehuda Sadeh <yehuda@inktank.com>2013-02-11 17:05:07 -0800
commitadca757223b4118ffcf1810264e320d7bd263053 (patch)
tree6dce03534d5fdcef9c674846de308f9748097991
parent887a2559f57df1d6b81d667d26fe1f31a3664aec (diff)
downloadceph-adca757223b4118ffcf1810264e320d7bd263053.tar.gz
moved rgw/rgw_json.* common/ceph_json.*
Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
-rw-r--r--src/Makefile.am5
-rw-r--r--src/common/ceph_json.cc (renamed from src/rgw/rgw_json.cc)18
-rw-r--r--src/common/ceph_json.h (renamed from src/rgw/rgw_json.h)12
-rw-r--r--src/rgw/rgw_common.cc2
-rw-r--r--src/rgw/rgw_jsonparser.cc4
-rw-r--r--src/rgw/rgw_policy_s3.cc4
-rw-r--r--src/rgw/rgw_swift.cc8
7 files changed, 26 insertions, 27 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 50164d13b4f..123d83ffc6b 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -128,7 +128,6 @@ bin_PROGRAMS += monmaptool crushtool osdmaptool
rgw_dencoder_src = rgw/rgw_dencoder.cc \
rgw/rgw_acl.cc \
rgw/rgw_common.cc \
- rgw/rgw_json.cc \
rgw/rgw_json_enc.cc
ceph_dencoder_SOURCES = test/encoding/ceph_dencoder.cc ${rgw_dencoder_src}
@@ -353,7 +352,6 @@ librgw_a_SOURCES = \
rgw/rgw_fcgi.cc \
rgw/rgw_xml.cc \
rgw/rgw_usage.cc \
- rgw/rgw_json.cc \
rgw/rgw_json_enc.cc \
rgw/rgw_user.cc \
rgw/rgw_tools.cc \
@@ -1310,6 +1308,7 @@ libcommon_files = \
common/entity_name.cc \
common/ceph_crypto.cc \
common/ceph_crypto_cms.cc \
+ common/ceph_json.cc \
common/ipaddr.cc \
common/pick_address.cc \
include/addr_parsing.c \
@@ -1552,6 +1551,7 @@ noinst_HEADERS = \
common/config_opts.h\
common/ceph_crypto.h\
common/ceph_crypto_cms.h\
+ common/ceph_json.h\
common/utf8.h\
common/mime.h\
common/pick_address.h\
@@ -1882,7 +1882,6 @@ noinst_HEADERS = \
rgw/rgw_client_io.h\
rgw/rgw_fcgi.h\
rgw/rgw_xml.h\
- rgw/rgw_json.h\
rgw/rgw_cache.h\
rgw/rgw_common.h\
rgw/rgw_string.h\
diff --git a/src/rgw/rgw_json.cc b/src/common/ceph_json.cc
index 3cff30aa37b..536618aa7d8 100644
--- a/src/rgw/rgw_json.cc
+++ b/src/common/ceph_json.cc
@@ -1,8 +1,8 @@
#include <iostream>
#include <include/types.h>
+#include <errno.h>
-#include "rgw_json.h"
-#include "rgw_common.h"
+#include "common/ceph_json.h"
// for testing DELETE ME
#include <fstream>
@@ -198,24 +198,24 @@ vector<string> JSONObj::get_array_elements()
return elements;
}
-RGWJSONParser::RGWJSONParser() : buf_len(0), success(true)
+JSONParser::JSONParser() : buf_len(0), success(true)
{
}
-RGWJSONParser::~RGWJSONParser()
+JSONParser::~JSONParser()
{
}
-void RGWJSONParser::handle_data(const char *s, int len)
+void JSONParser::handle_data(const char *s, int len)
{
json_buffer.append(s, len); // check for problems with null termination FIXME
buf_len += len;
}
// parse a supplied JSON fragment
-bool RGWJSONParser::parse(const char *buf_, int len)
+bool JSONParser::parse(const char *buf_, int len)
{
string json_string = buf_;
// make a substring to len
@@ -230,7 +230,7 @@ bool RGWJSONParser::parse(const char *buf_, int len)
}
// parse the internal json_buffer up to len
-bool RGWJSONParser::parse(int len)
+bool JSONParser::parse(int len)
{
string json_string = json_buffer.substr(0, len);
success = read(json_string, data);
@@ -243,7 +243,7 @@ bool RGWJSONParser::parse(int len)
}
// parse the complete internal json_buffer
-bool RGWJSONParser::parse()
+bool JSONParser::parse()
{
success = read(json_buffer, data);
if (success)
@@ -255,7 +255,7 @@ bool RGWJSONParser::parse()
}
// parse a supplied ifstream, for testing. DELETE ME
-bool RGWJSONParser::parse(const char *file_name)
+bool JSONParser::parse(const char *file_name)
{
ifstream is(file_name);
success = read(is, data);
diff --git a/src/rgw/rgw_json.h b/src/common/ceph_json.h
index 4b6f00d9286..bfbd3fa6c5b 100644
--- a/src/rgw/rgw_json.h
+++ b/src/common/ceph_json.h
@@ -1,5 +1,5 @@
-#ifndef RGW_JSON_H
-#define RGW_JSON_H
+#ifndef CEPH_JSON_H
+#define CEPH_JSON_H
#include <iostream>
#include <include/types.h>
@@ -67,14 +67,14 @@ public:
vector<string> get_array_elements();
};
-class RGWJSONParser : public JSONObj
+class JSONParser : public JSONObj
{
int buf_len;
string json_buffer;
bool success;
public:
- RGWJSONParser();
- virtual ~RGWJSONParser();
+ JSONParser();
+ virtual ~JSONParser();
void handle_data(const char *s, int len);
bool parse(const char *buf_, int len);
@@ -95,7 +95,7 @@ public:
err(const string& m) : message(m) {}
};
- RGWJSONParser parser;
+ JSONParser parser;
JSONDecoder(bufferlist& bl) {
if (!parser.parse(bl.c_str(), bl.length())) {
diff --git a/src/rgw/rgw_common.cc b/src/rgw/rgw_common.cc
index 722ab232a76..0fcc941a4a5 100644
--- a/src/rgw/rgw_common.cc
+++ b/src/rgw/rgw_common.cc
@@ -1,11 +1,11 @@
#include <errno.h>
#include "json_spirit/json_spirit.h"
+#include "common/ceph_json.h"
#include "rgw_common.h"
#include "rgw_acl.h"
#include "rgw_string.h"
-#include "rgw_json.h"
#include "common/ceph_crypto.h"
#include "common/armor.h"
diff --git a/src/rgw/rgw_jsonparser.cc b/src/rgw/rgw_jsonparser.cc
index 820cc6216b6..ec1c4ce2355 100644
--- a/src/rgw/rgw_jsonparser.cc
+++ b/src/rgw/rgw_jsonparser.cc
@@ -7,8 +7,8 @@
#include "include/types.h"
#include "common/Formatter.h"
+#include "common/ceph_json.h"
-#include "rgw_json.h"
#include "rgw_common.h"
#define dout_subsys ceph_subsys_rgw
@@ -55,7 +55,7 @@ struct UserInfo {
int main(int argc, char **argv) {
- RGWJSONParser parser;
+ JSONParser parser;
char buf[1024];
bufferlist bl;
diff --git a/src/rgw/rgw_policy_s3.cc b/src/rgw/rgw_policy_s3.cc
index c0a88b485b2..fac05f18884 100644
--- a/src/rgw/rgw_policy_s3.cc
+++ b/src/rgw/rgw_policy_s3.cc
@@ -1,8 +1,8 @@
#include <errno.h>
+#include "common/ceph_json.h"
#include "rgw_policy_s3.h"
-#include "rgw_json.h"
#include "rgw_common.h"
@@ -229,7 +229,7 @@ int RGWPolicy::check(RGWPolicyEnv *env, string& err_msg)
int RGWPolicy::from_json(bufferlist& bl, string& err_msg)
{
- RGWJSONParser parser;
+ JSONParser parser;
if (!parser.parse(bl.c_str(), bl.length())) {
err_msg = "Malformed JSON";
diff --git a/src/rgw/rgw_swift.cc b/src/rgw/rgw_swift.cc
index 58d93fcead4..59117dc876a 100644
--- a/src/rgw/rgw_swift.cc
+++ b/src/rgw/rgw_swift.cc
@@ -2,7 +2,7 @@
#include <stdlib.h>
#include <unistd.h>
-#include "rgw_json.h"
+#include "common/ceph_json.h"
#include "rgw_common.h"
#include "rgw_swift.h"
#include "rgw_swift_auth.h"
@@ -102,7 +102,7 @@ int RGWSwift::validate_token(const char *token, struct rgw_swift_auth_info *info
int KeystoneToken::parse(CephContext *cct, bufferlist& bl)
{
- RGWJSONParser parser;
+ JSONParser parser;
if (!parser.parse(bl.c_str(), bl.length())) {
ldout(cct, 0) << "malformed json" << dendl;
@@ -404,7 +404,7 @@ int RGWSwift::check_revoked()
ldout(cct, 10) << "request returned " << bl.c_str() << dendl;
- RGWJSONParser parser;
+ JSONParser parser;
if (!parser.parse(bl.c_str(), bl.length())) {
ldout(cct, 0) << "malformed json" << dendl;
@@ -438,7 +438,7 @@ int RGWSwift::check_revoked()
ldout(cct, 10) << "ceph_decode_cms: decoded: " << json.c_str() << dendl;
- RGWJSONParser list_parser;
+ JSONParser list_parser;
if (!list_parser.parse(json.c_str(), json.length())) {
ldout(cct, 0) << "malformed json" << dendl;
return -EINVAL;