Blame


1 50b0790e 2020-09-11 stsp /*
2 50b0790e 2020-09-11 stsp * Copyright (c) 2020 Stefan Sperling <stsp@openbsd.org>
3 50b0790e 2020-09-11 stsp *
4 50b0790e 2020-09-11 stsp * Permission to use, copy, modify, and distribute this software for any
5 50b0790e 2020-09-11 stsp * purpose with or without fee is hereby granted, provided that the above
6 50b0790e 2020-09-11 stsp * copyright notice and this permission notice appear in all copies.
7 50b0790e 2020-09-11 stsp *
8 50b0790e 2020-09-11 stsp * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 50b0790e 2020-09-11 stsp * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 50b0790e 2020-09-11 stsp * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 50b0790e 2020-09-11 stsp * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 50b0790e 2020-09-11 stsp * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 50b0790e 2020-09-11 stsp * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 50b0790e 2020-09-11 stsp * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 50b0790e 2020-09-11 stsp */
16 50b0790e 2020-09-11 stsp
17 50b0790e 2020-09-11 stsp #include <sys/types.h>
18 8b925c6c 2022-07-16 thomas #include <sys/queue.h>
19 50b0790e 2020-09-11 stsp #include <sys/uio.h>
20 50b0790e 2020-09-11 stsp #include <sys/socket.h>
21 50b0790e 2020-09-11 stsp
22 50b0790e 2020-09-11 stsp #include <unistd.h>
23 50b0790e 2020-09-11 stsp #include <fcntl.h>
24 50b0790e 2020-09-11 stsp #include <errno.h>
25 50b0790e 2020-09-11 stsp #include <stdlib.h>
26 50b0790e 2020-09-11 stsp #include <stdio.h>
27 50b0790e 2020-09-11 stsp #include <stdint.h>
28 588a8092 2023-02-23 thomas #include <imsg.h>
29 588a8092 2023-02-23 thomas #include <sha1.h>
30 588a8092 2023-02-23 thomas #include <sha2.h>
31 50b0790e 2020-09-11 stsp #include <limits.h>
32 50b0790e 2020-09-11 stsp
33 dd038bc6 2021-09-21 thomas.ad #include "got_compat.h"
34 dd038bc6 2021-09-21 thomas.ad
35 50b0790e 2020-09-11 stsp #include "got_error.h"
36 50b0790e 2020-09-11 stsp #include "got_object.h"
37 50b0790e 2020-09-11 stsp #include "got_repository.h"
38 50b0790e 2020-09-11 stsp
39 50b0790e 2020-09-11 stsp #include "got_lib_gotconfig.h"
40 50b0790e 2020-09-11 stsp
41 ef20f542 2022-06-26 thomas #include "got_gotconfig.h"
42 ef20f542 2022-06-26 thomas
43 50b0790e 2020-09-11 stsp void
44 50b0790e 2020-09-11 stsp got_gotconfig_free(struct got_gotconfig *conf)
45 50b0790e 2020-09-11 stsp {
46 50b0790e 2020-09-11 stsp int i;
47 50b0790e 2020-09-11 stsp
48 a9705505 2020-09-18 stsp if (conf == NULL)
49 a9705505 2020-09-18 stsp return;
50 a9705505 2020-09-18 stsp
51 50b0790e 2020-09-11 stsp free(conf->author);
52 50b0790e 2020-09-11 stsp
53 b8adfa55 2020-09-25 stsp for (i = 0; i < conf->nremotes; i++)
54 b8adfa55 2020-09-25 stsp got_repo_free_remote_repo_data(&conf->remotes[i]);
55 50b0790e 2020-09-11 stsp free(conf->remotes);
56 50b0790e 2020-09-11 stsp free(conf);
57 50b0790e 2020-09-11 stsp }
58 50b0790e 2020-09-11 stsp
59 50b0790e 2020-09-11 stsp const char *
60 50b0790e 2020-09-11 stsp got_gotconfig_get_author(const struct got_gotconfig *conf)
61 50b0790e 2020-09-11 stsp {
62 50b0790e 2020-09-11 stsp return conf->author;
63 50b0790e 2020-09-11 stsp }
64 50b0790e 2020-09-11 stsp
65 50b0790e 2020-09-11 stsp void
66 50b0790e 2020-09-11 stsp got_gotconfig_get_remotes(int *nremotes, const struct got_remote_repo **remotes,
67 50b0790e 2020-09-11 stsp const struct got_gotconfig *conf)
68 50b0790e 2020-09-11 stsp {
69 50b0790e 2020-09-11 stsp *nremotes = conf->nremotes;
70 50b0790e 2020-09-11 stsp *remotes = conf->remotes;
71 50b0790e 2020-09-11 stsp }
72 871bd038 2022-07-03 thomas
73 871bd038 2022-07-03 thomas const char *
74 871bd038 2022-07-03 thomas got_gotconfig_get_allowed_signers_file(const struct got_gotconfig *conf)
75 871bd038 2022-07-03 thomas {
76 871bd038 2022-07-03 thomas return conf->allowed_signers_file;
77 871bd038 2022-07-03 thomas }
78 871bd038 2022-07-03 thomas
79 871bd038 2022-07-03 thomas const char *
80 871bd038 2022-07-03 thomas got_gotconfig_get_revoked_signers_file(const struct got_gotconfig *conf)
81 871bd038 2022-07-03 thomas {
82 871bd038 2022-07-03 thomas return conf->revoked_signers_file;
83 871bd038 2022-07-03 thomas }
84 ff5e1f09 2022-07-06 thomas
85 ff5e1f09 2022-07-06 thomas const char *
86 ff5e1f09 2022-07-06 thomas got_gotconfig_get_signer_id(const struct got_gotconfig *conf)
87 ff5e1f09 2022-07-06 thomas {
88 ff5e1f09 2022-07-06 thomas return conf->signer_id;
89 ff5e1f09 2022-07-06 thomas }