xref: /freebsd/contrib/bc/src/bc.c (revision d101cdd6)
150696a6eSStefan Eßer /*
250696a6eSStefan Eßer  * *****************************************************************************
350696a6eSStefan Eßer  *
450696a6eSStefan Eßer  * SPDX-License-Identifier: BSD-2-Clause
550696a6eSStefan Eßer  *
6d101cdd6SStefan Eßer  * Copyright (c) 2018-2023 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 bc.
3350696a6eSStefan Eßer  *
3450696a6eSStefan Eßer  */
3550696a6eSStefan Eßer 
3650696a6eSStefan Eßer #if BC_ENABLED
3750696a6eSStefan Eßer 
3850696a6eSStefan Eßer #include <string.h>
3950696a6eSStefan Eßer 
4050696a6eSStefan Eßer #include <bc.h>
4150696a6eSStefan Eßer #include <vm.h>
4250696a6eSStefan Eßer 
4344d4804dSStefan Eßer /**
4444d4804dSStefan Eßer  * The main function for bc.
4544d4804dSStefan Eßer  * @param argc  The number of arguments.
4644d4804dSStefan Eßer  * @param argv  The arguments.
4744d4804dSStefan Eßer  */
4878bc019dSStefan Eßer void
bc_main(int argc,char * argv[])4978bc019dSStefan Eßer bc_main(int argc, char* argv[])
5078bc019dSStefan Eßer {
5144d4804dSStefan Eßer 	// All of these just set bc-specific items in BcVm.
5250696a6eSStefan Eßer 
53d101cdd6SStefan Eßer 	vm->read_ret = BC_INST_RET;
54d101cdd6SStefan Eßer 	vm->help = bc_help;
55d101cdd6SStefan Eßer 	vm->sigmsg = bc_sig_msg;
56d101cdd6SStefan Eßer 	vm->siglen = bc_sig_msg_len;
5750696a6eSStefan Eßer 
58d101cdd6SStefan Eßer 	vm->next = bc_lex_token;
59d101cdd6SStefan Eßer 	vm->parse = bc_parse_parse;
60d101cdd6SStefan Eßer 	vm->expr = bc_parse_expr;
6150696a6eSStefan Eßer 
6244d4804dSStefan Eßer 	bc_vm_boot(argc, argv);
6350696a6eSStefan Eßer }
6450696a6eSStefan Eßer #endif // BC_ENABLED
65