libfossil
fossil-path.h File Reference
#include "fossil-internal.h"

Go to the source code of this file.

Data Structures

struct  fsl_path
 A utility type for collecting "paths" between two checkin versions. More...
 
struct  fsl_path_node
 Holds information for a single node in a path of checkin versions. More...
 

Macros

#define fsl_path_empty_m   {0,0,fsl_id_bag_empty_m,0,0,0,0}
 An empty-initialize fsl_path object, intended for const-copy initialization. More...
 

Typedefs

typedef struct fsl_path fsl_path
 
typedef struct fsl_path_node fsl_path_node
 

Functions

FSL_EXPORT void fsl_path_clear (fsl_path *path)
 Frees all nodes in path (which must not be NULL) and resets all state in path. More...
 
FSL_EXPORT fsl_path_nodefsl_path_first (fsl_path *p)
 Returns the first node in p's path. More...
 
FSL_EXPORT fsl_path_nodefsl_path_last (fsl_path *p)
 Returns the last node in p's path. More...
 
FSL_EXPORT int fsl_path_length (fsl_path const *p)
 Returns p's path length. More...
 
FSL_EXPORT fsl_path_nodefsl_path_midpoint (fsl_path *path)
 Find the mid-point of the path. More...
 
FSL_EXPORT fsl_path_nodefsl_path_next (fsl_path_node *p)
 Returns the next node p's path. More...
 
FSL_EXPORT int fsl_path_shortest (fsl_cx *f, fsl_path *path, fsl_id_t iFrom, fsl_id_t iTo, char directOnly, char oneWayOnly)
 Computes the shortest path from checkin versions iFrom to iTo (inclusive), storing the result state in path. More...
 

Variables

FSL_EXPORT const fsl_path fsl_path_empty
 An empty-initialize fsl_path object, intended for copy initialization. More...
 

Macro Definition Documentation

#define fsl_path_empty_m   {0,0,fsl_id_bag_empty_m,0,0,0,0}

An empty-initialize fsl_path object, intended for const-copy initialization.

Definition at line 86 of file fossil-path.h.

Typedef Documentation

typedef struct fsl_path fsl_path

Definition at line 32 of file fossil-path.h.

typedef struct fsl_path_node fsl_path_node

Definition at line 31 of file fossil-path.h.

Function Documentation

FSL_EXPORT void fsl_path_clear ( fsl_path path)

Frees all nodes in path (which must not be NULL) and resets all state in path.

Does not free path.

FSL_EXPORT fsl_path_node* fsl_path_first ( fsl_path p)

Returns the first node in p's path.

The returned node is owned by path may be invalidated by any APIs which manipulate path.

FSL_EXPORT fsl_path_node* fsl_path_last ( fsl_path p)

Returns the last node in p's path.

The returned node is owned by path may be invalidated by any APIs which manipulate path.

FSL_EXPORT int fsl_path_length ( fsl_path const *  p)

Returns p's path length.

FSL_EXPORT fsl_path_node* fsl_path_midpoint ( fsl_path path)

Find the mid-point of the path.

If the path contains fewer than 2 steps, returns 0. The returned node is owned by path may be invalidated by any APIs which manipulate path.

FSL_EXPORT fsl_path_node* fsl_path_next ( fsl_path_node p)

Returns the next node p's path.

The returned node is owned by path may be invalidated by any APIs which manipulate path.

Intended to be used like this:

1 for( p = fsl_path_first(path) ;
2 p ;
3 p = fsl_path_next(p)){
4 ...
5 }
FSL_EXPORT int fsl_path_shortest ( fsl_cx f,
fsl_path path,
fsl_id_t  iFrom,
fsl_id_t  iTo,
char  directOnly,
char  oneWayOnly 
)

Computes the shortest path from checkin versions iFrom to iTo (inclusive), storing the result state in path.

If path has state before this is called, it is cleared by this call.

iFrom and iTo must both be valid checkin version RIDs.

If directOnly is true, then use only the "primary" links from parent to child. In other words, ignore merges.

On success, returns 0 and path->pStart will point to the beginning of the path (the iFrom node). If pStart is 0 then no path could be found but 0 is still returned.

Elements of the path can be traversed like so:

1 fsl_path path = fsl_path_empty;
2 fsl_path_node * n = 0;
3 int rc = fsl_path_shortest(f, &path, versionFrom, versionTo, 1, 0);
4 if(rc) { ... error ... }
5 for( n = fsl_path_first(&path); n; n = fsl_path_next(n) ){
6 ...
7 }
8 fsl_path_clear(&path);

On error, f's error state may be updated with a description of the problem.

Variable Documentation

FSL_EXPORT const fsl_path fsl_path_empty

An empty-initialize fsl_path object, intended for copy initialization.

Definition at line 92 of file fossil-path.h.