c-ipfs/include/ipfs/path/path.h
Jose Marcial Vieira Bisneto ac4cc8feaa path/path.c: Implemented SplitN.
Renamed Segments() to SplitN(), added parameters, and created a new
Segments() using SplitN() while maintaining the original functionality.
2016-11-26 10:39:53 -03:00

34 lines
976 B
C

#ifndef IPFS_PATH_H
#define IPFS_PATH_H
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"
};
enum {
ErrBadPath = 1,
ErrNoComponents,
ErrCidDecode,
ErrNoLink,
ErrNoLinkFmt
} PathErrs;
char* PathFromCid (struct Cid *c);
char** SplitN (char *p, char *delim, int n);
char** Segments (char *p);
int SegmentsLength (char **s);
void FreeSegments (char ***s);
int IsJustAKey (char *p);
int PopLastSegment (char **str, char *p);
char *PathFromSegments(char *prefix, char **seg);
int ParseCidToPath (char *dst, char *txt);
int ParsePath (char *dst, char *txt);
int PathIsValid (char *p);
#endif // IPFS_PATH_H