#ifndef TOOL_COMMON_H
#define TOOL_COMMON_H
#include <stdbool.h>
#include <stddef.h>
#include <stdio.h>
#include "nitroarc.h"
#ifdef __GNUC__
# define ATTR_FORMAT(f, a) __attribute__((format(printf, f, a)))
#else
# define ATTR_FORMAT(f, a)
#endif
#define PROGRAM "nitroarc"
#define PROGRAM_NOFILE "no archive file specified (missing -f option?)"
#define PROGRAM_HELP "try '%s --help' for more information"
#define PROGRAM_ENONE 0
#define PROGRAM_EGENERAL 1
#define PROGRAM_EFILEIO 2
#define PROGRAM_EALLOC 3
#define PROGRAM_ELIBERROR 127
typedef struct options options_t;
struct options {
unsigned int mode : 4; unsigned int verbose : 1; unsigned int help : 1; unsigned int version : 1; unsigned int no_header : 1; unsigned int index : 1; unsigned int no_recurse : 1; unsigned int named : 1; unsigned int stripped : 1;
int argc;
const char **argv;
const char *name;
const char *directory; const char *file; const char *format; const char *files_from; const char *exclude_from; const char *exclude_pat; };
ATTR_FORMAT(1, 2) void progerr(const char *fmt, ...);
ATTR_FORMAT(1, 2) void proglog(const char *fmt, ...);
int open_file(const char *path, const char *mode, FILE **out_f);
int load_file(const char *path, char **out_buf, size_t *out_size);
int write_file(const char *path, void *data, size_t size);
int read_archive(const char *data, size_t size, nitroarc_t *narc);
int set_logfile(bool verbose);
int set_workdir(const char *path);
int ensure_mkdir(const char *path);
#endif