2 * $OpenBSD: dc.c,v 1.5 2004/01/13 08:17:41 otto Exp $
3 * $DragonFly: src/usr.bin/dc/dc.c,v 1.1 2004/09/20 04:20:39 dillon Exp $
7 * Copyright (c) 2003, Otto Moerbeek <otto@drijf.net>
9 * Permission to use, copy, modify, and distribute this software for any
10 * purpose with or without fee is hereby granted, provided that the above
11 * copyright notice and this permission notice appear in all copies.
13 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
28 static void usage(void);
30 extern char *__progname
;
35 fprintf(stderr
, "usage: %s [-x] [file]\n", __progname
);
40 main(int argc
, char *argv
[])
43 bool extended_regs
= false;
47 /* accept and ignore a single dash to be 4.4BSD dc(1) compatible */
48 while ((ch
= getopt(argc
, argv
, "x-")) != -1) {
62 init_bmachine(extended_regs
);
69 file
= fopen(argv
[0], "r");
71 err(1, "cannot open file %s", argv
[0]);
72 src_setstream(&src
, file
);
78 * BSD dc and Solaris dc continue with stdin after processing
79 * the file given as the argument.
81 src_setstream(&src
, stdin
);