Skip to content
suit Artifact [ed2f72ab84]
Login

Artifact [ed2f72ab84]

Artifact ed2f72ab84ad5feb5a98e42a4bd32f005161ab9cc060926b73891eb6cbfb3228:


#ifndef SUIT_MACHINE_H
#define SUIT_MACHINE_H

#include <stddef.h>

// The machine's name: $SUIT_HOME/machine, one name on one line. A machine
// without the file has no name.

constexpr size_t MACHINE_MAX = 64;

// True if the LEN bytes are a name: 1 to MACHINE_MAX of A-Z a-z 0-9 . _ -
bool machine_name_ok(const char *s, size_t len);

// Read PATH into NAME (room for MACHINE_MAX + 1). A file that is not there
// leaves NAME empty. Returns 0, or 1 after saying on stderr what is wrong.
int machine_read(const char *path, char *name);

// Write NAME (already checked) to PATH atomically. Returns 0, or 1 after
// saying why.
int machine_write(const char *path, const char *name);

#endif