/*--------------------------------------------------------------------------*\
    LINUX_LOGO 5.11 -- Shows a Logo With some System Info - 15 November 2010
    by Vince Weaver ( vince _at_ deater.net, http://www.deater.net/weave )
    SUPPORTS Linux (most architectures) and some non-Linux OSes
\*--------------------------------------------------------------------------*/

HISTORY: 
  
   Back in the summer of 1997 there was a recurring topic on the linux-kernel
   list about having a "boot-up" penguin on all architectures. There 
   were many arguments back and forth, but eventually the primary consensus 
   was that this would be better done in user-space.  [Eventually the fbcon 
   people snuck it in anyway].  In any case, those of us running on text
   consoles wanted a penguin too, and barring some attempts to use a vga-font 
   hack to get one displayed, the best way to get this was a user-space
   text-mode program.
   
   I used a ppm of the Linux penguin and a ppm2ansi converter from 
   Rasterman [www.rasterman.com], and then touched it up with a trial 
   version of THEDRAW under DosEmu.  Dredging up some talents left
   over from my Ansi-art BBS days I eventually hacked together a rough 
   likeness of Ewing's Linux Penguin.  I added some system info from 
   /proc, and linux_logo was born.
   
   The program itself has grown more "feature-full" as people around the
   world send in their patches.  The newer versions are primarily minor
   cosmetic fixes.  But I get a lot of positive feedback from this tiny
   little program I created one summer day........

-----------------------------------------------------------------------
CONFIG FILES
-----------------------------------------------------------------------

  As of 3.9b5 linux_logo now reads ~/.linux_logo [that is, the
     hidden file .linux_logo in your home directory] and
     /etc/linux_logo.conf before parsing the command line options.
     
  The format of the config files is a bit of a hack.  Just put in the
  file the command line options you want passed to linux_logo.
    
  Thus if you put in ~/.linux_logo
  
-a -c -F "Linux Logo on a #M Mhz Machine"

  Then when you run "linux_logo" it will automatically show an ASCII classic
  logo with the formatting command applied.
  
  This is a bit ugly, but is was simpler and [at the time] seemed more elegant
  than writing a separate dot file parser....
 
