aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_common.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/gnunet_common.h')
-rw-r--r--src/include/gnunet_common.h70
1 files changed, 28 insertions, 42 deletions
diff --git a/src/include/gnunet_common.h b/src/include/gnunet_common.h
index 6c27b88a3..ab639122c 100644
--- a/src/include/gnunet_common.h
+++ b/src/include/gnunet_common.h
@@ -248,24 +248,6 @@ struct GNUNET_MessageHeader
248 248
249}; 249};
250 250
251
252/**
253 * @brief A SHA-512 hashcode
254 */
255struct GNUNET_HashCode
256{
257 uint32_t bits[512 / 8 / sizeof (uint32_t)]; /* = 16 */
258};
259
260
261/**
262 * The identity of the host (basically the SHA-512 hashcode of
263 * it's public key).
264 */
265struct GNUNET_PeerIdentity
266{
267 struct GNUNET_HashCode hashPubKey;
268};
269GNUNET_NETWORK_STRUCT_END 251GNUNET_NETWORK_STRUCT_END
270 252
271/** 253/**
@@ -273,9 +255,9 @@ GNUNET_NETWORK_STRUCT_END
273 * 255 *
274 * @param cls closure 256 * @param cls closure
275 * @param filename complete filename (absolute path) 257 * @param filename complete filename (absolute path)
276 * @return GNUNET_OK to continue to iterate, 258 * @return #GNUNET_OK to continue to iterate,
277 * GNUNET_NO to stop iteration with no error, 259 * #GNUNET_NO to stop iteration with no error,
278 * GNUNET_SYSERR to abort iteration with error! 260 * #GNUNET_SYSERR to abort iteration with error!
279 */ 261 */
280typedef int (*GNUNET_FileNameCallback) (void *cls, const char *filename); 262typedef int (*GNUNET_FileNameCallback) (void *cls, const char *filename);
281 263
@@ -325,8 +307,10 @@ GNUNET_get_log_skip ();
325 307
326#if !defined(GNUNET_CULL_LOGGING) 308#if !defined(GNUNET_CULL_LOGGING)
327int 309int
328GNUNET_get_log_call_status (int caller_level, const char *comp, 310GNUNET_get_log_call_status (int caller_level,
329 const char *file, const char *function, int line); 311 const char *comp,
312 const char *file,
313 const char *function, int line);
330#endif 314#endif
331 315
332 316
@@ -529,7 +513,7 @@ GNUNET_h2s_full (const struct GNUNET_HashCode * hc);
529 * 513 *
530 * @param pid the peer identity 514 * @param pid the peer identity
531 * @return string form of the pid; will be overwritten by next 515 * @return string form of the pid; will be overwritten by next
532 * call to GNUNET_i2s. 516 * call to #GNUNET_i2s.
533 */ 517 */
534const char * 518const char *
535GNUNET_i2s (const struct GNUNET_PeerIdentity *pid); 519GNUNET_i2s (const struct GNUNET_PeerIdentity *pid);
@@ -543,7 +527,7 @@ GNUNET_i2s (const struct GNUNET_PeerIdentity *pid);
543 * 527 *
544 * @param pid the peer identity 528 * @param pid the peer identity
545 * @return string form of the pid; will be overwritten by next 529 * @return string form of the pid; will be overwritten by next
546 * call to GNUNET_i2s. 530 * call to #GNUNET_i2s.
547 */ 531 */
548const char * 532const char *
549GNUNET_i2s_full (const struct GNUNET_PeerIdentity *pid); 533GNUNET_i2s_full (const struct GNUNET_PeerIdentity *pid);
@@ -688,8 +672,8 @@ GNUNET_ntoh_double (double d);
688 672
689/** 673/**
690 * @ingroup memory 674 * @ingroup memory
691 * Allocate a struct or union of the given 'type'. 675 * Allocate a struct or union of the given @a type.
692 * Wrapper around GNUNET_malloc that returns a pointer 676 * Wrapper around #GNUNET_malloc that returns a pointer
693 * to the newly created object of the correct type. 677 * to the newly created object of the correct type.
694 * 678 *
695 * @param type name of the struct or union, i.e. pass 'struct Foo'. 679 * @param type name of the struct or union, i.e. pass 'struct Foo'.
@@ -741,17 +725,17 @@ GNUNET_ntoh_double (double d);
741 * @ingroup memory 725 * @ingroup memory
742 * Wrapper around free. Frees the memory referred to by ptr. 726 * Wrapper around free. Frees the memory referred to by ptr.
743 * Note that is is generally better to free memory that was 727 * Note that is is generally better to free memory that was
744 * allocated with GNUNET_array_grow using GNUNET_array_grow(mem, size, 0) instead of GNUNET_free. 728 * allocated with #GNUNET_array_grow using #GNUNET_array_grow(mem, size, 0) instead of #GNUNET_free.
745 * 729 *
746 * @param ptr location where to free the memory. ptr must have 730 * @param ptr location where to free the memory. ptr must have
747 * been returned by GNUNET_strdup, GNUNET_strndup, GNUNET_malloc or GNUNET_array_grow earlier. 731 * been returned by #GNUNET_strdup, #GNUNET_strndup, #GNUNET_malloc or #GNUNET_array_grow earlier.
748 */ 732 */
749#define GNUNET_free(ptr) GNUNET_xfree_(ptr, __FILE__, __LINE__) 733#define GNUNET_free(ptr) GNUNET_xfree_(ptr, __FILE__, __LINE__)
750 734
751/** 735/**
752 * @ingroup memory 736 * @ingroup memory
753 * Free the memory pointed to by ptr if ptr is not NULL. 737 * Free the memory pointed to by ptr if ptr is not NULL.
754 * Equivalent to if (ptr!=null)GNUNET_free(ptr). 738 * Equivalent to `if (NULL != ptr) GNUNET_free(ptr)`.
755 * 739 *
756 * @param ptr the location in memory to free 740 * @param ptr the location in memory to free
757 */ 741 */
@@ -759,7 +743,7 @@ GNUNET_ntoh_double (double d);
759 743
760/** 744/**
761 * @ingroup memory 745 * @ingroup memory
762 * Wrapper around GNUNET_strdup. Makes a copy of the zero-terminated string 746 * Wrapper around #GNUNET_xstrdup_. Makes a copy of the zero-terminated string
763 * pointed to by a. 747 * pointed to by a.
764 * 748 *
765 * @param a pointer to a zero-terminated string 749 * @param a pointer to a zero-terminated string
@@ -769,7 +753,7 @@ GNUNET_ntoh_double (double d);
769 753
770/** 754/**
771 * @ingroup memory 755 * @ingroup memory
772 * Wrapper around GNUNET_strndup. Makes a partial copy of the string 756 * Wrapper around #GNUNET_xstrndup_. Makes a partial copy of the string
773 * pointed to by a. 757 * pointed to by a.
774 * 758 *
775 * @param a pointer to a string 759 * @param a pointer to a string
@@ -781,8 +765,8 @@ GNUNET_ntoh_double (double d);
781/** 765/**
782 * @ingroup memory 766 * @ingroup memory
783 * Grow a well-typed (!) array. This is a convenience 767 * Grow a well-typed (!) array. This is a convenience
784 * method to grow a vector <tt>arr</tt> of size <tt>size</tt> 768 * method to grow a vector @a arr of size @a size
785 * to the new (target) size <tt>tsize</tt>. 769 * to the new (target) size @a tsize.
786 * <p> 770 * <p>
787 * 771 *
788 * Example (simple, well-typed stack): 772 * Example (simple, well-typed stack):
@@ -826,7 +810,7 @@ GNUNET_ntoh_double (double d);
826 * Like snprintf, just aborts if the buffer is of insufficient size. 810 * Like snprintf, just aborts if the buffer is of insufficient size.
827 * 811 *
828 * @param buf pointer to buffer that is written to 812 * @param buf pointer to buffer that is written to
829 * @param size number of bytes in buf 813 * @param size number of bytes in @a buf
830 * @param format format strings 814 * @param format format strings
831 * @param ... data for format string 815 * @param ... data for format string
832 * @return number of bytes written to buf or negative value on error 816 * @return number of bytes written to buf or negative value on error
@@ -853,7 +837,7 @@ GNUNET_asprintf (char **buf, const char *format, ...);
853/** 837/**
854 * Allocate memory. Checks the return value, aborts if no more 838 * Allocate memory. Checks the return value, aborts if no more
855 * memory is available. Don't use GNUNET_xmalloc_ directly. Use the 839 * memory is available. Don't use GNUNET_xmalloc_ directly. Use the
856 * GNUNET_malloc macro. 840 * #GNUNET_malloc macro.
857 * The memory will be zero'ed out. 841 * The memory will be zero'ed out.
858 * 842 *
859 * @param size number of bytes to allocate 843 * @param size number of bytes to allocate
@@ -868,7 +852,7 @@ GNUNET_xmalloc_ (size_t size, const char *filename, int linenumber);
868/** 852/**
869 * Allocate and initialize memory. Checks the return value, aborts if no more 853 * Allocate and initialize memory. Checks the return value, aborts if no more
870 * memory is available. Don't use GNUNET_xmemdup_ directly. Use the 854 * memory is available. Don't use GNUNET_xmemdup_ directly. Use the
871 * GNUNET_memdup macro. 855 * #GNUNET_memdup macro.
872 * 856 *
873 * @param buf buffer to initialize from (must contain size bytes) 857 * @param buf buffer to initialize from (must contain size bytes)
874 * @param size number of bytes to allocate 858 * @param size number of bytes to allocate
@@ -885,7 +869,7 @@ GNUNET_xmemdup_ (const void *buf, size_t size, const char *filename,
885 * Allocate memory. This function does not check if the allocation 869 * Allocate memory. This function does not check if the allocation
886 * request is within reasonable bounds, allowing allocations larger 870 * request is within reasonable bounds, allowing allocations larger
887 * than 40 MB. If you don't expect the possibility of very large 871 * than 40 MB. If you don't expect the possibility of very large
888 * allocations, use GNUNET_malloc instead. The memory will be zero'ed 872 * allocations, use #GNUNET_malloc instead. The memory will be zero'ed
889 * out. 873 * out.
890 * 874 *
891 * @param size number of bytes to allocate 875 * @param size number of bytes to allocate
@@ -896,6 +880,7 @@ GNUNET_xmemdup_ (const void *buf, size_t size, const char *filename,
896void * 880void *
897GNUNET_xmalloc_unchecked_ (size_t size, const char *filename, int linenumber); 881GNUNET_xmalloc_unchecked_ (size_t size, const char *filename, int linenumber);
898 882
883
899/** 884/**
900 * Reallocate memory. Checks the return value, aborts if no more 885 * Reallocate memory. Checks the return value, aborts if no more
901 * memory is available. 886 * memory is available.
@@ -903,10 +888,11 @@ GNUNET_xmalloc_unchecked_ (size_t size, const char *filename, int linenumber);
903void * 888void *
904GNUNET_xrealloc_ (void *ptr, size_t n, const char *filename, int linenumber); 889GNUNET_xrealloc_ (void *ptr, size_t n, const char *filename, int linenumber);
905 890
891
906/** 892/**
907 * Free memory. Merely a wrapper for the case that we 893 * Free memory. Merely a wrapper for the case that we
908 * want to keep track of allocations. Don't use GNUNET_xfree_ 894 * want to keep track of allocations. Don't use GNUNET_xfree_
909 * directly. Use the GNUNET_free macro. 895 * directly. Use the #GNUNET_free macro.
910 * 896 *
911 * @param ptr pointer to memory to free 897 * @param ptr pointer to memory to free
912 * @param filename where is this call being made (for debugging) 898 * @param filename where is this call being made (for debugging)
@@ -917,7 +903,7 @@ GNUNET_xfree_ (void *ptr, const char *filename, int linenumber);
917 903
918 904
919/** 905/**
920 * Dup a string. Don't call GNUNET_xstrdup_ directly. Use the GNUNET_strdup macro. 906 * Dup a string. Don't call GNUNET_xstrdup_ directly. Use the #GNUNET_strdup macro.
921 * @param str string to duplicate 907 * @param str string to duplicate
922 * @param filename where is this call being made (for debugging) 908 * @param filename where is this call being made (for debugging)
923 * @param linenumber line where this call is being made (for debugging) 909 * @param linenumber line where this call is being made (for debugging)
@@ -927,7 +913,7 @@ char *
927GNUNET_xstrdup_ (const char *str, const char *filename, int linenumber); 913GNUNET_xstrdup_ (const char *str, const char *filename, int linenumber);
928 914
929/** 915/**
930 * Dup partially a string. Don't call GNUNET_xstrndup_ directly. Use the GNUNET_strndup macro. 916 * Dup partially a string. Don't call GNUNET_xstrndup_ directly. Use the #GNUNET_strndup macro.
931 * 917 *
932 * @param str string to duplicate 918 * @param str string to duplicate
933 * @param len length of the string to duplicate 919 * @param len length of the string to duplicate
@@ -944,7 +930,7 @@ GNUNET_xstrndup_ (const char *str, size_t len, const char *filename,
944 * Grows old by (*oldCount-newCount)*elementSize 930 * Grows old by (*oldCount-newCount)*elementSize
945 * bytes and sets *oldCount to newCount. 931 * bytes and sets *oldCount to newCount.
946 * 932 *
947 * Don't call GNUNET_xgrow_ directly. Use the GNUNET_array_grow macro. 933 * Don't call GNUNET_xgrow_ directly. Use the #GNUNET_array_grow macro.
948 * 934 *
949 * @param old address of the pointer to the array 935 * @param old address of the pointer to the array
950 * *old may be NULL 936 * *old may be NULL