2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these libraries and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $XConsortium: nocom.c /main/2 1996/05/08 19:40:06 drk $ */
24 /***************************************************************
26 * AT&T - PROPRIETARY *
28 * THIS IS PROPRIETARY SOURCE CODE LICENSED BY *
31 * Copyright (c) 1995 AT&T Corp. *
32 * All Rights Reserved *
34 * This software is licensed by AT&T Corp. *
35 * under the terms and conditions of the license in *
36 * http://www.research.att.com/orgs/ssr/book/reuse *
38 * This software was created by the *
39 * Software Engineering Research Department *
40 * AT&T Bell Laboratories *
42 * For further information contact *
43 * gsf@research.att.com *
45 ***************************************************************/
47 /* : : generated by proto : : */
49 #if !defined(__PROTO__)
50 #if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
51 #if defined(__cplusplus)
52 #define __MANGLE__ "C"
57 #define __PROTO__(x) x
59 #define __PARAM__(n,o) n
60 #if !defined(__STDC__) && !defined(__cplusplus)
61 #if !defined(c_plusplus)
72 #define __PROTO__(x) ()
73 #define __OTORP__(x) x
74 #define __PARAM__(n,o) o
82 #if defined(__cplusplus) || defined(c_plusplus)
83 #define __VARARG__ ...
87 #if defined(__STDARG__)
88 #define __VA_START__(p,a) va_start(p,a)
90 #define __VA_START__(p,a) va_start(p)
93 static const char id[] = "\n@(#)nocom (AT&T Bell Laboratories) 08/11/94\0\n";
104 if (sfsprintf(buf, sizeof(buf), "#%s %d\n", sync <= 0 ? "line" : "", line) <= line - prev) \
106 sfputr(sfstdout, buf, -1); \
109 else while (prev++ < line) \
110 sfputc(sfstdout, '\n'); \
112 sfputc(sfstdout, c); \
120 nocom __PARAM__((register Sfio_t* sp, char* file), (sp, file)) __OTORP__(register Sfio_t* sp; char* file;){
123 register int data = 0;
125 unsigned long line = 0;
126 unsigned long prev = 0;
127 unsigned long directive = 0;
144 sfmove(sp, sfstdout, SF_UNBOUND, -1);
148 switch (c = sfgetc(sp))
184 if (directive == line)
187 sfputc(sfstdout, ' ');
191 switch (c = sfgetc(sp))
210 if (directive == line)
213 sfputc(sfstdout, ' ');
217 if (p == '/' || p == '=')
218 sfputc(sfstdout, ' ');
223 if (p == c || p == '=')
224 sfputc(sfstdout, ' ');
228 sfputc(sfstdout, ' ');
240 sfputc(sfstdout, '\n');
245 if (sync >= 0 && !data)
247 if (s = sfgetr(sp, '\n', 1))
249 while (*s == ' ' && *s == '\t')
254 line = strtol(s, NiL, 10);
258 if (!line && strneq(s, "pragma prototyped", 17))
264 sfsprintf(buf, sizeof(buf), "proto -ns %s", file);
267 else if (sfseek(sp, 0L, SEEK_SET))
269 error(2, "%s: must be seekable to run proto", file);
272 if (!(sp = sfpopen(sp, s, "r")))
274 error(2, "%s: cannot run proto", file);
280 if (!strneq(s, "ident", 5) && !strneq(s, "line", 4) && !strneq(s, "pragma", 6))
283 if (!p || strchr(s, '"'))
285 if (p) sfputc(sfstdout, c);
287 sfputr(sfstdout, s, '\n');
299 switch (c = sfgetc(sp))
304 for (;;) switch (sfgetc(sp))
315 for (;;) switch (sfgetc(sp))
324 sfputc(sfstdout, '\n');
340 sfputc(sfstdout, '\n');
367 switch (c = sfgetc(sp))
373 switch (c = sfgetc(sp))
405 main __PARAM__((int argc, char** argv), (argc, argv)) __OTORP__(int argc; char** argv;){
411 error_info.id = "nocom";
412 while (c = optget(argv, " [file ...]")) switch (c)
415 error(ERROR_USAGE|4, opt_info.arg);
418 error(2, opt_info.arg);
421 argv += opt_info.index;
422 if (error_info.errors)
423 error(ERROR_USAGE|4, optusage(NiL));
424 if (!*argv) nocom(sfstdin, "/dev/stdin");
425 else while (s = *argv++)
427 if (!(sp = sfopen(NiL, s, "r")))
428 error(ERROR_SYSTEM|2, "%s: cannot read", s);
435 exit(error_info.errors != 0);