Hello, What did you think about this : ------------------------------------ include/pwdb/_pwdb_macros.h /* * This is for debugging purposes ONLY. DO NOT use on live systems !!! * You have been warned :-) - CG * * to get automated debugging to the log file, it must be created manually. * _PWDB_LOGFILE must exist, mode 666 */ #ifndef _PWDB_LOGFILE #define _PWDB_LOGFILE "/tmp/pwdb-debug.log" #endif static void _pwdb_output_debug_info(const char *file, const char *fn , const int line) { FILE *logfile; int must_close = 1; if (!(logfile = fopen(_PWDB_LOGFILE,"a"))) { logfile = stderr; must_close = 0; } fprintf(logfile,"[%s:%s(%d)] ",file, fn, line); if (must_close) { fflush(logfile); fclose(logfile); } } Many times in this script, but also in libpwdb/_pwdb_macros.h The developer warn in the source code, but no way to see this message when using the librairy. Regards.
I think this can be considered safe, there's a big warning there about using it. In general, it's up to developers to use library functions safely (ie, in this case defining _PWDB_LOGFILE if he wants to use the debugging stuff). He's wrong about fopen() failing if the file doesnt exist though, append will still create it, if that's what he meant.