2002-04-06 06:45:31 +00:00
|
|
|
#define CCACHE_VERSION "1.5"
|
2002-03-26 14:46:43 +00:00
|
|
|
|
2002-03-31 09:02:21 +00:00
|
|
|
#include "config.h"
|
2002-03-26 14:46:43 +00:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/wait.h>
|
2002-03-27 07:06:45 +00:00
|
|
|
#include <sys/mman.h>
|
2002-03-30 10:43:26 +00:00
|
|
|
#include <sys/file.h>
|
2002-03-26 14:46:43 +00:00
|
|
|
#include <fcntl.h>
|
2002-03-27 09:46:40 +00:00
|
|
|
#include <time.h>
|
2002-03-26 14:46:43 +00:00
|
|
|
#include <string.h>
|
|
|
|
#include <ctype.h>
|
2002-03-26 22:25:14 +00:00
|
|
|
#include <utime.h>
|
2002-03-26 14:46:43 +00:00
|
|
|
#include <stdarg.h>
|
2002-03-27 09:46:40 +00:00
|
|
|
#include <dirent.h>
|
2002-03-31 05:01:05 +00:00
|
|
|
#include <limits.h>
|
2002-03-26 14:46:43 +00:00
|
|
|
|
|
|
|
#define STATUS_NOTFOUND 3
|
|
|
|
#define STATUS_FATAL 4
|
|
|
|
#define STATUS_NOCACHE 5
|
|
|
|
|
2002-03-30 00:24:23 +00:00
|
|
|
#define MYNAME "ccache"
|
|
|
|
|
2002-03-30 10:43:26 +00:00
|
|
|
#define LIMIT_MULTIPLE 0.8
|
|
|
|
|
|
|
|
enum stats {
|
|
|
|
STATS_NONE=0,
|
|
|
|
STATS_STDOUT,
|
|
|
|
STATS_STATUS,
|
|
|
|
STATS_ERROR,
|
|
|
|
STATS_TOCACHE,
|
|
|
|
STATS_PREPROCESSOR,
|
|
|
|
STATS_COMPILER,
|
|
|
|
STATS_MISSING,
|
|
|
|
STATS_CACHED,
|
|
|
|
STATS_ARGS,
|
|
|
|
STATS_LINK,
|
|
|
|
STATS_NUMFILES,
|
|
|
|
STATS_TOTALSIZE,
|
|
|
|
STATS_MAXFILES,
|
|
|
|
STATS_MAXSIZE,
|
2002-04-01 02:59:06 +00:00
|
|
|
STATS_NOTC,
|
|
|
|
STATS_DEVICE,
|
|
|
|
STATS_NOINPUT,
|
2002-03-30 10:43:26 +00:00
|
|
|
|
|
|
|
STATS_END
|
|
|
|
};
|
|
|
|
|
2002-03-26 14:46:43 +00:00
|
|
|
typedef unsigned uint32;
|
|
|
|
|
|
|
|
#include "mdfour.h"
|
|
|
|
|
|
|
|
void hash_start(void);
|
|
|
|
void hash_string(const char *s);
|
2002-03-26 22:25:14 +00:00
|
|
|
void hash_int(int x);
|
2002-03-26 14:46:43 +00:00
|
|
|
void hash_file(const char *fname);
|
|
|
|
char *hash_result(void);
|
2002-03-27 07:06:45 +00:00
|
|
|
void hash_buffer(const char *s, int len);
|
2002-03-26 14:46:43 +00:00
|
|
|
|
2002-03-26 23:58:31 +00:00
|
|
|
void cc_log(const char *format, ...);
|
2002-03-26 14:46:43 +00:00
|
|
|
void fatal(const char *msg);
|
|
|
|
|
|
|
|
void copy_fd(int fd_in, int fd_out);
|
2002-03-27 05:40:28 +00:00
|
|
|
int copy_file(const char *src, const char *dest);
|
2002-03-26 14:46:43 +00:00
|
|
|
|
2002-03-26 22:25:14 +00:00
|
|
|
int create_dir(const char *dir);
|
2002-03-27 02:17:02 +00:00
|
|
|
void x_asprintf(char **ptr, const char *format, ...);
|
2002-03-27 01:38:55 +00:00
|
|
|
char *x_strdup(const char *s);
|
2002-03-28 05:37:27 +00:00
|
|
|
void *x_realloc(void *ptr, size_t size);
|
|
|
|
void *x_malloc(size_t size);
|
|
|
|
void traverse(const char *dir, void (*fn)(const char *, struct stat *));
|
2002-03-30 00:24:23 +00:00
|
|
|
char *basename(const char *s);
|
2002-03-30 10:43:26 +00:00
|
|
|
char *dirname(char *s);
|
|
|
|
int lock_fd(int fd);
|
|
|
|
size_t file_size(struct stat *st);
|
|
|
|
int safe_open(const char *fname);
|
2002-03-31 05:01:05 +00:00
|
|
|
char *x_realpath(const char *path);
|
2002-03-30 10:43:26 +00:00
|
|
|
|
|
|
|
void stats_update(enum stats stat);
|
|
|
|
void stats_zero(void);
|
|
|
|
void stats_summary(void);
|
|
|
|
void stats_tocache(size_t size);
|
|
|
|
void stats_read(const char *stats_file, unsigned counters[STATS_END]);
|
|
|
|
void stats_set_limits(long maxfiles, long maxsize);
|
|
|
|
size_t value_units(const char *s);
|
2002-04-01 00:50:03 +00:00
|
|
|
void display_size(unsigned v);
|
2002-03-30 10:43:26 +00:00
|
|
|
void stats_set_sizes(const char *dir, size_t num_files, size_t total_size);
|
|
|
|
|
2002-04-01 00:23:31 +00:00
|
|
|
int unify_hash(const char *fname);
|
|
|
|
|
2002-03-31 14:26:49 +00:00
|
|
|
|
2002-03-30 10:43:26 +00:00
|
|
|
|
|
|
|
void cleanup_dir(const char *dir, size_t maxfiles, size_t maxsize);
|
|
|
|
void cleanup_all(const char *dir);
|
2002-03-26 22:25:14 +00:00
|
|
|
|
2002-03-27 00:39:06 +00:00
|
|
|
int execute(char **argv,
|
|
|
|
const char *path_stdout,
|
|
|
|
const char *path_stderr);
|
2002-03-26 14:46:43 +00:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
char **argv;
|
|
|
|
int argc;
|
|
|
|
} ARGS;
|
|
|
|
|
|
|
|
|
|
|
|
ARGS *args_init(void);
|
|
|
|
void args_add(ARGS *args, const char *s);
|
2002-03-27 08:40:13 +00:00
|
|
|
void args_pop(ARGS *args, int n);
|
|
|
|
|
2002-04-06 06:45:31 +00:00
|
|
|
#if HAVE_COMPAR_FN_T
|
|
|
|
#define COMPAR_FN_T __compar_fn_t
|
|
|
|
#else
|
|
|
|
typedef int (*COMPAR_FN_T)(const void *, const void *);
|
|
|
|
#endif
|