154do_get (
const uint64_t next_uid);
189 fprintf (stderr,
_ (
"Dumped %" PRIu64
" records\n"),
record_count);
211 if (
sizeof(dr) != len)
214 _ (
"Short write to file: %zd bytes expecting %zd\n"),
226 _ (
"Short write to file: %zd bytes expecting %zd\n"),
257 fprintf (stderr,
_ (
"Error queueing datastore GET operation\n"));
282 fprintf (stderr,
_ (
"Unable to open dump file: %s\n"),
file_name);
321 fprintf (stderr,
_ (
"Failed to store item: %s, aborting\n"),
msg);
331 fprintf (stderr,
_ (
"Inserted %" PRIu64
" records\n"),
record_count);
336 else if (
sizeof(dr) != len)
339 _ (
"Short read from file: %zd bytes expecting %zd\n"),
348 const size_t size = ntohl (dr.
size);
354 _ (
"Short read from file: %zd bytes expecting %zd\n"),
379 fprintf (stderr,
_ (
"Error queueing datastore PUT operation\n"));
404 fprintf (stderr,
_ (
"Unable to open dump file: %s\n"),
file_name);
418 fprintf (stderr,
_ (
"Input file is not of a supported format\n"));
443 fprintf (stderr,
_ (
"Failed connecting to the datastore.\n"));
455 _ (
"Please choose at least one operation: %s, %s\n"),
472main (
int argc,
char *
const *argv)
478 "Dump all records from the datastore"),
483 "Insert records into the datastore"),
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
struct GNUNET_GETOPT_CommandLineOption options[]
struct GNUNET_MessageHeader * msg
#define gettext_noop(String)
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
static void do_get(const uint64_t next_uid)
Perform next GET operation.
static struct GNUNET_DISK_FileHandle * file_handle
Dump file handle.
static uint64_t record_count
Record count.
static const uint8_t MAGIC_BYTES[16]
Magic header bytes.
static int dump
Dump the database.
static struct GNUNET_DATASTORE_QueueEntry * qe
Current operation.
static void get_cb(void *cls, const struct GNUNET_HashCode *key, size_t size, const void *data, enum GNUNET_BLOCK_Type type, uint32_t priority, uint32_t anonymity, uint32_t replication, struct GNUNET_TIME_Absolute expiration, uint64_t uid)
Process a datum that was stored in the datastore.
static int ret
Global return value.
static void do_shutdown(void *cls)
static void put_cb(void *cls, int32_t success, struct GNUNET_TIME_Absolute min_expiration, const char *msg)
Continuation called to notify client about result of the operation.
static void start_insert(void)
Begin inserting into the database.
static char * file_name
Dump file name.
static struct GNUNET_DATASTORE_Handle * datastore
Handle for datastore.
static void run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
Main function that will be run by the scheduler.
static int insert
Insert into the database.
static GNUNET_NETWORK_STRUCT_END const size_t MAGIC_LEN
Length of our magic header.
int main(int argc, char *const *argv)
The main function to manipulate datastores.
static void start_dump(void)
Begin dumping the database.
static unsigned int replication
Desired replication level.
static char * data
The data to insert into the dht.
struct GNUNET_HashCode key
The key used in the DHT.
static struct GNUNET_TIME_Relative expiration
User supplied expiration value.
static unsigned int anonymity
static uint32_t type
Type string converted to DNS type value.
static struct GNUNET_TIME_Absolute min_expiration
Minimum time that content should have to not be discarded instantly (time stamp of any content that w...
void GNUNET_DATASTORE_disconnect(struct GNUNET_DATASTORE_Handle *h, int drop)
Disconnect from the datastore service (and free associated resources).
void GNUNET_DATASTORE_cancel(struct GNUNET_DATASTORE_QueueEntry *qe)
Cancel a datastore operation.
struct GNUNET_DATASTORE_QueueEntry * GNUNET_DATASTORE_put(struct GNUNET_DATASTORE_Handle *h, uint32_t rid, const struct GNUNET_HashCode *key, size_t size, const void *data, enum GNUNET_BLOCK_Type type, uint32_t priority, uint32_t anonymity, uint32_t replication, struct GNUNET_TIME_Absolute expiration, unsigned int queue_priority, unsigned int max_queue_size, GNUNET_DATASTORE_ContinuationWithStatus cont, void *cont_cls)
Store an item in the datastore.
struct GNUNET_DATASTORE_Handle * GNUNET_DATASTORE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the datastore service.
struct GNUNET_DATASTORE_QueueEntry * GNUNET_DATASTORE_get_key(struct GNUNET_DATASTORE_Handle *h, uint64_t next_uid, bool random, const struct GNUNET_HashCode *key, enum GNUNET_BLOCK_Type type, unsigned int queue_priority, unsigned int max_queue_size, GNUNET_DATASTORE_DatumProcessor proc, void *proc_cls)
Get a result for a particular key from the datastore.
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.
struct GNUNET_DISK_FileHandle * GNUNET_DISK_get_handle_from_int_fd(int fno)
Get a handle from a native integer FD.
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_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_NONE
Nobody is allowed to do anything to the file.
@ GNUNET_DISK_PERM_USER_WRITE
Owner can write.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_filename(char shortName, const char *name, const char *argumentHelp, const char *description, char **str)
Allow user to specify a filename (automatically path expanded).
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_flag(char shortName, const char *name, const char *description, int *val)
Allow user to specify a flag (which internally means setting an integer to 1/GNUNET_YES/GNUNET_OK.
#define GNUNET_NETWORK_STRUCT_BEGIN
Define as empty, GNUNET_PACKED should suffice, but this won't work on W32.
#define GNUNET_NETWORK_STRUCT_END
Define as empty, GNUNET_PACKED should suffice, but this won't work on W32;.
#define GNUNET_PACKED
gcc-ism to get packed structs.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
const struct GNUNET_OS_ProjectData * GNUNET_OS_project_data_gnunet(void)
Return default project data used by 'libgnunetutil' for GNUnet.
enum GNUNET_GenericReturnValue GNUNET_PROGRAM_run(const struct GNUNET_OS_ProjectData *pd, int argc, char *const *argv, const char *binaryName, const char *binaryHelp, const struct GNUNET_GETOPT_CommandLineOption *options, GNUNET_PROGRAM_Main task, void *task_cls)
Run a standard GNUnet command startup sequence (initialize loggers and configuration,...
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_shutdown(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run on shutdown, that is when a CTRL-C signal is received,...
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_ntoh(struct GNUNET_TIME_AbsoluteNBO a)
Convert absolute time from network byte order.
#define GNUNET_TIME_UNIT_ZERO_ABS
Absolute time zero.
struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton(struct GNUNET_TIME_Absolute a)
Convert absolute time to network byte order.
static unsigned int size
Size of the "table".
GNUNET_BLOCK_Type
WARNING: This header is generated! In order to add DHT block types, you must register them in GANA,...
@ GNUNET_BLOCK_TYPE_ANY
Identifier for any block.
uint32_t replication
Desired replication level (NBO).
struct GNUNET_TIME_AbsoluteNBO expiration
Expiration time (NBO).
uint32_t type
Type of the item (NBO) (actually an enum GNUNET_BLOCK_Type)
uint32_t anonymity
Desired anonymity level (NBO).
uint32_t size
Number of bytes in the item (NBO).
uint32_t priority
Priority of the item (NBO).
struct GNUNET_HashCode key
Key under which the item can be found.
Handle to the datastore service.
Entry in our priority queue.
unsigned int priority
Priority in the queue.
Handle used to access files (and pipes).
Definition of a command line option.
Time for absolute time used by GNUnet, in microseconds and in network byte order.
Time for absolute times used by GNUnet, in microseconds.