Reimplementation of Pijul in C, for education, fun and absolutely no profit
#ifndef ANI_HUNK_H
#define ANI_HUNK_H

struct local {
	str path;
	uint64_t line; /* Defined as usize, probably better as u64 */
};

enum basehunktype {
	FILE_MOVE,
	FILE_DEL,
	FILE_UNDEL,
	FILE_ADD,
	SOLVE_NAME_CONFLICT,
	UNSOLVE_NAME_CONFLICT,
	EDIT,
	REPLACEMENT,
	SOLVE_ORDER_CONFLICT,
	UNSOLVE_ORDER_CONFLICT,
	RESURRECT_ZOMBIES,
	ADD_ROOT,
	DEL_ROOT,
};

struct filemove {
	struct atom del;
	struct atom add;
	str path;
};

struct filedel {
	struct atom del;
	struct atom contents; /* FIXME Option<struct atom> */
	str path;
	str encoding;
};

struct fileundel {
	struct atom undel;
	struct atom contents; /* FIXME Option<struct atom> */
	str path;
	str encoding; /* Option<struct encoding> */
};

struct fileadd {
	struct atom addname;
	struct atom addinode;
	struct atom contents; /* FIXME Option<struct atom> */
	str path;
	str encoding;
};

struct edit {
	struct atom change;
	struct local local;
	str encoding;
};

struct replacement {
	struct atom change;
	struct atom replacement;
	struct local local;
	str encoding;
};

struct solveorderconflict {
	struct atom change;
	struct local local;
};

struct unsolveorderconflict {
	struct atom change;
	struct local local;
};

struct solvenameconflict {
	struct atom name;
	str path;
};

struct unsolvenameconflict {
	struct atom name;
	str path;
};

struct resurrectzombies {
	struct atom change;
	struct local local;
	str encoding;
};

struct addroot {
	struct atom name;
	struct atom inode;
};

struct delroot {
	struct atom name;
	struct atom inode;
};

struct basehunk {
	enum basehunktype hunktype;
	union {
		struct filemove filemove;
		struct filedel filedel;
		struct fileundel fileundel;
		struct fileadd fileadd;
		struct edit edit;
		struct replacement replacement;
		struct solveorderconflict solveorderconflict;
		struct unsolveorderconflict unsolveorderconflict;
		struct solvenameconflict solvenameconflict;
		struct unsolvenameconflict unsolvenameconflict;
		struct resurrectzombies resurrectzombies;
		struct addroot addroot;
		struct delroot delroot;
	};
};

struct hunklist {
	size_t len;
	struct basehunk *entries;
};

struct filemetadata {
	/*
	 * metadata - DIR_BIT = 0x200, unix permissions are in
	 * 0x1ff. See libpijul/src/pristine/inode_metadata
	 */
	uint16_t inodemetadata;
	str basename;
	str encoding; /* Optional<Encoding> */
};

const char *hunk_basehunk_type_str(enum basehunktype);
void hunklistinit(struct hunklist *, size_t);
void hunklistfree(struct hunklist *);

#endif