Skip to content

Commit

Permalink
YDA-5623: format microservices with clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
lwesterhof committed Mar 11, 2024
1 parent 13ea2b5 commit 537a12b
Show file tree
Hide file tree
Showing 10 changed files with 743 additions and 781 deletions.
293 changes: 159 additions & 134 deletions src/Archive.hh

Large diffs are not rendered by default.

73 changes: 39 additions & 34 deletions src/CredentialsStore.hh
Original file line number Diff line number Diff line change
@@ -1,56 +1,61 @@
#include "jansson.h"
#include "irods_includes.hh"

# define CREDS_STORE "/var/lib/irods/.credentials_store/store_config.json"

#define CREDS_STORE "/var/lib/irods/.credentials_store/store_config.json"

/*
* keep it simple
*/
class CredentialsStore {
public:
class CredentialsStore
{
public:
// load stored values
CredentialsStore() {
json_error_t error;

store = json_load_file(CREDS_STORE, 0, &error);
if (store == NULL) {
rodsLog(LOG_ERROR, "Failed to load credentials store");
}
// store is returned with refcount 1
CredentialsStore()
{
json_error_t error;

store = json_load_file(CREDS_STORE, 0, &error);
if (store == NULL) {
rodsLog(LOG_ERROR, "Failed to load credentials store");
}
// store is returned with refcount 1
}
// free stored values
~CredentialsStore() {
if (store != NULL) {
json_decref(store);
}
~CredentialsStore()
{
if (store != NULL) {
json_decref(store);
}
}

// check that the store is properly initialized
bool isLoaded() {
return (store != NULL);
bool isLoaded()
{
return (store != NULL);
}

// check that the store has a credential
bool has(const char *key) {
return (store != NULL && json_object_get(store, key) != NULL);
bool has(const char* key)
{
return (store != NULL && json_object_get(store, key) != NULL);
}

// get a credential from the store
const char *get(const char *key) {
if (store != NULL) {
json_t *value;

value = json_object_get(store, key);
if (value != NULL && json_is_string(value)) {
return json_string_value(value);
}
}

rodsLog(LOG_ERROR, "Failed to retrieve credential \"%s\"", key);
return NULL;
const char* get(const char* key)
{
if (store != NULL) {
json_t* value;

value = json_object_get(store, key);
if (value != NULL && json_is_string(value)) {
return json_string_value(value);
}
}

rodsLog(LOG_ERROR, "Failed to retrieve credential \"%s\"", key);
return NULL;
}

private:
json_t *store; // in-memory copy of credentials store
private:
json_t* store; // in-memory copy of credentials store
};
Loading

0 comments on commit 537a12b

Please sign in to comment.