forked from canonical/mini-iso-tools
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcommon.h
More file actions
53 lines (44 loc) · 1.55 KB
/
common.h
File metadata and controls
53 lines (44 loc) · 1.55 KB
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
/*
* Copyright 2022-2023 Canonical Ltd.
*
* SPDX-License-Identifier: GPL-3.0
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3, as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see
* <http://www.gnu.org/licenses/>.
*/
#pragma once
#define _GNU_SOURCE
#define UNUSED(X) __attribute__((unused(X)))
#include <stdbool.h>
#include <stdint.h>
typedef struct _iso_data
{
char *label;
char *url;
char *sha256sum;
int64_t size;
} iso_data_t;
typedef struct _choices
{
int capacity; /* number of items allocated in the values array */
int cur; /* index of the currently selected choice */
int len; /* how many items in the values array actually used */
iso_data_t **values; /* data array of iso choices */
} choices_t;
iso_data_t *iso_data_create(char *label, char *url, char *sha256sum,
int64_t size);
void iso_data_free(iso_data_t *iso_data);
choices_t *choices_create(int len);
void choices_free(choices_t *choices);
bool choices_append(choices_t *choices, iso_data_t *data);
char *saprintf(char *fmt, ...) __attribute__((format(printf, 1, 2)));