Debian Codegraph @

lib/doc/bin/docproc.c

raw symbols SCIP
1 /*
2 * docproc is a simple preprocessor for the template files
3 * used as placeholders for the kernel internal documentation.
4 * docproc is used for documentation-frontend and
5 * dependency-generator.
6 * The two usages have in common that they require
7 * some knowledge of the .tmpl syntax, therefore they
8 * are kept together.
9 *
10 * documentation-frontend
11 * Scans the template file and call kernel-doc for
12 * all occurrences of ![EIF]file
13 * Beforehand each referenced file is scanned for
14 * any symbols that are exported via these macros:
15 * EXPORT_SYMBOL(), EXPORT_SYMBOL_GPL(), &
16 * EXPORT_SYMBOL_GPL_FUTURE()
17 * This is used to create proper -function and
18 * -nofunction arguments in calls to kernel-doc.
19 * Usage: docproc doc file.tmpl
20 *
21 * dependency-generator:
22 * Scans the template file and list all files
23 * referenced in a format recognized by make.
24 * Usage: docproc depend file.tmpl
25 * Writes dependency information to stdout
26 * in the following format:
27 * file.tmpl src.c src2.c
28 * The filenames are obtained from the following constructs:
29 * !Efilename
30 * !Ifilename
31 * !Dfilename
32 * !Ffilename
33 * !Pfilename
34 *
35 */
36
37 #define _GNU_SOURCEcxx . . $ `lib/doc/bin/docproc.c:37:9`!
38 #include <stdio.h>
39 #include <stdlib.h>
40 #include <string.h>
41 #include <ctype.h>
42 #include <unistd.h>
43 #include <limits.h>
44 #include <errno.h>
45 #include <sys/types.h>
46 #include <sys/wait.h>
47
48 /* exitstatus is used to keep track of any failing calls to kernel-doc,
49 * but execution continues. */
50 int exitstatuscxx . . $ exitstatus. = 0;
51
52 typedef void DFLcxx . . $ DFL#(char *);
53 DFLcxx . . $ DFL# *defaultlinecxx . . $ defaultline.;
54
55 typedef void FILEONLYcxx . . $ FILEONLY#(char * file);
56 FILEONLYcxx . . $ FILEONLY# *internalfunctionscxx . . $ internalfunctions.;
57 FILEONLYcxx . . $ FILEONLY# *externalfunctionscxx . . $ externalfunctions.;
58 FILEONLYcxx . . $ FILEONLY# *symbolsonlycxx . . $ symbolsonly.;
59 FILEONLYcxx . . $ FILEONLY# *findallcxx . . $ findall.;
60
61 typedef void FILELINEcxx . . $ FILELINE#(char * file, char * line);
62 FILELINEcxx . . $ FILELINE# * singlefunctionscxx . . $ singlefunctions.;
63 FILELINEcxx . . $ FILELINE# * entity_systemcxx . . $ entity_system.;
64 FILELINEcxx . . $ FILELINE# * docsectioncxx . . $ docsection.;
65
66 #define MAXLINESZcxx . . $ `lib/doc/bin/docproc.c:66:9`! 2048
67 #define MAXFILEScxx . . $ `lib/doc/bin/docproc.c:67:9`! 250
68 #define KERNELDOCPATHcxx . . $ `lib/doc/bin/docproc.c:68:9`! "doc/bin/"
69 #define KERNELDOCcxx . . $ `lib/doc/bin/docproc.c:69:9`! "kernel-doc"
70 #define DOCBOOKcxx . . $ `lib/doc/bin/docproc.c:70:9`! "-docbook"
71 #define LISTcxx . . $ `lib/doc/bin/docproc.c:71:9`! "-list"
72 #define FUNCTIONcxx . . $ `lib/doc/bin/docproc.c:72:9`! "-function"
73 #define NOFUNCTIONcxx . . $ `lib/doc/bin/docproc.c:73:9`! "-nofunction"
74 #define NODOCSECTIONScxx . . $ `lib/doc/bin/docproc.c:74:9`! "-no-doc-sections"
75 #define SHOWNOTFOUNDcxx . . $ `lib/doc/bin/docproc.c:75:9`! "-show-not-found"
76
77 static char *srctreecxx . . $ srctree., *kernsrctreecxx . . $ kernsrctree.;
78
79 static char **all_listcxx . . $ all_list. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
80 static size_t all_list_lencxx . . $ all_list_len. = 0;
81
82 static void consume_symbolcxx . . $ consume_symbol(85c52e162fed56f9).(const char *sym)
83 {
84 size_t i;
85
86 for (i = 0; i < all_list_lencxx . . $ all_list_len.; i++) {
87 if (!all_listcxx . . $ all_list.[i])
88 continue;
89 if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(sym, all_listcxx . . $ all_list.[i]))
90 continue;
91 all_listcxx . . $ all_list.[i] = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
92 break;
93 }
94 }
95
96 static void usagecxx . . $ usage(49f6e7a06ebc5aa8). (void)
97 {
98 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "Usage: docproc {doc|depend} file\n");
99 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "Input is read from file.tmpl. Output is sent to stdout\n");
100 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "doc: frontend when generating kernel documentation\n");
101 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "depend: generate list of files referenced within file\n");
102 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "Environment variable SRCTREE: absolute path to sources.\n");
103 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " KBUILD_SRC: absolute path to kernel source tree.\n");
104 }
105
106 /*
107 * Execute kernel-doc with parameters given in svec
108 */
109 static void exec_kernel_doccxx . . $ exec_kernel_doc(3ed91490e421178f).(char **svec)
110 {
111 pid_tcxx . . $ pid_t# pid;
112 int ret;
113 char real_filename[PATH_MAXcxx . . $ `<external>/6347054901304145714/limits.h:13:9`! + 1];
114 /* Make sure output generated so far are flushed */
115 fflushcxx . . $ fflush(89bc1efcdac0ca22).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!);
116 switch (pid=forkcxx . . $ fork(b126dc7c1de90089).()) {
117 case -1:
118 perrorcxx . . $ perror(85c52e162fed56f9).("fork");
119 exitcxx . . $ exit(3ca292c338df9bb3).(1);
120 case 0:
121 memsetcxx . . $ memset(d1de1e4fb215f1c6).(real_filename, 0, sizeof(real_filename));
122 strncatcxx . . $ strncat(255158a415b673b0).(real_filename, kernsrctreecxx . . $ kernsrctree., PATH_MAXcxx . . $ `<external>/6347054901304145714/limits.h:13:9`!);
123 strncatcxx . . $ strncat(255158a415b673b0).(real_filename, "/" KERNELDOCPATHcxx . . $ `lib/doc/bin/docproc.c:68:9`! KERNELDOCcxx . . $ `lib/doc/bin/docproc.c:69:9`!,
124 PATH_MAXcxx . . $ `<external>/6347054901304145714/limits.h:13:9`! - strlencxx . . $ strlen(751346f8406fd082).(real_filename));
125 execvpcxx . . $ execvp(8a4102a9cf05ffcd).(real_filename, svec);
126 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "exec ");
127 perrorcxx . . $ perror(85c52e162fed56f9).(real_filename);
128 exitcxx . . $ exit(3ca292c338df9bb3).(1);
129 default:
130 waitpidcxx . . $ waitpid(1df93256b606fe1f).(pid, &ret ,0);
131 }
132 if (WIFEXITEDcxx . . $ `<external>/10696550936717951914/stdlib.h:47:10`!(ret))
133 exitstatuscxx . . $ exitstatus. |= WEXITSTATUScxx . . $ `<external>/10696550936717951914/stdlib.h:44:10`!(ret);
134 else
135 exitstatuscxx . . $ exitstatus. = 0xff;
136 }
137
138 /* Types used to create list of all exported symbols in a number of files */
139 struct symbolscxx . . $ symbols#
140 {
141 char *namecxx . . $ symbols#name.;
142 };
143
144 struct symfilecxx . . $ symfile#
145 {
146 char *filenamecxx . . $ symfile#filename.;
147 struct symbolscxx . . $ symbols# *symbollistcxx . . $ symfile#symbollist.;
148 unsigned int symbolcntcxx . . $ symfile#symbolcnt.;
149 };
150
151 struct symfilecxx . . $ symfile# symfilelistcxx . . $ symfilelist.[MAXFILEScxx . . $ `lib/doc/bin/docproc.c:67:9`!];
152 int symfilecntcxx . . $ symfilecnt. = 0;
153
154 static void add_new_symbolcxx . . $ add_new_symbol(81c977722f3e6cbe).(struct symfilecxx . . $ symfile# *sym, char * symname)
155 {
156 sym->symbollistcxx . . $ symfile#symbollist. =
157 realloccxx . . $ realloc(417ab160f6baadc6).(sym->symbollistcxx . . $ symfile#symbollist.,
158 (sym->symbolcntcxx . . $ symfile#symbolcnt. + 1) * sizeof(struct symbolscxx . . $ symbols#));
159 if (!sym->symbollistcxx . . $ symfile#symbollist.) {
160 perrorcxx . . $ perror(85c52e162fed56f9).("realloc");
161 exitcxx . . $ exit(3ca292c338df9bb3).(1);
162 }
163 sym->symbollistcxx . . $ symfile#symbollist.[sym->symbolcntcxx . . $ symfile#symbolcnt.++].namecxx . . $ symbols#name. = strdupcxx . . $ strdup(a8b8e32347182212).(symname);
164 }
165
166 /* Add a filename to the list */
167 static struct symfilecxx . . $ symfile# * add_new_filecxx . . $ add_new_file(f0121a96b93029ab).(char * filename)
168 {
169 symfilelistcxx . . $ symfilelist.[symfilecntcxx . . $ symfilecnt.++].filenamecxx . . $ symfile#filename. = strdupcxx . . $ strdup(a8b8e32347182212).(filename);
170 return &symfilelistcxx . . $ symfilelist.[symfilecntcxx . . $ symfilecnt. - 1];
171 }
172
173 /* Check if file already are present in the list */
174 static struct symfilecxx . . $ symfile# * filename_existcxx . . $ filename_exist(f0121a96b93029ab).(char * filename)
175 {
176 int i;
177 for (i=0; i < symfilecntcxx . . $ symfilecnt.; i++)
178 if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(symfilelistcxx . . $ symfilelist.[i].filenamecxx . . $ symfile#filename., filename) == 0)
179 return &symfilelistcxx . . $ symfilelist.[i];
180 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
181 }
182
183 /*
184 * List all files referenced within the template file.
185 * Files are separated by tabs.
186 */
187 static void adddepcxx . . $ adddep(fda57c8427c60377).(char * file) { printfcxx . . $ printf(581fddd72a8db8fc).("\t%s", file); }
188 static void adddep2cxx . . $ adddep2(d0489a02ea06dfc6).(char * file, char * line) { (void)line; adddepcxx . . $ adddep(fda57c8427c60377).(file); }
189 static void noactioncxx . . $ noaction(fda57c8427c60377).(char * line) { (void)line; }
190 static void noaction2cxx . . $ noaction2(d0489a02ea06dfc6).(char * file, char * line) { (void)file; (void)line; }
191 /* Echo the line without further action */
192 static void printlinecxx . . $ printline(fda57c8427c60377).(char * line) { printfcxx . . $ printf(581fddd72a8db8fc).("%s", line); }
193
194 /*
195 * Find all symbols in filename that are exported with EXPORT_SYMBOL &
196 * EXPORT_SYMBOL_GPL (& EXPORT_SYMBOL_GPL_FUTURE implicitly).
197 * All symbols located are stored in symfilelist.
198 */
199 static void find_export_symbolscxx . . $ find_export_symbols(fda57c8427c60377).(char * filename)
200 {
201 FILEcxx . . $ FILE# * fp;
202 struct symfilecxx . . $ symfile# *sym;
203 char line[MAXLINESZcxx . . $ `lib/doc/bin/docproc.c:66:9`!];
204 if (filename_existcxx . . $ filename_exist(f0121a96b93029ab).(filename) == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) {
205 char real_filename[PATH_MAXcxx . . $ `<external>/6347054901304145714/limits.h:13:9`! + 1];
206 memsetcxx . . $ memset(d1de1e4fb215f1c6).(real_filename, 0, sizeof(real_filename));
207 strncatcxx . . $ strncat(255158a415b673b0).(real_filename, srctreecxx . . $ srctree., PATH_MAXcxx . . $ `<external>/6347054901304145714/limits.h:13:9`!);
208 strncatcxx . . $ strncat(255158a415b673b0).(real_filename, "/", PATH_MAXcxx . . $ `<external>/6347054901304145714/limits.h:13:9`! - strlencxx . . $ strlen(751346f8406fd082).(real_filename));
209 strncatcxx . . $ strncat(255158a415b673b0).(real_filename, filename,
210 PATH_MAXcxx . . $ `<external>/6347054901304145714/limits.h:13:9`! - strlencxx . . $ strlen(751346f8406fd082).(real_filename));
211 sym = add_new_filecxx . . $ add_new_file(f0121a96b93029ab).(filename);
212 fp = fopencxx . . $ fopen(82ec0787cd37e0a3).(real_filename, "r");
213 if (fp == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) {
214 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "docproc: ");
215 perrorcxx . . $ perror(85c52e162fed56f9).(real_filename);
216 exitcxx . . $ exit(3ca292c338df9bb3).(1);
217 }
218 while (fgetscxx . . $ fgets(efb0aaba7ac866ae).(line, MAXLINESZcxx . . $ `lib/doc/bin/docproc.c:66:9`!, fp)) {
219 char *p;
220 char *e;
221 if (((p = strstrcxx . . $ strstr(a713fe7b9a57cf96).(line, "EXPORT_SYMBOL_GPL")) != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) ||
222 ((p = strstrcxx . . $ strstr(a713fe7b9a57cf96).(line, "EXPORT_SYMBOL")) != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)) {
223 /* Skip EXPORT_SYMBOL{_GPL} */
224 while (isalnumcxx . . $ `<external>/17904084882347303253/ctype.h:189:10`!(*p) || *p == '_')
225 p++;
226 /* Remove parentheses & additional whitespace */
227 while (isspacecxx . . $ `<external>/17904084882347303253/ctype.h:197:10`!(*p))
228 p++;
229 if (*p != '(')
230 continue; /* Syntax error? */
231 else
232 p++;
233 while (isspacecxx . . $ `<external>/17904084882347303253/ctype.h:197:10`!(*p))
234 p++;
235 e = p;
236 while (isalnumcxx . . $ `<external>/17904084882347303253/ctype.h:189:10`!(*e) || *e == '_')
237 e++;
238 *e = '\0';
239 add_new_symbolcxx . . $ add_new_symbol(81c977722f3e6cbe).(sym, p);
240 }
241 }
242 fclosecxx . . $ fclose(89bc1efcdac0ca22).(fp);
243 }
244 }
245
246 /*
247 * Document all external or internal functions in a file.
248 * Call kernel-doc with following parameters:
249 * kernel-doc -docbook -nofunction function_name1 filename
250 * Function names are obtained from all the src files
251 * by find_export_symbols.
252 * intfunc uses -nofunction
253 * extfunc uses -function
254 */
255 static void docfunctionscxx . . $ docfunctions(d0489a02ea06dfc6).(char * filename, char * type)
256 {
257 unsigned int j;
258 int i;
259 unsigned int symcnt = 0;
260 int idx = 0;
261 char **vec;
262
263 for (i=0; i <= symfilecntcxx . . $ symfilecnt.; i++)
264 symcnt += symfilelistcxx . . $ symfilelist.[i].symbolcntcxx . . $ symfile#symbolcnt.;
265 vec = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).((2 + 2 * symcnt + 3) * sizeof(char *));
266 if (vec == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) {
267 perrorcxx . . $ perror(85c52e162fed56f9).("docproc: ");
268 exitcxx . . $ exit(3ca292c338df9bb3).(1);
269 }
270 vec[idx++] = KERNELDOCcxx . . $ `lib/doc/bin/docproc.c:69:9`!;
271 vec[idx++] = DOCBOOKcxx . . $ `lib/doc/bin/docproc.c:70:9`!;
272 vec[idx++] = NODOCSECTIONScxx . . $ `lib/doc/bin/docproc.c:74:9`!;
273 for (i=0; i < symfilecntcxx . . $ symfilecnt.; i++) {
274 struct symfilecxx . . $ symfile# * sym = &symfilelistcxx . . $ symfilelist.[i];
275 for (j=0; j < sym->symbolcntcxx . . $ symfile#symbolcnt.; j++) {
276 vec[idx++] = type;
277 consume_symbolcxx . . $ consume_symbol(85c52e162fed56f9).(sym->symbollistcxx . . $ symfile#symbollist.[j].namecxx . . $ symbols#name.);
278 vec[idx++] = sym->symbollistcxx . . $ symfile#symbollist.[j].namecxx . . $ symbols#name.;
279 }
280 }
281 vec[idx++] = filename;
282 vec[idx] = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
283 printfcxx . . $ printf(581fddd72a8db8fc).("<!-- %s -->\n", filename);
284 exec_kernel_doccxx . . $ exec_kernel_doc(3ed91490e421178f).(vec);
285 fflushcxx . . $ fflush(89bc1efcdac0ca22).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!);
286 freecxx . . $ free(5d22bdacc48458e8).(vec);
287 }
288 static void intfunccxx . . $ intfunc(fda57c8427c60377).(char * filename) { docfunctionscxx . . $ docfunctions(d0489a02ea06dfc6).(filename, NOFUNCTIONcxx . . $ `lib/doc/bin/docproc.c:73:9`!); }
289 static void extfunccxx . . $ extfunc(fda57c8427c60377).(char * filename) { docfunctionscxx . . $ docfunctions(d0489a02ea06dfc6).(filename, FUNCTIONcxx . . $ `lib/doc/bin/docproc.c:72:9`!); }
290
291 /*
292 * Document specific function(s) in a file.
293 * Call kernel-doc with the following parameters:
294 * kernel-doc -docbook -function function1 [-function function2]
295 */
296 static void singfunccxx . . $ singfunc(d0489a02ea06dfc6).(char * filename, char * line)
297 {
298 char *vec[200]; /* Enough for specific functions */
299 int i, idx = 0;
300 int startofsym = 1;
301 vec[idx++] = KERNELDOCcxx . . $ `lib/doc/bin/docproc.c:69:9`!;
302 vec[idx++] = DOCBOOKcxx . . $ `lib/doc/bin/docproc.c:70:9`!;
303 vec[idx++] = SHOWNOTFOUNDcxx . . $ `lib/doc/bin/docproc.c:75:9`!;
304
305 /* Split line up in individual parameters preceded by FUNCTION */
306 for (i=0; line[i]; i++) {
307 if (isspacecxx . . $ `<external>/17904084882347303253/ctype.h:197:10`!(line[i])) {
308 line[i] = '\0';
309 startofsym = 1;
310 continue;
311 }
312 if (startofsym) {
313 startofsym = 0;
314 vec[idx++] = FUNCTIONcxx . . $ `lib/doc/bin/docproc.c:72:9`!;
315 vec[idx++] = &line[i];
316 }
317 }
318 for (i = 0; i < idx; i++) {
319 if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(vec[i], FUNCTIONcxx . . $ `lib/doc/bin/docproc.c:72:9`!))
320 continue;
321 consume_symbolcxx . . $ consume_symbol(85c52e162fed56f9).(vec[i + 1]);
322 }
323 vec[idx++] = filename;
324 vec[idx] = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
325 exec_kernel_doccxx . . $ exec_kernel_doc(3ed91490e421178f).(vec);
326 }
327
328 /*
329 * Insert specific documentation section from a file.
330 * Call kernel-doc with the following parameters:
331 * kernel-doc -docbook -function "doc section" filename
332 */
333 static void docsectcxx . . $ docsect(d0489a02ea06dfc6).(char *filename, char *line)
334 {
335 /* kerneldoc -docbook -show-not-found -function "section" file NULL */
336 char *vec[7];
337 char *s;
338
339 for (s = line; *s; s++)
340 if (*s == '\n')
341 *s = '\0';
342
343 if (asprintfcxx . . $ asprintf(70ad09b5e10823c4).(&s, "DOC: %s", line) < 0) {
344 perrorcxx . . $ perror(85c52e162fed56f9).("asprintf");
345 exitcxx . . $ exit(3ca292c338df9bb3).(1);
346 }
347 consume_symbolcxx . . $ consume_symbol(85c52e162fed56f9).(s);
348 freecxx . . $ free(5d22bdacc48458e8).(s);
349
350 vec[0] = KERNELDOCcxx . . $ `lib/doc/bin/docproc.c:69:9`!;
351 vec[1] = DOCBOOKcxx . . $ `lib/doc/bin/docproc.c:70:9`!;
352 vec[2] = SHOWNOTFOUNDcxx . . $ `lib/doc/bin/docproc.c:75:9`!;
353 vec[3] = FUNCTIONcxx . . $ `lib/doc/bin/docproc.c:72:9`!;
354 vec[4] = line;
355 vec[5] = filename;
356 vec[6] = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
357 exec_kernel_doccxx . . $ exec_kernel_doc(3ed91490e421178f).(vec);
358 }
359
360 static void find_all_symbolscxx . . $ find_all_symbols(fda57c8427c60377).(char *filename)
361 {
362 char *vec[4]; /* kerneldoc -list file NULL */
363 pid_tcxx . . $ pid_t# pid;
364 ssize_tcxx . . $ ssize_t# ret;
365 char real_filename[PATH_MAXcxx . . $ `<external>/6347054901304145714/limits.h:13:9`! + 1];
366 int pipefd[2];
367 char *data, *str;
368 size_t i, count, start, data_len = 0;
369
370 vec[0] = KERNELDOCcxx . . $ `lib/doc/bin/docproc.c:69:9`!;
371 vec[1] = LISTcxx . . $ `lib/doc/bin/docproc.c:71:9`!;
372 vec[2] = filename;
373 vec[3] = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
374
375 if (pipecxx . . $ pipe(a5f7824ee4986326).(pipefd)) {
376 perrorcxx . . $ perror(85c52e162fed56f9).("pipe");
377 exitcxx . . $ exit(3ca292c338df9bb3).(1);
378 }
379
380 switch (pid=forkcxx . . $ fork(b126dc7c1de90089).()) {
381 case -1:
382 perrorcxx . . $ perror(85c52e162fed56f9).("fork");
383 exitcxx . . $ exit(3ca292c338df9bb3).(1);
384 case 0:
385 closecxx . . $ close(7864480464b09eea).(pipefd[0]);
386 dup2cxx . . $ dup2(9b79fb6aee4c0440).(pipefd[1], 1);
387 memsetcxx . . $ memset(d1de1e4fb215f1c6).(real_filename, 0, sizeof(real_filename));
388 strncatcxx . . $ strncat(255158a415b673b0).(real_filename, kernsrctreecxx . . $ kernsrctree., PATH_MAXcxx . . $ `<external>/6347054901304145714/limits.h:13:9`!);
389 strncatcxx . . $ strncat(255158a415b673b0).(real_filename, "/" KERNELDOCPATHcxx . . $ `lib/doc/bin/docproc.c:68:9`! KERNELDOCcxx . . $ `lib/doc/bin/docproc.c:69:9`!,
390 PATH_MAXcxx . . $ `<external>/6347054901304145714/limits.h:13:9`! - strlencxx . . $ strlen(751346f8406fd082).(real_filename));
391 execvpcxx . . $ execvp(8a4102a9cf05ffcd).(real_filename, vec);
392 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "exec ");
393 perrorcxx . . $ perror(85c52e162fed56f9).(real_filename);
394 exitcxx . . $ exit(3ca292c338df9bb3).(1);
395 default:
396 closecxx . . $ close(7864480464b09eea).(pipefd[1]);
397 data = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(4096);
398 if (!data) {
399 perrorcxx . . $ perror(85c52e162fed56f9).("malloc");
400 exitcxx . . $ exit(3ca292c338df9bb3).(1);
401 }
402 do {
403 while ((ret = readcxx . . $ read(7e34d0a36f355389).(pipefd[0],
404 data + data_len,
405 4096)) > 0) {
406 data_len += (size_t)ret;
407 data = realloccxx . . $ realloc(417ab160f6baadc6).(data, data_len + 4096);
408 if (!data) {
409 perrorcxx . . $ perror(85c52e162fed56f9).("realloc");
410 exitcxx . . $ exit(3ca292c338df9bb3).(1);
411 }
412 }
413 } while (ret == -EAGAINcxx . . $ `<external>/8987895939074593727/errno-base.h:15:9`!);
414 if (ret != 0) {
415 perrorcxx . . $ perror(85c52e162fed56f9).("read");
416 exitcxx . . $ exit(3ca292c338df9bb3).(1);
417 }
418 waitpidcxx . . $ waitpid(1df93256b606fe1f).(pid, (int *)&ret ,0);
419 }
420 if (WIFEXITEDcxx . . $ `<external>/10696550936717951914/stdlib.h:47:10`!(ret))
421 exitstatuscxx . . $ exitstatus. |= (int)WEXITSTATUScxx . . $ `<external>/10696550936717951914/stdlib.h:44:10`!(ret);
422 else
423 exitstatuscxx . . $ exitstatus. = 0xff;
424
425 count = 0;
426 /* poor man's strtok, but with counting */
427 for (i = 0; i < data_len; i++) {
428 if (data[i] == '\n') {
429 count++;
430 data[i] = '\0';
431 }
432 }
433 start = all_list_lencxx . . $ all_list_len.;
434 all_list_lencxx . . $ all_list_len. += count;
435 all_listcxx . . $ all_list. = realloccxx . . $ realloc(417ab160f6baadc6).(all_listcxx . . $ all_list., sizeof(char *) * all_list_lencxx . . $ all_list_len.);
436 if (!all_listcxx . . $ all_list.) {
437 perrorcxx . . $ perror(85c52e162fed56f9).("realloc");
438 exitcxx . . $ exit(3ca292c338df9bb3).(1);
439 }
440 str = data;
441 for (i = 0; i < data_len && start != all_list_lencxx . . $ all_list_len.; i++) {
442 if (data[i] == '\0') {
443 all_listcxx . . $ all_list.[start] = str;
444 str = data + i + 1;
445 start++;
446 }
447 }
448 freecxx . . $ free(5d22bdacc48458e8).(data);
449 }
450
451 /*
452 * Parse file, calling action specific functions for:
453 * 1) Lines containing !E
454 * 2) Lines containing !I
455 * 3) Lines containing !D
456 * 4) Lines containing !F
457 * 5) Lines containing !P
458 * 6) Lines containing !C
459 * 7) Default lines - lines not matching the above
460 */
461 static void parse_filecxx . . $ parse_file(8d4262d45fc644ab).(FILEcxx . . $ FILE# *infile)
462 {
463 char line[MAXLINESZcxx . . $ `lib/doc/bin/docproc.c:66:9`!];
464 char * s;
465 while (fgetscxx . . $ fgets(efb0aaba7ac866ae).(line, MAXLINESZcxx . . $ `lib/doc/bin/docproc.c:66:9`!, infile)) {
466 if (line[0] == '!') {
467 s = line + 2;
468 switch (line[1]) {
469 case 'E':
470 while (*s && !isspacecxx . . $ `<external>/17904084882347303253/ctype.h:197:10`!(*s)) s++;
471 *s = '\0';
472 externalfunctionscxx . . $ externalfunctions.(line+2);
473 break;
474 case 'I':
475 while (*s && !isspacecxx . . $ `<external>/17904084882347303253/ctype.h:197:10`!(*s)) s++;
476 *s = '\0';
477 internalfunctionscxx . . $ internalfunctions.(line+2);
478 break;
479 case 'D':
480 while (*s && !isspacecxx . . $ `<external>/17904084882347303253/ctype.h:197:10`!(*s)) s++;
481 *s = '\0';
482 symbolsonlycxx . . $ symbolsonly.(line+2);
483 break;
484 case 'F':
485 /* filename */
486 while (*s && !isspacecxx . . $ `<external>/17904084882347303253/ctype.h:197:10`!(*s)) s++;
487 *s++ = '\0';
488 /* function names */
489 while (isspacecxx . . $ `<external>/17904084882347303253/ctype.h:197:10`!(*s))
490 s++;
491 singlefunctionscxx . . $ singlefunctions.(line +2, s);
492 break;
493 case 'P':
494 /* filename */
495 while (*s && !isspacecxx . . $ `<external>/17904084882347303253/ctype.h:197:10`!(*s)) s++;
496 *s++ = '\0';
497 /* DOC: section name */
498 while (isspacecxx . . $ `<external>/17904084882347303253/ctype.h:197:10`!(*s))
499 s++;
500 docsectioncxx . . $ docsection.(line + 2, s);
501 break;
502 case 'C':
503 while (*s && !isspacecxx . . $ `<external>/17904084882347303253/ctype.h:197:10`!(*s)) s++;
504 *s = '\0';
505 if (findallcxx . . $ findall.)
506 findallcxx . . $ findall.(line+2);
507 break;
508 default:
509 defaultlinecxx . . $ defaultline.(line);
510 }
511 } else {
512 defaultlinecxx . . $ defaultline.(line);
513 }
514 }
515 fflushcxx . . $ fflush(89bc1efcdac0ca22).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!);
516 }
517
518
519 int maincxx . . $ main(afcd3168fc1188a4).(int argc, char *argv[])
520 {
521 FILEcxx . . $ FILE# * infile;
522 unsigned int i;
523
524 srctreecxx . . $ srctree. = getenvcxx . . $ getenv(a8b8e32347182212).("SRCTREE");
525 if (!srctreecxx . . $ srctree.)
526 srctreecxx . . $ srctree. = getcwdcxx . . $ getcwd(dff97f9eb74e1544).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0);
527 kernsrctreecxx . . $ kernsrctree. = getenvcxx . . $ getenv(a8b8e32347182212).("KBUILD_SRC");
528 if (!kernsrctreecxx . . $ kernsrctree. || !*kernsrctreecxx . . $ kernsrctree.)
529 kernsrctreecxx . . $ kernsrctree. = srctreecxx . . $ srctree.;
530 if (argc != 3) {
531 usagecxx . . $ usage(49f6e7a06ebc5aa8).();
532 exitcxx . . $ exit(3ca292c338df9bb3).(1);
533 }
534 /* Open file, exit on error */
535 infile = fopencxx . . $ fopen(82ec0787cd37e0a3).(argv[2], "r");
536 if (infile == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) {
537 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "docproc: ");
538 perrorcxx . . $ perror(85c52e162fed56f9).(argv[2]);
539 exitcxx . . $ exit(3ca292c338df9bb3).(2);
540 }
541
542 if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).("doc", argv[1]) == 0) {
543 /* Need to do this in two passes.
544 * First pass is used to collect all symbols exported
545 * in the various files;
546 * Second pass generate the documentation.
547 * This is required because some functions are declared
548 * and exported in different files :-((
549 */
550 /* Collect symbols */
551 defaultlinecxx . . $ defaultline. = noactioncxx . . $ noaction(fda57c8427c60377).;
552 internalfunctionscxx . . $ internalfunctions. = find_export_symbolscxx . . $ find_export_symbols(fda57c8427c60377).;
553 externalfunctionscxx . . $ externalfunctions. = find_export_symbolscxx . . $ find_export_symbols(fda57c8427c60377).;
554 symbolsonlycxx . . $ symbolsonly. = find_export_symbolscxx . . $ find_export_symbols(fda57c8427c60377).;
555 singlefunctionscxx . . $ singlefunctions. = noaction2cxx . . $ noaction2(d0489a02ea06dfc6).;
556 docsectioncxx . . $ docsection. = noaction2cxx . . $ noaction2(d0489a02ea06dfc6).;
557 findallcxx . . $ findall. = find_all_symbolscxx . . $ find_all_symbols(fda57c8427c60377).;
558 parse_filecxx . . $ parse_file(8d4262d45fc644ab).(infile);
559
560 /* Rewind to start from beginning of file again */
561 fseekcxx . . $ fseek(543fae30d249f6b1).(infile, 0, SEEK_SETcxx . . $ `<external>/232824719582829767/stdio.h:110:9`!);
562 defaultlinecxx . . $ defaultline. = printlinecxx . . $ printline(fda57c8427c60377).;
563 internalfunctionscxx . . $ internalfunctions. = intfunccxx . . $ intfunc(fda57c8427c60377).;
564 externalfunctionscxx . . $ externalfunctions. = extfunccxx . . $ extfunc(fda57c8427c60377).;
565 symbolsonlycxx . . $ symbolsonly. = printlinecxx . . $ printline(fda57c8427c60377).;
566 singlefunctionscxx . . $ singlefunctions. = singfunccxx . . $ singfunc(d0489a02ea06dfc6).;
567 docsectioncxx . . $ docsection. = docsectcxx . . $ docsect(d0489a02ea06dfc6).;
568 findallcxx . . $ findall. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
569
570 parse_filecxx . . $ parse_file(8d4262d45fc644ab).(infile);
571
572 for (i = 0; i < all_list_lencxx . . $ all_list_len.; i++) {
573 if (!all_listcxx . . $ all_list.[i])
574 continue;
575 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "Warning: didn't use docs for %s\n",
576 all_listcxx . . $ all_list.[i]);
577 }
578 } else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).("depend", argv[1]) == 0) {
579 /* Create first part of dependency chain
580 * file.tmpl */
581 printfcxx . . $ printf(581fddd72a8db8fc).("%s\t", argv[2]);
582 defaultlinecxx . . $ defaultline. = noactioncxx . . $ noaction(fda57c8427c60377).;
583 internalfunctionscxx . . $ internalfunctions. = adddepcxx . . $ adddep(fda57c8427c60377).;
584 externalfunctionscxx . . $ externalfunctions. = adddepcxx . . $ adddep(fda57c8427c60377).;
585 symbolsonlycxx . . $ symbolsonly. = adddepcxx . . $ adddep(fda57c8427c60377).;
586 singlefunctionscxx . . $ singlefunctions. = adddep2cxx . . $ adddep2(d0489a02ea06dfc6).;
587 docsectioncxx . . $ docsection. = adddep2cxx . . $ adddep2(d0489a02ea06dfc6).;
588 findallcxx . . $ findall. = adddepcxx . . $ adddep(fda57c8427c60377).;
589 parse_filecxx . . $ parse_file(8d4262d45fc644ab).(infile);
590 printfcxx . . $ printf(581fddd72a8db8fc).("\n");
591 } else {
592 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "Unknown option: %s\n", argv[1]);
593 exitcxx . . $ exit(3ca292c338df9bb3).(1);
594 }
595 fclosecxx . . $ fclose(89bc1efcdac0ca22).(infile);
596 fflushcxx . . $ fflush(89bc1efcdac0ca22).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!);
597 return exitstatuscxx . . $ exitstatus.;
598 }