~ubuntu-branches/ubuntu/quantal/ceph/quantal

« back to all changes in this revision

Viewing changes to src/rgw/rgw_aclparser.cc

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2012-07-16 09:56:24 UTC
  • mfrom: (0.3.11)
  • mto: This revision was merged to the branch mainline in revision 17.
  • Revision ID: package-import@ubuntu.com-20120716095624-azr2w4hbhei1rxmx
Tags: upstream-0.48
ImportĀ upstreamĀ versionĀ 0.48

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <string.h>
 
2
 
 
3
#include "common/ceph_context.h"
 
4
#include "include/types.h"
 
5
#include "rgw/rgw_acl.h"
 
6
 
 
7
#include <iostream>
 
8
#include <map>
 
9
 
 
10
#define dout_subsys ceph_subsys_rgw
 
11
 
 
12
int main(int argc, char **argv) {
 
13
  RGWACLXMLParser parser;
 
14
 
 
15
  if (!parser.init())
 
16
    exit(1);
 
17
 
 
18
  char buf[1024];
 
19
 
 
20
  for (;;) {
 
21
    int done;
 
22
    int len;
 
23
 
 
24
    len = fread(buf, 1, sizeof(buf), stdin);
 
25
    if (ferror(stdin)) {
 
26
      fprintf(stderr, "Read error\n");
 
27
      exit(-1);
 
28
    }
 
29
    done = feof(stdin);
 
30
 
 
31
    parser.parse(buf, len, done);
 
32
 
 
33
    if (done)
 
34
      break;
 
35
  }
 
36
 
 
37
  RGWAccessControlPolicy *policy = (RGWAccessControlPolicy *)parser.find_first("AccessControlPolicy");
 
38
 
 
39
  if (policy) {
 
40
    string id="79a59df900b949e55d96a1e698fbacedfd6e09d98eacf8f8d5218e7cd47ef2be";
 
41
    dout(10) << hex << policy->get_perm(g_ceph_context, id, RGW_PERM_ALL) << dec << dendl;
 
42
    policy->to_xml(cout);
 
43
  }
 
44
 
 
45
  cout << parser.get_xml() << endl;
 
46
 
 
47
  bufferlist bl;
 
48
  policy->encode(bl);
 
49
 
 
50
  RGWAccessControlPolicy newpol;
 
51
  bufferlist::iterator iter = bl.begin();
 
52
  newpol.decode(iter);
 
53
 
 
54
  newpol.to_xml(cout);
 
55
 
 
56
  exit(0);
 
57
}
 
58