19 if ((homedir =
getenv (
"HOME")) == NULL)
21 homedir = getpwuid (getuid ())->pw_dir;
40 buffer, strlen (buffer) + 1))
54 size_t filename_size = strlen (
get_homedir ()) + 1 + strlen (
".local") + 1
55 + strlen (
"pabc-reclaim") + 1;
56 snprintf (
pabc_dir, filename_size,
"%s/%s/%s",
86 *buffer = calloc ((
size_t) lSize + 1,
sizeof(
char));
92 if (r != (
size_t) lSize)
105 struct pabc_public_parameters *
113 struct pabc_public_parameters *pp;
122 if (PABC_OK != pabc_decode_and_new_public_parameters (
ctx, &pp, buffer))
125 "Failed to decode public parameters\n");
126 PABC_FREE_NULL (buffer);
129 PABC_FREE_NULL (buffer);
136 char const *
const pp_name,
137 struct pabc_public_parameters **pp)
172 struct pabc_public_parameters *
const pp)
178 struct pabc_context *
ctx = NULL;
181 PABC_ASSERT (pabc_new_ctx (&
ctx));
183 status = pabc_encode_public_parameters (
ctx, pp, &json);
188 "Failed to encode public parameters.\n");
189 pabc_free_ctx (&
ctx);
193 size_t filename_size =
200 PABC_FREE_NULL (json);
201 pabc_free_ctx (&
ctx);
211 PABC_FREE_NULL (json);
212 pabc_free_ctx (&
ctx);
216 PABC_FREE_NULL (json);
217 pabc_free_ctx (&
ctx);
224 char const *
const pp_name,
225 struct pabc_context
const *
const ctx,
226 struct pabc_public_parameters
const *
const pp,
227 struct pabc_user_context *
const usr_ctx)
235 if (NULL == usr_name)
262 status = pabc_encode_user_ctx (
ctx, pp, usr_ctx, &json);
270 size_t fname_size = strlen (
get_pabcdir ()) + 1 + strlen (usr_name) + 1
274 snprintf (fname, fname_size,
"%s/%s_%s%s",
get_pabcdir (), usr_name,
296 char const *
const pp_name,
297 struct pabc_context
const *
const ctx,
298 struct pabc_public_parameters
const *
const pp,
299 struct pabc_user_context **usr_ctx)
307 if (NULL == usr_name)
334 size_t fname_size = strlen (
get_pabcdir ()) + 1 + strlen (usr_name) + 1
337 snprintf (fname, fname_size,
"%s/%s_%s%s",
get_pabcdir (), usr_name,
344 "Failed to read `%s'\n", fname);
345 PABC_FREE_NULL (fname);
350 status = pabc_new_user_context (
ctx, pp, usr_ctx);
356 status = pabc_decode_user_ctx (
ctx, pp, *usr_ctx, json);
360 pabc_free_user_context (
ctx, pp, usr_ctx);
uint16_t status
See PRISM_STATUS_*-constants.
static struct GNUNET_DISK_FileHandle * fh
File handle to STDIN, for reading restart/quit commands.
static struct GNUNET_DNSSTUB_Context * ctx
Context for DNS resolution.
struct GNUNET_DISK_FileHandle * GNUNET_DISK_file_open(const char *fn, enum GNUNET_DISK_OpenFlags flags, enum GNUNET_DISK_AccessPermissions perm)
Open a file.
enum GNUNET_GenericReturnValue GNUNET_DISK_file_test(const char *fil)
Check that fil corresponds to a filename (of a file that exists and that is not a directory).
ssize_t GNUNET_DISK_file_write(const struct GNUNET_DISK_FileHandle *h, const void *buffer, size_t n)
Write a buffer to a file.
off_t GNUNET_DISK_file_seek(const struct GNUNET_DISK_FileHandle *h, off_t offset, enum GNUNET_DISK_Seek whence)
Move the read/write pointer in a file.
enum GNUNET_GenericReturnValue GNUNET_DISK_directory_test(const char *fil, int is_readable)
Test if fil is a directory and listable.
enum GNUNET_GenericReturnValue GNUNET_DISK_file_close(struct GNUNET_DISK_FileHandle *h)
Close an open file.
ssize_t GNUNET_DISK_file_read(const struct GNUNET_DISK_FileHandle *h, void *result, size_t len)
Read the contents of a binary file into a buffer.
enum GNUNET_GenericReturnValue GNUNET_DISK_directory_create(const char *dir)
Implementation of "mkdir -p".
@ GNUNET_DISK_OPEN_READ
Open the file for reading.
@ GNUNET_DISK_OPEN_WRITE
Open the file for writing.
@ GNUNET_DISK_OPEN_TRUNCATE
Truncate file if it exists.
@ GNUNET_DISK_OPEN_CREATE
Create file if it doesn't exist.
@ GNUNET_DISK_PERM_USER_READ
Owner can read.
@ GNUNET_DISK_PERM_USER_WRITE
Owner can write.
@ GNUNET_DISK_SEEK_SET
Seek an absolute position (from the start of the file).
@ GNUNET_DISK_SEEK_END
Seek an absolute position from the end of the file.
#define GNUNET_log(kind,...)
GNUNET_GenericReturnValue
Named constants for return values.
@ GNUNET_ERROR_TYPE_ERROR
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
size_t GNUNET_STRINGS_urlencode(const char *data, size_t len, char **out)
url/percent encode (RFC3986).
enum GNUNET_GenericReturnValue read_file(char const *const filename, char **buffer)
static char pabc_dir[4096+1]
enum GNUNET_GenericReturnValue PABC_write_public_parameters(char const *const pp_name, struct pabc_public_parameters *const pp)
enum GNUNET_GenericReturnValue PABC_load_public_parameters(struct pabc_context *const ctx, char const *const pp_name, struct pabc_public_parameters **pp)
struct pabc_public_parameters * PABC_read_issuer_ppfile(const char *f, struct pabc_context *const ctx)
static const char * get_pabcdir()
static const char * get_homedir()
static enum GNUNET_GenericReturnValue init_pabc_dir()
enum GNUNET_GenericReturnValue PABC_write_usr_ctx(char const *const usr_name, char const *const pp_name, struct pabc_context const *const ctx, struct pabc_public_parameters const *const pp, struct pabc_user_context *const usr_ctx)
static enum GNUNET_GenericReturnValue write_file(char const *const filename, const char *buffer)
enum GNUNET_GenericReturnValue PABC_read_usr_ctx(char const *const usr_name, char const *const pp_name, struct pabc_context const *const ctx, struct pabc_public_parameters const *const pp, struct pabc_user_context **usr_ctx)
Handle used to access files (and pipes).