xref: /onnv-gate/usr/src/cmd/cmd-inet/usr.sbin/in.ftpd/xferlog.c (revision 0:68f95e015346)
1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate  * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
3*0Sstevel@tonic-gate  * Use is subject to license terms.
4*0Sstevel@tonic-gate  */
5*0Sstevel@tonic-gate 
6*0Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
7*0Sstevel@tonic-gate 
8*0Sstevel@tonic-gate #include "config.h"
9*0Sstevel@tonic-gate #include <string.h>
10*0Sstevel@tonic-gate #include "extensions.h"
11*0Sstevel@tonic-gate #include "proto.h"
12*0Sstevel@tonic-gate 
13*0Sstevel@tonic-gate #define DEFXFERFORMAT	"%T %Xt %R %Xn %XP %Xy %Xf %Xd %Xm %U ftp %Xa %u %Xc"
14*0Sstevel@tonic-gate 
15*0Sstevel@tonic-gate int xferdone = 0;
16*0Sstevel@tonic-gate struct xferstat xfervalues;
17*0Sstevel@tonic-gate char xferlog_format[MAXXFERSTRLEN] = DEFXFERFORMAT;
18*0Sstevel@tonic-gate 
19*0Sstevel@tonic-gate /*************************************************************************/
20*0Sstevel@tonic-gate /* FUNCTION  : get_xferlog_format                                        */
21*0Sstevel@tonic-gate /* PURPOSE   : Read the xferlog format string from ftpaccess into        */
22*0Sstevel@tonic-gate /*             xferlog_format if it exists otherwise load default string */
23*0Sstevel@tonic-gate /* ARGUMENTS : none                                                      */
24*0Sstevel@tonic-gate /*************************************************************************/
25*0Sstevel@tonic-gate 
get_xferlog_format(void)26*0Sstevel@tonic-gate void get_xferlog_format(void)
27*0Sstevel@tonic-gate {
28*0Sstevel@tonic-gate     int which;
29*0Sstevel@tonic-gate     struct aclmember *entry = (struct aclmember *)NULL;
30*0Sstevel@tonic-gate 
31*0Sstevel@tonic-gate     /* xferlog format <formatstring> */
32*0Sstevel@tonic-gate     xferlog_format[0] = '\0';
33*0Sstevel@tonic-gate     while (getaclentry("xferlog", &entry)) {
34*0Sstevel@tonic-gate 	if (ARG0 && (strcasecmp(ARG0, "format") == 0)) {
35*0Sstevel@tonic-gate 	    for (which = 1; (which < MAXARGS) && ARG[which]; which++) {
36*0Sstevel@tonic-gate 		if (which > 1) {
37*0Sstevel@tonic-gate 		    if (strlcat(xferlog_format, " ",
38*0Sstevel@tonic-gate 			sizeof(xferlog_format)) >= sizeof(xferlog_format))
39*0Sstevel@tonic-gate 			break;
40*0Sstevel@tonic-gate 		}
41*0Sstevel@tonic-gate 		if (strlcat(xferlog_format, ARG[which],
42*0Sstevel@tonic-gate 		    sizeof(xferlog_format)) >= sizeof(xferlog_format))
43*0Sstevel@tonic-gate 		    break;
44*0Sstevel@tonic-gate 	    }
45*0Sstevel@tonic-gate 	    break;
46*0Sstevel@tonic-gate 	}
47*0Sstevel@tonic-gate     }
48*0Sstevel@tonic-gate 
49*0Sstevel@tonic-gate     /* default xferlog format */
50*0Sstevel@tonic-gate     if (xferlog_format[0] == '\0')
51*0Sstevel@tonic-gate 	(void) strlcpy(xferlog_format, DEFXFERFORMAT, sizeof(xferlog_format));
52*0Sstevel@tonic-gate }
53