aboutsummaryrefslogtreecommitdiffstats
path: root/src/instance.h
blob: 76d249ee8674fcedc3cb830641b681fe191fd630 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#ifndef L2SU_INSTANCE_H_INCLUDED
#define L2SU_INSTANCE_H_INCLUDED

#include "uuid/uuid.h"
#include "digest/digest.h"
#include <stddef.h>

struct l2_instance {
  uuid_t uuid;
  char *name;
  char *path;

  struct l2_instance *next;
  struct l2_instance *prev;
};

#define L2_DOWNLOAD_NO_SIZE ((size_t)0)

enum {
  INSTANCE_SUCCESS, /* instance operation succeeded */
  INSTANCE_ERRNO,   /* instance operation failed (error code in errno) */
  INSTANCE_EJSON,   /* instance operation failed (JSON error) */
  INSTANCE_EFORMAT  /* instance file is malformed */
};

extern const char *const l2_instance_errormsg[];

/* load all instances (must be called after initialization) */
int l2_instance_load_all(void);

int l2_instance_save_all(void);

int l2_instance_add_instance(const struct l2_instance *inst);
int l2_instance_del_instance(struct l2_instance *inst);
int l2_instance_rename_instance(struct l2_instance *inst, const char *newname);

struct l2_instance *l2_instance_find_by_uuid(const uuid_t *id);
struct l2_instance *l2_instance_find_by_name(const char *name);

#endif /* include guard */