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.h81
1 files changed, 50 insertions, 31 deletions
diff --git a/src/include/gnunet_common.h b/src/include/gnunet_common.h
index f884d9a24..2636824d3 100644
--- a/src/include/gnunet_common.h
+++ b/src/include/gnunet_common.h
@@ -168,7 +168,8 @@ typedef void (*GNUNET_Logger) (void *cls, enum GNUNET_ErrorType kind,
168 * @param message what is the message (format string) 168 * @param message what is the message (format string)
169 * @param ... arguments for format string 169 * @param ... arguments for format string
170 */ 170 */
171void GNUNET_log (enum GNUNET_ErrorType kind, const char *message, ...); 171void
172GNUNET_log (enum GNUNET_ErrorType kind, const char *message, ...);
172 173
173 174
174 175
@@ -181,8 +182,9 @@ void GNUNET_log (enum GNUNET_ErrorType kind, const char *message, ...);
181 * @param message what is the message (format string) 182 * @param message what is the message (format string)
182 * @param ... arguments for format string 183 * @param ... arguments for format string
183 */ 184 */
184void GNUNET_log_from (enum GNUNET_ErrorType kind, const char *comp, 185void
185 const char *message, ...); 186GNUNET_log_from (enum GNUNET_ErrorType kind, const char *comp,
187 const char *message, ...);
186 188
187 189
188/** 190/**
@@ -191,7 +193,8 @@ void GNUNET_log_from (enum GNUNET_ErrorType kind, const char *comp,
191 * @param n number of log calls to ignore 193 * @param n number of log calls to ignore
192 * @param check_reset GNUNET_YES to assert that the log skip counter is currently zero 194 * @param check_reset GNUNET_YES to assert that the log skip counter is currently zero
193 */ 195 */
194void GNUNET_log_skip (unsigned int n, int check_reset); 196void
197GNUNET_log_skip (unsigned int n, int check_reset);
195 198
196 199
197/** 200/**
@@ -202,8 +205,8 @@ void GNUNET_log_skip (unsigned int n, int check_reset);
202 * @param logfile change logging to logfile (use NULL to keep stderr) 205 * @param logfile change logging to logfile (use NULL to keep stderr)
203 * @return GNUNET_OK on success, GNUNET_SYSERR if logfile could not be opened 206 * @return GNUNET_OK on success, GNUNET_SYSERR if logfile could not be opened
204 */ 207 */
205int GNUNET_log_setup (const char *comp, const char *loglevel, 208int
206 const char *logfile); 209GNUNET_log_setup (const char *comp, const char *loglevel, const char *logfile);
207 210
208 211
209/** 212/**
@@ -212,7 +215,8 @@ int GNUNET_log_setup (const char *comp, const char *loglevel,
212 * @param logger log function 215 * @param logger log function
213 * @param logger_cls closure for logger 216 * @param logger_cls closure for logger
214 */ 217 */
215void GNUNET_logger_add (GNUNET_Logger logger, void *logger_cls); 218void
219GNUNET_logger_add (GNUNET_Logger logger, void *logger_cls);
216 220
217 221
218/** 222/**
@@ -221,7 +225,8 @@ void GNUNET_logger_add (GNUNET_Logger logger, void *logger_cls);
221 * @param logger log function 225 * @param logger log function
222 * @param logger_cls closure for logger 226 * @param logger_cls closure for logger
223 */ 227 */
224void GNUNET_logger_remove (GNUNET_Logger logger, void *logger_cls); 228void
229GNUNET_logger_remove (GNUNET_Logger logger, void *logger_cls);
225 230
226 231
227/** 232/**
@@ -232,7 +237,8 @@ void GNUNET_logger_remove (GNUNET_Logger logger, void *logger_cls);
232 * @param hc the hash code 237 * @param hc the hash code
233 * @return string 238 * @return string
234 */ 239 */
235const char *GNUNET_h2s (const GNUNET_HashCode * hc); 240const char *
241GNUNET_h2s (const GNUNET_HashCode * hc);
236 242
237 243
238/** 244/**
@@ -244,7 +250,8 @@ const char *GNUNET_h2s (const GNUNET_HashCode * hc);
244 * @param hc the hash code 250 * @param hc the hash code
245 * @return string 251 * @return string
246 */ 252 */
247const char *GNUNET_h2s_full (const GNUNET_HashCode * hc); 253const char *
254GNUNET_h2s_full (const GNUNET_HashCode * hc);
248 255
249 256
250/** 257/**
@@ -256,7 +263,8 @@ const char *GNUNET_h2s_full (const GNUNET_HashCode * hc);
256 * @return string form of the pid; will be overwritten by next 263 * @return string form of the pid; will be overwritten by next
257 * call to GNUNET_i2s. 264 * call to GNUNET_i2s.
258 */ 265 */
259const char *GNUNET_i2s (const struct GNUNET_PeerIdentity *pid); 266const char *
267GNUNET_i2s (const struct GNUNET_PeerIdentity *pid);
260 268
261 269
262/** 270/**
@@ -269,7 +277,8 @@ const char *GNUNET_i2s (const struct GNUNET_PeerIdentity *pid);
269 * @return nicely formatted string for the address 277 * @return nicely formatted string for the address
270 * will be overwritten by next call to GNUNET_a2s. 278 * will be overwritten by next call to GNUNET_a2s.
271 */ 279 */
272const char *GNUNET_a2s (const struct sockaddr *addr, socklen_t addrlen); 280const char *
281GNUNET_a2s (const struct sockaddr *addr, socklen_t addrlen);
273 282
274/** 283/**
275 * Convert error type to string. 284 * Convert error type to string.
@@ -277,7 +286,8 @@ const char *GNUNET_a2s (const struct sockaddr *addr, socklen_t addrlen);
277 * @param kind type to convert 286 * @param kind type to convert
278 * @return string corresponding to the type 287 * @return string corresponding to the type
279 */ 288 */
280const char *GNUNET_error_type_to_string (enum GNUNET_ErrorType kind); 289const char *
290GNUNET_error_type_to_string (enum GNUNET_ErrorType kind);
281 291
282 292
283/** 293/**
@@ -327,14 +337,16 @@ const char *GNUNET_error_type_to_string (enum GNUNET_ErrorType kind);
327 * @param n the value in network byte order 337 * @param n the value in network byte order
328 * @return the same value in host byte order 338 * @return the same value in host byte order
329 */ 339 */
330unsigned long long GNUNET_ntohll (unsigned long long n); 340unsigned long long
341GNUNET_ntohll (unsigned long long n);
331 342
332/** 343/**
333 * Convert a long long to network-byte-order. 344 * Convert a long long to network-byte-order.
334 * @param n the value in host byte order 345 * @param n the value in host byte order
335 * @return the same value in network byte order 346 * @return the same value in network byte order
336 */ 347 */
337unsigned long long GNUNET_htonll (unsigned long long n); 348unsigned long long
349GNUNET_htonll (unsigned long long n);
338 350
339 351
340/* ************************* allocation functions ****************** */ 352/* ************************* allocation functions ****************** */
@@ -468,7 +480,8 @@ unsigned long long GNUNET_htonll (unsigned long long n);
468 * @param ... data for format string 480 * @param ... data for format string
469 * @return number of bytes written to buf or negative value on error 481 * @return number of bytes written to buf or negative value on error
470 */ 482 */
471int GNUNET_snprintf (char *buf, size_t size, const char *format, ...); 483int
484GNUNET_snprintf (char *buf, size_t size, const char *format, ...);
472 485
473 486
474/** 487/**
@@ -479,7 +492,8 @@ int GNUNET_snprintf (char *buf, size_t size, const char *format, ...);
479 * @param ... data for format string 492 * @param ... data for format string
480 * @return number of bytes in "*buf" excluding 0-termination 493 * @return number of bytes in "*buf" excluding 0-termination
481 */ 494 */
482int GNUNET_asprintf (char **buf, const char *format, ...); 495int
496GNUNET_asprintf (char **buf, const char *format, ...);
483 497
484 498
485/* ************** internal implementations, use macros above! ************** */ 499/* ************** internal implementations, use macros above! ************** */
@@ -495,7 +509,8 @@ int GNUNET_asprintf (char **buf, const char *format, ...);
495 * @param linenumber line where this call is being made (for debugging) 509 * @param linenumber line where this call is being made (for debugging)
496 * @return allocated memory, never NULL 510 * @return allocated memory, never NULL
497 */ 511 */
498void *GNUNET_xmalloc_ (size_t size, const char *filename, int linenumber); 512void *
513GNUNET_xmalloc_ (size_t size, const char *filename, int linenumber);
499 514
500 515
501 516
@@ -510,8 +525,9 @@ void *GNUNET_xmalloc_ (size_t size, const char *filename, int linenumber);
510 * @param linenumber line where this call is being made (for debugging) 525 * @param linenumber line where this call is being made (for debugging)
511 * @return allocated memory, never NULL 526 * @return allocated memory, never NULL
512 */ 527 */
513void *GNUNET_xmemdup_ (const void *buf, size_t size, const char *filename, 528void *
514 int linenumber); 529GNUNET_xmemdup_ (const void *buf, size_t size, const char *filename,
530 int linenumber);
515 531
516 532
517/** 533/**
@@ -526,15 +542,15 @@ void *GNUNET_xmemdup_ (const void *buf, size_t size, const char *filename,
526 * @param linenumber line where this call is being made (for debugging) 542 * @param linenumber line where this call is being made (for debugging)
527 * @return pointer to size bytes of memory, NULL if we do not have enough memory 543 * @return pointer to size bytes of memory, NULL if we do not have enough memory
528 */ 544 */
529void *GNUNET_xmalloc_unchecked_ (size_t size, const char *filename, 545void *
530 int linenumber); 546GNUNET_xmalloc_unchecked_ (size_t size, const char *filename, int linenumber);
531 547
532/** 548/**
533 * Reallocate memory. Checks the return value, aborts if no more 549 * Reallocate memory. Checks the return value, aborts if no more
534 * memory is available. 550 * memory is available.
535 */ 551 */
536void *GNUNET_xrealloc_ (void *ptr, size_t n, const char *filename, 552void *
537 int linenumber); 553GNUNET_xrealloc_ (void *ptr, size_t n, const char *filename, int linenumber);
538 554
539/** 555/**
540 * Free memory. Merely a wrapper for the case that we 556 * Free memory. Merely a wrapper for the case that we
@@ -545,7 +561,8 @@ void *GNUNET_xrealloc_ (void *ptr, size_t n, const char *filename,
545 * @param filename where is this call being made (for debugging) 561 * @param filename where is this call being made (for debugging)
546 * @param linenumber line where this call is being made (for debugging) 562 * @param linenumber line where this call is being made (for debugging)
547 */ 563 */
548void GNUNET_xfree_ (void *ptr, const char *filename, int linenumber); 564void
565GNUNET_xfree_ (void *ptr, const char *filename, int linenumber);
549 566
550 567
551/** 568/**
@@ -555,7 +572,8 @@ void GNUNET_xfree_ (void *ptr, const char *filename, int linenumber);
555 * @param linenumber line where this call is being made (for debugging) 572 * @param linenumber line where this call is being made (for debugging)
556 * @return the duplicated string 573 * @return the duplicated string
557 */ 574 */
558char *GNUNET_xstrdup_ (const char *str, const char *filename, int linenumber); 575char *
576GNUNET_xstrdup_ (const char *str, const char *filename, int linenumber);
559 577
560/** 578/**
561 * Dup partially a string. Don't call GNUNET_xstrndup_ directly. Use the GNUNET_strndup macro. 579 * Dup partially a string. Don't call GNUNET_xstrndup_ directly. Use the GNUNET_strndup macro.
@@ -565,8 +583,9 @@ char *GNUNET_xstrdup_ (const char *str, const char *filename, int linenumber);
565 * @param linenumber line where this call is being made (for debugging) 583 * @param linenumber line where this call is being made (for debugging)
566 * @return the duplicated string 584 * @return the duplicated string
567 */ 585 */
568char *GNUNET_xstrndup_ (const char *str, size_t len, const char *filename, 586char *
569 int linenumber); 587GNUNET_xstrndup_ (const char *str, size_t len, const char *filename,
588 int linenumber);
570 589
571/** 590/**
572 * Grow an array, the new elements are zeroed out. 591 * Grow an array, the new elements are zeroed out.
@@ -583,9 +602,9 @@ char *GNUNET_xstrndup_ (const char *str, size_t len, const char *filename,
583 * @param filename where is this call being made (for debugging) 602 * @param filename where is this call being made (for debugging)
584 * @param linenumber line where this call is being made (for debugging) 603 * @param linenumber line where this call is being made (for debugging)
585 */ 604 */
586void GNUNET_xgrow_ (void **old, size_t elementSize, unsigned int *oldCount, 605void
587 unsigned int newCount, const char *filename, 606GNUNET_xgrow_ (void **old, size_t elementSize, unsigned int *oldCount,
588 int linenumber); 607 unsigned int newCount, const char *filename, int linenumber);
589 608
590 609
591 610