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_details.h
Go to the documentation of this file.
1 /*
2 ** Copyright 2014-2016 The Earlham Institute
3 **
4 ** Licensed under the Apache License, Version 2.0 (the "License");
5 ** you may not use this file except in compliance with the License.
6 ** You may obtain a copy of the License at
7 **
8 ** http://www.apache.org/licenses/LICENSE-2.0
9 **
10 ** Unless required by applicable law or agreed to in writing, software
11 ** distributed under the License is distributed on an "AS IS" BASIS,
12 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 ** See the License for the specific language governing permissions and
14 ** limitations under the License.
15 */
16 
22 #ifndef USER_DETAILS_H
23 #define USER_DETAILS_H
24 
25 #include "bson/bson.h"
26 
27 #include "jansson.h"
28 
29 #include "typedefs.h"
31 #include "linked_list.h"
32 #include "schema_keys.h"
33 #include "view_format.h"
34 
35 
40 typedef struct User
41 {
42  bson_oid_t *us_id_p;
43 
45  char *us_email_s;
46 
48  char *us_surname_s;
49 
52 
56  char *us_org_s;
57 
59  char *us_orcid_s;
60 
61 
62 } User;
63 
64 
65 typedef struct UserNode
66 {
69 } UserNode;
70 
71 
72 
73 #ifndef DOXYGEN_SHOULD_SKIP_THIS
74 
75 
76 #ifdef ALLOCATE_USER_TAGS
77  #define USER_PREFIX GRASSROOTS_USERS_API
78  #define USER_VAL(x) = x
79  #define USER_CONCAT_VAL(x,y) = x y
80 #else
81  #define USER_PREFIX extern GRASSROOTS_USERS_API
82  #define USER_VAL(x)
83  #define USER_CONCAT_VAL(x,y)
84 #endif
85 
86 #endif /* #ifndef DOXYGEN_SHOULD_SKIP_THIS */
87 
88 
89 USER_PREFIX const char *US_FORENAME_S USER_CONCAT_VAL (CONTEXT_PREFIX_SCHEMA_ORG_S, "givenName");
90 
91 USER_PREFIX const char *US_SURNAME_S USER_CONCAT_VAL (CONTEXT_PREFIX_SCHEMA_ORG_S, "familyName");
92 
93 USER_PREFIX const char *US_EMAIL_S USER_CONCAT_VAL (CONTEXT_PREFIX_SCHEMA_ORG_S, "email");
94 
95 USER_PREFIX const char *US_AFFILATION_S USER_CONCAT_VAL (CONTEXT_PREFIX_SCHEMA_ORG_S, "affiliation");
96 
97 USER_PREFIX const char *US_ORCID_S USER_VAL ("orcid");
98 
99 
100 
101 #ifdef __cplusplus
102 extern "C"
103 {
104 #endif
105 
118 GRASSROOTS_USERS_API User *AllocateUser (bson_oid_t *id_p, const char *email_s, const char *forename_s, const char *surname_s, const char *org_s, const char *orcid_s);
119 
120 
127 GRASSROOTS_USERS_API void FreeUser (User *user_p);
128 
129 
137 GRASSROOTS_USERS_API json_t *GetUserAsJSON (const User *user_p, const ViewFormat vf);
138 
139 
140 
148 GRASSROOTS_USERS_API User *GetUserFromJSON (const json_t *user_json_p);
149 
150 
151 
160 GRASSROOTS_USERS_API User *GetUserFromNamedJSON (const json_t *json_p, const char *user_key_s);
161 
162 
163 
173 GRASSROOTS_USERS_API bool AddUserToJSON (const User *user_p, json_t *json_p, const char * const user_key_s, const ViewFormat vf);
174 
175 
176 
177 
187 GRASSROOTS_USERS_API char *GetFullUsername (const User *user_p);
188 
189 
197 GRASSROOTS_USERS_API void FreeFullUsername (char *name_s);
198 
199 
208 
209 
210 
218 
219 
220 
221 #ifdef __cplusplus
222 }
223 #endif
224 
225 
226 #endif /* #ifndef USER_DETAILS_H */
User::AllocateUser
GRASSROOTS_USERS_API User * AllocateUser(bson_oid_t *id_p, const char *email_s, const char *forename_s, const char *surname_s, const char *org_s, const char *orcid_s)
Allocate a User with the given details.
USER_VAL
const USER_PREFIX char *US_ORCID_S USER_VAL("orcid")
User::FreeFullUsername
GRASSROOTS_USERS_API void FreeFullUsername(char *name_s)
Free a username that was previously generated by a call to GetFullUsername().
UserNode::AllocateUserNode
GRASSROOTS_USERS_API UserNode * AllocateUserNode(User *user_p)
Allocate a UserNode.
User::us_id_p
bson_oid_t * us_id_p
Definition: user_details.h:42
UserNode::un_user_p
User * un_user_p
Definition: user_details.h:68
User::us_orcid_s
char * us_orcid_s
The user's orcid.
Definition: user_details.h:59
User::us_surname_s
char * us_surname_s
The user's surname(s)
Definition: user_details.h:48
User::us_org_s
char * us_org_s
The organisation that the user is associated with.
Definition: user_details.h:56
User::GetUserFromNamedJSON
GRASSROOTS_USERS_API User * GetUserFromNamedJSON(const json_t *json_p, const char *user_key_s)
Get a User from a json representation which is the named child object of the given json.
UserNode
Definition: user_details.h:65
schema_keys.h
The keys for the Grassroots Schema.
User::us_forename_s
char * us_forename_s
The user's forename(s)
Definition: user_details.h:51
CONTEXT_PREFIX_SCHEMA_ORG_S
#define CONTEXT_PREFIX_SCHEMA_ORG_S
Definition: schema_keys.h:103
typedefs.h
User::GetUserFromJSON
GRASSROOTS_USERS_API User * GetUserFromJSON(const json_t *user_json_p)
Get a User from a json representation.
grassroots_users_library.h
UserNode::FreeUserNode
GRASSROOTS_USERS_API void FreeUserNode(ListItem *node_p)
Free a UserNode and its associated User.
USER_CONCAT_VAL
const USER_PREFIX char *US_FORENAME_S USER_CONCAT_VAL(CONTEXT_PREFIX_SCHEMA_ORG_S, "givenName")
UserNode::un_node
ListItem un_node
Definition: user_details.h:67
GRASSROOTS_USERS_API
#define GRASSROOTS_USERS_API
Definition: grassroots_users_library.h:46
User::GetUserAsJSON
GRASSROOTS_USERS_API json_t * GetUserAsJSON(const User *user_p, const ViewFormat vf)
Get the json for a User.
User
A datatype to store user credentials.
Definition: user_details.h:40
User::GetFullUsername
GRASSROOTS_USERS_API char * GetFullUsername(const User *user_p)
Get the full name of a a User.
User::FreeUser
GRASSROOTS_USERS_API void FreeUser(User *user_p)
Free a User.
linked_list.h
A doubly-linked list.
User::AddUserToJSON
GRASSROOTS_USERS_API bool AddUserToJSON(const User *user_p, json_t *json_p, const char *const user_key_s, const ViewFormat vf)
Add a compound User json to another piece of json.
User::us_email_s
char * us_email_s
The user's email address.
Definition: user_details.h:45
ViewFormat
ViewFormat
An indicator of what the output destination is for the JSON data values.
Definition: view_format.h:19
view_format.h
ListItem
A doubly-linked node that points to its predecessor and successor.
Definition: linked_list.h:43