1/* 2 * dutil.c - AIX utility functions whose compilation conflicts with the 3 * general header file tree defined by lsof.h and dlsof.h -- e.g., 4 * the conflict between <time.h> and <sys/time.h> for the time(2) 5 * and localtime(3) functions 6 * 7 * V. Abell 8 * Purdue University 9 */ 10 11 12/* 13 * Copyright 2008 Purdue Research Foundation, West Lafayette, Indiana 14 * 47907. All rights reserved. 15 * 16 * Written by Victor A. Abell 17 * 18 * This software is not subject to any license of the American Telephone 19 * and Telegraph Company or the Regents of the University of California. 20 * 21 * Permission is granted to anyone to use this software for any purpose on 22 * any computer system, and to alter it and redistribute it freely, subject 23 * to the following restrictions: 24 * 25 * 1. Neither the authors nor Purdue University are responsible for any 26 * consequences of the use of this software. 27 * 28 * 2. The origin of this software must not be misrepresented, either by 29 * explicit claim or by omission. Credit to the authors and Purdue 30 * University must appear in documentation and sources. 31 * 32 * 3. Altered versions must be plainly marked as such, and must not be 33 * misrepresented as being the original software. 34 * 35 * 4. This notice may not be removed or altered. 36 */ 37 38 39#ifndef lint 40static char copyright[] = 41"@(#) Copyright 2008 Purdue Research Foundation.\nAll rights reserved.\n"; 42static char *rcsid = "$Id: util.c,v 1.1 2008/04/01 11:56:53 abe Exp $"; 43#endif 44 45#if defined(HAS_STRFTIME) 46#include <time.h> 47#endif /* defined(HAS_STRFTIME) */ 48 49 50/* 51 * util_strftime() -- utility function to call strftime(3) without header 52 * file distractions 53 */ 54 55int 56util_strftime(fmtr, fmtl, fmt) 57 char *fmtr; /* format output receiver */ 58 int fmtl; /* sizeof(*fmtr) */ 59 char *fmt; /* format */ 60{ 61 62#if defined(HAS_STRFTIME) 63 struct tm *lt; 64 time_t tm; 65 66 tm = time((time_t *)NULL); 67 lt = localtime(&tm); 68 return(strftime(fmtr, fmtl, fmt, lt)); 69#else /* !defined(HAS_STRFTIME) */ 70 return(0); 71#endif /* defined(HAS_STRFTIME) */ 72 73} 74