1 |
/* |
2 |
The Malete project - the Z39.2/Z39.50 database framework of OpenIsis. |
3 |
Version 0.9.x (patchlevel see file Version) |
4 |
Copyright (C) 2001-2003 by Erik Grziwotz, erik@openisis.org |
5 |
|
6 |
This library is free software; you can redistribute it and/or |
7 |
modify it under the terms of the GNU Lesser General Public |
8 |
License as published by the Free Software Foundation; either |
9 |
version 2.1 of the License, or (at your option) any later version. |
10 |
|
11 |
This library is distributed in the hope that it will be useful, |
12 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
14 |
See the GNU Lesser General Public License for more details. |
15 |
|
16 |
You should have received a copy of the GNU Lesser General Public |
17 |
License along with this library; if not, write to the Free Software |
18 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
19 |
|
20 |
see README for more information |
21 |
EOH */ |
22 |
|
23 |
/* |
24 |
$Id: bytestat.c,v 1.1 2004/11/03 12:56:28 kripke Exp $ |
25 |
count usage of bytes in stream |
26 |
*/ |
27 |
|
28 |
#include <unistd.h> |
29 |
#include <stdio.h> |
30 |
|
31 |
static unsigned int cnt[256]; |
32 |
static unsigned char buf[0x2000]; |
33 |
|
34 |
int main (int argc, char **argv) |
35 |
{ |
36 |
int i; |
37 |
while (0 < (i = read(0, buf, sizeof buf))) { |
38 |
unsigned char *p = buf+i; |
39 |
while (p-- > buf) cnt[*p]++; |
40 |
} |
41 |
for (i=0; i<256; i++) |
42 |
if (cnt[i]) |
43 |
printf("%3d\t'%c'\t%d\n", i, 0xe0&i ? i : '?', cnt[i]); |
44 |
return 0; |
45 |
} |