1/* 2 * Copyright (c) 2005, Bull S.A.. All rights reserved. 3 * Created by: Sebastien Decugis 4 5 * This program is free software; you can redistribute it and/or modify it 6 * under the terms of version 2 of the GNU General Public License as 7 * published by the Free Software Foundation. 8 * 9 * This program is distributed in the hope that it would be useful, but 10 * WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 * 13 * You should have received a copy of the GNU General Public License along 14 * with this program; if not, write the Free Software Foundation, Inc., 59 15 * Temple Place - Suite 330, Boston MA 02111-1307, USA. 16 * 17 18 19 * This file is a wrapper to use the tests from the NPTL Test & Trace Project 20 * with either the Linux Test Project or the Open POSIX Test Suite. 21 22 * The following function are defined: 23 * void output_init() 24 * void output_fini() 25 * void output(char * string, ...) 26 * 27 * The are used to output informative text (as a printf). 28 */ 29 30#include <time.h> 31#include <sys/types.h> 32 33/* We use a mutex to avoid conflicts in traces */ 34static pthread_mutex_t m_trace = PTHREAD_MUTEX_INITIALIZER; 35 36/*****************************************************************************************/ 37/******************************* stdout module *****************************************/ 38/*****************************************************************************************/ 39/* The following functions will output to stdout */ 40#if (1) 41void output_init() 42{ 43 /* do nothing */ 44 return; 45} 46void output( char * string, ... ) 47{ 48 va_list ap; 49 char *ts="[??:??:??]"; 50 struct tm * now; 51 time_t nw; 52 53 pthread_mutex_lock(&m_trace); 54 nw = time(NULL); 55 now = localtime(&nw); 56 if (now == NULL) 57 printf(ts); 58 else 59 printf("[%2.2d:%2.2d:%2.2d]", now->tm_hour, now->tm_min, now->tm_sec); 60 va_start( ap, string); 61 vprintf(string, ap); 62 va_end(ap); 63 pthread_mutex_unlock(&m_trace); 64} 65void output_fini() 66{ 67 /*do nothing */ 68 return; 69} 70#endif 71 72