util.c
changeset 16 e6a640ad2cc2
parent 14 51eb85ae4de4
child 18 d4ce82194b64
equal deleted inserted replaced
15:2706fc514dea 16:e6a640ad2cc2
    73 	va_start( args, fmt );
    73 	va_start( args, fmt );
    74 	fprintf( stderr, "%s [%s] #%d %d (%s:%d): ",
    74 	fprintf( stderr, "%s [%s] #%d %d (%s:%d): ",
    75 			 PROG, timestamp, getpid(), level, file, line );
    75 			 PROG, timestamp, getpid(), level, file, line );
    76 	vfprintf( stderr, fmt, args );
    76 	vfprintf( stderr, fmt, args );
    77 	va_end( args );
    77 	va_end( args );
       
    78 	fflush( stderr );
    78 
    79 
    79 	return;
    80 	return;
    80 }
    81 }
    81 
    82 
    82 
    83 
    86 void
    87 void
    87 out( const char *str )
    88 out( const char *str )
    88 {
    89 {
    89 	if ( v.debugmode >= 5 ) return;
    90 	if ( v.debugmode >= 5 ) return;
    90 	fprintf( stdout, "%s", str );
    91 	fprintf( stdout, "%s", str );
       
    92 	fflush( stdout );
    91 	return;
    93 	return;
    92 }
    94 }
    93 
    95 
    94 
    96 
    95 /*
    97 /*
   162 	if ( new_len > LINE_MAX || (line_realloc = realloc(line, sizeof(char) * new_len)) == NULL ) {
   164 	if ( new_len > LINE_MAX || (line_realloc = realloc(line, sizeof(char) * new_len)) == NULL ) {
   163 		debug( 5, LOC, "Ignoring line %d, error while allocating memory: %s\n",
   165 		debug( 5, LOC, "Ignoring line %d, error while allocating memory: %s\n",
   164 				v.timer.lines+1, (line_realloc == NULL ? strerror(errno) : "Line too large") );
   166 				v.timer.lines+1, (line_realloc == NULL ? strerror(errno) : "Line too large") );
   165 		free( line ), line = NULL;
   167 		free( line ), line = NULL;
   166 		printf( "\n" );
   168 		printf( "\n" );
       
   169 		fflush( stdout );
   167 	}
   170 	}
   168 	else {
   171 	else {
   169 		line = line_realloc;
   172 		line = line_realloc;
   170 		memcpy( line + offset, buf, LINE_BUFSIZE );
   173 		memcpy( line + offset, buf, LINE_BUFSIZE );
   171 	}
   174 	}