1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
36 #if (defined(_WIN32) || defined(_MSDOS) || defined(__IBMC__))
45 extern int cppgetopt(int, char *const *, const char *);
46 extern char *optarg
, rcsid
[];
49 int Pflag
= 0; /* print no line information */
50 int Iflag
= 0; /* print includes */
51 int Mflag
= 0; /* print macor expansion */
52 int Aflag
= 0; /* translate character sets */
53 int Xflag
= 0; /* print pragma for include/import */
54 int Vflag
= 0; /* verbose flag */
55 int Cflag
= 0; /* do not remove any comments */
58 extern void setup_kwtab(void);
61 setup(int argc
, char **argv
)
68 while ((c
= cppgetopt(argc
, argv
, "NOPV:I:D:U:F:A:X:u:l:+")) != -1)
72 for (i
= 0; i
< NINCLUDE
; i
++)
73 if (includelist
[i
].always
== 1)
74 includelist
[i
].deleted
= 1;
78 for (i
= NINCLUDE
- 2; i
>= 0; i
--)
80 if (includelist
[i
].file
== NULL
)
82 includelist
[i
].always
= 1;
83 includelist
[i
].file
= optarg
;
88 error(FATAL
, "Too many -I directives");
94 setsource("<cmdarg>", -1, -1, optarg
, 0);
101 case 'P': /* Lineinfo */
106 for (n
= 0; (c
= optarg
[n
]) != '\0'; n
++)
126 fprintf(stderr
, "%s %s\n", argv
[0], rcsid
);
130 error(WARNING
, "Unknown verbose option %c", c
);
135 for (n
= 0; (c
= optarg
[n
]) != '\0'; n
++)
153 while (isspace(*dp
)) dp
++;
155 for (i
= NINCLUDE
- 1; i
>= 0; i
--)
157 if (wraplist
[i
].file
== NULL
)
159 wraplist
[i
].file
= dp
;
164 error(WARNING
, "Too many -Xw directives");
168 error(WARNING
, "Unknown extension option %c", c
);
176 case 'u': /* -undef fuer GCC (dummy) */
177 case 'l': /* -lang-c++ fuer GCC (dummy) */
188 if ((fp
= strrchr(argv
[optind
], '/')) != NULL
)
190 int len
= fp
- argv
[optind
];
192 dp
= (char *) newstring((uchar
*) argv
[optind
], len
+ 1, 0);
195 fp
= (char *) newstring((uchar
*) argv
[optind
], strlen(argv
[optind
]), 0);
196 if ((fd
= open(fp
, O_RDONLY
)) < 0)
197 error(FATAL
, "Can't open input file %s", fp
);
200 if (optind
+ 1 < argc
)
202 #if defined(WNT) && (_MSC_VER >= 1400)
203 int fdo
= creat(argv
[optind
+ 1], _S_IREAD
| _S_IWRITE
);
205 int fdo
= creat(argv
[optind
+ 1], 0666 );
208 error(FATAL
, "Can't open output file %s", argv
[optind
+ 1]);
212 includelist
[NINCLUDE
- 1].always
= 0;
213 includelist
[NINCLUDE
- 1].file
= dp
;
214 setsource(fp
, -1, fd
, NULL
, 0);
218 /* memmove is defined here because some vendors don't provide it at
219 all and others do a terrible job (like calling malloc) */
221 #if !defined(__IBMC__) && !defined(WNT) && !defined(__GLIBC__)
224 memmove(void *dp
, const void *sp
, size_t n
)
226 unsigned char *cdp
, *csp
;
231 csp
= (unsigned char *) sp
;