Main Page | Modules | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

urn.c File Reference


Detailed Description

URN handling of specific formats.

Author:
Raphael Manfredi
Date:
2002-2004

#include "common.h"
#include "base32.h"
#include "misc.h"
#include "urn.h"
#include "override.h"

Functions

gboolean parse_base32_sha1 (const gchar *buf, size_t size, struct sha1 *sha1)
 Validate SHA1 starting in NUL-terminated `buf' as a proper base32 encoding of a SHA1 hash, and write decoded value in `retval'.
gboolean urn_get_sha1 (const gchar *buf, struct sha1 *sha1)
 Locate the start of "urn:sha1:" or "urn:bitprint:" indications and extract the SHA1 out of it, placing it in the supplied `digest' buffer.
gboolean urn_get_bitprint (const gchar *buf, size_t size, struct sha1 *sha1, struct tth *tth)
gboolean urn_get_tth (const gchar *buf, size_t size, struct tth *tth)
gboolean urn_get_sha1_no_prefix (const gchar *buf, struct sha1 *sha1)
 This is the same as urn_get_sha1(), only the leading "urn:" part is missing (typically a URN embedded in a GGEP "u").


Function Documentation

gboolean parse_base32_sha1 const gchar *  buf,
size_t  size,
struct sha1 sha1
 

Validate SHA1 starting in NUL-terminated `buf' as a proper base32 encoding of a SHA1 hash, and write decoded value in `retval'.

The SHA1 typically comes from HTTP, in a X-Gnutella-Content-URN header.

Returns:
TRUE if the SHA1 was valid and properly decoded, FALSE on error.

gboolean urn_get_bitprint const gchar *  buf,
size_t  size,
struct sha1 sha1,
struct tth tth
 

gboolean urn_get_sha1 const gchar *  buf,
struct sha1 sha1
 

Locate the start of "urn:sha1:" or "urn:bitprint:" indications and extract the SHA1 out of it, placing it in the supplied `digest' buffer.

Returns:
whether we successfully extracted the SHA1.

gboolean urn_get_sha1_no_prefix const gchar *  buf,
struct sha1 sha1
 

This is the same as urn_get_sha1(), only the leading "urn:" part is missing (typically a URN embedded in a GGEP "u").

`buf' MUST start with "sha1:" or "bitprint:" indications. Since the leading "urn:" part is missing, we cannot be lenient.

Extract the SHA1 out of it, placing it in the supplied `digest' buffer.

Returns:
whether we successfully extracted the SHA1.

gboolean urn_get_tth const gchar *  buf,
size_t  size,
struct tth tth
 


Generated on Sat Jun 30 17:53:31 2007 for gtk-gnutella by  doxygen 1.3.9.1