1 /////////////////////////////////////////////////////////////////////////
2 // $Id: usage.cc,v 1.4 2003/10/07 01:44:34 danielg4 Exp $
3 /////////////////////////////////////////////////////////////////////////
5 // Copyright (C) 2001 MandrakeSoft S.A.
9 // 75002 Paris - France
10 // http://www.linux-mandrake.com/
11 // http://www.mandrakesoft.com/
13 // This library is free software; you can redistribute it and/or
14 // modify it under the terms of the GNU Lesser General Public
15 // License as published by the Free Software Foundation; either
16 // version 2 of the License, or (at your option) any later version.
18 // This library is distributed in the hope that it will be useful,
19 // but WITHOUT ANY WARRANTY; without even the implied warranty of
20 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 // Lesser General Public License for more details.
23 // You should have received a copy of the GNU Lesser General Public
24 // License along with this library; if not, write to the Free Software
25 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 #include <sys/types.h>
35 unsigned char bios
[65536];
38 main(int argc
, char *argv
[])
42 unsigned org
, last_org
, offset
;
44 unsigned int to_read
, index
;
45 double elements
, ratio
;
48 fprintf(stderr
, "Usage: usage bios-file org-file\n");
52 bios_file
= open(argv
[1], O_RDONLY
);
53 org_file
= fopen(argv
[2], "r");
55 if ( (bios_file
<0) | (org_file
==NULL
) ) {
56 fprintf(stderr
, "problems opening files.\n");
60 printf("files opened OK\n");
65 retval
= read(bios_file
, &bios
[index
], to_read
);
67 fprintf(stderr
, "problem reading bios file\n");
73 printf("bios file read in OK\n");
78 retval
= fscanf(org_file
, "0x%x\n", &org
);
79 if (retval
<= 0) break;
80 printf("%04x .. %04x ", last_org
, org
-1);
81 for (offset
=org
-1; offset
>last_org
; offset
--) {
82 if (bios
[offset
] != 0) break;
84 if (offset
> last_org
) {
85 elements
= (1.0 + double(offset
) - double(last_org
));
88 if (bios
[last_org
] == 0)
94 ratio
= elements
/ (double(org
) - double(last_org
));
96 printf("%6.2lf\n", ratio
);