fsautoproc
Basic file transformation automation management utility
Loading...
Searching...
No Matches
index.h File Reference

File index mapping and serialization functions. More...

#include <stdio.h>
#include "fs.h"
Include dependency graph for index.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  inode_s
 Individual file node in the index map. More...
 
struct  index_s
 Index map structure for storing file nodes. More...
 

Macros

#define INDEXBUCKETS   64
 The fixed number of buckets in the index map.
 

Functions

struct inode_sindexfind (const struct index_s *idx, const char *fp)
 Searches the index for a node with a matching filepath.
 
int indexwrite (struct index_s *idx, FILE *s)
 Flattens the index map into a sorted array of nodes (by filepath). The list is then written to the file stream and freed.
 
int indexread (struct index_s *idx, FILE *s)
 Reads a file stream and deserializes the contents into a map of individual file nodes.
 
struct inode_sindexput (struct index_s *idx, struct inode_s node)
 Copies the node and inserts it into the index mapping.
 
void indexfree (struct index_s *idx)
 Frees all nodes in the index map.
 
struct inode_s ** indexlist (const struct index_s *idx)
 Flattens the index map into an unsorted array of nodes. The list is dynamically allocated and must be freed by the caller. Array size is determined by the size field in the index struct.
 

Detailed Description

File index mapping and serialization functions.

Macro Definition Documentation

◆ INDEXBUCKETS

#define INDEXBUCKETS   64

The fixed number of buckets in the index map.

Function Documentation

◆ indexfind()

struct inode_s * indexfind ( const struct index_s * idx,
const char * fp )

Searches the index for a node with a matching filepath.

Parameters
idxThe index to search
fpThe search value (filepath) to compare
Returns
If a match is found, its pointer is returned, otherwise NULL.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ indexfree()

void indexfree ( struct index_s * idx)

Frees all nodes in the index map.

Parameters
idxThe index to free
Here is the call graph for this function:
Here is the caller graph for this function:

◆ indexlist()

struct inode_s ** indexlist ( const struct index_s * idx)

Flattens the index map into an unsorted array of nodes. The list is dynamically allocated and must be freed by the caller. Array size is determined by the size field in the index struct.

Parameters
idxThe index to flatten
Returns
If successful, a pointer to an array of size idx->size is returned. Otherwise, NULL is returned and errno is set.
Here is the caller graph for this function:

◆ indexput()

struct inode_s * indexput ( struct index_s * idx,
struct inode_s node )

Copies the node and inserts it into the index mapping.

Parameters
idxThe index to insert into
nodeThe node to insert
Returns
The pointer to the new node in the index map, otherwise NULL is returned and errno is set.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ indexread()

int indexread ( struct index_s * idx,
FILE * s )

Reads a file stream and deserializes the contents into a map of individual file nodes.

Parameters
idxThe index to populate
sThe file stream to read from
Returns
If successful, 0 is returned. Otherwise, -1 is returned and errno is set.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ indexwrite()

int indexwrite ( struct index_s * idx,
FILE * s )

Flattens the index map into a sorted array of nodes (by filepath). The list is then written to the file stream and freed.

Parameters
idxThe index to flatten
sThe file stream to write to
Returns
If successful, 0 is returned. Otherwise, -1 is returned and errno is set.
Here is the call graph for this function:
Here is the caller graph for this function: