source: src/router/proftpd/utils/utils.h @ 17876

Last change on this file since 17876 was 17876, checked in by BrainSlayer, 19 months ago

update proftp

File size: 4.1 KB
Line 
1/*
2 * ProFTPD - FTP server daemon
3 * Copyright (c) 1997, 1998 Public Flood Software
4 * Copyright (c) 1999, 2000 MacGyver aka Habeeb J. Dihu <macgyver@tos.net>
5 * Copyright (c) 2001-2011 The ProFTPD Project team
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
20 *
21 * As a special exemption, Public Flood Software/MacGyver aka Habeeb J. Dihu
22 * and other respective copyright holders give permission to link this program
23 * with OpenSSL, and distribute the resulting executable, without including
24 * the source code for OpenSSL in the source distribution.
25 */
26
27/* Scoreboard routines.
28 *
29 * $Id: utils.h,v 1.28 2011/05/23 20:35:35 castaglia Exp $
30 */
31
32#ifndef UTILS_UTILS_H
33#define UTILS_UTILS_H
34
35#include "config.h"
36#include "version.h"
37#include "options.h"
38
39#include <ctype.h>
40#include <errno.h>
41#include <fcntl.h>
42#include <stdio.h>
43#include <stdlib.h>
44#include <string.h>
45#include <time.h>
46
47#ifdef HAVE_GETOPT_H
48#  include <getopt.h>
49#else
50#  include "../lib/getopt.h"
51#endif /* !HAVE_GETOPT_H */
52
53#ifdef HAVE_UNISTD_H
54# include <unistd.h>
55#endif
56
57#ifdef HAVE_NETINET_IN_H
58# include <netinet/in.h>
59#endif
60
61#ifdef HAVE_SIGNAL_H
62# include <signal.h>
63#endif
64
65#ifdef HAVE_SYS_FILE_H
66# include <sys/file.h>
67#endif
68
69#ifdef HAVE_SYS_SOCKET_H
70# include <sys/socket.h>
71#endif
72
73#ifdef HAVE_SYS_STAT_H
74# include <sys/stat.h>
75#endif
76
77#include "default_paths.h"
78
79#define FALSE   0
80#define TRUE    1
81
82#ifndef INET_ADDRSTRLEN
83# define INET_ADDRSTRLEN        16
84#endif /* INET_ADDRSTRLEN */
85
86#ifndef INET6_ADDRSTRLEN
87# define INET6_ADDRSTRLEN       46
88#endif /* INET6_ADDRSTRLEN */
89
90/* UTIL_SCOREBOARD_VERSION is used for checking for scoreboard compatibility
91 */
92#define UTIL_SCOREBOARD_VERSION        0x01040003
93
94/* Structure used as a header for scoreboard files.
95 */
96#define UTIL_SCOREBOARD_MAGIC                   0xdeadbeef
97
98typedef struct {
99
100  /* Always 0xDEADBEEF */
101  unsigned long sch_magic;
102
103  /* Version of proftpd that created the scoreboard file */
104  unsigned long sch_version;
105
106  /* PID of the process to which this scoreboard belongs, or zero if inetd */
107  pid_t sch_pid;
108
109  /* Time when the daemon wrote this header */
110  time_t sch_uptime;
111
112} pr_scoreboard_header_t;
113
114/* Structure used for writing scoreboard file entries.
115 */
116
117typedef struct {
118  pid_t sce_pid;
119  uid_t sce_uid;
120  gid_t sce_gid;
121  char sce_user[32];
122
123  int sce_server_port;
124  char sce_server_addr[80], sce_server_label[32];
125
126#ifdef PR_USE_IPV6
127  char sce_client_addr[INET6_ADDRSTRLEN];
128#else
129  char sce_client_addr[INET_ADDRSTRLEN];
130#endif /* PR_USE_IPV6 */
131  char sce_client_name[PR_TUNABLE_SCOREBOARD_BUFFER_SIZE];
132
133  char sce_class[32];
134  char sce_protocol[32];
135  char sce_cwd[PR_TUNABLE_SCOREBOARD_BUFFER_SIZE];
136
137  char sce_cmd[65];
138  char sce_cmd_arg[PR_TUNABLE_SCOREBOARD_BUFFER_SIZE];
139
140  time_t sce_begin_idle, sce_begin_session;
141
142  off_t sce_xfer_size, sce_xfer_done, sce_xfer_len;
143  unsigned long sce_xfer_elapsed;
144
145} pr_scoreboard_entry_t;
146
147/* Scoreboard error values */
148#define UTIL_SCORE_ERR_BAD_MAGIC        -2
149#define UTIL_SCORE_ERR_OLDER_VERSION    -3
150#define UTIL_SCORE_ERR_NEWER_VERSION    -4
151
152char *util_sstrncpy(char *, const char *, size_t);
153
154const char *util_get_scoreboard(void);
155int util_set_scoreboard(const char *);
156
157char *util_scan_config(const char *, const char *);
158
159int util_close_scoreboard(void);
160int util_open_scoreboard(int);
161pid_t util_scoreboard_get_daemon_pid(void);
162time_t util_scoreboard_get_daemon_uptime(void);
163pr_scoreboard_entry_t *util_scoreboard_entry_read(void);
164int util_scoreboard_scrub(int);
165
166#endif /* UTILS_UTILS_H */
Note: See TracBrowser for help on using the repository browser.