• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2004, 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.,
15  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16  *
17 
18  * This file is a wrapper to use the tests from the NPTL Test & Trace Project
19  * with either the Linux Test Project or the Open POSIX Test Suite.
20 
21  * The following function are defined:
22  * void output_init()
23  * void output_fini()
24  * void output(char * string, ...)
25  *
26  * The are used to output informative text (as a printf).
27  */
28 
29 #include <time.h>
30 #include <sys/types.h>
31 
32 /* We use a mutex to avoid conflicts in traces */
33 static pthread_mutex_t m_trace = PTHREAD_MUTEX_INITIALIZER;
34 
35 /*****************************************************************************************/
36 /******************************* stdout module *****************************************/
37 /*****************************************************************************************/
38 /* The following functions will output to stdout */
39 #if (1)
output_init()40 void output_init()
41 {
42 	/* do nothing */
43 	return;
44 }
45 
output(char * string,...)46 void 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,
60 		       now->tm_sec);
61 	va_start(ap, string);
62 	vprintf(string, ap);
63 	va_end(ap);
64 	pthread_mutex_unlock(&m_trace);
65 }
66 
output_fini()67 void output_fini()
68 {
69 	/*do nothing */
70 	return;
71 }
72 #endif
73