namesys/path: Changed error messages to a separate file.

This commit is contained in:
Jose Marcial Vieira Bisneto 2016-12-08 07:08:34 -03:00
parent 84f24797f4
commit 7a3d0c5e0b
5 changed files with 48 additions and 60 deletions

46
include/ipfs/errs.h Normal file
View file

@ -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

View file

@ -3,40 +3,7 @@
#define DefaultDepthLimit 32 #define DefaultDepthLimit 32
#ifdef NAMESYS_C #include "ipfs/errs.h"
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;
typedef struct s_resolvers { typedef struct s_resolvers {
char *protocol; char *protocol;

View file

@ -1,30 +1,7 @@
#ifndef IPFS_PATH_H #ifndef IPFS_PATH_H
#define IPFS_PATH_H #define IPFS_PATH_H
#ifdef IPFS_PATH_C #include "ipfs/errs.h"
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;
char* ipfs_path_from_cid (struct Cid *c); char* ipfs_path_from_cid (struct Cid *c);
char** ipfs_path_split_n (char *p, char *delim, int n); char** ipfs_path_split_n (char *p, char *delim, int n);

View file

@ -3,7 +3,6 @@
#include <time.h> #include <time.h>
#include "ipfs/cid/cid.h" #include "ipfs/cid/cid.h"
#include "ipfs/path/path.h" #include "ipfs/path/path.h"
#define NAMESYS_C
#include "ipfs/namesys/namesys.h" #include "ipfs/namesys/namesys.h"
/* mpns (a multi-protocol NameSystem) implements generic IPFS naming. /* mpns (a multi-protocol NameSystem) implements generic IPFS naming.

View file

@ -1,7 +1,6 @@
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <ipfs/cid/cid.h> #include <ipfs/cid/cid.h>
#define IPFS_PATH_C
#include <ipfs/path/path.h> #include <ipfs/path/path.h>
// FromCid safely converts a cid.Cid type to a Path type // FromCid safely converts a cid.Cid type to a Path type