|
Packit Service |
87a54e |
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
|
Packit |
5756e2 |
/*
|
|
Packit |
5756e2 |
* Copyright (C) 2018 Red Hat, Inc.
|
|
Packit |
5756e2 |
*/
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
#ifndef __NM_IO_UTILS_H__
|
|
Packit |
5756e2 |
#define __NM_IO_UTILS_H__
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
#include "nm-macros-internal.h"
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
/*****************************************************************************/
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
/**
|
|
Packit |
5756e2 |
* NMUtilsFileGetContentsFlags:
|
|
Packit |
5756e2 |
* @NM_UTILS_FILE_GET_CONTENTS_FLAG_NONE: no flag
|
|
Packit |
5756e2 |
* @NM_UTILS_FILE_GET_CONTENTS_FLAG_SECRET: if present, ensure that no
|
|
Packit |
5756e2 |
* data is left in memory. Essentially, it means to call nm_explicit_bzero()
|
|
Packit |
5756e2 |
* to not leave key material on the heap (when reading secrets).
|
|
Packit |
5756e2 |
*/
|
|
Packit |
5756e2 |
typedef enum {
|
|
Packit Service |
a1bd4f |
NM_UTILS_FILE_GET_CONTENTS_FLAG_NONE = 0,
|
|
Packit Service |
a1bd4f |
NM_UTILS_FILE_GET_CONTENTS_FLAG_SECRET = (1 << 0),
|
|
Packit |
5756e2 |
} NMUtilsFileGetContentsFlags;
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
gboolean nm_utils_fd_get_contents(int fd,
|
|
Packit Service |
a1bd4f |
gboolean close_fd,
|
|
Packit Service |
a1bd4f |
gsize max_length,
|
|
Packit Service |
a1bd4f |
NMUtilsFileGetContentsFlags flags,
|
|
Packit Service |
a1bd4f |
char ** contents,
|
|
Packit Service |
a1bd4f |
gsize * length,
|
|
Packit Service |
a1bd4f |
int * out_errsv,
|
|
Packit Service |
a1bd4f |
GError ** error);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
gboolean nm_utils_file_get_contents(int dirfd,
|
|
Packit Service |
a1bd4f |
const char * filename,
|
|
Packit Service |
a1bd4f |
gsize max_length,
|
|
Packit Service |
a1bd4f |
NMUtilsFileGetContentsFlags flags,
|
|
Packit Service |
a1bd4f |
char ** contents,
|
|
Packit Service |
a1bd4f |
gsize * length,
|
|
Packit Service |
a1bd4f |
int * out_errsv,
|
|
Packit Service |
a1bd4f |
GError ** error);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
gboolean nm_utils_file_set_contents(const char *filename,
|
|
Packit Service |
a1bd4f |
const char *contents,
|
|
Packit Service |
a1bd4f |
gssize length,
|
|
Packit Service |
a1bd4f |
mode_t mode,
|
|
Packit Service |
a1bd4f |
int * out_errsv,
|
|
Packit Service |
a1bd4f |
GError ** error);
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
struct _NMStrBuf;
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
gssize nm_utils_fd_read(int fd, struct _NMStrBuf *out_string);
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
struct stat;
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
int nm_utils_file_stat(const char *filename, struct stat *out_st);
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
#endif /* __NM_IO_UTILS_H__ */
|