* Serialize meta-data to target.
*
* @param md metadata to serialize
+ * @param target where to write the serialized metadata
* @param size maximum number of bytes available
* @param opt is it ok to just write SOME of the
* meta-data to match the size constraint,
GNUNET_CONTAINER_MetaDataSerializationOptions
opt);
+
/**
- * Compute size of the meta-data in
- * serialized form.
+ * Estimate (!) the size of the meta-data in
+ * serialized form. The estimate MAY be higher
+ * than what is strictly needed.
*
* @param md metadata to inspect
* @param opt is it ok to just write SOME of the
/**
* Unlock a part of a file
* @param fh file handle
- * @param lockStart absolute position from where to unlock
- * @param lockEnd absolute position until where to unlock
+ * @param unlockStart absolute position from where to unlock
+ * @param unlockEnd absolute position until where to unlock
* @return GNUNET_OK on success, GNUNET_SYSERR on error
*/
int
*
* @param cfg configuration to use
* @param serviceName name of the service asking
- * @param varargs is NULL-terminated list of
+ * @param ... is NULL-terminated list of
* path components to append to the
* private directory name.
* @return the constructed filename
/**
* Flush an existing bulk report to the output.
*
- * @param datastr our current timestamp
+ * @param datestr our current timestamp
*/
static void
flush_bulk (const char *datestr)
* @return GNUNET_OK on success, GNUNET_SYSERR on error
*/
int
-GNUNET_CONFIGURATION_write (struct GNUNET_CONFIGURATION_Handle *data,
+GNUNET_CONFIGURATION_write (struct GNUNET_CONFIGURATION_Handle *cfg,
const char *filename)
{
struct ConfigSection *sec;
}
GNUNET_free (fn);
error = 0;
- sec = data->sections;
+ sec = cfg->sections;
while (sec != NULL)
{
if (0 > fprintf (fp, "[%s]\n", sec->name))
GNUNET_assert (0 == fclose (fp));
if (error != 0)
{
- data->dirty = GNUNET_SYSERR; /* last write failed */
+ cfg->dirty = GNUNET_SYSERR; /* last write failed */
return GNUNET_SYSERR;
}
- data->dirty = GNUNET_NO; /* last write succeeded */
+ cfg->dirty = GNUNET_NO; /* last write succeeded */
return GNUNET_OK;
}
/**
- * FIXME.
+ * Copy a configuration value to the given target configuration.
+ * Overwrites existing entries.
*
* @param cls the destination configuration (struct GNUNET_CONFIGURATION_Handle*)
- * @param section FIXME
- * @param option FIXME
- * @param value FIXME
+ * @param section section for the value
+ * @param option option name of the value
+ * @param value value to copy
*/
static void
copy_entry (void *cls,
/**
* Duplicate an existing configuration object.
*
- * @param c configuration to duplicate
+ * @param cfg configuration to duplicate
* @return duplicate configuration
*/
struct GNUNET_CONFIGURATION_Handle *
/**
* FIXME.
*
- * @param data FIXME
+ * @param cfg FIXME
* @param section FIXME
* @return matching entry, NULL if not found
*/
static struct ConfigSection *
-findSection (const struct GNUNET_CONFIGURATION_Handle *data, const char *section)
+findSection (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section)
{
struct ConfigSection *pos;
- pos = data->sections;
+ pos = cfg->sections;
while ((pos != NULL) && (0 != strcasecmp (section, pos->name)))
pos = pos->next;
return pos;
/**
* FIXME.
*
- * @param data FIXME
+ * @param cfg FIXME
* @param section FIXME
* @param key FIXME
* @return matching entry, NULL if not found
*/
static struct ConfigEntry *
-findEntry (const struct GNUNET_CONFIGURATION_Handle *data,
+findEntry (const struct GNUNET_CONFIGURATION_Handle *cfg,
const char *section, const char *key)
{
struct ConfigSection *sec;
struct ConfigEntry *pos;
- sec = findSection (data, section);
+ sec = findSection (cfg, section);
if (sec == NULL)
return NULL;
pos = sec->entries;
*/
void
GNUNET_CONFIGURATION_set_value_string (struct GNUNET_CONFIGURATION_Handle
- *data,
+ *cfg,
const char *section,
const char *option, const char *value)
{
struct ConfigSection *sec;
struct ConfigEntry *e;
- e = findEntry (data, section, option);
+ e = findEntry (cfg, section, option);
if (e != NULL)
{
GNUNET_free_non_null (e->val);
e->val = GNUNET_strdup (value);
return;
}
- sec = findSection (data, section);
+ sec = findSection (cfg, section);
if (sec == NULL)
{
sec = GNUNET_malloc (sizeof (struct ConfigSection));
sec->name = GNUNET_strdup (section);
- sec->next = data->sections;
- data->sections = sec;
+ sec->next = cfg->sections;
+ cfg->sections = sec;
}
e = GNUNET_malloc (sizeof (struct ConfigEntry));
e->key = GNUNET_strdup (option);
* "FOO" is set to "DIRECTORY".
*
* @param cfg configuration to use for path expansion
- * @param old string to $-expand (will be freed!)
+ * @param orig string to $-expand (will be freed!)
* @return $-expanded string
*/
char *
*/
int
GNUNET_CONFIGURATION_get_value_filename (const struct GNUNET_CONFIGURATION_Handle
- *data, const char *section,
+ *cfg, const char *section,
const char *option, char **value)
{
int ret;
char *tmp;
tmp = NULL;
- ret = GNUNET_CONFIGURATION_get_value_string (data, section, option, &tmp);
+ ret = GNUNET_CONFIGURATION_get_value_string (cfg, section, option, &tmp);
if (ret == GNUNET_SYSERR)
return ret;
if (tmp != NULL)
{
- tmp = GNUNET_CONFIGURATION_expand_dollar (data, tmp);
+ tmp = GNUNET_CONFIGURATION_expand_dollar (cfg, tmp);
*value = GNUNET_STRINGS_filename_expand (tmp);
GNUNET_free (tmp);
if (*value == NULL)
*/
int
GNUNET_CONFIGURATION_load (struct GNUNET_CONFIGURATION_Handle *cfg,
- const char *cfgfn)
+ const char *filename)
{
char *baseconfig;
char *ipath;
GNUNET_free (ipath);
if ((GNUNET_OK !=
GNUNET_CONFIGURATION_parse (cfg, baseconfig)) ||
- (!((cfgfn == NULL) ||
- (GNUNET_OK == GNUNET_CONFIGURATION_parse (cfg, cfgfn)))))
+ (!((filename == NULL) ||
+ (GNUNET_OK == GNUNET_CONFIGURATION_parse (cfg, filename)))))
{
GNUNET_free (baseconfig);
return GNUNET_SYSERR;
* Scheduler let us know that we're either ready to write on the
* socket OR connect timed out. Do the right thing.
*
- * @param ap the address we were probing
+ * @param cls the "struct AddressProbe*" with the address that we are probing
* @param tc success or failure info about the connect attempt.
*/
static void
* receive call per socket at any given point in time (so do not
* call receive again until the receiver callback has been invoked).
*
- * @param sched scheduler to use
* @param sock socket handle
* @param max maximum number of bytes to read
* @param timeout maximum amount of time to wait (use -1 for "forever")
* Copy the raw data of this bloomfilter into
* the given data array.
*
+ * @param bf bloomfilter to take the raw data from
* @param data where to write the data
* @param size the size of the given data array
* @return GNUNET_SYSERR if the data array is not big enough
/**
* Get a thumbnail from the meta-data (if present).
*
+ * @param md metadata to get the thumbnail from
* @param thumb will be set to the thumbnail data. Must be
* freed by the caller!
* @return number of bytes in thumbnail, 0 if not available
return ret;
}
+
static unsigned int
tryCompression (char *data, unsigned int oldSize)
{
/**
* Serialize meta-data to target.
*
- * @param size maximum number of bytes available
+ * @param md metadata to serialize
+ * @param target where to write the serialized metadata
+ * @param max maximum number of bytes available in target
* @param part is it ok to just write SOME of the
* meta-data to match the size constraint,
* possibly discarding some data?
* Estimate (!) the size of the meta-data in
* serialized form. The estimate MAY be higher
* than what is strictly needed.
+ *
+ * @param md metadata to inspect
+ * @param opt is it ok to just write SOME of the
+ * meta-data to match the size constraint,
+ * possibly discarding some data?
+ * @return number of bytes needed for serialization, -1 on error
*/
ssize_t
GNUNET_CONTAINER_meta_data_get_serialized_size (const struct
GNUNET_CONTAINER_MetaData *md,
enum
GNUNET_CONTAINER_MetaDataSerializationOptions
- part)
+ opt)
{
struct MetaDataHeader *hdr;
size_t size;
memcpy (&((char *) hdr)[pos], md->items[i].data, len);
pos += len;
}
- if ((part & GNUNET_CONTAINER_META_DATA_SERIALIZE_NO_COMPRESS) == 0)
+ if ((opt & GNUNET_CONTAINER_META_DATA_SERIALIZE_NO_COMPRESS) == 0)
{
pos =
tryCompression ((char *) &hdr[1],
return size;
}
+
/**
* Deserialize meta-data. Initializes md.
- * @param size number of bytes available
+ *
+ * @param input buffer with the serialized metadata
+ * @param size number of bytes available in input
* @return MD on success, NULL on error (i.e.
* bad format)
*/
*
* @param l list
* @param buf payload buffer to find
- * @param lenght of the payload
+ * @param len length of the payload (number of bytes in buf)
*/
int
GNUNET_CONTAINER_slist_contains (const struct GNUNET_CONTAINER_SList *l,
* Create the directory structure for storing
* a file.
*
- * @param dir name of a file in the directory
+ * @param filename name of a file in the directory
* @returns GNUNET_OK on success,
* GNUNET_SYSERR on failure,
* GNUNET_NO if the directory
* exists but is not writeable for us
*/
int
-GNUNET_DISK_directory_create_for_file (const char *dir)
+GNUNET_DISK_directory_create_for_file (const char *filename)
{
char *rdir;
int len;
int ret;
- rdir = GNUNET_STRINGS_filename_expand (dir);
+ rdir = GNUNET_STRINGS_filename_expand (filename);
if (rdir == NULL)
return GNUNET_SYSERR;
len = strlen (rdir);
*
* @param cfg configuration to use (determines HOME)
* @param serviceName name of the service
- * @param varargs is NULL-terminated list of
+ * @param ... is NULL-terminated list of
* path components to append to the
* private directory name.
* @return the constructed filename
\r
/**\r
* Make a non-inheritable to child processes\r
- * @param socket\r
+ *\r
+ * @param h the socket to make non-inheritable\r
* @return GNUNET_OK on success, GNUNET_SYSERR otherwise\r
* @warning Not implemented on Windows\r
*/\r
int\r
GNUNET_NETWORK_socket_set_inheritable (const struct GNUNET_NETWORK_Handle\r
- *desc)\r
+ *h)\r
{\r
#ifdef MINGW\r
errno = ENOSYS;\r
return GNUNET_SYSERR;\r
#else\r
- return fcntl (desc->fd, F_SETFD,\r
- fcntl (desc->fd,\r
- F_GETFD) | FD_CLOEXEC) ==\r
- 0 ? GNUNET_OK : GNUNET_SYSERR;\r
+ int i;\r
+\r
+ i = fcntl (h->fd, F_GETFD);\r
+ if (i == (i | FD_CLOEXEC))\r
+ return GNUNET_OK;\r
+ return (fcntl (h->fd, F_SETFD, i | FD_CLOEXEC) == 0)\r
+ ? GNUNET_OK : GNUNET_SYSERR;\r
#endif\r
}\r
\r