summaryrefslogtreecommitdiffstats
path: root/utils/capabilities.h
blob: 80f03bd1edc458342787c712f9ae3fa938dd7fa7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
  Copyright (c) 2018 Red Hat, Inc. <http://www.redhat.com>
  This file is part of gluster-block.

  This file is licensed to you under your choice of the GNU Lesser
  General Public License, version 3 or any later version (LGPLv3 or
  later), or the GNU General Public License, version 2 (GPLv2), in all
  cases as published by the Free Software Foundation.
*/


# include "block.h"
# include "common.h"


typedef struct gbCapObj {
  char cap[256];
  bool status;
} gbCapObj;


typedef struct gbCapResp {
  int capMax;
  gbCapObj *response;
} gbCapResp;


enum gbCapabilities {
  GB_CREATE_CAP,
  GB_CREATE_HA_CAP,
  GB_CREATE_PREALLOC_CAP,
  GB_CREATE_AUTH_CAP,

  GB_DELETE_CAP,
  GB_DELETE_FORCE_CAP,

  GB_MODIFY_CAP,
  GB_MODIFY_AUTH_CAP,

  GB_REPLACE_CAP,

  GB_JSON_CAP,

  GB_CAP_MAX
};


static const char *const gbCapabilitiesLookup[] = {
  [GB_CREATE_CAP]              = "create",
  [GB_CREATE_HA_CAP]           = "create_ha",
  [GB_CREATE_PREALLOC_CAP]     = "create_prealloc",
  [GB_CREATE_AUTH_CAP]         = "create_auth",

  [GB_DELETE_CAP]              = "delete",
  [GB_DELETE_FORCE_CAP]        = "delete_force",

  [GB_MODIFY_CAP]              = "modify",
  [GB_MODIFY_AUTH_CAP]         = "modify_auth",

  [GB_REPLACE_CAP]             = "replace",

  [GB_JSON_CAP]                = "json",

  [GB_CAP_MAX]                 = NULL
};


int gbCapabilitiesEnumParse(const char *cap);
int gbSetCapabilties (blockResponse **c);