/source/print.c
C | 167 lines | 111 code | 6 blank | 50 comment | 0 complexity | 5d8ba0a9c622be92eba4f989c2bc641a MD5 | raw file
- /*******************************************************************************
- * Copyright (c) 2010, Jean-David Gadina - www.xs-labs.com
- * Distributed under the Boost Software License, Version 1.0.
- *
- * Boost Software License - Version 1.0 - August 17th, 2003
- *
- * Permission is hereby granted, free of charge, to any person or organization
- * obtaining a copy of the software and accompanying documentation covered by
- * this license (the "Software") to use, reproduce, display, distribute,
- * execute, and transmit the Software, and to prepare derivative works of the
- * Software, and to permit third-parties to whom the Software is furnished to
- * do so, all subject to the following:
- *
- * The copyright notices in the Software and this entire statement, including
- * the above license grant, this restriction and the following disclaimer,
- * must be included in all copies of the Software, in whole or in part, and
- * all derivative works of the Software, unless such copies or derivative
- * works are solely in the form of machine-executable object code generated by
- * a source language processor.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
- * SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
- * FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- ******************************************************************************/
- /* $Id$ */
- /*!
- * @header print.c
- * @copyright (c) 2010 - Jean-David Gadina - www.xs-labs.com
- * @abstract Print functions
- */
- #include "braindead.h"
- /*!
- * @function bd_print_version
- * @abstract
- * @result void
- */
- void bd_print_version( void )
- {
- printf( "Version: %s\n", BD_VERSION );
- }
- /*!
- * @function bd_print_help
- * @abstract Prints the program's help dialog
- * @param exec The program's executable name
- * @result void
- */
- void bd_print_help( char * exec )
- {
- printf
- (
- "\n"
- "Usage: %s [OPTIONS] [TARGET]\n"
- "--------------------------------------------------------------------------------\n"
- "\n"
- " - By default, enters the interactive mode and interprets brainfuck code\n"
- " from stdin.\n"
- " Type \"x\", \"X\", \"q\" or \"Q\" to exit the interactive mode.\n"
- "\n"
- " - If [TARGET] is specified, interprets it as a brainfuck code file and\n"
- " displays the result on the standard output.\n"
- "\n"
- "Code samples:\n"
- "--------------------------------------------------------------------------------\n"
- "\n"
- " - Here's the brainfuck code to use to print \"Hello World!\":\n"
- " ++++++++++\n"
- " [>+++>+++++++>++++++++>++++++++++>+++++++++++<<<<<-]\n"
- " >>++.>>+.+++++++..>+.<<<<++.>>+++++++.>>.+++.<.--------.<<<+.\n"
- "\n"
- " - Here's the brainfuck code to use to create a 'cat' like command:\n"
- " ,[.,]\n"
- "\n"
- "Examples:\n"
- "--------------------------------------------------------------------------------\n"
- "\n"
- " - Entering into interactive mode:\n"
- " $ braindead\n"
- "\n"
- " - Running a brainfuck script:\n"
- " $ braindead path/to/file\n"
- "\n"
- " - Running a brainfuck script by reading characters by characters, allocating\n"
- " only 2 stack cells at a time, and displaying debug informations:\n"
- " $ braindead -drm 1 2 path/to/file\n"
- "\n"
- " - Running a brainfuck script with input from a file instead of stdin:\n"
- " $ braindead path/to/file < path/to/input/file\n"
- "\n"
- "Available command line arguments:\n"
- "--------------------------------------------------------------------------------\n"
- "\n"
- " -h, boolean, --help\n"
- " Displays help about the command\n"
- "\n"
- " -v, boolean, --version\n"
- " Displays the version number\n"
- "\n"
- " -l, boolean, --license\n"
- " Displays the license text\n"
- "\n"
- " -m, integer, --malloc\n"
- " Allocates <X> stack cells at a time (default is 85)\n"
- "\n"
- " -r, integer, --read\n"
- " Read <X> bytes from input file at a time (default is 1024)\n"
- "\n"
- " -d, boolean, --debug\n"
- " Debug mode - Displays every operation\n"
- "\n"
- " -b, boolean, --enable-breakpoints\n"
- " Enables the use of '@' symbols in the brainfuck code for breakpoints\n"
- "\n"
- " -s, boolean, --enable-stack-debug\n"
- " Enables the use of '$' symbols in the brainfuck code for stack debugging\n"
- "\n"
- " -z, boolean, --enable-stack-reset\n"
- " Enables the use of '%%' symbols in the brainfuck code for stack reset\n"
- "\n",
- exec
- );
- }
- /*!
- * @function bd_print_license
- * @abstract Prints the program's license terms
- * @result void
- */
- void bd_print_license( void )
- {
- printf
- (
- "\n"
- "Boost Software License - Version 1.0 - August 17th, 2003\n"
- "\n"
- "Permission is hereby granted, free of charge, to any person or organization\n"
- "obtaining a copy of the software and accompanying documentation covered by\n"
- "this license (the \"Software\") to use, reproduce, display, distribute,\n"
- "execute, and transmit the Software, and to prepare derivative works of the\n"
- "Software, and to permit third-parties to whom the Software is furnished to\n"
- "do so, all subject to the following:\n"
- "\n"
- "The copyright notices in the Software and this entire statement, including\n"
- "the above license grant, this restriction and the following disclaimer,\n"
- "must be included in all copies of the Software, in whole or in part, and\n"
- "all derivative works of the Software, unless such copies or derivative\n"
- "works are solely in the form of machine-executable object code generated by\n"
- "a source language processor.\n"
- "\n"
- "THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n"
- "IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n"
- "FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT\n"
- "SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE\n"
- "FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,\n"
- "ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n"
- "DEALINGS IN THE SOFTWARE.\n"
- "\n"
- );
- }