From 7a3d0c5e0bf241d6126a125fc19fa8b3460b9af5 Mon Sep 17 00:00:00 2001 From: Jose Marcial Vieira Bisneto Date: Thu, 8 Dec 2016 07:08:34 -0300 Subject: [PATCH] namesys/path: Changed error messages to a separate file. --- include/ipfs/errs.h | 46 ++++++++++++++++++++++++++++++++++ include/ipfs/namesys/namesys.h | 35 +------------------------- include/ipfs/path/path.h | 25 +----------------- namesys/namesys.c | 1 - path/path.c | 1 - 5 files changed, 48 insertions(+), 60 deletions(-) create mode 100644 include/ipfs/errs.h diff --git a/include/ipfs/errs.h b/include/ipfs/errs.h new file mode 100644 index 0000000..e3c0707 --- /dev/null +++ b/include/ipfs/errs.h @@ -0,0 +1,46 @@ +#ifndef IPFS_ERRS_H + #define IPFS_ERRS_H + + char *Err[] = { + NULL, + "ErrAllocFailed", + "ErrNULLPointer", + "ErrPipe", + "ErrPoll", + "Could not publish name." + "Could not resolve name.", + "Could not resolve name (recursion limit exceeded).", + "expired record", + "unrecognized validity type", + "not a valid proquint string", + "not a valid domain name", + "not a valid dnslink entry" + // ErrBadPath is returned when a given path is incorrectly formatted + "invalid 'ipfs ref' path", + // Paths after a protocol must contain at least one component + "path must contain at least one component", + "TODO: ErrCidDecode", + NULL, + "no link named %s under %s" + }; + + enum { + ErrAllocFailed = 1, + ErrNULLPointer, + ErrPipe, + ErrPoll, + ErrPublishFailed, + ErrResolveFailed, + ErrResolveRecursion, + ErrExpiredRecord, + ErrUnrecognizedValidity, + ErrInvalidProquint, + ErrInvalidDomain, + ErrInvalidDNSLink + ErrBadPath, + ErrNoComponents, + ErrCidDecode, + ErrNoLink, + ErrNoLinkFmt + } ErrsIdx; +#endif // IPFS_ERRS_H diff --git a/include/ipfs/namesys/namesys.h b/include/ipfs/namesys/namesys.h index 9ff92dd..1f0734a 100644 --- a/include/ipfs/namesys/namesys.h +++ b/include/ipfs/namesys/namesys.h @@ -3,40 +3,7 @@ #define DefaultDepthLimit 32 - #ifdef NAMESYS_C - char *ErrNamesys[] = { - NULL, - "ErrAllocFailed", - "ErrNULLPointer", - "ErrPipe", - "ErrPoll", - "Could not publish name." - "Could not resolve name.", - "Could not resolve name (recursion limit exceeded).", - "expired record", - "unrecognized validity type", - "not a valid proquint string", - "not a valid domain name", - "not a valid dnslink entry" - }; - #else - extern char *ErrNamesys; - #endif // NAMESYS_C - - enum { - ErrAllocFailed = 1, - ErrNULLPointer, - ErrPipe, - ErrPoll, - ErrPublishFailed, - ErrResolveFailed, - ErrResolveRecursion, - ErrExpiredRecord, - ErrUnrecognizedValidity, - ErrInvalidProquint, - ErrInvalidDomain, - ErrInvalidDNSLink - } NamesysErrs; + #include "ipfs/errs.h" typedef struct s_resolvers { char *protocol; diff --git a/include/ipfs/path/path.h b/include/ipfs/path/path.h index 17850bf..e588c67 100644 --- a/include/ipfs/path/path.h +++ b/include/ipfs/path/path.h @@ -1,30 +1,7 @@ #ifndef IPFS_PATH_H #define IPFS_PATH_H - #ifdef IPFS_PATH_C - char *ErrPath[] = { - NULL, - "ErrAllocFailed", - // ErrBadPath is returned when a given path is incorrectly formatted - "invalid 'ipfs ref' path", - // Paths after a protocol must contain at least one component - "path must contain at least one component", - "TODO: ErrCidDecode", - NULL, - "no link named %s under %s" - }; - #else - extern char **ErrPath; - #endif // IPFS_PATH_C - - enum { - ErrAllocFailed = 1, - ErrBadPath, - ErrNoComponents, - ErrCidDecode, - ErrNoLink, - ErrNoLinkFmt - } PathErrs; + #include "ipfs/errs.h" char* ipfs_path_from_cid (struct Cid *c); char** ipfs_path_split_n (char *p, char *delim, int n); diff --git a/namesys/namesys.c b/namesys/namesys.c index f6eed85..9b3abff 100644 --- a/namesys/namesys.c +++ b/namesys/namesys.c @@ -3,7 +3,6 @@ #include #include "ipfs/cid/cid.h" #include "ipfs/path/path.h" -#define NAMESYS_C #include "ipfs/namesys/namesys.h" /* mpns (a multi-protocol NameSystem) implements generic IPFS naming. diff --git a/path/path.c b/path/path.c index 948ac41..11e6fc8 100644 --- a/path/path.c +++ b/path/path.c @@ -1,7 +1,6 @@ #include #include #include -#define IPFS_PATH_C #include // FromCid safely converts a cid.Cid type to a Path type