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

yamux
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
#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;

View File

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

View File

@ -3,7 +3,6 @@
#include <time.h>
#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.

View File

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