2019-04-21 00:46:08 +02:00
|
|
|
#ifndef UTIL_H
|
|
|
|
#define UTIL_H
|
|
|
|
/**
|
|
|
|
* \file util.h
|
|
|
|
* \brief utility functions
|
|
|
|
*/
|
|
|
|
|
2019-09-01 22:36:58 +02:00
|
|
|
#include <pthread.h>
|
2019-09-01 02:21:40 +02:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
2019-09-01 09:52:18 +02:00
|
|
|
/**
|
|
|
|
* \brief the maximum length of a path and a URL.
|
|
|
|
* \details This corresponds the maximum path length under Ext4.
|
|
|
|
*/
|
|
|
|
#define MAX_PATH_LEN 4096
|
|
|
|
|
|
|
|
/** \brief the maximum length of a filename. */
|
|
|
|
#define MAX_FILENAME_LEN 255
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief wrapper for pthread_mutex_lock()
|
|
|
|
*/
|
2019-09-01 22:36:58 +02:00
|
|
|
void PTHREAD_MUTEX_LOCK(pthread_mutex_t *x);
|
2019-09-01 02:21:40 +02:00
|
|
|
|
2019-09-01 09:52:18 +02:00
|
|
|
/**
|
|
|
|
* \brief wrapper for pthread_mutex_unlock()
|
|
|
|
*/
|
2019-09-01 22:36:58 +02:00
|
|
|
void PTHREAD_MUTEX_UNLOCK(pthread_mutex_t *x);
|
|
|
|
|
2019-09-01 02:21:40 +02:00
|
|
|
|
2019-04-26 08:39:45 +02:00
|
|
|
/**
|
|
|
|
* \brief append a path
|
|
|
|
* \details This function appends a path with the next level, while taking the
|
|
|
|
* trailing slash of the upper level into account.
|
2019-04-30 00:40:21 +02:00
|
|
|
*
|
2019-04-30 09:05:46 +02:00
|
|
|
* Please free the char * after use.
|
2019-04-26 08:39:45 +02:00
|
|
|
*/
|
|
|
|
char *path_append(const char *path, const char *filename);
|
2019-04-21 00:46:08 +02:00
|
|
|
|
2019-04-25 00:58:26 +02:00
|
|
|
/**
|
|
|
|
* \brief division, but rounded to the nearest integer rather than truncating
|
|
|
|
*/
|
|
|
|
int64_t round_div(int64_t a, int64_t b);
|
|
|
|
|
2019-04-26 08:39:45 +02:00
|
|
|
|
2019-04-21 00:46:08 +02:00
|
|
|
#endif
|