~ubuntu-branches/debian/sid/rlinetd/sid

« back to all changes in this revision

Viewing changes to db.c

  • Committer: Bazaar Package Importer
  • Author(s): Robert Luberda
  • Date: 2010-03-20 18:03:45 UTC
  • mfrom: (2.3.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20100320180345-x1srfbe2tg00ezsf
Tags: 0.7-1
* New upstream version.
* Recommend rsyslog instead of sysklogd (closes: #526922).
* update-inetd:
  + add support for enabling, disabling and removing entries;
  + use ucf for managing generated files;
  + ignore ucf files in rlinetd.conf;
  + make appropriate changes in  postinst and postrm scripts.
* Set debhelper compat level to 7
* Standards-Version: 3.8.4 (no changes). 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#include <ctype.h>
2
 
#include <fcntl.h>
3
 
#include <netinet/in.h>
4
 
#include <stdio.h>
5
 
#include <stdlib.h>
6
 
#include <string.h>
7
 
#include <sys/stat.h>
8
 
#include <sys/types.h>
9
 
#include <sysexits.h>
10
 
#include <config.h>
11
 
 
12
 
#ifdef HAVE_CAPABILITIES
13
 
#include <sys/capability.h>
14
 
#endif
15
 
 
16
 
#include "db.h"
17
 
#include "rlinetd.h"
18
 
#include "strings.h"
19
 
#include "error.h"
20
 
 
21
 
struct argvtab *argvs = NULL;
22
 
int numargvs = 0;
23
 
 
24
 
struct rlimit *rlimits = NULL;
25
 
int numrlimits = 0;
26
 
 
27
 
struct logtab *logtabs = NULL;
28
 
int numlogtabs = 0;
29
 
 
30
 
char **strings = NULL;
31
 
int numstrings = 0;
32
 
 
33
 
struct buftab *bufs = NULL;
34
 
int numbufs = 0;
35
 
 
36
 
struct oplist *oplists = NULL;
37
 
int numoplists = 0;
38
 
 
39
 
struct pidtab pidtabs[8] = {
40
 
        { 0, NULL, NULL, NULL, 0, NULL },
41
 
        { 0, NULL, NULL, NULL, 0, NULL },
42
 
        { 0, NULL, NULL, NULL, 0, NULL },
43
 
        { 0, NULL, NULL, NULL, 0, NULL },
44
 
        { 0, NULL, NULL, NULL, 0, NULL },
45
 
        { 0, NULL, NULL, NULL, 0, NULL },
46
 
        { 0, NULL, NULL, NULL, 0, NULL },
47
 
        { 0, NULL, NULL, NULL, 0, NULL }
48
 
};
49
 
 
50
 
struct semaphore *sems = NULL;
51
 
int numsems = 0;
52
 
 
53
 
#ifdef HAVE_CAPABILITIES
54
 
cap_t *caps;
55
 
int numcaps;
56
 
#endif
57
 
 
58
 
fd_set *fdsets = NULL;
59
 
int numfdsets = 0;
60
 
 
61
 
void pidtab_init() {
62
 
        memset(pidtabs, 0, 8 * sizeof(struct pidtab));
63
 
}
64
 
 
65
 
static struct pidtab *pidtab_new() {
66
 
        struct pidtab *p;
67
 
        
68
 
        p = (struct pidtab *)malloc(sizeof(struct pidtab));
69
 
        if (!p)
70
 
                rl_fatal(EX_SOFTWARE, "ABORT - Can't allocate memory");
71
 
        memset(p, 0, sizeof(struct pidtab));
72
 
        return p;
73
 
}
74
 
 
75
 
void pidtab_add(pid_t pid, int onexit, struct rl_instance *inst) {
76
 
        struct pidtab *p = pidtab_new();
77
 
        p->pid = pid;
78
 
        p->inst = inst;
79
 
        p->onexit = onexit;
80
 
        p->prev = pidtabs + (pid & 0x7);
81
 
        p->next = p->prev->next;
82
 
        p->prev->next = p;
83
 
        if(p->next)
84
 
                p->next->prev = p;
85
 
}
86
 
 
87
 
struct pidtab *pidtab_get(pid_t pid) {
88
 
        struct pidtab *p;
89
 
 
90
 
        p = pidtabs[pid & 0x7].next;
91
 
        if(!p)
92
 
                return NULL;
93
 
        do {
94
 
                if(p->pid == pid) {
95
 
                        return p;
96
 
                }
97
 
        } while((p = p->next));
98
 
        return NULL;
99
 
}
100
 
 
101
 
struct logtab *logtab_get(int i) {
102
 
        return logtabs + i;
103
 
}
104
 
 
105
 
struct rlimit *rlimittab_get(int i) {
106
 
        return rlimits + i;
107
 
}
108
 
 
109
 
struct argvtab *argvtab_get(int i) {
110
 
        return argvs + i;
111
 
}
112
 
 
113
 
#ifdef HAVE_CAPABILITIES
114
 
 
115
 
cap_t captab_get(int i) {
116
 
        return caps[i];
117
 
}
118
 
 
119
 
#endif /* HAVE_CAPABILITIES */
120
 
 
121
 
char *stringtab_get(int i) {
122
 
        return strings[i];
123
 
}
124
 
 
125
 
struct buftab *buftab_get(int i) {
126
 
        return bufs + i;
127
 
}
128
 
 
129
 
rl_opcode_t *oplisttab_get(int i) {
130
 
        return oplists[i].ops_list;
131
 
}
132
 
 
133
 
struct semaphore *semaphore_get(int i) {
134
 
        return sems + i;
135
 
}
136
 
 
137
 
fd_set *fdsettab_get(int i) {
138
 
        return fdsets + i;
139
 
}
140
 
 
141
 
/* vim: set ts=2: */