Move error codes to separate header file
This commit is contained in:
parent
3f6acc9f42
commit
61e4168fbc
|
@ -6,6 +6,7 @@
|
||||||
/* convert.h - character set conversion routines. */
|
/* convert.h - character set conversion routines. */
|
||||||
|
|
||||||
#include "lib/defs.h"
|
#include "lib/defs.h"
|
||||||
|
#include "lib/error.h"
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
/* Constants for CR and LF. Note that we should not use '\n' or '\r'
|
/* Constants for CR and LF. Note that we should not use '\n' or '\r'
|
||||||
|
|
|
@ -12,6 +12,7 @@ cc_library(
|
||||||
"crc32.h",
|
"crc32.h",
|
||||||
"defs.h",
|
"defs.h",
|
||||||
"endian.h",
|
"endian.h",
|
||||||
|
"error.h",
|
||||||
"util.h",
|
"util.h",
|
||||||
],
|
],
|
||||||
copts = COPTS,
|
copts = COPTS,
|
||||||
|
|
19
lib/defs.h
19
lib/defs.h
|
@ -90,25 +90,6 @@ typedef long Size;
|
||||||
|
|
||||||
#endif
|
#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
|
// Memory allocation
|
||||||
// =============================================================================
|
// =============================================================================
|
||||||
|
|
|
@ -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
|
|
@ -6,6 +6,7 @@
|
||||||
// test.h - unit testing definitions.
|
// test.h - unit testing definitions.
|
||||||
|
|
||||||
#include "lib/defs.h"
|
#include "lib/defs.h"
|
||||||
|
#include "lib/error.h"
|
||||||
|
|
||||||
// The number of test failures.
|
// The number of test failures.
|
||||||
extern int gFailCount;
|
extern int gFailCount;
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
// Mozilla Public License, version 2.0. See LICENSE.txt for details.
|
// Mozilla Public License, version 2.0. See LICENSE.txt for details.
|
||||||
#ifndef LIB_UTIL_H
|
#ifndef LIB_UTIL_H
|
||||||
#define LIB_UTIL_H
|
#define LIB_UTIL_H
|
||||||
#include "lib/defs.h"
|
#include "lib/error.h"
|
||||||
|
|
||||||
// Print an error message and exit.
|
// Print an error message and exit.
|
||||||
void Fatalf(const char *msg, ...)
|
void Fatalf(const char *msg, ...)
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
// Mozilla Public License, version 2.0. See LICENSE.txt for details.
|
// Mozilla Public License, version 2.0. See LICENSE.txt for details.
|
||||||
#include "sync/tree.h"
|
#include "sync/tree.h"
|
||||||
|
|
||||||
|
#include "lib/error.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#define GetNode(nodes, ref) ((nodes) + (ref)-1)
|
#define GetNode(nodes, ref) ((nodes) + (ref)-1)
|
||||||
|
|
Loading…
Reference in New Issue