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)
105struct 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)
174 struct pabc_public_parameters *
const pp)
180 struct pabc_context *
ctx = NULL;
185 PABC_ASSERT (pabc_new_ctx (&
ctx));
187 status = pabc_encode_public_parameters (
ctx, pp, &json);
192 "Failed to encode public parameters.\n");
193 pabc_free_ctx (&
ctx);
197 size_t filename_size =
204 PABC_FREE_NULL (json);
205 pabc_free_ctx (&
ctx);
215 PABC_FREE_NULL (json);
216 pabc_free_ctx (&
ctx);
220 PABC_FREE_NULL (json);
221 pabc_free_ctx (&
ctx);
228 char const *
const pp_name,
229 struct pabc_context
const *
const ctx,
230 struct pabc_public_parameters
const *
const pp,
231 struct pabc_user_context *
const usr_ctx)
239 if (NULL == usr_name)
268 status = pabc_encode_user_ctx (
ctx, pp, usr_ctx, &json);
276 size_t fname_size = strlen (
get_pabcdir ()) + 1 + strlen (usr_name) + 1
280 snprintf (fname, fname_size,
"%s/%s_%s%s",
get_pabcdir (), usr_name,
302 char const *
const pp_name,
303 struct pabc_context
const *
const ctx,
304 struct pabc_public_parameters
const *
const pp,
305 struct pabc_user_context **usr_ctx)
313 if (NULL == usr_name)
342 size_t fname_size = strlen (
get_pabcdir ()) + 1 + strlen (usr_name) + 1
345 snprintf (fname, fname_size,
"%s/%s_%s%s",
get_pabcdir (), usr_name,
352 "Failed to read `%s'\n", fname);
353 PABC_FREE_NULL (fname);
358 status = pabc_new_user_context (
ctx, pp, usr_ctx);
364 status = pabc_decode_user_ctx (
ctx, pp, *usr_ctx, json);
368 pabc_free_user_context (
ctx, pp, usr_ctx);
static struct GNUNET_FS_Handle * ctx
static int status
The program status; 0 for success.
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(size_t len, const char data[static len], char **out)
url/percent encode (RFC3986).
enum GNUNET_GenericReturnValue read_file(char const *const filename, char **buffer)
static char pabc_dir[4096+1]
struct pabc_public_parameters * PABC_read_issuer_ppfile(const char *f, struct pabc_context *const ctx)
static const char * get_homedir()
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)
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 const char * get_pabcdir()
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).