#include "pabc_helper.h"
#include <pwd.h>
#include <stdlib.h>
#include <unistd.h>
Go to the source code of this file.
|
static const char * | get_homedir () |
|
static enum GNUNET_GenericReturnValue | write_file (char const *const filename, const char *buffer) |
|
static enum GNUNET_GenericReturnValue | init_pabc_dir () |
|
static const char * | get_pabcdir () |
|
enum GNUNET_GenericReturnValue | read_file (char const *const filename, char **buffer) |
|
struct pabc_public_parameters * | PABC_read_issuer_ppfile (const char *f, struct pabc_context *const ctx) |
|
enum GNUNET_GenericReturnValue | PABC_load_public_parameters (struct pabc_context *const ctx, char const *const pp_name, struct pabc_public_parameters **pp) |
|
enum GNUNET_GenericReturnValue | PABC_write_public_parameters (char const *const pp_name, struct pabc_public_parameters *const pp) |
|
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) |
|
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) |
|
◆ get_homedir()
static const char* get_homedir |
( |
| ) |
|
|
static |
Definition at line 15 of file pabc_helper.c.
18 if ((homedir =
getenv (
"HOME")) == NULL)
20 homedir = getpwuid (getuid ())->pw_dir;
References getenv().
◆ write_file()
Definition at line 15 of file pabc_helper.c.
39 buffer, strlen (buffer) + 1))
static struct GNUNET_DISK_FileHandle * fh
File handle to STDIN, for reading restart/quit commands.
struct GNUNET_DISK_FileHandle * GNUNET_DISK_file_open(const char *fn, enum GNUNET_DISK_OpenFlags flags, enum GNUNET_DISK_AccessPermissions perm)
Open a file.
ssize_t GNUNET_DISK_file_write(const struct GNUNET_DISK_FileHandle *h, const void *buffer, size_t n)
Write a buffer to a file.
enum GNUNET_GenericReturnValue GNUNET_DISK_file_close(struct GNUNET_DISK_FileHandle *h)
Close an open file.
@ 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.
Handle used to access files (and pipes).
◆ init_pabc_dir()
Definition at line 15 of file pabc_helper.c.
53 size_t filename_size = strlen (
get_homedir ()) + 1 + strlen (
".local") + 1
54 + strlen (
"pabc-reclaim") + 1;
55 snprintf (
pabc_dir, filename_size,
"%s/%s/%s",
enum GNUNET_GenericReturnValue GNUNET_DISK_directory_create(const char *dir)
Implementation of "mkdir -p".
static char pabc_dir[4096+1]
static const char * get_homedir()
Referenced by get_pabcdir().
◆ get_pabcdir()
static const char* get_pabcdir |
( |
| ) |
|
|
static |
◆ read_file()
Definition at line 62 of file pabc_helper.c.
85 *buffer = calloc ((
size_t) lSize + 1,
sizeof(
char));
91 if (r != (
size_t) lSize)
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).
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.
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.
@ GNUNET_DISK_OPEN_READ
Open the file for reading.
@ 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_free(ptr)
Wrapper around free.
Referenced by main(), netjail_stop_run(), PABC_load_public_parameters(), and start_helper().
◆ PABC_read_issuer_ppfile()
struct pabc_public_parameters* PABC_read_issuer_ppfile |
( |
const char * |
f, |
|
|
struct pabc_context *const |
ctx |
|
) |
| |
Definition at line 105 of file pabc_helper.c.
112 struct pabc_public_parameters *pp;
121 if (PABC_OK != pabc_decode_and_new_public_parameters (
ctx, &pp, buffer))
124 "Failed to decode public parameters\n");
125 PABC_FREE_NULL (buffer);
128 PABC_FREE_NULL (buffer);
static struct GNUNET_DNSSTUB_Context * ctx
Context for DNS resolution.
#define GNUNET_log(kind,...)
@ GNUNET_ERROR_TYPE_ERROR
enum GNUNET_GenericReturnValue read_file(char const *const filename, char **buffer)
◆ PABC_load_public_parameters()
enum GNUNET_GenericReturnValue PABC_load_public_parameters |
( |
struct pabc_context *const |
ctx, |
|
|
char const *const |
pp_name, |
|
|
struct pabc_public_parameters ** |
pp |
|
) |
| |
◆ PABC_write_public_parameters()
enum GNUNET_GenericReturnValue PABC_write_public_parameters |
( |
char const *const |
pp_name, |
|
|
struct pabc_public_parameters *const |
pp |
|
) |
| |
Definition at line 105 of file pabc_helper.c.
177 struct pabc_context *
ctx = NULL;
180 PABC_ASSERT (pabc_new_ctx (&
ctx));
182 status = pabc_encode_public_parameters (
ctx, pp, &json);
187 "Failed to encode public parameters.\n");
188 pabc_free_ctx (&
ctx);
192 size_t filename_size =
199 PABC_FREE_NULL (json);
200 pabc_free_ctx (&
ctx);
210 PABC_FREE_NULL (json);
211 pabc_free_ctx (&
ctx);
215 PABC_FREE_NULL (json);
216 pabc_free_ctx (&
ctx);
uint16_t status
See PRISM_STATUS_*-constants.
#define GNUNET_malloc(size)
Wrapper around malloc.
static enum GNUNET_GenericReturnValue write_file(char const *const filename, const char *buffer)
Referenced by cr_cont().
◆ PABC_write_usr_ctx()
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 |
|
) |
| |
Definition at line 105 of file pabc_helper.c.
234 if (NULL == usr_name)
261 status = pabc_encode_user_ctx (
ctx, pp, usr_ctx, &json);
269 size_t fname_size = strlen (
get_pabcdir ()) + 1 + strlen (usr_name) + 1
273 snprintf (fname, fname_size,
"%s/%s_%s%s",
get_pabcdir (), usr_name,
Referenced by cr_cont().
◆ PABC_read_usr_ctx()
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 |
|
) |
| |
Definition at line 105 of file pabc_helper.c.
306 if (NULL == usr_name)
333 size_t fname_size = strlen (
get_pabcdir ()) + 1 + strlen (usr_name) + 1
336 snprintf (fname, fname_size,
"%s/%s_%s%s",
get_pabcdir (), usr_name,
343 "Failed to read `%s'\n", fname);
344 PABC_FREE_NULL (fname);
349 status = pabc_new_user_context (
ctx, pp, usr_ctx);
355 status = pabc_decode_user_ctx (
ctx, pp, *usr_ctx, json);
359 pabc_free_user_context (
ctx, pp, usr_ctx);
Referenced by cr_cont(), and pabc_create_presentation().
◆ pabc_dir