File: audit.c

package info (click to toggle)
filter 2.6.3-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, jessie, jessie-kfreebsd, lenny, sarge, squeeze, wheezy
  • size: 728 kB
  • ctags: 706
  • sloc: ansic: 4,033; sh: 3,932; makefile: 198
file content (79 lines) | stat: -rw-r--r-- 1,875 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79

static char rcsid[] ="@(#)$Id: audit.c,v 5.3 1993/02/09 19:04:38 syd Exp $";

/*******************************************************************************
 *  The Elm Mail System  -  $Revision: 5.3 $   $State: Exp $
 *
 * 			Copyright (c) 1988-1992 USENET Community Trust
 * 			Copyright (c) 1986,1987 Dave Taylor
 *******************************************************************************
 * Bug reports, patches, comments, suggestions should be sent to:
 *
 *	Philip Brown    filter@bolthole.com
 *
 *******************************************************************************
 * $Log: audit.c,v $
 * Revision 5.3  1993/02/09  19:04:38  syd
 * use standard include method on time.h style includes
 *
 * Revision 5.2  1993/01/27  21:30:10  syd
 * fix include syntax
 *
 * Revision 5.1  1993/01/27  19:40:18  syd
 * Initial checkin
 *
 *
 ******************************************************************************/


/** allow date/time to be combined with username in verbose audit

**/

#include <stdio.h>
#include <fcntl.h>
#include <errno.h>

#ifdef I_TIME
#  include <time.h>
#endif
#ifdef I_SYSTIME
#  include <sys/time.h>
#endif

#include "defs.h"
#include "filter.h"
#include "s_filter.h"

extern int      errno;

char           *
date_n_user()
{
    static char     date[NLEN];
    static char    *stuff = NULL;
    time_t          now;

    now = time(NULL);
    if (!strftime(date, NLEN, "%c", localtime(&now)))
        return (username);
    if (stuff)
        free(stuff);
    if (!(stuff = malloc(strlen(username) + strlen(date) + 3)))
        return (username);
    sprintf(stuff, "%s %s", date, username);
	return(stuff);
}

char *
datestring()
{
    static char     date[NLEN];
    time_t          now;

    now = time(NULL);
    if (!strftime(date, NLEN, "%c", localtime(&now)))
        return ("[strftime failed?]" );
    return(date);
}