summaryrefslogtreecommitdiff
path: root/usr.sbin/acme-client/parse.h
blob: c727b85a37ab613607b09f3b53f973ab507822cf (plain)
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*	$OpenBSD: parse.h,v 1.1 2016/09/18 20:18:25 benno Exp $ */
/*
 * Copyright (c) 2016 Sebastian Benoit <benno@openbsd.org>
 *
 * Permission to use, copy, modify, and distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */
#ifndef PARSE_H
#define PARSE_H

#include <sys/queue.h>

#define AUTH_MAXLEN	120	/* max lenght of an authority_c name */
#define DOMAIN_MAXLEN	255	/* max len of a domain name (rfc2181) */

/*
 * XXX other size limits needed?
 * limit all paths to PATH_MAX
 */

struct authority_c {
	LIST_ENTRY(authority_c)	 entry;
	char		       	*name;
	char		       	*agreement;
	char		       	*api;
	char		       	*account;
};

struct domain_c {
	LIST_ENTRY(domain_c)	 entry;
	LIST_HEAD(, altname_c)	altname_list;
	char		       	*domain;
	char		       	*key;
	char		       	*cert;
	char		       	*auth;
};

struct altname_c {
	LIST_ENTRY(altname_c)	 entry;
	char		       	*domain;
};

struct keyfile {
	LIST_ENTRY(keyfile)	 entry;
	char			*name;
};

#define ACME_OPT_VERBOSE	0x00000001

struct acme_conf {
	int			 opts;
	LIST_HEAD(, authority_c) authority_list;
	LIST_HEAD(, domain_c)	 domain_list;
	LIST_HEAD(, keyfile)	 used_key_list;
};

struct acme_conf	*parse_config(const char *, int);
int			 cmdline_symset(char *);

/* use these to find a authority or domain by name */
struct authority_c	*authority_find(struct acme_conf *, char *);
struct authority_c	*authority_find0(struct acme_conf *);
struct domain_c		*domain_find(struct acme_conf *, char *);

int			 domain_valid(const char *);

#endif /* PARSE_H */