Blame util.c

Packit 6f02de
/*
Packit 6f02de
 * dutil.c - AIX utility functions whose compilation conflicts with the
Packit 6f02de
 *	     general header file tree defined by lsof.h and dlsof.h -- e.g.,
Packit 6f02de
 *	     the conflict between <time.h> and <sys/time.h> for the time(2)
Packit 6f02de
 *	     and localtime(3) functions
Packit 6f02de
 *
Packit 6f02de
 * V. Abell
Packit 6f02de
 * Purdue University
Packit 6f02de
 */
Packit 6f02de
Packit 6f02de
Packit 6f02de
/*
Packit 6f02de
 * Copyright 2008 Purdue Research Foundation, West Lafayette, Indiana
Packit 6f02de
 * 47907.  All rights reserved.
Packit 6f02de
 *
Packit 6f02de
 * Written by Victor A. Abell
Packit 6f02de
 *
Packit 6f02de
 * This software is not subject to any license of the American Telephone
Packit 6f02de
 * and Telegraph Company or the Regents of the University of California.
Packit 6f02de
 *
Packit 6f02de
 * Permission is granted to anyone to use this software for any purpose on
Packit 6f02de
 * any computer system, and to alter it and redistribute it freely, subject
Packit 6f02de
 * to the following restrictions:
Packit 6f02de
 *
Packit 6f02de
 * 1. Neither the authors nor Purdue University are responsible for any
Packit 6f02de
 *    consequences of the use of this software.
Packit 6f02de
 *
Packit 6f02de
 * 2. The origin of this software must not be misrepresented, either by
Packit 6f02de
 *    explicit claim or by omission.  Credit to the authors and Purdue
Packit 6f02de
 *    University must appear in documentation and sources.
Packit 6f02de
 *
Packit 6f02de
 * 3. Altered versions must be plainly marked as such, and must not be
Packit 6f02de
 *    misrepresented as being the original software.
Packit 6f02de
 *
Packit 6f02de
 * 4. This notice may not be removed or altered.
Packit 6f02de
 */
Packit 6f02de
Packit 6f02de
Packit 6f02de
#ifndef lint
Packit 6f02de
static char copyright[] =
Packit 6f02de
"@(#) Copyright 2008 Purdue Research Foundation.\nAll rights reserved.\n";
Packit 6f02de
static char *rcsid = "$Id: util.c,v 1.1 2008/04/01 11:56:53 abe Exp $";
Packit 6f02de
#endif
Packit 6f02de
Packit 6f02de
#if	defined(HAS_STRFTIME)
Packit 6f02de
#include <time.h>
Packit 6f02de
#endif	/* defined(HAS_STRFTIME) */
Packit 6f02de
Packit 6f02de
Packit 6f02de
/*
Packit 6f02de
 * util_strftime() -- utility function to call strftime(3) without header
Packit 6f02de
 *		      file distractions
Packit 6f02de
 */
Packit 6f02de
Packit 6f02de
int
Packit 6f02de
util_strftime(fmtr, fmtl, fmt)
Packit 6f02de
	char *fmtr;			/* format output receiver */
Packit 6f02de
	int fmtl;			/* sizeof(*fmtr) */
Packit 6f02de
	char *fmt;			/* format */
Packit 6f02de
{
Packit 6f02de
Packit 6f02de
#if	defined(HAS_STRFTIME)
Packit 6f02de
	struct tm *lt;
Packit 6f02de
	time_t tm;
Packit 6f02de
Packit 6f02de
	tm = time((time_t *)NULL);
Packit 6f02de
	lt = localtime(&tm;;
Packit 6f02de
	return(strftime(fmtr, fmtl, fmt, lt));
Packit 6f02de
#else	/* !defined(HAS_STRFTIME) */
Packit 6f02de
	return(0);
Packit 6f02de
#endif	/* defined(HAS_STRFTIME) */
Packit 6f02de
Packit 6f02de
}