banner.c

来自「This a framework to test new ideas in tr」· C语言 代码 · 共 175 行

C
175
字号
/***************************************************************** * * SYSVbanner.c * * This is a PD version of the SYS V banner program (at least I think * it is compatible to SYS V) which I wrote to use with the clock * program written by: **     DCF, Inc. **     14623 North 49th Place **     Scottsdale, AZ 85254 * and published in the net comp.sources.misc newsgroup in early July * since the BSD banner program works quite differently. * * There is no copyright or responsibility accepted for the use * of this software. * * Brian Wallis, brw@jim.odr.oz, 4 July 1988 * *****************************************************************//* Changes by David Frey, david@eos.lugs.ch, 3 February 1997: * 1. protoized and indented, 2. changed @ character to # */#include <stdio.h>#include <stdlib.h>#include <string.h>char *glyphs[] =  {    "         ###  ### ###  # #   ##### ###   #  ##     ###  ",    "         ###  ### ###  # #  #  #  ## #  #  #  #    ###   ",    "         ###   #   # ########  #   ### #    ##      #   ",    "          #            # #   #####    #    ###     #    ",    "                     #######   #  #  # ####   # #       ",    "         ###           # #  #  #  # #  # ##    #        ",    "         ###           # #   ##### #   ### #### #       ",    "   ##    ##                                            #",    "  #        #   #   #    #                             # ",    " #          #   # #     #                            #  ",    " #          # ### ### #####   ###   #####           #   ",    " #          #   # #     #     ###           ###    #    ",    "  #        #   #   #    #      #            ###   #     ",    "   ##    ##                   #             ###  #      ",    "  ###     #    #####  ##### #      ####### ##### #######",    " #   #   ##   #     ##     ##    # #      #     ##    # ",    "# #   # # #         #      ##    # #      #          #  ",    "#  #  #   #    #####  ##### ####### ##### ######    #   ",    "#   # #   #   #            #     #       ##     #  #    ",    " #   #    #   #      #     #     # #     ##     #  #    ",    "  ###   ##### ####### #####      #  #####  #####   #    ",    " #####  #####    #     ###      #           #     ##### ",    "#     ##     #  # #    ###     #             #   #     #",    "#     ##     #   #            #     #####     #        #",    " #####  ######         ###   #                 #     ## ",    "#     #      #   #     ###    #     #####     #     #   ",    "#     ##     #  # #     #      #             #          ",    " #####  #####    #     #        #           #       #   ",    " #####    #   ######  ##### ###### ############## ##### ",    "#     #  # #  #     ##     ##     ##      #      #     #",    "# ### # #   # #     ##      #     ##      #      #      ",    "# # # ##     ####### #      #     ######  #####  #  ####",    "# #### ########     ##      #     ##      #      #     #",    "#     ##     ##     ##     ##     ##      #      #     #",    " ##### #     #######  ##### ###### ########       ##### ",    "#     #  ###        ##    # #      #     ##     ########",    "#     #   #         ##   #  #      ##   ####    ##     #",    "#     #   #         ##  #   #      # # # ## #   ##     #",    "#######   #         ####    #      #  #  ##  #  ##     #",    "#     #   #   #     ##  #   #      #     ##   # ##     #",    "#     #   #   #     ##   #  #      #     ##    ###     #",    "#     #  ###   ##### #    # ########     ##     ########",    "######  ##### ######  ##### ########     ##     ##     #",    "#     ##     ##     ##     #   #   #     ##     ##  #  #",    "#     ##     ##     ##         #   #     ##     ##  #  #",    "###### #     #######  #####    #   #     ##     ##  #  #",    "#      #   # ##   #        #   #   #     # #   # #  #  #",    "#      #    # #    # #     #   #   #     #  # #  #  #  #",    "#       #### ##     # #####    #    #####    #    ## ## ",    "#     ##     ######## ##### #       #####    #          ",    " #   #  #   #      #  #      #          #   # #         ",    "  # #    # #      #   #       #         #  #   #        ",    "   #      #      #    #        #        #               ",    "  # #     #     #     #         #       #               ",    " #   #    #    #      #          #      #               ",    "#     #   #   ####### #####       # #####        #######",    "  ###                                                   ",    "  ###     ##   #####   ####  #####  ###### ######  #### ",    "   #     #  #  #    # #    # #    # #      #      #    #",    "    #   #    # #####  #      #    # #####  #####  #     ",    "        ###### #    # #      #    # #      #      #  ###",    "        #    # #    # #    # #    # #      #      #    #",    "        #    # #####   ####  #####  ###### #       #### ",    "                                                        ",    " #    #    #        # #    # #      #    # #    #  #### ",    " #    #    #        # #   #  #      ##  ## ##   # #    #",    " ######    #        # ####   #      # ## # # #  # #    #",    " #    #    #        # #  #   #      #    # #  # # #    #",    " #    #    #   #    # #   #  #      #    # #   ## #    #",    " #    #    #    ####  #    # ###### #    # #    #  #### ",    "                                                        ",    " #####   ####  #####   ####   ##### #    # #    # #    #",    " #    # #    # #    # #         #   #    # #    # #    #",    " #    # #    # #    #  ####     #   #    # #    # #    #",    " #####  #  # # #####       #    #   #    # #    # # ## #",    " #      #   #  #   #  #    #    #   #    #  #  #  ##  ##",    " #       ### # #    #  ####     #    ####    ##   #    #",    "                       ###     #     ###   ##    # # # #",    " #    #  #   # ###### #        #        # #  #  # # # # ",    "  #  #    # #      #  #        #        #     ## # # # #",    "   ##      #      #  ##                 ##        # # # ",    "   ##      #     #    #        #        #        # # # #",    "  #  #     #    #     #        #        #         # # # ",    " #    #    #   ######  ###     #     ###         # # # #"};void drawLine( char *txt, int len ){  int a, b, c, ind;  char *line;    line = malloc( len * 8 );  for (a = 0; a < 7; a++) {    for (b = 0; b < len; b++) {      if ((ind = txt[b] - ' ') < 0)	ind = 0;      for (c = 0; c < 7; c++) {	line[b * 8 + c] = glyphs[(ind / 8 * 7) + a][(ind % 8 * 7) + c];      }      line[b * 8 + 7] = ' ';    }    for (b = len * 8 - 1; b >= 0; b--) {      if (line[b] != ' ')	break;      line[b] = '\0';    }    puts(line);  }  free( line );  puts("");}int main(int argc, char **argv) {  int len;  char *env, *t;  int columns = 80;  env = getenv( "COLUMNS" );  if ( env ){    columns = atoi( env );  }  columns /= 8;  for (argv++; --argc; argv++) {    t = *argv;    len = strlen( t );    while ( len > 0 ){      drawLine( t, len < columns ? len : columns );      len -= columns;      t += columns;    }  }  return 0;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?