style for files taglialegna.* apiFile.*
This commit is contained in:
@ -5,39 +5,74 @@
|
||||
#include <stdio.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#include <fileQueue.h>
|
||||
#include "fileQueue.h"
|
||||
|
||||
typedef struct taglia_s {
|
||||
FILE *file;
|
||||
size_t max_files;
|
||||
long max_size;
|
||||
size_t cache_misses;
|
||||
pthread_mutex_t m; // per sincronizzare le scritture al file
|
||||
pthread_mutex_t m; /* per sincronizzare le scritture al file */
|
||||
} taglia_t;
|
||||
|
||||
// crea una nuova istanza
|
||||
// \param file: file su cui scrivere i dati
|
||||
// \param n: numero di parametri opzionali
|
||||
// parametri opzionali in questo ordine:
|
||||
// max_files, max_size, cache_misses
|
||||
// \return istanza creata, NULL se errore
|
||||
|
||||
/**
|
||||
* @brief Creates new instance
|
||||
*
|
||||
* @param file path to file to write into
|
||||
* @param n number of optional parameters, in order:
|
||||
* int max_files, int max_size, int cache_misses
|
||||
* @return created istance, NULL if error
|
||||
*/
|
||||
taglia_t *taglia_init(char *file, int n, ...);
|
||||
|
||||
// elimina un'istanza deallocando e chiudendo le rispettive risorse
|
||||
|
||||
/**
|
||||
* @brief Deallocates instance
|
||||
*
|
||||
* @param taglia instance to deallocate
|
||||
*/
|
||||
void taglia_del(taglia_t *taglia);
|
||||
|
||||
// scrive quello contenuto dentro a buf sul file
|
||||
// \return numero di char scritti, -1 se errore
|
||||
|
||||
/**
|
||||
* @brief Writes buffer to the log
|
||||
*
|
||||
* @param taglia
|
||||
* @param buf NULL terminated string to write
|
||||
* @return number of char written, -1 if error occurred
|
||||
*/
|
||||
size_t taglia_write(taglia_t *taglia, char *buf);
|
||||
|
||||
// scrive il contenuto di buf sul file con ora associata
|
||||
|
||||
/**
|
||||
* @brief Writes buffer to the log with timestamp
|
||||
*
|
||||
* @param taglia
|
||||
* @param buf NULL terminated string to write
|
||||
* @return number of char written, -1 if error occurred
|
||||
*/
|
||||
size_t taglia_log(taglia_t *taglia, char *buf);
|
||||
|
||||
// update delle statistiche
|
||||
// \return 0 successo, -1 errore
|
||||
|
||||
/**
|
||||
* @brief Updates statistics
|
||||
*
|
||||
* @param taglia
|
||||
* @param queue structure that holds the files
|
||||
* @param miss number of cache misses to add
|
||||
* @return 1 if success, -1 if error occurred
|
||||
*/
|
||||
int taglia_update(taglia_t *taglia, queueT *queue, int miss);
|
||||
|
||||
// print delle statistiche attuali su stream
|
||||
|
||||
/**
|
||||
* @brief Writes stats to the stream and to the log
|
||||
*
|
||||
* @param taglia
|
||||
* @param stream
|
||||
* @return 0 if success, -1 if error occurred
|
||||
*/
|
||||
int taglia_stats(taglia_t *taglia, FILE *stream);
|
||||
|
||||
#endif /* _TAGLIALEGNA */
|
||||
|
||||
Reference in New Issue
Block a user