diff --git a/convert/convert.h b/convert/convert.h index b6f6d8a..3f23f9e 100644 --- a/convert/convert.h +++ b/convert/convert.h @@ -6,6 +6,7 @@ /* convert.h - character set conversion routines. */ #include "lib/defs.h" +#include "lib/error.h" enum { /* Constants for CR and LF. Note that we should not use '\n' or '\r' diff --git a/lib/BUILD.bazel b/lib/BUILD.bazel index 4c48ef4..5d0502f 100644 --- a/lib/BUILD.bazel +++ b/lib/BUILD.bazel @@ -12,6 +12,7 @@ cc_library( "crc32.h", "defs.h", "endian.h", + "error.h", "util.h", ], copts = COPTS, diff --git a/lib/defs.h b/lib/defs.h index 589ae8f..ae29254 100644 --- a/lib/defs.h +++ b/lib/defs.h @@ -90,25 +90,6 @@ typedef long Size; #endif -// ============================================================================= -// Error codes and error reporting -// ============================================================================= - -// Error codes. -typedef enum { - // No error (success). Equal to 0. - kErrorOK, - - // Memory allocation failed. - kErrorNoMemory, - - // Invaild table data. - kErrorBadData, - - // Too many files in one directory. - kErrorDirectoryTooLarge -} ErrorCode; - // ============================================================================= // Memory allocation // ============================================================================= diff --git a/lib/error.h b/lib/error.h new file mode 100644 index 0000000..7da7664 --- /dev/null +++ b/lib/error.h @@ -0,0 +1,22 @@ +// Copyright 2022 Dietrich Epp. +// This file is part of SyncFiles. SyncFiles is licensed under the terms of the +// Mozilla Public License, version 2.0. See LICENSE.txt for details. +#ifndef LIB_ERROR_H +#define LIB_ERROR_H + +// Error codes. +typedef enum { + // No error (success). Equal to 0. + kErrorOK, + + // Memory allocation failed. + kErrorNoMemory, + + // Invaild table data. + kErrorBadData, + + // Too many files in one directory. + kErrorDirectoryTooLarge, +} ErrorCode; + +#endif diff --git a/lib/test.h b/lib/test.h index e56028d..4739251 100644 --- a/lib/test.h +++ b/lib/test.h @@ -6,6 +6,7 @@ // test.h - unit testing definitions. #include "lib/defs.h" +#include "lib/error.h" // The number of test failures. extern int gFailCount; diff --git a/lib/util.h b/lib/util.h index 6ba0a1a..424154d 100644 --- a/lib/util.h +++ b/lib/util.h @@ -3,7 +3,7 @@ // Mozilla Public License, version 2.0. See LICENSE.txt for details. #ifndef LIB_UTIL_H #define LIB_UTIL_H -#include "lib/defs.h" +#include "lib/error.h" // Print an error message and exit. void Fatalf(const char *msg, ...) diff --git a/sync/tree.c b/sync/tree.c index a697c50..0289e6d 100644 --- a/sync/tree.c +++ b/sync/tree.c @@ -3,6 +3,8 @@ // Mozilla Public License, version 2.0. See LICENSE.txt for details. #include "sync/tree.h" +#include "lib/error.h" + #include #define GetNode(nodes, ref) ((nodes) + (ref)-1)