Added file queue handling

This commit is contained in:
elvis
2022-03-15 00:30:04 +01:00
parent b4ca73b8d6
commit a72f0a0fad
7 changed files with 993 additions and 51 deletions

View File

@ -1,16 +0,0 @@
#pragma once
#ifndef _SERVER_STATUS
#define _SERVER_STATUS
typedef struct {
pthread_mutex_t *mtx;
pthread_cond_t *cond;
long max_space_occupied;
long cur_space_occupied;
long max_files;
long cur_files;
char exiting;
} serverStatus;
#endif /* _SERVER_STATUS */

18
lib/utils/serverUtil.h Normal file
View File

@ -0,0 +1,18 @@
#pragma once
#ifndef _SERVER_UTIL
#define _SERVER_UTIL
#include <ini.h>
#include <stdio.h>
#include <inttypes.h>
#define CONFGETINT(var, config, t, q, p, base) \
var = (int) strtol(ini_get(config, t, q), p, base); \
if(var<=0) { \
fprintf(stderr, "ERROR reading config for variable %c\n", t); \
ini_free(config); \
return 1; \
}
#endif /* _SERVER_STATUS */

View File

@ -83,25 +83,6 @@ static inline void print_error(const char * str, ...) {
free(p);
}
/**
* \brief Controlla se la stringa passata come primo argomento e' un numero.
* \return 0 ok 1 non e' un numbero 2 overflow/underflow
*/
static inline int isNumber(const char* s, long* n) {
if (s==NULL) return 1;
if (strlen(s)==0) return 1;
char* e = NULL;
errno=0;
long val = strtol(s, &e, 10);
if (errno == ERANGE) return 2; // overflow/underflow
if (e != NULL && *e == (char)0) {
*n = val;
return 0; // successo
}
return 1; // non e' un numero
}
#define LOCK(l) if (pthread_mutex_lock(l)!=0) { \
fprintf(stderr, "ERRORE FATALE lock\n"); \
pthread_exit((void*)EXIT_FAILURE); \