[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r8898 - in gnunet: . src/fs
From: |
gnunet |
Subject: |
[GNUnet-SVN] r8898 - in gnunet: . src/fs |
Date: |
Sun, 30 Aug 2009 13:24:21 -0600 |
Author: grothoff
Date: 2009-08-30 13:24:21 -0600 (Sun, 30 Aug 2009)
New Revision: 8898
Modified:
gnunet/HACKING
gnunet/src/fs/fs.c
gnunet/src/fs/fs.h
gnunet/src/fs/fs_directory.c
gnunet/src/fs/fs_publish.c
Log:
clarification
Modified: gnunet/HACKING
===================================================================
--- gnunet/HACKING 2009-08-30 19:16:31 UTC (rev 8897)
+++ gnunet/HACKING 2009-08-30 19:24:21 UTC (rev 8898)
@@ -27,6 +27,13 @@
- must start with "GNUNET_modulename_" and be defined in "modulename.c"
- exceptions: those defined in gnunet_common.h
+private (library-internal) symbols (including structs & macros):
+- must NOT start with any prefix
+- must not be exported in a way that linkers could use them or
+ other libraries might see them via headers; they must be either
+ declared/defined in C source files or in headers that are in
+ the respective directory under src/modulename/ and NEVER be
+ declared in src/include/.
testcases:
- must be called "test_module-under-test_case-description.c"
Modified: gnunet/src/fs/fs.c
===================================================================
--- gnunet/src/fs/fs.c 2009-08-30 19:16:31 UTC (rev 8897)
+++ gnunet/src/fs/fs.c 2009-08-30 19:24:21 UTC (rev 8898)
@@ -61,6 +61,7 @@
ret->upcb_cls = upcb_cls;
ret->client = client;
// FIXME: setup receive-loop with client
+
// FIXME: deserialize state; use client-name to find master-directory!
// Deserialize-Upload:
// * read FNs for upload FIs, deserialize each
Modified: gnunet/src/fs/fs.h
===================================================================
--- gnunet/src/fs/fs.h 2009-08-30 19:16:31 UTC (rev 8897)
+++ gnunet/src/fs/fs.h 2009-08-30 19:24:21 UTC (rev 8898)
@@ -32,7 +32,7 @@
/**
* Size of the individual blocks used for file-sharing.
*/
-#define GNUNET_FS_DBLOCK_SIZE (32*1024)
+#define DBLOCK_SIZE (32*1024)
/**
@@ -42,14 +42,14 @@
* value is 32768 byte / 128 byte = 256
* (128 byte = 2 * 512 bits). DO NOT CHANGE!
*/
-#define GNUNET_FS_CHK_PER_INODE 256
+#define CHK_PER_INODE 256
/**
* Maximum size for a file to be considered for
* inlining in a directory.
*/
-#define GNUNET_FS_MAX_INLINE_SIZE 65536
+#define MAX_INLINE_SIZE 65536
@@ -509,7 +509,7 @@
/**
* @brief keyword block (advertising data under a keyword)
*/
-struct GNUNET_FS_KBlock
+struct KBlock
{
/**
@@ -536,7 +536,7 @@
/**
* @brief namespace content block (advertising data under an identifier in a
namespace)
*/
-struct GNUNET_FS_SBlock
+struct SBlock
{
/**
@@ -571,8 +571,13 @@
};
+struct IndexStartMessage
+{
+};
+
+
#endif
/* end of fs.h */
Modified: gnunet/src/fs/fs_directory.c
===================================================================
--- gnunet/src/fs/fs_directory.c 2009-08-30 19:16:31 UTC (rev 8897)
+++ gnunet/src/fs/fs_directory.c 2009-08-30 19:24:21 UTC (rev 8898)
@@ -173,11 +173,11 @@
/* URI is never empty, must be end of block,
skip to next alignment */
align =
- ((pos / GNUNET_FS_DBLOCK_SIZE) + 1) * GNUNET_FS_DBLOCK_SIZE;
+ ((pos / DBLOCK_SIZE) + 1) * DBLOCK_SIZE;
if (align == pos)
{
/* if we were already aligned, still skip a block! */
- align += GNUNET_FS_DBLOCK_SIZE;
+ align += DBLOCK_SIZE;
}
pos = align;
if (pos >= size)
@@ -333,7 +333,7 @@
fsize = GNUNET_FS_uri_chk_get_file_size (GNUNET_FS_uri_loc_get_uri
(uri));
else
fsize = 0; /* not given */
- if (fsize > GNUNET_FS_MAX_INLINE_SIZE)
+ if (fsize > MAX_INLINE_SIZE)
fsize = 0; /* too large */
if (NULL != memchr (data, 0, fsize))
fsize = 0; /* must not have 0's in data! */
@@ -353,8 +353,8 @@
mdxs =
GNUNET_CONTAINER_meta_data_get_serialized_size (meta,
GNUNET_CONTAINER_META_DATA_SERIALIZE_FULL);
- if ( (slen + sizeof (uint32_t) + mdxs - 1) / GNUNET_FS_DBLOCK_SIZE ==
- (slen + sizeof (uint32_t) + mds - 1) / GNUNET_FS_DBLOCK_SIZE)
+ if ( (slen + sizeof (uint32_t) + mdxs - 1) / DBLOCK_SIZE ==
+ (slen + sizeof (uint32_t) + mds - 1) / DBLOCK_SIZE)
{
/* adding full data would not cause us to cross
additional blocks, so add it! */
@@ -392,7 +392,7 @@
/**
* Given the start and end position of a block of
* data, return the end position of that data
- * after alignment to the GNUNET_FS_DBLOCK_SIZE.
+ * after alignment to the DBLOCK_SIZE.
*/
static size_t
do_align (size_t start_position,
@@ -400,7 +400,7 @@
{
size_t align;
- align = (end_position / GNUNET_FS_DBLOCK_SIZE) * GNUNET_FS_DBLOCK_SIZE;
+ align = (end_position / DBLOCK_SIZE) * DBLOCK_SIZE;
if ((start_position < align) && (end_position > align))
return align + end_position - start_position;
return end_position;
@@ -442,28 +442,28 @@
{
cval = perm[j];
cend = cpos + sizes[cval];
- if (cpos % GNUNET_FS_DBLOCK_SIZE == 0)
+ if (cpos % DBLOCK_SIZE == 0)
{
/* prefer placing the largest blocks first */
- cbad = -(cend % GNUNET_FS_DBLOCK_SIZE);
+ cbad = -(cend % DBLOCK_SIZE);
}
else
{
- if (cpos / GNUNET_FS_DBLOCK_SIZE ==
- cend / GNUNET_FS_DBLOCK_SIZE)
+ if (cpos / DBLOCK_SIZE ==
+ cend / DBLOCK_SIZE)
{
/* Data fits into the same block! Prefer small left-overs! */
cbad =
- GNUNET_FS_DBLOCK_SIZE - cend % GNUNET_FS_DBLOCK_SIZE;
+ DBLOCK_SIZE - cend % DBLOCK_SIZE;
}
else
{
/* Would have to waste space to re-align, add big factor,
this
case is a real loss (proportional to space wasted)! */
cbad =
- GNUNET_FS_DBLOCK_SIZE * (GNUNET_FS_DBLOCK_SIZE -
+ DBLOCK_SIZE * (DBLOCK_SIZE -
cpos %
- GNUNET_FS_DBLOCK_SIZE);
+ DBLOCK_SIZE);
}
}
if (cbad < badness)
Modified: gnunet/src/fs/fs_publish.c
===================================================================
--- gnunet/src/fs/fs_publish.c 2009-08-30 19:16:31 UTC (rev 8897)
+++ gnunet/src/fs/fs_publish.c 2009-08-30 19:24:21 UTC (rev 8898)
@@ -360,16 +360,16 @@
uint64_t fl;
treeDepth = 1;
- fl = GNUNET_FS_DBLOCK_SIZE;
+ fl = DBLOCK_SIZE;
while (fl < flen)
{
treeDepth++;
- if (fl * GNUNET_FS_CHK_PER_INODE < fl)
+ if (fl * CHK_PER_INODE < fl)
{
/* integer overflow, this is a HUGE file... */
return treeDepth;
}
- fl = fl * GNUNET_FS_CHK_PER_INODE;
+ fl = fl * CHK_PER_INODE;
}
return treeDepth;
}
@@ -393,20 +393,20 @@
uint64_t bds;
GNUNET_assert (height > 0);
- bds = GNUNET_FS_DBLOCK_SIZE; /* number of bytes each CHK at level "i"
+ bds = DBLOCK_SIZE; /* number of bytes each CHK at level "i"
corresponds to */
for (i=0;i<height;i++)
- bds *= GNUNET_FS_CHK_PER_INODE;
+ bds *= CHK_PER_INODE;
mod = offset % bds;
if (0 == mod)
{
/* we were triggered at the end of a full block */
- ret = GNUNET_FS_CHK_PER_INODE;
+ ret = CHK_PER_INODE;
}
else
{
/* we were triggered at the end of the file */
- bds /= GNUNET_FS_CHK_PER_INODE;
+ bds /= CHK_PER_INODE;
ret = mod / bds;
if (0 != mod % bds)
ret++;
@@ -432,13 +432,13 @@
unsigned int ret;
unsigned int i;
- bds = GNUNET_FS_DBLOCK_SIZE; /* number of bytes each CHK at level "i"
+ bds = DBLOCK_SIZE; /* number of bytes each CHK at level "i"
corresponds to */
for (i=0;i<height;i++)
- bds *= GNUNET_FS_CHK_PER_INODE;
+ bds *= CHK_PER_INODE;
GNUNET_assert (0 == (offset % bds));
ret = offset / bds;
- return ret % GNUNET_FS_CHK_PER_INODE;
+ return ret % CHK_PER_INODE;
}
@@ -460,8 +460,8 @@
const void *pt_block;
uint16_t pt_size;
char *emsg;
- char iob[GNUNET_FS_DBLOCK_SIZE];
- char enc[GNUNET_FS_DBLOCK_SIZE];
+ char iob[DBLOCK_SIZE];
+ char enc[DBLOCK_SIZE];
struct GNUNET_CRYPTO_AesSessionKey sk;
struct GNUNET_CRYPTO_AesInitializationVector iv;
uint64_t size;
@@ -491,7 +491,7 @@
else
{
raw_data = NULL;
- if ( (dirpos->data.file.file_size <
GNUNET_FS_MAX_INLINE_SIZE) &&
+ if ( (dirpos->data.file.file_size < MAX_INLINE_SIZE) &&
(dirpos->data.file.file_size > 0) )
{
raw_data = GNUNET_malloc (dirpos->data.file.file_size);
@@ -524,21 +524,21 @@
p->chk_tree_depth = compute_depth (size);
p->chk_tree = GNUNET_malloc (p->chk_tree_depth *
sizeof (struct ContentHashKey) *
- GNUNET_FS_CHK_PER_INODE);
+ CHK_PER_INODE);
p->current_depth = p->chk_tree_depth;
}
if (p->current_depth == p->chk_tree_depth)
{
if (p->is_directory)
{
- pt_size = GNUNET_MIN(GNUNET_FS_DBLOCK_SIZE,
+ pt_size = GNUNET_MIN(DBLOCK_SIZE,
p->data.dir.dir_size - p->publish_offset);
dd = p->data.dir.dir_data;
pt_block = &dd[p->publish_offset];
}
else
{
- pt_size = GNUNET_MIN(GNUNET_FS_DBLOCK_SIZE,
+ pt_size = GNUNET_MIN(DBLOCK_SIZE,
p->data.file.file_size - p->publish_offset);
emsg = NULL;
if (pt_size !=
@@ -579,11 +579,11 @@
pt_size = compute_iblock_size (p->chk_tree_depth - p->current_depth,
p->publish_offset);
pt_block = &p->chk_tree[p->current_depth *
- GNUNET_FS_CHK_PER_INODE];
+ CHK_PER_INODE];
}
off = compute_chk_offset (p->chk_tree_depth - p->current_depth,
p->publish_offset);
- mychk = &p->chk_tree[(p->current_depth-1)*GNUNET_FS_CHK_PER_INODE+off];
+ mychk = &p->chk_tree[(p->current_depth-1)*CHK_PER_INODE+off];
GNUNET_CRYPTO_hash (pt_block, pt_size, &mychk->key);
GNUNET_CRYPTO_hash_to_aes_key (&mychk->key, &sk, &iv);
GNUNET_CRYPTO_aes_encrypt (pt_block,
@@ -645,12 +645,12 @@
{
p->publish_offset += pt_size;
if ( (p->publish_offset == size) ||
- (0 == p->publish_offset % (GNUNET_FS_CHK_PER_INODE *
GNUNET_FS_DBLOCK_SIZE) ) )
+ (0 == p->publish_offset % (CHK_PER_INODE * DBLOCK_SIZE) ) )
p->current_depth--;
}
else
{
- if ( (off == GNUNET_FS_CHK_PER_INODE) ||
+ if ( (off == CHK_PER_INODE) ||
(p->publish_offset == size) )
p->current_depth--;
else
@@ -951,13 +951,13 @@
* (in plaintext), has "mdsize+slen" more
* bytes than the struct would suggest.
*/
- struct GNUNET_FS_KBlock *kb;
+ struct KBlock *kb;
/**
* Buffer of the same size as "kb" for
* the encrypted version.
*/
- struct GNUNET_FS_KBlock *cpy;
+ struct KBlock *cpy;
/**
* Handle to the datastore, NULL if we are just
@@ -1114,7 +1114,7 @@
0,
&query,
pkc->mdsize +
- sizeof (struct GNUNET_FS_KBlock) +
+ sizeof (struct KBlock) +
pkc->slen,
pkc->cpy,
GNUNET_DATASTORE_BLOCKTYPE_KBLOCK,
@@ -1181,11 +1181,11 @@
GNUNET_assert (pkc->mdsize >= 0);
uris = GNUNET_FS_uri_to_string (uri);
pkc->slen = strlen (uris) + 1;
- size = pkc->mdsize + sizeof (struct GNUNET_FS_KBlock) + pkc->slen;
+ size = pkc->mdsize + sizeof (struct KBlock) + pkc->slen;
if (size > MAX_KBLOCK_SIZE)
{
size = MAX_KBLOCK_SIZE;
- pkc->mdsize = size - sizeof (struct GNUNET_FS_KBlock) - pkc->slen;
+ pkc->mdsize = size - sizeof (struct KBlock) - pkc->slen;
}
pkc->kb = GNUNET_malloc (size);
kbe = (char *) &pkc->kb[1];
@@ -1206,7 +1206,7 @@
GNUNET_free (pkc);
return;
}
- size = sizeof (struct GNUNET_FS_KBlock) + pkc->slen + pkc->mdsize;
+ size = sizeof (struct KBlock) + pkc->slen + pkc->mdsize;
pkc->cpy = GNUNET_malloc (size);
pkc->cpy->purpose.size = htonl (sizeof (struct
GNUNET_CRYPTO_RsaSignaturePurpose) +
@@ -1322,8 +1322,8 @@
size_t nidlen;
size_t idlen;
ssize_t mdsize;
- struct GNUNET_FS_SBlock *sb;
- struct GNUNET_FS_SBlock *sb_enc;
+ struct SBlock *sb;
+ struct SBlock *sb_enc;
char *dest;
GNUNET_HashCode key; /* hash of thisId = key */
GNUNET_HashCode id; /* hash of hc = identifier */
@@ -1337,13 +1337,13 @@
mdsize = GNUNET_CONTAINER_meta_data_get_serialized_size (meta,
GNUNET_CONTAINER_META_DATA_SERIALIZE_PART);
- size = sizeof (struct GNUNET_FS_SBlock) + slen + nidlen + mdsize;
+ size = sizeof (struct SBlock) + slen + nidlen + mdsize;
if (size > MAX_SBLOCK_SIZE)
{
size = MAX_SBLOCK_SIZE;
- mdsize = size - (sizeof (struct GNUNET_FS_SBlock) + slen + nidlen);
+ mdsize = size - (sizeof (struct SBlock) + slen + nidlen);
}
- sb = GNUNET_malloc (sizeof (struct GNUNET_FS_SBlock) + size);
+ sb = GNUNET_malloc (sizeof (struct SBlock) + size);
dest = (char *) &sb[1];
memcpy (dest, update, nidlen);
dest += nidlen;
@@ -1363,8 +1363,8 @@
_("Internal error."));
return;
}
- size = sizeof (struct GNUNET_FS_SBlock) + mdsize + slen + nidlen;
- sb_enc = GNUNET_malloc (sizeof (struct GNUNET_FS_SBlock) + size);
+ size = sizeof (struct SBlock) + mdsize + slen + nidlen;
+ sb_enc = GNUNET_malloc (sizeof (struct SBlock) + size);
GNUNET_CRYPTO_hash (identifier, idlen, &key);
GNUNET_CRYPTO_hash (&key, sizeof (GNUNET_HashCode), &id);
sks_uri = GNUNET_malloc (sizeof (struct GNUNET_FS_Uri));
@@ -1379,14 +1379,14 @@
&sb_enc->identifier);
GNUNET_CRYPTO_hash_to_aes_key (&key, &sk, &iv);
GNUNET_CRYPTO_aes_encrypt (&sb[1],
- size - sizeof (struct GNUNET_FS_SBlock),
+ size - sizeof (struct SBlock),
&sk,
&iv,
&sb_enc[1]);
GNUNET_free (sb);
sb_enc->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_FS_SBLOCK);
sb_enc->purpose.size = htonl(slen + mdsize + nidlen
- + sizeof(struct GNUNET_FS_SBlock)
+ + sizeof(struct SBlock)
- sizeof(struct GNUNET_CRYPTO_RsaSignature));
GNUNET_assert (GNUNET_OK ==
GNUNET_CRYPTO_rsa_sign (namespace->key,
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r8898 - in gnunet: . src/fs,
gnunet <=