1198389Smav/*
2198389Smav * Copyright (c) 2004, Bull S.A..  All rights reserved.
3198389Smav * Created by: Sebastien Decugis
4198389Smav
5198389Smav * This program is free software; you can redistribute it and/or modify it
6198389Smav * under the terms of version 2 of the GNU General Public License as
7198389Smav * published by the Free Software Foundation.
8198389Smav *
9198389Smav * This program is distributed in the hope that it would be useful, but
10198389Smav * WITHOUT ANY WARRANTY; without even the implied warranty of
11198389Smav * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12198389Smav *
13198389Smav * You should have received a copy of the GNU General Public License along
14198389Smav * with this program; if not, write the Free Software Foundation, Inc., 59
15198389Smav * Temple Place - Suite 330, Boston MA 02111-1307, USA.
16198389Smav *
17198389Smav
18198389Smav
19198389Smav * This file is a wrapper to use the tests from the NPTL Test & Trace Project
20198389Smav * with either the Linux Test Project or the Open POSIX Test Suite.
21198389Smav
22198389Smav * The following function are defined:
23198389Smav * void output_init()
24198389Smav * void output_fini()
25198389Smav * void output(char * string, ...)
26198389Smav *
27198389Smav * The are used to output informative text (as a printf).
28198389Smav */
29198389Smav
30198389Smav#include <time.h>
31198389Smav#include <sys/types.h>
32198389Smav
33198389Smav/* We use a mutex to avoid conflicts in traces */
34198389Smavstatic pthread_mutex_t m_trace = PTHREAD_MUTEX_INITIALIZER;
35198389Smav
36198389Smav/*****************************************************************************************/
37198389Smav/******************************* stdout module *****************************************/
38198389Smav/*****************************************************************************************/
39198389Smav/* The following functions will output to stdout */
40198389Smav#if (1)
41198389Smavvoid output_init()
42198389Smav{
43198389Smav	/* do nothing */
44198389Smav	return;
45198389Smav}
46198389Smavvoid output( char * string, ... )
47198389Smav{
48198389Smav   va_list ap;
49198389Smav   char *ts="[??:??:??]";
50198389Smav   struct tm * now;
51198389Smav   time_t nw;
52198389Smav
53198389Smav   pthread_mutex_lock(&m_trace);
54198389Smav   nw = time(NULL);
55198389Smav   now = localtime(&nw);
56198389Smav   if (now == NULL)
57200218Smav      printf(ts);
58198389Smav   else
59198389Smav      printf("[%2.2d:%2.2d:%2.2d]", now->tm_hour, now->tm_min, now->tm_sec);
60198389Smav   va_start( ap, string);
61198389Smav   vprintf(string, ap);
62198389Smav   va_end(ap);
63198389Smav   pthread_mutex_unlock(&m_trace);
64198389Smav}
65198389Smavvoid output_fini()
66198389Smav{
67199321Smav	/*do nothing */
68198389Smav	return;
69198389Smav}
70198389Smav#endif
71198389Smav
72199321Smav