Ejemplo n.º 1
0
Archivo: output.c Proyecto: rhash/RHash
/**
 * Initialize pointers to output functions.
 */
void setup_output(void)
{
	rhash_data.out = stdout;
	rhash_data.log = stderr;

	setup_log_stream(&rhash_data.log, opt.log);
	setup_log_stream(&rhash_data.out, opt.output);
}
Ejemplo n.º 2
0
static void setup_log_stream(FILE **p_stream, const char *stream_path)
{
	if(stream_path) {
#ifdef _WIN32
		if( !(*p_stream = _wfsopen((wchar_t*)stream_path, L"w", _SH_DENYNO)) ) {
			stream_path = w2c((wchar_t*)stream_path);
#else
		if( !(*p_stream = fopen(stream_path, "w")) ) {
#endif
			log_error(_("%s: %s\n"), stream_path, strerror(errno));
			rsh_exit(2);
		}
	}
}

/**
 * Initialize pointers to output functions.
 */
void setup_output(void)
{
	rhash_data.out = stdout;
	rhash_data.log = stderr;

	if(opt.flags & OPT_PERCENTS) {
		/* we don't use _fileno() cause it is not in ISO C90, and so
		 * is incompatible with the GCC -ansi option */
		if(rhash_data.log == stderr && isatty(2)) {
			percents_output  = &p_perc; /* one-line percents */
		} else {
			percents_output  = &dots_perc; /* print percents as dots */
		}
	} else {
		percents_output  = &dummy_perc; /* no percents */
	}

	setup_log_stream(&rhash_data.out, opt.output);
	setup_log_stream(&rhash_data.log, opt.log);
}