Grassroots Infrastructure
The Grassroots Infrastructure is a suite of computing tools to help users and developers use scientific data infrastructure that can easily be interconnected.
user_group.h
Go to the documentation of this file.
1 /*
2  * usergroup.h
3  *
4  * Created on: 6 Dec 2023
5  * Author: billy
6  */
7 
8 #ifndef CORE_SHARED_UTIL_INCLUDE_USER_GROUP_H_
9 #define CORE_SHARED_UTIL_INCLUDE_USER_GROUP_H_
10 
11 #include "jansson.h"
12 
13 #include "typedefs.h"
15 #include "linked_list.h"
16 #include "user_details.h"
17 
18 
23 typedef struct UserGroup
24 {
25  char *ug_name_s;
27 } UserGroup;
28 
29 
30 typedef struct UserGroupNode
31 {
35 
36 
37 #ifndef DOXYGEN_SHOULD_SKIP_THIS
38 
39 
40 #ifdef ALLOCATE_USER_GROUP_TAGS
41  #define USER_GROUP_PREFIX GRASSROOTS_USERS_API
42  #define USER_GROUP_VAL(x) = x
43  #define USER_GROUP_CONCAT_VAL(x,y) = x y
44 #else
45  #define USER_GROUP_PREFIX extern GRASSROOTS_USERS_API
46  #define USER_GROUP_VAL(x)
47  #define USER_GROUP_CONCAT_VAL(x,y)
48 #endif
49 
50 #endif /* #ifndef DOXYGEN_SHOULD_SKIP_THIS */
51 
52 
53 USER_GROUP_PREFIX const char * const UG_NAME_S USER_GROUP_CONCAT_VAL (CONTEXT_PREFIX_SCHEMA_ORG_S, "name");
54 
55 USER_GROUP_PREFIX const char * const UG_USERS_S USER_GROUP_VAL ("users");
56 
57 
58 
59 
60 #ifdef __cplusplus
61 extern "C"
62 {
63 #endif
64 
65 
75 
76 
84 
85 
93 GRASSROOTS_USERS_API json_t *GetUserGroupAsJSON (UserGroup *group_p, const bool full_user_flag);
94 
95 
96 
104 GRASSROOTS_USERS_API UserGroup *GetUserGroupFromJSON (const json_t *group_json_p);
105 
106 
115 GRASSROOTS_USERS_API bool AddUserToGroup (UserGroup *group_p, User *user_p);
116 
117 
126 GRASSROOTS_USERS_API bool IsUserInGroup (const UserGroup * const group_p, const User * const user_p);
127 
128 
138 
139 
147 
148 
149 #ifdef __cplusplus
150 }
151 #endif
152 
153 
154 #endif /* CORE_SHARED_UTIL_INCLUDE_USER_GROUP_H_ */
UserGroup::IsUserInGroup
GRASSROOTS_USERS_API bool IsUserInGroup(const UserGroup *const group_p, const User *const user_p)
Check whether a given User is a member of a UserGroup.
UserGroup::AddUserToGroup
GRASSROOTS_USERS_API bool AddUserToGroup(UserGroup *group_p, User *user_p)
Add a given User to a UserGroup.
UserGroup::FreeUserGroup
GRASSROOTS_USERS_API void FreeUserGroup(UserGroup *group_p)
Free a UserGroup.
UserGroup
A datatype to store user credentials.
Definition: user_group.h:23
UserGroup::GetUserGroupAsJSON
GRASSROOTS_USERS_API json_t * GetUserGroupAsJSON(UserGroup *group_p, const bool full_user_flag)
Get the json for a UserGroup.
UserGroup::AllocateUserGroup
GRASSROOTS_USERS_API UserGroup * AllocateUserGroup(const char *name_s)
Allocate a UserGroup with the given name.
UserGroupNode
Definition: user_group.h:30
UserGroupNode::ugn_group_p
UserGroup * ugn_group_p
Definition: user_group.h:33
CONTEXT_PREFIX_SCHEMA_ORG_S
#define CONTEXT_PREFIX_SCHEMA_ORG_S
Definition: schema_keys.h:103
UserGroup::GetUserGroupFromJSON
GRASSROOTS_USERS_API UserGroup * GetUserGroupFromJSON(const json_t *group_json_p)
Get a UserGroup from a json representation.
typedefs.h
grassroots_users_library.h
LinkedList
A doubly-linked list that can be traversed in either direction.
Definition: linked_list.h:56
UserGroupNode::FreeUserGroupNode
GRASSROOTS_USERS_API void FreeUserGroupNode(ListItem *node_p)
Free a UserGroupNode.
UserGroup::ug_name_s
char * ug_name_s
Definition: user_group.h:25
GRASSROOTS_USERS_API
#define GRASSROOTS_USERS_API
Definition: grassroots_users_library.h:46
User
A datatype to store user credentials.
Definition: user_details.h:40
USER_GROUP_VAL
const USER_GROUP_PREFIX char *const UG_USERS_S USER_GROUP_VAL("users")
user_details.h
UserGroupNode::AllocateUserGroupNode
GRASSROOTS_USERS_API UserGroupNode * AllocateUserGroupNode(UserGroup *group_p)
Allocate a UserGroupNode for the given UserGroup.
linked_list.h
A doubly-linked list.
UserGroupNode::ugn_node
ListItem ugn_node
Definition: user_group.h:32
UserGroup::ug_users_p
LinkedList * ug_users_p
Definition: user_group.h:26
ListItem
A doubly-linked node that points to its predecessor and successor.
Definition: linked_list.h:43
USER_GROUP_CONCAT_VAL
const USER_GROUP_PREFIX char *const UG_NAME_S USER_GROUP_CONCAT_VAL(CONTEXT_PREFIX_SCHEMA_ORG_S, "name")