78 lines
2.2 KiB
C
78 lines
2.2 KiB
C
/****************************************************************************
|
|
* Header file for utility functions *
|
|
****************************************************************************/
|
|
|
|
/**
|
|
* @file utils.h
|
|
* @author Celine Mercier (celine.mercier@metabarcoding.org)
|
|
* @date 29 March 2016
|
|
* @brief Header file for utility functions.
|
|
*/
|
|
|
|
|
|
#ifndef UTILS_H_
|
|
#define UTILS_H_
|
|
|
|
#include <stdio.h>
|
|
#include <sys/stat.h>
|
|
|
|
#include "obidms.h"
|
|
|
|
|
|
#define FORMATTED_TIME_LENGTH (1024) /**< The length allocated for the character string containing a formatted date.
|
|
*/
|
|
#define ONE_IF_ZERO(x) (((x)==0)?1:(x)) /**< If x is equal to 0, x takes the value 1.
|
|
*/
|
|
|
|
|
|
/**
|
|
* @brief Counts the number of files and directories in a directory.
|
|
*
|
|
* @param dir_path The absolute path of the directory.
|
|
*
|
|
* @returns The number of files and directories in the directory.
|
|
*
|
|
* @since April 2016
|
|
* @author Celine Mercier (celine.mercier@metabarcoding.org)
|
|
*/
|
|
int count_dir(char* dir_path);
|
|
|
|
|
|
/**
|
|
* @brief Formats a date in a way that is easy to read.
|
|
*
|
|
* @warning The pointer returned must be freed by the caller.
|
|
*
|
|
* @param date A date.
|
|
*
|
|
* @returns The date formatted in a way that is easy to read.
|
|
*
|
|
* @since October 2015
|
|
* @author Celine Mercier (celine.mercier@metabarcoding.org)
|
|
*/
|
|
char* obi_format_date(time_t date);
|
|
|
|
|
|
/**
|
|
* @brief Allocates a chunk of memory aligned on 16 bytes boundary.
|
|
*
|
|
* @warning The pointer returned must be freed by the caller.
|
|
* @warning The memory chunk pointed at by the returned pointer can be
|
|
* smaller than the size asked for, since the address is shifted
|
|
* to be aligned.
|
|
*
|
|
* @param size The size in bytes of the memory chunk to be allocated.
|
|
* Ideally the closest multiple of 16 greater than the wanted size.
|
|
* @param shift A pointer on an integer corresponding to the shift made to align
|
|
* the address. Used to free the memory chunk.
|
|
*
|
|
* @returns The pointer on the aligned memory.
|
|
*
|
|
* @since May 2016
|
|
* @author Celine Mercier (celine.mercier@metabarcoding.org)
|
|
*/
|
|
void* obi_get_memory_aligned_on_16(int size, int* shift);
|
|
|
|
|
|
#endif /* UTILS_H_ */
|