Go to the source code of this file.
Data Structures | |
struct | ScanTreeNode |
A node of a directory tree. More... | |
struct | RecursionContext |
Closure for the 'scan_callback'. More... | |
Functions | |
static void | free_tree (struct ScanTreeNode *tree) |
Free memory of the tree structure. More... | |
static int | write_all (const void *buf, size_t size) |
Write size bytes from buf into the output_stream. More... | |
static int | write_message (uint16_t message_type, const char *data, size_t data_length) |
Write message to the master process. More... | |
static int | preprocess_file (const char *filename, struct ScanTreeNode **dst) |
Function called to (recursively) add all of the files in the directory to the tree. More... | |
static int | scan_callback (void *cls, const char *filename) |
Function called by the directory iterator to (recursively) add all of the files in the directory to the tree. More... | |
static int | extract_files (struct ScanTreeNode *item) |
Extract metadata from files. More... | |
static void | ignore_sigpipe () |
Install a signal handler to ignore SIGPIPE. More... | |
static void | make_dev_zero (int fd, int flags) |
Turn the given file descriptor in to '/dev/null'. More... | |
int | main (int argc, char *const *argv) |
Main function of the helper process to extract meta data. More... | |
Variables | |
static int | output_stream |
File descriptor we use for IPC with the parent. More... | |
|
static |
Free memory of the tree structure.
tree | tree to free |
Definition at line 164 of file gnunet-helper-fs-publish.c.
References ScanTreeNode::children_head, ScanTreeNode::children_tail, ScanTreeNode::filename, free_tree(), GNUNET_CONTAINER_DLL_remove, GNUNET_free, and ScanTreeNode::parent.
Referenced by free_tree(), main(), and preprocess_file().
|
static |
Write size bytes from buf into the output_stream.
buf | buffer with data to write |
size | number of bytes to write |
Definition at line 187 of file gnunet-helper-fs-publish.c.
References GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_OK, GNUNET_SYSERR, output_stream, and size.
Referenced by write_message().
|
static |
Write message to the master process.
message_type | message type to use |
data | data to append, NULL for none |
data_length | number of bytes in data |
Definition at line 218 of file gnunet-helper-fs-publish.c.
References data, GNUNET_OK, GNUNET_SYSERR, GNUNET_MessageHeader::size, GNUNET_MessageHeader::type, and write_all().
Referenced by extract_files(), main(), and preprocess_file().
|
static |
Function called to (recursively) add all of the files in the directory to the tree.
Called by the directory scanner to initiate the scan. Does NOT yet add any metadata.
filename | file or directory to scan |
dst | where to store the resulting share tree item; NULL is stored in dst upon recoverable errors (GNUNET_OK is returned) |
Definition at line 309 of file gnunet-helper-fs-publish.c.
References ScanTreeNode::file_size, filename, ScanTreeNode::filename, free_tree(), GNUNET_DISK_directory_scan(), GNUNET_DISK_file_size(), GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_PROGRESS_DIRECTORY, GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_PROGRESS_FILE, GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_SKIP_FILE, GNUNET_new, GNUNET_NO, GNUNET_OK, GNUNET_strdup, GNUNET_SYSERR, GNUNET_YES, ScanTreeNode::is_directory, RecursionContext::parent, scan_callback(), RecursionContext::stop, and write_message().
Referenced by main(), and scan_callback().
|
static |
Function called by the directory iterator to (recursively) add all of the files in the directory to the tree.
Called by the directory scanner to initiate the scan. Does NOT yet add any metadata.
cls | the struct RecursionContext |
filename | file or directory to scan |
Definition at line 278 of file gnunet-helper-fs-publish.c.
References ScanTreeNode::children_head, ScanTreeNode::children_tail, filename, GNUNET_CONTAINER_DLL_insert, GNUNET_OK, GNUNET_SYSERR, GNUNET_YES, ScanTreeNode::parent, RecursionContext::parent, preprocess_file(), and RecursionContext::stop.
Referenced by preprocess_file().
|
static |
Extract metadata from files.
item | entry we are processing |
Definition at line 375 of file gnunet-helper-fs-publish.c.
References ScanTreeNode::children_head, extract_files(), ScanTreeNode::filename, GNUNET_break, GNUNET_FS_meta_data_create(), GNUNET_FS_meta_data_destroy(), GNUNET_FS_meta_data_get_serialized_size(), GNUNET_FS_meta_data_serialize(), GNUNET_FS_META_DATA_SERIALIZE_PART, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_META_DATA, GNUNET_OK, GNUNET_SYSERR, GNUNET_YES, ScanTreeNode::is_directory, meta, ScanTreeNode::next, plugins, size, and write_message().
Referenced by extract_files(), and main().
|
static |
Install a signal handler to ignore SIGPIPE.
Definition at line 446 of file gnunet-helper-fs-publish.c.
Referenced by main().
|
static |
Turn the given file descriptor in to '/dev/null'.
fd | fd to bind to /dev/null |
flags | flags to use (O_RDONLY or O_WRONLY) |
Definition at line 473 of file gnunet-helper-fs-publish.c.
References GNUNET_assert, and GNUNET_break.
Referenced by main().
int main | ( | int | argc, |
char *const * | argv | ||
) |
Main function of the helper process to extract meta data.
argc | should be 3 |
argv | [0] our binary name [1] name of the file or directory to process [2] "-" to disable extraction, NULL for defaults, otherwise custom plugins to load from LE |
Definition at line 498 of file gnunet-helper-fs-publish.c.
References extract_files(), free_tree(), GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_COUNTING_DONE, GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_ERROR, GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_FINISHED, GNUNET_OK, ignore_sigpipe(), make_dev_zero(), output_stream, plugins, preprocess_file(), and write_message().
|
static |
File descriptor we use for IPC with the parent.
Definition at line 94 of file gnunet-helper-fs-publish.c.
Referenced by main(), and write_all().