5 static const char from
[] = "/var/lib/fprint/fw";
6 static const char to
[] = "@to@";
8 FILE* fopen_wrapper(const char* fn
, const char* mode
) {
9 size_t fn_len
= strlen(fn
);
10 size_t from_len
= strlen(from
);
11 if (fn_len
> from_len
&& memcmp(fn
, from
, from_len
) == 0) {
12 size_t to_len
= strlen(to
);
13 char* rewritten
= calloc(fn_len
+ (to_len
- from_len
) + 1, 1);
14 memcpy(rewritten
, to
, to_len
);
15 memcpy(rewritten
+ to_len
, fn
+ from_len
, fn_len
- from_len
);
17 printf("fopen_wrapper.c: Replacing path '%s' with '%s'\n", fn
, rewritten
);
18 FILE* result
= fopen(rewritten
, mode
);
22 return fopen(fn
, mode
);