lib: Add functions to ease pseudo fs read/write

This adds SAFE_FILE_SCANF() and SAFE_FILE_PRINTF()
safe functions that operate like scanf and printf
but works with a path instead of the FILE pointer.

The file is opened and closed automatically and
all possible error conditions are handled. With
this we can reduce the number of fopen, fscanf, fclose
sequencies (with possibly incomplete error handling).

This also adds SAFE_CP() which is intended replacement
for system("cp ...") code.

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
3 files changed