Skip to content
suit Documentation
Login

Documentation

#ifndef SUIT_STAMP_H
#define SUIT_STAMP_H

#include <stddef.h>

constexpr int EXIT_UNCHANGED = 0;
constexpr int EXIT_CHANGED = 10;
constexpr int EXIT_NO_STAMP = 11;
constexpr int EXIT_BAD_STAMP = 12;

constexpr size_t STAMP_FILE_MAX = 1048576;
constexpr size_t STAMP_PATH_MAX = 4096;

// Fill OUT with "$SUIT_HOME/NAME" ("$HOME/.suit/NAME" without SUIT_HOME).
// Returns the length of the home folder part, or 0 after saying why.
size_t suit_home_path(char *out, size_t cap, const char *name);

// Writes $SUIT_HOME/stamp (default ~/.suit/stamp) atomically: the line
// "suit stamp 2", then one line for each path. Returns 0 or a nonzero exit code
// after reporting on stderr.
int stamp_write(int npaths, char *const *paths);

// The no-change compare. Reads the stamp, stats each path, and writes only
// to stdout and stderr: no file is created or changed and nothing is
// allocated. With REPORT it prints "changed: PATH" for each path that differs.
// A stamp whose first line is not "suit stamp 2" but a path line was written by
// an older suit: it is a change, reported as the stamp's own path.
// Returns one of the EXIT_ codes, or 1 if it cannot read the stamp.
int stamp_check(bool report);

#endif