diff options
author | Manuel Bentele | 2020-10-23 15:18:01 +0200 |
---|---|---|
committer | Manuel Bentele | 2020-10-23 15:18:01 +0200 |
commit | dbb41ce2b7f309d394054a6bd1e33afd578798a5 (patch) | |
tree | 6a31092063d9f2fb5ac5720ec6759040e793c3d5 /src/kernel/tests/include/old/old_safe_file_ops.h | |
parent | Set Linux kernel version to unknown if it is not detectable (diff) | |
download | xloop-dbb41ce2b7f309d394054a6bd1e33afd578798a5.tar.gz xloop-dbb41ce2b7f309d394054a6bd1e33afd578798a5.tar.xz xloop-dbb41ce2b7f309d394054a6bd1e33afd578798a5.zip |
Move the source code of all xloop components to the common 'src' directory
Diffstat (limited to 'src/kernel/tests/include/old/old_safe_file_ops.h')
-rw-r--r-- | src/kernel/tests/include/old/old_safe_file_ops.h | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/src/kernel/tests/include/old/old_safe_file_ops.h b/src/kernel/tests/include/old/old_safe_file_ops.h new file mode 100644 index 0000000..d6e2d29 --- /dev/null +++ b/src/kernel/tests/include/old/old_safe_file_ops.h @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2012-2016 Cyril Hrubis <chrubis@suse.cz> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY 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/>. + */ + + /* + + This code helps with file reading/writing files providing scanf/printf like + interface that opens and closes the file automatically. + + This kind of interface is especially useful for reading/writing values + from/to pseudo filesystems like procfs or sysfs. + + */ + +#ifndef SAFE_FILE_OPS +#define SAFE_FILE_OPS + +#include "safe_file_ops_fn.h" + +#define FILE_SCANF(path, fmt, ...) \ + file_scanf(__FILE__, __LINE__, \ + (path), (fmt), ## __VA_ARGS__) + +#define SAFE_FILE_SCANF(cleanup_fn, path, fmt, ...) \ + safe_file_scanf(__FILE__, __LINE__, (cleanup_fn), \ + (path), (fmt), ## __VA_ARGS__) + +#define FILE_LINES_SCANF(cleanup_fn, path, fmt, ...) \ + file_lines_scanf(__FILE__, __LINE__, (cleanup_fn), 0, \ + (path), (fmt), ## __VA_ARGS__) + +#define SAFE_FILE_LINES_SCANF(cleanup_fn, path, fmt, ...) \ + file_lines_scanf(__FILE__, __LINE__, (cleanup_fn), 1, \ + (path), (fmt), ## __VA_ARGS__) + +#define FILE_PRINTF(path, fmt, ...) \ + file_printf(__FILE__, __LINE__, \ + (path), (fmt), ## __VA_ARGS__) + +#define SAFE_FILE_PRINTF(cleanup_fn, path, fmt, ...) \ + safe_file_printf(__FILE__, __LINE__, (cleanup_fn), \ + (path), (fmt), ## __VA_ARGS__) + +#define SAFE_CP(cleanup_fn, src, dst) \ + safe_cp(__FILE__, __LINE__, (cleanup_fn), (src), (dst)) + +#define SAFE_TOUCH(cleanup_fn, pathname, mode, times) \ + safe_touch(__FILE__, __LINE__, (cleanup_fn), \ + (pathname), (mode), (times)) + +#endif /* SAFE_FILE_OPS */ |