12c28215423293e443469a07ae7011135d058b671Garrett Cooper/* 22c28215423293e443469a07ae7011135d058b671Garrett Cooper * Copyright (c) 2004, Bull S.A.. All rights reserved. 32c28215423293e443469a07ae7011135d058b671Garrett Cooper * Created by: Sebastien Decugis 42c28215423293e443469a07ae7011135d058b671Garrett Cooper 52c28215423293e443469a07ae7011135d058b671Garrett Cooper * This program is free software; you can redistribute it and/or modify it 62c28215423293e443469a07ae7011135d058b671Garrett Cooper * under the terms of version 2 of the GNU General Public License as 72c28215423293e443469a07ae7011135d058b671Garrett Cooper * published by the Free Software Foundation. 82c28215423293e443469a07ae7011135d058b671Garrett Cooper * 92c28215423293e443469a07ae7011135d058b671Garrett Cooper * This program is distributed in the hope that it would be useful, but 102c28215423293e443469a07ae7011135d058b671Garrett Cooper * WITHOUT ANY WARRANTY; without even the implied warranty of 112c28215423293e443469a07ae7011135d058b671Garrett Cooper * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 122c28215423293e443469a07ae7011135d058b671Garrett Cooper * 132c28215423293e443469a07ae7011135d058b671Garrett Cooper * You should have received a copy of the GNU General Public License along 14fed9641096e27f79a0f2d9adfe9839dd8d11dc0fWanlong Gao * with this program; if not, write the Free Software Foundation, Inc., 15fed9641096e27f79a0f2d9adfe9839dd8d11dc0fWanlong Gao * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 162c28215423293e443469a07ae7011135d058b671Garrett Cooper * 172c28215423293e443469a07ae7011135d058b671Garrett Cooper 182c28215423293e443469a07ae7011135d058b671Garrett Cooper * This file is a wrapper to use the tests from the NPTL Test & Trace Project 192c28215423293e443469a07ae7011135d058b671Garrett Cooper * with either the Linux Test Project or the Open POSIX Test Suite. 202c28215423293e443469a07ae7011135d058b671Garrett Cooper 212c28215423293e443469a07ae7011135d058b671Garrett Cooper * The following function are defined: 222c28215423293e443469a07ae7011135d058b671Garrett Cooper * void output_init() 232c28215423293e443469a07ae7011135d058b671Garrett Cooper * void output_fini() 242c28215423293e443469a07ae7011135d058b671Garrett Cooper * void output(char * string, ...) 252c28215423293e443469a07ae7011135d058b671Garrett Cooper * 262c28215423293e443469a07ae7011135d058b671Garrett Cooper * The are used to output informative text (as a printf). 272c28215423293e443469a07ae7011135d058b671Garrett Cooper */ 282c28215423293e443469a07ae7011135d058b671Garrett Cooper 292c28215423293e443469a07ae7011135d058b671Garrett Cooper#include <time.h> 302c28215423293e443469a07ae7011135d058b671Garrett Cooper#include <sys/types.h> 312c28215423293e443469a07ae7011135d058b671Garrett Cooper 322c28215423293e443469a07ae7011135d058b671Garrett Cooper/* We use a mutex to avoid conflicts in traces */ 332c28215423293e443469a07ae7011135d058b671Garrett Cooperstatic pthread_mutex_t m_trace = PTHREAD_MUTEX_INITIALIZER; 342c28215423293e443469a07ae7011135d058b671Garrett Cooper 352c28215423293e443469a07ae7011135d058b671Garrett Cooper/*****************************************************************************************/ 362c28215423293e443469a07ae7011135d058b671Garrett Cooper/******************************* stdout module *****************************************/ 372c28215423293e443469a07ae7011135d058b671Garrett Cooper/*****************************************************************************************/ 382c28215423293e443469a07ae7011135d058b671Garrett Cooper/* The following functions will output to stdout */ 392c28215423293e443469a07ae7011135d058b671Garrett Cooper#if (1) 402c28215423293e443469a07ae7011135d058b671Garrett Coopervoid output_init() 412c28215423293e443469a07ae7011135d058b671Garrett Cooper{ 422c28215423293e443469a07ae7011135d058b671Garrett Cooper /* do nothing */ 432c28215423293e443469a07ae7011135d058b671Garrett Cooper return; 442c28215423293e443469a07ae7011135d058b671Garrett Cooper} 45354ebb48db8e66a853a58379a4808d5dcd1ceac3Wanlong Gao 46354ebb48db8e66a853a58379a4808d5dcd1ceac3Wanlong Gaovoid output(char *string, ...) 472c28215423293e443469a07ae7011135d058b671Garrett Cooper{ 48354ebb48db8e66a853a58379a4808d5dcd1ceac3Wanlong Gao va_list ap; 49354ebb48db8e66a853a58379a4808d5dcd1ceac3Wanlong Gao char *ts = "[??:??:??]"; 50354ebb48db8e66a853a58379a4808d5dcd1ceac3Wanlong Gao struct tm *now; 51354ebb48db8e66a853a58379a4808d5dcd1ceac3Wanlong Gao time_t nw; 522c28215423293e443469a07ae7011135d058b671Garrett Cooper 53354ebb48db8e66a853a58379a4808d5dcd1ceac3Wanlong Gao pthread_mutex_lock(&m_trace); 54354ebb48db8e66a853a58379a4808d5dcd1ceac3Wanlong Gao nw = time(NULL); 55354ebb48db8e66a853a58379a4808d5dcd1ceac3Wanlong Gao now = localtime(&nw); 56354ebb48db8e66a853a58379a4808d5dcd1ceac3Wanlong Gao if (now == NULL) 57354ebb48db8e66a853a58379a4808d5dcd1ceac3Wanlong Gao printf(ts); 58354ebb48db8e66a853a58379a4808d5dcd1ceac3Wanlong Gao else 59354ebb48db8e66a853a58379a4808d5dcd1ceac3Wanlong Gao printf("[%2.2d:%2.2d:%2.2d]", now->tm_hour, now->tm_min, 60354ebb48db8e66a853a58379a4808d5dcd1ceac3Wanlong Gao now->tm_sec); 61354ebb48db8e66a853a58379a4808d5dcd1ceac3Wanlong Gao va_start(ap, string); 62354ebb48db8e66a853a58379a4808d5dcd1ceac3Wanlong Gao vprintf(string, ap); 63354ebb48db8e66a853a58379a4808d5dcd1ceac3Wanlong Gao va_end(ap); 64354ebb48db8e66a853a58379a4808d5dcd1ceac3Wanlong Gao pthread_mutex_unlock(&m_trace); 652c28215423293e443469a07ae7011135d058b671Garrett Cooper} 66354ebb48db8e66a853a58379a4808d5dcd1ceac3Wanlong Gao 672c28215423293e443469a07ae7011135d058b671Garrett Coopervoid output_fini() 682c28215423293e443469a07ae7011135d058b671Garrett Cooper{ 692c28215423293e443469a07ae7011135d058b671Garrett Cooper /*do nothing */ 702c28215423293e443469a07ae7011135d058b671Garrett Cooper return; 712c28215423293e443469a07ae7011135d058b671Garrett Cooper} 72ec6edca7aa42b6affd989ef91b5897f96795e40fChris Dearman#endif 73