2016-11-17 20:06:17 +00:00
|
|
|
#ifndef IPFS_PATH_H
|
|
|
|
#define IPFS_PATH_H
|
|
|
|
|
2016-11-29 23:34:59 +00:00
|
|
|
#ifdef IPFS_PATH_C
|
|
|
|
char *ErrPath[] = {
|
|
|
|
NULL,
|
|
|
|
// 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
|
2016-11-17 20:06:17 +00:00
|
|
|
|
|
|
|
enum {
|
|
|
|
ErrBadPath = 1,
|
|
|
|
ErrNoComponents,
|
|
|
|
ErrCidDecode,
|
|
|
|
ErrNoLink,
|
|
|
|
ErrNoLinkFmt
|
|
|
|
} PathErrs;
|
|
|
|
|
2016-11-17 20:47:31 +00:00
|
|
|
char* PathFromCid (struct Cid *c);
|
2016-11-26 13:39:53 +00:00
|
|
|
char** SplitN (char *p, char *delim, int n);
|
2016-11-17 20:06:17 +00:00
|
|
|
char** Segments (char *p);
|
|
|
|
int SegmentsLength (char **s);
|
|
|
|
void FreeSegments (char ***s);
|
|
|
|
int IsJustAKey (char *p);
|
2016-11-26 13:20:23 +00:00
|
|
|
int PopLastSegment (char **str, char *p);
|
2016-11-17 20:06:17 +00:00
|
|
|
char *PathFromSegments(char *prefix, char **seg);
|
|
|
|
int ParseCidToPath (char *dst, char *txt);
|
|
|
|
int ParsePath (char *dst, char *txt);
|
|
|
|
int PathIsValid (char *p);
|
2016-12-01 09:48:16 +00:00
|
|
|
|
|
|
|
// Resolver provides path resolution to IPFS
|
|
|
|
// It has a pointer to a DAGService, which is uses to resolve nodes.
|
|
|
|
// TODO: now that this is more modular, try to unify this code with the
|
|
|
|
// the resolvers in namesys
|
|
|
|
typedef struct s_resolver {
|
|
|
|
DAGService DAG;
|
|
|
|
int (*ResolveOnce)(NodeLink **lnk, Context ctx, DAGService *ds, Node **nd, char *name);
|
|
|
|
} Resolver;
|
2016-11-17 20:06:17 +00:00
|
|
|
#endif // IPFS_PATH_H
|