/* This file is part of cardwords
   (c) 1999 Tobias Peters
   see file COPYING for the copyright terms.
   
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

// cardwords_count.cc

#include "cardwords_char.hh"
#include <vector>
#include <unistd.h>

int
main (int argc, char ** argv)
{
  // Refuse to run as root:
  if (getuid() == 0 || geteuid() == 0) {
    cerr << "This program is part of a game. Do not run this program as root."
         << endl;
    return 1;
  }

  if (argc < 2) {
    cerr << "Need a charset definition file as argument."
         << endl;
    return 1;
  }
  CardWords_Char::define_from_file(argv[1]);

  CardWords_Char c;
  vector<size_t> occurrences (CardWords_Char::noOfChars(), 0);

  while (cin) {
    cin >> c;
    occurrences[c.internal_no()]++;
  }

  size_t index;
  for (index = 1; index < occurrences.size(); ++index) {
    cout << CardWords_Char::get_cardwords_char_with_internal_no(index)
         << ": "
         << occurrences[index]
         << endl;
  }
}
