Update.
[platform/upstream/glibc.git] / login / programs / utmpd-private.h
1 /* Copyright (C) 1997 Free Software Foundation, Inc.
2    This file is part of the GNU C Library.
3    Contributed by Mark Kettenis <kettenis@phys.uva.nl>, 1997.
4
5    The GNU C Library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Library General Public License as
7    published by the Free Software Foundation; either version 2 of the
8    License, or (at your option) any later version.
9
10    The GNU C Library is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    Library General Public License for more details.
14
15    You should have received a copy of the GNU Library General Public
16    License along with the GNU C Library; see the file COPYING.LIB.  If not,
17    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18    Boston, MA 02111-1307, USA.  */
19
20 #ifndef _UTMPD_PRIVATE_H
21 #define _UTMPD_PRIVATE_H        1
22
23 #include <time.h>
24 #include <utmp.h>
25
26
27 /* The number of connections we allow.  */
28 #ifndef MAX_CONNECTIONS
29 #define MAX_CONNECTIONS 16
30 #endif
31
32
33 typedef struct utmp_database
34 {
35   int fd;
36   int old_fd;
37   char *file;
38   char *old_file;
39   time_t mtime;
40 } utmp_database;
41
42
43 /* The databases we handle.  */
44 extern utmp_database *utmp_db;
45 extern utmp_database *wtmp_db;
46
47
48 typedef struct client_connection
49 {
50   int sock;
51   /* Access permissions.  */
52   int access;
53
54   /* Read pointer.  */
55   void *read_base;
56   void *read_ptr;
57   void *read_end;
58
59   /* Write buffer.  */
60   void *write_base;
61   void *write_ptr;
62   void *write_end;
63
64   /* Database to use for this connection.  */
65   utmp_database *database;
66   /* Position pointer.  */
67   int position;
68   
69   /* Last read entry.  */
70   struct utmp last_entry;
71
72   /* Pointers to the next and previous connections in the list.  */
73   struct client_connection *next;
74   struct client_connection *prev;
75 } client_connection;
76
77
78 /* This variable indicates if we have forked.  If set, we log messages
79    via the system logger.  Otherwise we simply print the program name
80    and the message to standard error.  */
81 extern int forked;
82
83
84 /* Database functions.  */
85 utmp_database *open_database (const char *file, const char *old_file);
86 int synchronize_database (utmp_database *database);
87 void close_database (utmp_database *database);
88 int read_entry (utmp_database *database, int position, struct utmp *entry);
89 int write_entry (utmp_database *database, int position,
90                  const struct utmp *entry);
91 int append_entry (utmp_database *database, const struct utmp *entry);
92 int read_old_entry (utmp_database *database, int position, struct utmp *entry);
93 int write_old_entry (utmp_database *database, int position,
94                      const struct utmp *entry);
95
96 /* Connection oriented functions.  */
97 client_connection *accept_connection (int sock, int access);
98 client_connection *find_connection (int sock);
99 void close_connection (client_connection *connection);
100 int read_data (client_connection *connection);
101 int write_data (client_connection *connection);
102
103 int proc_utmp_eq (const struct utmp *entry, const struct utmp *match);
104
105 void error (int status, int errnum, const char *message, ...);
106 void warning (int errnum, const char *message, ...);
107
108
109 #endif /* utmpd-private.h  */
110