xref: /freebsd/contrib/bc/src/dc.c (revision 12e0d316644a4f80f5f1f78cf07bd93def43b1ca)
150696a6eSStefan Eßer /*
250696a6eSStefan Eßer  * *****************************************************************************
350696a6eSStefan Eßer  *
450696a6eSStefan Eßer  * SPDX-License-Identifier: BSD-2-Clause
550696a6eSStefan Eßer  *
6a970610aSStefan Eßer  * Copyright (c) 2018-2024 Gavin D. Howard and contributors.
750696a6eSStefan Eßer  *
850696a6eSStefan Eßer  * Redistribution and use in source and binary forms, with or without
950696a6eSStefan Eßer  * modification, are permitted provided that the following conditions are met:
1050696a6eSStefan Eßer  *
1150696a6eSStefan Eßer  * * Redistributions of source code must retain the above copyright notice, this
1250696a6eSStefan Eßer  *   list of conditions and the following disclaimer.
1350696a6eSStefan Eßer  *
1450696a6eSStefan Eßer  * * Redistributions in binary form must reproduce the above copyright notice,
1550696a6eSStefan Eßer  *   this list of conditions and the following disclaimer in the documentation
1650696a6eSStefan Eßer  *   and/or other materials provided with the distribution.
1750696a6eSStefan Eßer  *
1850696a6eSStefan Eßer  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
1950696a6eSStefan Eßer  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2050696a6eSStefan Eßer  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2150696a6eSStefan Eßer  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
2250696a6eSStefan Eßer  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2350696a6eSStefan Eßer  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2450696a6eSStefan Eßer  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2550696a6eSStefan Eßer  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
2650696a6eSStefan Eßer  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2750696a6eSStefan Eßer  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2850696a6eSStefan Eßer  * POSSIBILITY OF SUCH DAMAGE.
2950696a6eSStefan Eßer  *
3050696a6eSStefan Eßer  * *****************************************************************************
3150696a6eSStefan Eßer  *
3250696a6eSStefan Eßer  * The main procedure of dc.
3350696a6eSStefan Eßer  *
3450696a6eSStefan Eßer  */
3550696a6eSStefan Eßer 
3650696a6eSStefan Eßer #if DC_ENABLED
3750696a6eSStefan Eßer 
3850696a6eSStefan Eßer #include <string.h>
3950696a6eSStefan Eßer 
4050696a6eSStefan Eßer #include <dc.h>
4150696a6eSStefan Eßer #include <vm.h>
4250696a6eSStefan Eßer 
4344d4804dSStefan Eßer /**
4444d4804dSStefan Eßer  * The main function for dc.
4544d4804dSStefan Eßer  * @param argc  The number of arguments.
4644d4804dSStefan Eßer  * @param argv  The arguments.
4744d4804dSStefan Eßer  */
48a970610aSStefan Eßer BcStatus
dc_main(int argc,const char * argv[])49*12e0d316SStefan Eßer dc_main(int argc, const char* argv[])
5078bc019dSStefan Eßer {
5144d4804dSStefan Eßer 	// All of these just set dc-specific items in BcVm.
5250696a6eSStefan Eßer 
53d101cdd6SStefan Eßer 	vm->read_ret = BC_INST_POP_EXEC;
54d101cdd6SStefan Eßer 	vm->help = dc_help;
55d101cdd6SStefan Eßer 	vm->sigmsg = dc_sig_msg;
56d101cdd6SStefan Eßer 	vm->siglen = dc_sig_msg_len;
5750696a6eSStefan Eßer 
58d101cdd6SStefan Eßer 	vm->next = dc_lex_token;
59d101cdd6SStefan Eßer 	vm->parse = dc_parse_parse;
60d101cdd6SStefan Eßer 	vm->expr = dc_parse_expr;
6150696a6eSStefan Eßer 
62a970610aSStefan Eßer 	return bc_vm_boot(argc, argv);
6350696a6eSStefan Eßer }
64*12e0d316SStefan Eßer 
6550696a6eSStefan Eßer #endif // DC_ENABLED
66