aboutsummaryrefslogtreecommitdiff
path: root/src/gnunet_chat_util.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/gnunet_chat_util.h')
-rw-r--r--src/gnunet_chat_util.h106
1 files changed, 101 insertions, 5 deletions
diff --git a/src/gnunet_chat_util.h b/src/gnunet_chat_util.h
index c94c32c..55f13de 100644
--- a/src/gnunet_chat_util.h
+++ b/src/gnunet_chat_util.h
@@ -32,50 +32,146 @@
32#include <gnunet/gnunet_messenger_service.h> 32#include <gnunet/gnunet_messenger_service.h>
33#include <gnunet/gnunet_util_lib.h> 33#include <gnunet/gnunet_util_lib.h>
34 34
35/**
36 * Enum for the types of chat contexts.
37 */
35enum GNUNET_CHAT_ContextType 38enum GNUNET_CHAT_ContextType
36{ 39{
37 GNUNET_CHAT_CONTEXT_TYPE_CONTACT = 1, 40 /**
38 GNUNET_CHAT_CONTEXT_TYPE_GROUP = 2, 41 * Contact context type
39 GNUNET_CHAT_CONTEXT_TYPE_UNKNOWN = 0 42 */
43 GNUNET_CHAT_CONTEXT_TYPE_CONTACT = 1,/**< GNUNET_CHAT_CONTEXT_TYPE_CONTACT */
44
45 /**
46 * Group context type
47 */
48 GNUNET_CHAT_CONTEXT_TYPE_GROUP = 2,/**< GNUNET_CHAT_CONTEXT_TYPE_GROUP */
49
50 /**
51 * Unknown context type
52 */
53 GNUNET_CHAT_CONTEXT_TYPE_UNKNOWN = 0 /**< GNUNET_CHAT_CONTEXT_TYPE_UNKNOWN */
40}; 54};
41 55
56/**
57 * Converts a unique messenger contact, being consistent <i>member</i>
58 * of multiple messenger rooms via memory consistency, into a short
59 * hash variant for map access as key.
60 *
61 * @param[in] member Messenger contact
62 * @param[out] shorthash Short hash
63 */
42void 64void
43util_shorthash_from_member (const struct GNUNET_MESSENGER_Contact *member, 65util_shorthash_from_member (const struct GNUNET_MESSENGER_Contact *member,
44 struct GNUNET_ShortHashCode *shorthash); 66 struct GNUNET_ShortHashCode *shorthash);
45 67
68/**
69 * Updates the stored content of a <i>field</i> with
70 * a given <i>name</i>.
71 *
72 * @param[in] name Name
73 * @param[out] field String field
74 */
46void 75void
47util_set_name_field (const char *name, char **field); 76util_set_name_field (const char *name, char **field);
48 77
78/**
79 * Generates the <i>hash</i> of a file under a given
80 * <i>filename</i>.
81 *
82 * @param[in] filename File name
83 * @param[out] hash Hash of file
84 * @return #GNUNET_OK on success, otherwise #GNUNET_SYSERR
85 */
49int 86int
50util_hash_file (const char *filename, struct GNUNET_HashCode *hash); 87util_hash_file (const char *filename, struct GNUNET_HashCode *hash);
51 88
89/**
90 * Encrypts a file inplace under a given <i>filename</i>
91 * with a selected symmetric <i>key</i> and its <i>hash</i>
92 * as initialization vector.
93 *
94 * @param[in] filename File name
95 * @param[in] hash Hash of file
96 * @param[in] key Symmetric key
97 * @return #GNUNET_OK on success, otherwise #GNUNET_SYSERR
98 */
52int 99int
53util_encrypt_file (const char *filename, 100util_encrypt_file (const char *filename,
54 const struct GNUNET_HashCode *hash, 101 const struct GNUNET_HashCode *hash,
55 const struct GNUNET_CRYPTO_SymmetricSessionKey *key); 102 const struct GNUNET_CRYPTO_SymmetricSessionKey *key);
56 103
104/**
105 * Decrypts a file inplace under a given <i>filename</i>
106 * with a selected symmetric <i>key</i> and its <i>hash</i>
107 * as parameter for the initialization vector and comparison
108 * to verify success.
109 *
110 * @param[in] filename File name
111 * @param[in] hash Hash of file
112 * @param[in] key Symmetric key
113 * @return #GNUNET_OK on success, otherwise #GNUNET_SYSERR
114 */
57int 115int
58util_decrypt_file (const char *filename, 116util_decrypt_file (const char *filename,
59 const struct GNUNET_HashCode *hash, 117 const struct GNUNET_HashCode *hash,
60 const struct GNUNET_CRYPTO_SymmetricSessionKey *key); 118 const struct GNUNET_CRYPTO_SymmetricSessionKey *key);
61 119
120/**
121 * Append the path of a <i>directory</i> and a custom
122 * subdirectory name to a composed <i>filename</i>.
123 *
124 * @param[in] directory Directory path
125 * @param[in] subdir Subdirectory name
126 * @param[out] filename Filename
127 * @return Number of bytes in filename excluding 0-termination
128 */
62int 129int
63util_get_dirname (const char *directory, 130util_get_dirname (const char *directory,
64 const char *subdir, 131 const char *subdir,
65 char **filename); 132 char **filename);
66 133
134/**
135 * Append the path of a <i>directory</i>, a custom
136 * subdirectory name and a <i>hash</i> to a composed
137 * <i>filename</i>.
138 *
139 * @param[in] directory Directory path
140 * @param[in] subdir Subdirectory name
141 * @param[in] hash Hash
142 * @param[out] filename Filename
143 * @return Number of bytes in filename excluding 0-termination
144 */
67int 145int
68util_get_filename (const char *directory, 146util_get_filename (const char *directory,
69 const char *subdir, 147 const char *subdir,
70 const struct GNUNET_HashCode *hash, 148 const struct GNUNET_HashCode *hash,
71 char **filename); 149 char **filename);
72 150
151/**
152 * Construct a composed <i>label</i> from a given context
153 * <i>type</i> and the <i>hash</i> of the contexts room.
154 *
155 * @param[in] type Chat context type
156 * @param[in] hash Hash of room
157 * @param[out] label Namestore label
158 * @return Number of bytes in label excluding 0-termination
159 */
73int 160int
74util_get_context_label (enum GNUNET_CHAT_ContextType type, 161util_get_context_label (enum GNUNET_CHAT_ContextType type,
75 const struct GNUNET_HashCode *hash, 162 const struct GNUNET_HashCode *hash,
76 char **label); 163 char **label);
77 164
78int util_lobby_name (const struct GNUNET_HashCode *hash, 165/**
79 char **name); 166 * Provide a standardized <i>name</i> for a lobby using
167 * a given <i>hash</i> of its internal room.
168 *
169 * @param[in] hash Hash of room
170 * @param[out] name Name of lobby
171 * @return Number of bytes in name excluding 0-termination
172 */
173int
174util_lobby_name (const struct GNUNET_HashCode *hash,
175 char **name);
80 176
81#endif /* GNUNET_CHAT_UTIL_H_ */ 177#endif /* GNUNET_CHAT_UTIL_H_ */