]> glassweightruler.freedombox.rocks Git - Ventoy.git/blob - LinuxGUI/Ventoy2Disk/Core/ventoy_util.h
1.0.65 release
[Ventoy.git] / LinuxGUI / Ventoy2Disk / Core / ventoy_util.h
1 /******************************************************************************
2 * ventoy_util.h
3 *
4 * Copyright (c) 2021, longpanda <admin@ventoy.net>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 3 of the
9 * License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
18 *
19 */
20 #ifndef __VENTOY_UTIL_H__
21 #define __VENTOY_UTIL_H__
22
23 extern char g_log_file[PATH_MAX];
24 extern char g_ini_file[PATH_MAX];
25
26 #define check_free(p) if (p) free(p)
27 #define vtoy_safe_close_fd(fd) \
28 {\
29 if ((fd) >= 0) \
30 { \
31 close(fd); \
32 (fd) = -1; \
33 }\
34 }
35
36 extern uint8_t g_mbr_template[512];
37 void ventoy_gen_preudo_uuid(void *uuid);
38 int ventoy_get_disk_part_name(const char *dev, int part, char *partbuf, int bufsize);
39 int ventoy_get_sys_file_line(char *buffer, int buflen, const char *fmt, ...);
40 uint64_t ventoy_get_human_readable_gb(uint64_t SizeBytes);
41 void ventoy_md5(const void *data, uint32_t len, uint8_t *md5);
42 int ventoy_is_disk_mounted(const char *devpath);
43 int ventoy_try_umount_disk(const char *devpath);
44 int unxz(unsigned char *in, int in_size,
45 int (*fill)(void *dest, unsigned int size),
46 int (*flush)(void *src, unsigned int size),
47 unsigned char *out, int *in_used,
48 void (*error)(char *x));
49 int ventoy_read_file_to_buf(const char *FileName, int ExtLen, void **Bufer, int *BufLen);
50 const char * ventoy_get_local_version(void);
51 int ventoy_fill_gpt(uint64_t size, uint64_t reserve, int align4k, VTOY_GPT_INFO *gpt);
52 int ventoy_fill_mbr(uint64_t size, uint64_t reserve, int align4k, MBR_HEAD *pMBR);
53
54 #endif /* __VENTOY_UTIL_H__ */
55