aboutsummaryrefslogtreecommitdiff
path: root/libcap/RCS/_makenames.c,v
blob: 236d4bed05951ba2ca9b59ea95c1406c1a87ff63 (plain)
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
head	1.4;
access;
symbols;
locks; strict;
comment	@ * @;


1.4
date	98.06.07.15.50.12;	author morgan;	state Exp;
branches;
next	1.3;

1.3
date	98.05.24.22.54.09;	author morgan;	state Exp;
branches;
next	1.2;

1.2
date	97.05.04.05.35.46;	author morgan;	state Exp;
branches;
next	1.1;

1.1
date	97.04.28.00.57.11;	author morgan;	state Exp;
branches;
next	;


desc
@Ansi partner to zefram's one line sed command
@


1.4
log
@updated to accommodate kernel's real header file :*)
@
text
@/*
 * $Id: _makenames.c,v 1.3 1998/05/24 22:54:09 morgan Exp morgan $
 *
 * Copyright (c) 1997-8 Andrew G. Morgan <morgan@@linux.kernel.org>
 *
 * This is a file to make the capability <-> string mappings for
 * libcap.
 */

#include <stdio.h>
#include <stdlib.h>
#include <linux/capability.h>

/*
 * #include 'sed' generated array
 */

struct {
    int index;
    const char *name;
} const list[] = {
#include "cap_names.sed"
    {-1, NULL}
};

/* this should be more than big enough (factor of three at least) */
const char *pointers[8*sizeof(struct __user_cap_data_struct)];

int main(void)
{
    int i, maxcaps=0;

    for ( i=0; list[i].index >= 0 && list[i].name; ++i ) {
	if (maxcaps < list[i].index) {
	    maxcaps = list[i].index;
	}
	pointers[list[i].index] = list[i].name;
    }

    printf("/*\n"
	   " * DO NOT EDIT: this file is generated automatically from\n"
	   " *\n"
	   " *     <linux/capability.h>\n"
	   " */\n"
	   "#define __CAP_BITS   %d\n"
	   "\n"
	   "#ifdef LIBCAP_PLEASE_INCLUDE_ARRAY\n"
	   "  char const *_cap_names[__CAP_BITS] = {\n", maxcaps);

    for (i=0; i<maxcaps; ++i) {
	if (pointers[i])
	    printf("      /* %d */\t\"%s\",\n", i, pointers[i]);
	else
	    printf("      /* %d */\tNULL,\t\t/* - presently unused */\n", i);
    }

    printf("  };\n"
	   "#endif /* LIBCAP_PLEASE_INCLUDE_ARRAY */\n"
	   "\n"
	   "/* END OF FILE */\n");

    exit(0);
}

/*
 * $Log: _makenames.c,v $
 * Revision 1.3  1998/05/24 22:54:09  morgan
 * updated for 2.1.104
 *
 * Revision 1.2  1997/05/04 05:35:46  morgan
 * cleaned up to #include sed output. also generates whole cap_names.c file
 *
 * Revision 1.1  1997/04/28 00:57:11  morgan
 * Initial revision
 *
 */
@


1.3
log
@updated for 2.1.104
@
text
@d2 1
a2 1
 * $Id: _makenames.c,v 1.2 1997/05/04 05:35:46 morgan Exp morgan $
d27 1
a27 1
const char *pointers[8*sizeof(struct _user_cap_data_struct)];
d67 3
@


1.2
log
@cleaned up to #include sed output. also generates whole cap_names.c file
@
text
@d2 1
a2 1
 * $Id: _makenames.c,v 1.1 1997/04/28 00:57:11 morgan Exp morgan $
d4 1
a4 1
 * Copyright (c) 1997 Andrew G. Morgan <morgan@@parc.power.net>
d26 2
a27 1
const char *pointers[__CAP_BITS];
d31 1
a31 1
    int i;
d34 3
d45 1
d47 2
a48 3
	   "#include \"libcap.h\"\n"
	   "\n"
	   "char const *_cap_names[__CAP_BITS] = {\n");
d50 1
a50 1
    for (i=0; i<__CAP_BITS; ++i) {
d52 1
a52 1
	    printf("    /* %d */\t\"%s\",\n", i, pointers[i]);
d54 1
a54 1
	    printf("    /* %d */\tNULL,\t\t/* - presently unused */\n", i);
d57 2
a58 1
    printf("};\n"
d67 3
@


1.1
log
@Initial revision
@
text
@d2 1
a2 1
 * $Id$
a10 2
#define __USE_BSD
#include <string.h>
d15 1
a15 2
 * Read the standard input for a list of index/string pairs
 * store them in an array and then output an array setting file
d18 7
a24 1
#define MAXBUFF 100
d26 1
a26 1
char *pointers[__CAP_BITS];
d28 1
a28 1
void main(void)
a29 1
    char buffer[MAXBUFF];
d32 3
a34 5
    while (fgets(buffer, MAXBUFF, stdin)) {
	char *tmp = buffer;

	tmp = strtok(tmp, "/");
	i = atoi(tmp);
d36 9
a44 6
	tmp = strtok(NULL, "/");
	if (tmp[strlen(tmp)-1] == '\n')
	    tmp[strlen(tmp)-1] = '\0';

	pointers[i] = strdup(tmp);
    }
d52 6
d61 4
a64 1
 * $Log$
@