Files
fsnap/include/utility.h
Fabio Scotto di Santolo c397728912 Unify error handling: output parameter, goto cleanup, errno preservation
- Replace global field variable with output parameter enum Fields *err
- Adopt single goto cleanup pattern across all functions
- Add errno preservation around cleanup in all modules
- Fix early return bug in create.c cleanup block
- Add ferror check in crc32() for silent read errors
- Document error contracts in all public headers
2026-08-26 14:20:00 +02:00

21 lines
623 B
C

#ifndef UTILITY_H
#define UTILITY_H
/* Concatenate src with n additional strings. Returns a newly allocated
string, or NULL on allocation failure. */
char *strconcat(const char *src, int n, ...);
/* Resolve path to an absolute canonical form. Returns a newly allocated
string, or NULL on failure (errno set by realpath). */
char *resolve_path(const char *path);
/* Copy file contents from src to dst.
Returns 0 on success, -1 on failure. */
int copy(const char *src, const char *dst);
/* Count lines in a file.
Returns the line count on success, -1 on failure. */
int count_lines(const char *file);
#endif