----------------------------------------------------------------------->
POTENTIAL USES FOR linux_logo
----------------------------------------------------------------------->

   There are so many uses, I split them off into a separate "USAGE" file.
   

 ----------------------------------------------------------------------->
 QUICKLY INSTALLING linux_logo
 ----------------------------------------------------------------------->
 
    untar and uncompress the file
        tar -xzvf linux_logo-5.11.tar.gz
	
    enter the directory
        cd linux_logo-5.11
	
    run "configure"
        ./configure
	
    compile the program
        make
	
    install (you'll probably want to do this as root) with
        make install
	

-------------------------------------------------------------------------->
ADVANCED LINUX_LOGO Installation
-------------------------------------------------------------------------->

   Destination directory:
     
      By default linux_logo is installed under /usr/local/
      
      To change this, run configure with
         "./configure --prefix=/usr"
      Where you can replace /usr with any location you want.

   Picking logos:

      You can choose which logos are compiled into linux_logo.  
      Many contributed logos can be found in the ./logos directory.
    
      By editing the file logo_config, you can pick which logos are included.
    
      You can create a linux_logo binary with ALL of them
      by doing
    
         make logos-all
       
      Note: this will overwrite the current logo_config, so be careful.
       
      Then use "linux_logo -L list" to see them, or 
      "linux_logo -L random" to randomly go through them
    
   Compile time changes:
   
      Edit the "defaults.h" file to change a lot of linux_logo's default
      behaviors.
    
   Translations:
   
      Initial internationalization support has been added.  If you are running
      with the LANGUAGE environmental variable set, and there is a translation
      for your language, then you should get linux_logo in your own tongue.
      
      This can be turned off by changing the USE_I18N option at the top
      of the defaults.h file.

   Cross compiling:

      If you are using linux_logo on an embedded system you might
      want to cross compile.  I tried to make this as easy as possible.
   
      For example, to cross-compile for avr32 on x86 (assuming you
      have all of the avr32 cross-compile tools installed) I do this:
   
         env CROSS=avr32-linux- ./configure
         make CROSS=avr32-linux- LDFLAGS=-static ARCH=avr32
       
      And the result is a working avr32 version of linux_logo

   On non-Linux architectures:
    
      You'll have to use GNU make.  This is often called "gmake".



--------------------------------------------------------------------------->
COMMAND LINE OPTIONS
--------------------------------------------------------------------------->

Usage:   linux_logo [-a] [-b] [-c] [-d] [-D file] [-e file] [-f] [-F] [-g]
                    [-h] [-i] [-k] [-l] [-n] [-o num] [-p] [-s] [-t str] [-u] [-v]
                    [-w Num] [-x] [-y] [-F format] [-L num | list | random_xx]
         [-a]     -- Display an ascii-only Logo
         [-b]     -- Display a Banner Logo!
         [-c]     -- Display a "Classic" type logo
         [-d]     -- disable "prettying" of output
         [-D file]-- use custom logo from "file"
         [-e file]-- Use "file" instead of /proc/cpuinfo [for debugging
         [-f]     -- force the screen clear before drawing
         [-F format] Format output.  See README.
      B  [-g]     -- give system info only
         [-h]     -- this help screen
	 [-i]     -- ignore the ~/.linux_logo and /etc/linux_logo.conf files
	 [-k]	  -- keep sysinfo flushed-left (non-centered)
      B  [-l]     -- display logo only
      C  [-o Num] -- offset output Num spaces to the right
         [-p]     -- preserve cursor location
         [-s]     -- skip Bogomips [speeds up on non-Linux platforms]
         [-t str] -- display user-supplied string
      *  [-u]     -- show uptime
         [-v]     -- version information
         [-w Num] -- set width of screen to Num [default 80]
      *  [-y]     -- show load average
         [-L ...] -- multiple Logo options.

 B=Banner mode only, C=Classic Mode Only  *=Works Only in Linux



More detailed explanations:

[-a]     : This option makes linux_logo output no fancy colors.  This is
           useful if you are viewing linux_logo over a black and white 
	   terminal, or a terminal that can't handle fancy escape sequences
	   well [like default win95 telnet].
	   
[-b]     : This option makes linux_logo display the first compiled-in "banner" 
           style logo.
	   
[-c]     : This option makes linux_logo display the first compiled-in 
           "classic" style logo.  Many people prefer this version of the
	   logo.  I made it myself using some complex manipulation of TheDraw 
	   and the 'official' logo.xpm that comes with the linux_sources.
	   
[-d]     : This option turns off Megahertz rounding and cpuinfo "prettying".
           That is, it prints your /proc/cpuinfo's "model name" verbatim,
	   instead of being clever and making it look nice.

[-D file]: Use an alternate logo on disk.  Just make sure 'file' points
           to a valid '.logo' file.  Read README.CUSTOM_LOGOS for more
	   info on how to make these.  Some can be found in the 
	   ./logos directory of the linux_logo distribution.

[-e file]: Specify an alternate cpuinfo file.  This is only really useful
           if you are debugging a /proc/cpuinfo file that is not from
	   your own computer.  Theoretically you could also use this to
	   make your old 386 appear to be a Pentium to users ;)

[-f]     : This option simply clears the screen before drawing the logo.

[-F format]: Use this to super-customize the output of the cpuinfo.  You 
           pass a string, for example "#V\n#U\n#L\n".  See the section
	   below entitled "THE NEAT NEW FORMAT COMMAND" for further info.

[-g]     : This option makes linux_logo display the system_info only.
           [Note.. this option only works in banner mode].  This is
	   useful if you have your own, better, ansi logo and you don't
	   want to mess with include files.  Just
	   "cat My_Logo >> out; linux_logo -g >> out" to get your logo with
	   my sysinfo.

[-h]     : This simply displays the help screen, which is much less verbose
           than this write-up.

[-i]     : linux_logo will look in ~/.linux_logo and /etc/linux_logo.conf
           for information on how to run linux_logo.  If the -i option
	   is passed, linux_logo will ignore those files

[-k]    :  keep sysinfo flushed-left (non-centered)

           In older versions of Linux_logo this modified how the logo
	   looked, I apologize for re-using the command-line option,
	   but there are only so many letters of the alphabet.

	   	   
[-l]     : This option displays the logo only [Only works in banner mode].
           This is useful if for whatever reason you don't want to see the
	   system info.

[-L num | NAME | list | random_xy]:  This option is used to manipulate compiled-in
           custom logos.  As of linux_logo 3.9 you can compile in an
	   arbitrary amount of logos, although the default is to just have
	   the original and banner logos.
	   
	   "-L list" will list all of the logos available
	   "-L NAME" will display the logo with name NAME.
	       the names available can be seen with the "-L list" command
	   "-L num" will display logo number num, where the number is
	       obtained using the "-L list" command
	   "-L random_xy" will pick a logo at random, with criteria xy.
	       When you replace x with the letter:
	          b : pick a random banner mode logo
                  c : pick a random classic mode logo
                  e : pick a logo from either banner or classic
	       When you replace y with the letter:
	          a: pick a random ascii logo
		  n: pick a non-ascii logo
		  e: pick either type of logo
	       So to summarize "-L random_ba" picks a random ascii banner,
	                       "-L random_ce" picks a random classic logo
			       "-L random_ee" picks any logo, etc, etc
			       
	   See README.CUSTOM_LOGOS for more info
	   
[-n]     : This option has been removed from linux_logo 3.9 and above.
           If you want to create a logo that looks different than the
	   default, read README.CUSTOM_LOGOS.

[-o Num] : This option will offset the logo towards the right of the screen
           Num spaces.

[-p]     : This option preserves the position of the cursor on the screen
           while drawing the logo under it.
	   
[-rX]    : This option has been removed from linux_logo 3.9 and above.
           If you want to create a logo that looks different than the
	   default, read README.CUSTOM_LOGOS.

[-s]     : This option skips the bogomips test on non-linux ports.  On 
           platforms that don't have the bogomips value in a /proc file,
	   linux_logo calculates the value itself using a GPL'd routine.
	   This can take a while, especially on slower machines, so it can
	   be disabled.
	   
[-t str] : This option displays user-supplied string (for example,
           Red Hat release or welcome...')  in first line of system info.
           See the "Things to do" section for ways to use this.
	   
[-u]     : This option displays the uptime along with the other system
           information.  While useless when putting logos in issue or motd
	   files, this option comes in handy if you are using linux_logo
	   to impress your friends.  Also, when used in conjunction with
	   the -g option, you can use linux_logo in Server-Side includes
	   in web pages.
	   
[-v]     : This option displays the version of linux_logo you are using.

[-w Num] : Use this option to set the width of the screen.  It helps in trying
           to center the banner mode. Default is 80 columns.
	   
[-x]     : This option has been removed from linux_logo 3.9 and above.
           If you want to create a logo that is narrower than the
	   default, read README.CUSTOM_LOGOS.
	   
[-y]     : Display the load average.  [Yes I have just about run out of
           letters to use as command line options ;)]

--------------------------------------------------------------------------->
TROUBLESHOOTING
--------------------------------------------------------------------------->

Know bugs: 
  
      Different architectures have odd /proc files.  If you send me
      a copy of relevant files (/proc/cpuinfo and /proc/version usually)
      I can see about adding support.
      
      On non-Linux platforms the BogoMips check can be quite slow.  To skip
         it use "linux_logo -s"
      
      To make easy updates to ansi files with difficult editors, 
         the combination ^[ is read as the ESC code (#27 decimal)
	 so this combination cannot be used in a picture.
	 
------------------------------------------------------------------------>
THE NEAT FORMAT COMMAND
------------------------------------------------------------------------>
These are instructions on how to use the Format command added in Linux Logo 3.0

The command line argument is -F.  

Special sequences start with "#" use "##" to make the "#" sign.  All other
characters [except "\n", the carriage return] are printed as is.

Special      Stands For                          Example
________________________________________________________________
  #B     Bogomips                            "374.37"
  #C     Compiled Date                       "#47 Fri Jan 8 10:37:09 EST 1999"
  #E     User Text [given with the -t]       "Given with -t option"
  #H     Hostname                            "deranged"
  #L     Load average                        "Load average 0.04, 0.01, 0.01"
  #M     Megahertz [where supported]         "188Mhz "
  #N     Number of CPU's                     "Two"
  #O     Operating System Name               "Linux"
  #P     Singular or Plural of "Processor"   "Processor"
  #R     Ram [in Megabytes]                  "64M"
  #S     Plural                              "s"
  #T     Type of CPU                         "K6"
  #U     Uptime                              "Uptime 10 hours 59 minutes"
  #V     Version of OS                       "2.2.0-pre5"
  #X     CPU Vendor                          "AMD "
  \n     carriage return


Notes:
  + The letter after the # must be capitalized.
  + Options not available are silently ignored.
  + Megahertz only available on some platforms and newer kernels.
  + See "defaults.h" on how to have #N report in non-english numbers.
  + Plural [#S] gives nothing if there is 1 cpu, gives 's' otherwise.
  + Processor [#P] gives "Processor" [or i18n equiv] when 1 cpu,
    "Processors" if more than 1.
  + The "-y" and "-u" [display uptime and load average] command line options
    don't affect the output if a custom format is used.
      
      
For example the default banner format is
"#O Version #V, Compiled #C\n#N #M#X#T #P, #R RAM, #B Bogomips Total\n#H\n"

which on my computer gives an output of:
       
      Linux Version 2.2.0-pre5, Compiled #47 Fri Jan 8 10:37:09 EST 1999
         One 188MHz AMD K6 Processor, 64M RAM, 374.37 Bogomips Total
		                    deranged
					
Another example would be
  linux_logo -F "Redhat Linux 5.2\nKernel Version #V\n#U\n#L\n"
which would give
                                Redhat Linux 5.2
			    Kernel Version 2.2.0-pre5
                            Uptime 11 hours 4 minutes
                          Load average 0.00, 0.00, 0.00
			
As you can see, the possibilities are endless.


------------------------------------------------------------------------>
CREATING/USING CUSTOM LOGOS
------------------------------------------------------------------------>
  See the file README.CUSTOM_LOGOS for more than you ever wanted to know
  about making and using your own logo files.
     
------------------------------------------------------------------------->
WHERE TO GET LINUX_LOGO:
------------------------------------------------------------------------->
  http://www.deater.net/weave/vmwprod/linux_logo
  http://sunsite.unc.edu/pub/Linux/logos/penguin/
  
Check out other programs by me at http://www.deater.net/weave/vmwprod

-------------------------------------------------------------------------->
THANKS
-------------------------------------------------------------------------->

   Many thanks to the people sending in patches and /proc/cpuinfo entries.
   Without you linux_logo wouldn't work on so many machines.
   
   Special thanks to Kristina (KRG) and my friends John Clemens and Marie
   Prosser.
   
-----------------
Vince
vince _at_ deater.net

