diff options
author | Donovan Baarda <abo@minkirri.apana.org.au> | 2021-08-19 15:23:03 +1000 |
---|---|---|
committer | Donovan Baarda <abo@minkirri.apana.org.au> | 2021-08-19 15:23:03 +1000 |
commit | 32c8169a4a5a91302d23095b3c5b5285862668cd (patch) | |
tree | 333e2ea10e95cf4a203f616815a6f9e71b5eb5f4 /src | |
parent | b9b02490d2be2b83fbe36764c5064c5fc84614c8 (diff) | |
download | librsync-32c8169a4a5a91302d23095b3c5b5285862668cd.tar.gz |
Add import guards to all header files that didn't have them.
Diffstat (limited to 'src')
-rw-r--r-- | src/buf.h | 4 | ||||
-rw-r--r-- | src/command.h | 4 | ||||
-rw-r--r-- | src/emit.h | 4 | ||||
-rw-r--r-- | src/hashtable.h | 12 | ||||
-rw-r--r-- | src/isprefix.h | 4 | ||||
-rw-r--r-- | src/job.h | 12 | ||||
-rw-r--r-- | src/mdfour.h | 10 | ||||
-rw-r--r-- | src/netint.h | 4 | ||||
-rw-r--r-- | src/prototab.h | 4 | ||||
-rw-r--r-- | src/stream.h | 4 | ||||
-rw-r--r-- | src/sumset.h | 18 | ||||
-rw-r--r-- | src/trace.h | 60 | ||||
-rw-r--r-- | src/util.h | 20 | ||||
-rw-r--r-- | src/whole.h | 4 |
14 files changed, 108 insertions, 56 deletions
@@ -18,6 +18,8 @@ * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#ifndef BUF_H +# define BUF_H typedef struct rs_filebuf rs_filebuf_t; @@ -28,3 +30,5 @@ void rs_filebuf_free(rs_filebuf_t *fb); rs_result rs_infilebuf_fill(rs_job_t *, rs_buffers_t *buf, void *fb); rs_result rs_outfilebuf_drain(rs_job_t *, rs_buffers_t *, void *fb); + +#endif /* !BUF_H */ diff --git a/src/command.h b/src/command.h index d125813..f164fe2 100644 --- a/src/command.h +++ b/src/command.h @@ -25,6 +25,8 @@ * * The vague idea is that eventually this file will be more abstract than * protocol.h, but it's not clear that will ever be required. */ +#ifndef COMMAND_H +# define COMMAND_H /** Classes of operation that can be present. Each may have several different * possible representations. */ @@ -47,3 +49,5 @@ typedef struct rs_op_kind_name { } rs_op_kind_name_t; char const *rs_op_kind_name(enum rs_op_kind); + +#endif /* !COMMAND_H */ @@ -21,8 +21,12 @@ /** \file emit.h * How to emit commands to the client. */ +#ifndef EMIT_H +# define EMIT_H void rs_emit_delta_header(rs_job_t *); void rs_emit_literal_cmd(rs_job_t *, int len); void rs_emit_end_cmd(rs_job_t *); void rs_emit_copy_cmd(rs_job_t *job, rs_long_t where, rs_long_t len); + +#endif /* !EMIT_H */ diff --git a/src/hashtable.h b/src/hashtable.h index 7aa815d..edb0dfd 100644 --- a/src/hashtable.h +++ b/src/hashtable.h @@ -17,12 +17,6 @@ * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#ifndef HASHTABLE_H -# define HASHTABLE_H - -# include <assert.h> -# include <stdlib.h> -# include <stdbool.h> /** \file hashtable.h * A generic open addressing hashtable. @@ -125,6 +119,12 @@ * can mutate the mymatch_t object for doing things like deferred and cached * evaluation of expensive match data. It can also access the whole myentry_t * object to match against more than just the key. */ +#ifndef HASHTABLE_H +# define HASHTABLE_H + +# include <assert.h> +# include <stdlib.h> +# include <stdbool.h> /** The hashtable type. */ typedef struct hashtable { diff --git a/src/isprefix.h b/src/isprefix.h index e24b193..293e6b1 100644 --- a/src/isprefix.h +++ b/src/isprefix.h @@ -17,6 +17,10 @@ * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#ifndef ISPREFIX_H +# define ISPREFIX_H /** Return true if TIP is a prefix of ICEBERG. */ int isprefix(char const *tip, char const *iceberg); + +endif /* !ISPREFIX_H */ @@ -18,9 +18,11 @@ * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#ifndef JOB_H +# define JOB_H -#include "mdfour.h" -#include "checksum.h" +# include "mdfour.h" +# include "checksum.h" /** The contents of this structure are private. */ struct rs_job { @@ -101,12 +103,14 @@ rs_job_t *rs_job_new(const char *, rs_result (*statefn)(rs_job_t *)); int rs_job_input_is_ending(rs_job_t *job); /** Magic job tag number for checking jobs have been initialized. */ -#define RS_JOB_TAG 20010225 +# define RS_JOB_TAG 20010225 /** Assert that a job is valid. * * We don't use a static inline function here so that assert failure output * points at where rs_job_check() was called from. */ -#define rs_job_check(job) do {\ +# define rs_job_check(job) do {\ assert(job->dogtag == RS_JOB_TAG);\ } while (0) + +endif /* !JOB_H */ diff --git a/src/mdfour.h b/src/mdfour.h index 41af810..45b13f4 100644 --- a/src/mdfour.h +++ b/src/mdfour.h @@ -19,15 +19,19 @@ * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#ifndef MDFOUR_H +# define MDFOUR_H /** \private Internal state while computing an MD4 hash. */ struct rs_mdfour { unsigned int A, B, C, D; -#ifdef UINT64_MAX +# ifdef UINT64_MAX uint64_t totalN; -#else +# else uint32_t totalN_hi, totalN_lo; -#endif +# endif int tail_len; unsigned char tail[64]; }; + +endif /* !MDFOUR_H */ diff --git a/src/netint.h b/src/netint.h index b8a05f8..27a4b0b 100644 --- a/src/netint.h +++ b/src/netint.h @@ -19,6 +19,8 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#ifndef NETINT_H +# define NETINT_H rs_result rs_squirt_byte(rs_job_t *job, rs_byte_t val); rs_result rs_squirt_netint(rs_job_t *job, rs_long_t val, int len); @@ -29,3 +31,5 @@ rs_result rs_suck_netint(rs_job_t *job, rs_long_t *val, int len); rs_result rs_suck_n4(rs_job_t *job, int *val); int rs_int_len(rs_long_t val); + +endif /* !NETINT_H */ diff --git a/src/prototab.h b/src/prototab.h index 7195d53..c8f6769 100644 --- a/src/prototab.h +++ b/src/prototab.h @@ -30,6 +30,8 @@ /** \file prototab.h * Delta file commands. */ +#ifndef PROTOTAB_H +# define PROTOTAB_H typedef struct rs_prototab_ent { enum rs_op_kind kind; @@ -297,3 +299,5 @@ enum { RS_OP_RESERVED_254 = 0xfe, RS_OP_RESERVED_255 = 0xff }; + +endif /* !PROTOTAB_H */ diff --git a/src/stream.h b/src/stream.h index 61a75b9..c854369 100644 --- a/src/stream.h +++ b/src/stream.h @@ -73,6 +73,8 @@ * On each call into a stream iterator, it should begin by trying to flush * output. This may well use up all the remaining stream space, in which case * nothing else can be done. */ +#ifndef STREAM_H +# define STREAM_H size_t rs_buffers_copy(rs_buffers_t *stream, size_t len); @@ -87,3 +89,5 @@ rs_result rs_scoop_readahead(rs_job_t *job, size_t len, void **ptr); rs_result rs_scoop_read(rs_job_t *job, size_t len, void **ptr); rs_result rs_scoop_read_rest(rs_job_t *job, size_t *len, void **ptr); size_t rs_scoop_total_avail(rs_job_t *job); + +endif /* !STREAM_H */ diff --git a/src/sumset.h b/src/sumset.h index 52bd7c4..0c6e529 100644 --- a/src/sumset.h +++ b/src/sumset.h @@ -19,10 +19,12 @@ * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#ifndef SUMSET_H +# define SUMSET_H -#include <assert.h> -#include "hashtable.h" -#include "checksum.h" +# include <assert.h> +# include "hashtable.h" +# include "checksum.h" /** Signature of a single block. */ typedef struct rs_block_sig { @@ -43,9 +45,9 @@ struct rs_signature { void *block_sigs; /**< The packed block_sigs for all blocks. */ hashtable_t *hashtable; /**< The hashtable for finding matches. */ /* The is extra stats not included in the hashtable stats. */ -#ifndef HASHTABLE_NSTATS +# ifndef HASHTABLE_NSTATS long calc_strong_count; /**< The count of strongsum calcs done. */ -#endif +# endif }; /** Initialize an rs_signature instance. @@ -82,7 +84,7 @@ rs_long_t rs_signature_find_match(rs_signature_t *sig, rs_weak_sum_t weak_sum, * * We don't use a static inline function here so that assert failure output * points at where rs_sig_args_check() was called from. */ -#define rs_sig_args_check(magic, block_len, strong_len) do {\ +# define rs_sig_args_check(magic, block_len, strong_len) do {\ assert(((magic) & ~0xff) == (RS_MD4_SIG_MAGIC & ~0xff));\ assert(((magic) & 0xf0) == 0x30 || ((magic) & 0xf0) == 0x40);\ assert((((magic) & 0x0f) == 0x06 &&\ @@ -97,7 +99,7 @@ rs_long_t rs_signature_find_match(rs_signature_t *sig, rs_weak_sum_t weak_sum, * * We don't use a static inline function here so that assert failure output * points at where rs_signature_check() was called from. */ -#define rs_signature_check(sig) do {\ +# define rs_signature_check(sig) do {\ rs_sig_args_check((sig)->magic, (sig)->block_len, (sig)->strong_sum_len);\ assert(0 <= (sig)->count && (sig)->count <= (sig)->size);\ assert(!(sig)->hashtable || (sig)->hashtable->count <= (sig)->count);\ @@ -132,3 +134,5 @@ static inline void rs_signature_calc_strong_sum(rs_signature_t const *sig, { rs_calc_strong_sum(rs_signature_strongsum_kind(sig), buf, len, sum); } + +endif /* !SUMSET_H */ diff --git a/src/trace.h b/src/trace.h index 9314b0e..f950dc9 100644 --- a/src/trace.h +++ b/src/trace.h @@ -31,49 +31,51 @@ * \todo A function like perror that includes strerror output. Apache does this * by adding flags as well as the severity level which say whether such * information should be included. */ +#ifndef TRACE_H +# define TRACE_H -#include <inttypes.h> +# include <inttypes.h> /* Printf format patters for standard librsync types. */ -#define FMT_LONG "%"PRIdMAX -#define FMT_WEAKSUM "%08"PRIx32 +# define FMT_LONG "%"PRIdMAX +# define FMT_WEAKSUM "%08"PRIx32 /* Old MSVC compilers don't support "%zu" and have "%Iu" instead. */ -#ifdef HAVE_PRINTF_Z -# define FMT_SIZE "%zu" -#else -# define FMT_SIZE "%Iu" -#endif +# ifdef HAVE_PRINTF_Z +# define FMT_SIZE "%zu" +# else +# define FMT_SIZE "%Iu" +# endif /* Some old compilers don't support __func_ and have __FUNCTION__ instead. */ -#ifndef HAVE___FUNC__ -# ifdef HAVE___FUNCTION__ -# define __func__ __FUNCTION__ -# else -# define __func__ "" +# ifndef HAVE___FUNC__ +# ifdef HAVE___FUNCTION__ +# define __func__ __FUNCTION__ +# else +# define __func__ "" +# endif # endif -#endif /* Non-GNUC compatible compilers don't support __attribute__(). */ -#ifndef __GNUC__ -# define __attribute__(x) -#endif +# ifndef __GNUC__ +# define __attribute__(x) +# endif void rs_log0(int level, char const *fn, char const *fmt, ...) __attribute__((format(printf, 3, 4))); /** \def rs_trace_enabled() * Call this before putting too much effort into generating trace messages. */ -#ifdef DO_RS_TRACE -# define rs_trace_enabled() ((rs_trace_level & RS_LOG_PRIMASK) >= RS_LOG_DEBUG) -# define rs_trace(...) rs_log0(RS_LOG_DEBUG, __func__, __VA_ARGS__) -#else -# define rs_trace_enabled() 0 -# define rs_trace(...) -#endif /* !DO_RS_TRACE */ +# ifdef DO_RS_TRACE +# define rs_trace_enabled() ((rs_trace_level & RS_LOG_PRIMASK) >= RS_LOG_DEBUG) +# define rs_trace(...) rs_log0(RS_LOG_DEBUG, __func__, __VA_ARGS__) +# else +# define rs_trace_enabled() 0 +# define rs_trace(...) +# endif /* !DO_RS_TRACE */ -#define rs_log(l, ...) rs_log0((l), __func__, __VA_ARGS__) -#define rs_warn(...) rs_log0(RS_LOG_WARNING, __func__, __VA_ARGS__) -#define rs_error(...) rs_log0(RS_LOG_ERR, __func__, __VA_ARGS__) -#define rs_fatal(...) do { \ +# define rs_log(l, ...) rs_log0((l), __func__, __VA_ARGS__) +# define rs_warn(...) rs_log0(RS_LOG_WARNING, __func__, __VA_ARGS__) +# define rs_error(...) rs_log0(RS_LOG_ERR, __func__, __VA_ARGS__) +# define rs_fatal(...) do { \ rs_log0(RS_LOG_CRIT, __func__, __VA_ARGS__); \ abort(); \ } while (0) @@ -84,3 +86,5 @@ enum { }; extern int rs_trace_level; + +endif /* !TRACE_H */ @@ -19,6 +19,8 @@ * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#ifndef UTIL_H +# define UTIL_H void *rs_alloc(size_t size, char const *name); void *rs_realloc(void *ptr, size_t size, char const *name); @@ -30,13 +32,15 @@ int rs_long_ln2(rs_long_t v); int rs_long_sqrt(rs_long_t v); /** Allocate and zero-fill an instance of TYPE. */ -#define rs_alloc_struct(type) \ +# define rs_alloc_struct(type) \ ((type *) rs_alloc_struct0(sizeof(type), #type)) -#ifdef __GNUC__ -# define UNUSED(x) x __attribute__((unused)) -#elif defined(__LCLINT__) || defined(S_SPLINT_S) -# define UNUSED(x) /*@unused@*/ x -#else /* !__GNUC__ && !__LCLINT__ */ -# define UNUSED(x) x -#endif /* !__GNUC__ && !__LCLINT__ */ +# ifdef __GNUC__ +# define UNUSED(x) x __attribute__((unused)) +# elif defined(__LCLINT__) || defined(S_SPLINT_S) +# define UNUSED(x) /*@unused@*/ x +# else /* !__GNUC__ && !__LCLINT__ */ +# define UNUSED(x) x +# endif /* !__GNUC__ && !__LCLINT__ */ + +endif /* !UTIL_H */ diff --git a/src/whole.h b/src/whole.h index 945f568..f848417 100644 --- a/src/whole.h +++ b/src/whole.h @@ -18,6 +18,10 @@ * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#ifndef WHOLE_H +# define WHOLE_H rs_result rs_whole_run(rs_job_t *job, FILE *in_file, FILE *out_file, int inbuflen, int outbuflen); + +endif /* !WHOLE_H */ |