X-Git-Url: http://git.tuebingen.mpg.de/?a=blobdiff_plain;ds=sidebyside;f=para.h;h=dea92910b02250efb4e6d11c03299bcd5153b5fa;hb=0a0bd1faa842fbee76bf3b25d6321cabfa433726;hp=5dec070f00458bd59d62fbb8fed1b3bc60cb31da;hpb=ae15406fdf6ac44dc7a15e62c2d0056abe7192ac;p=paraslash.git diff --git a/para.h b/para.h index 5dec070f..dea92910 100644 --- a/para.h +++ b/para.h @@ -52,9 +52,10 @@ /** last message before exit */ #define EMERG 7 -/** log messages with lower proirity than that will not be compiled in*/ +/** Log messages with lower priority than that will not be compiled in. */ #define COMPILE_TIME_LOGLEVEL 0 +/** \cond */ #if DEBUG > COMPILE_TIME_LOGLEVEL #define PARA_DEBUG_LOG(f,...) para_log(DEBUG, "%s: " f, __FUNCTION__, ## __VA_ARGS__) #else @@ -96,6 +97,7 @@ #else #define PARA_EMERG_LOG(...) #endif +/** \endcond */ /** * define a standard log function that always writes to stderr @@ -173,11 +175,18 @@ int stat_item_valid(const char *item); int stat_line_valid(const char *); void stat_client_write(const char *msg, int itemnum); int stat_client_add(int fd, long unsigned mask); +/** Loop over each status item. */ #define FOR_EACH_STAT_ITEM(i) for (i = 0; i < NUM_STAT_ITEMS; i++) __printf_2_3 void para_log(int, const char*, ...); -/* taken from printf man page */ +/** + * Write a log message to a dynamically allocated string. + * + * \param fmt Usual format string. + * \param p Result pointer. + * + * \sa printf(3). */ #define PARA_VSPRINTF(fmt, p) \ { \ int n; \ @@ -201,6 +210,13 @@ __printf_2_3 void para_log(int, const char*, ...); } \ } +/** + * Return a random non-negative integer in an interval. + * + * \param max Determines maximal possible return value. + * + * \return An integer between zero and \p max - 1, inclusively. + */ static inline int para_random(unsigned max) { return ((max + 0.0) * (rand() / (RAND_MAX + 1.0)));