~ubuntu-branches/ubuntu/feisty/apex/feisty

« back to all changes in this revision

Viewing changes to src/lib/dump.c

  • Committer: Bazaar Package Importer
  • Author(s): Marc Singer
  • Date: 2006-10-22 14:20:13 UTC
  • Revision ID: james.westby@ubuntu.com-20061022142013-zy5md2199ipggdxq
Tags: 1.4.7
* New command line starts RTC.
* Moved the environment to the same block as the loader.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* dump.c
 
2
 
 
3
   written by Marc Singer
 
4
   16 Nov 2004
 
5
 
 
6
   Copyright (C) 2004 Marc Singer
 
7
 
 
8
   This program is free software; you can redistribute it and/or
 
9
   modify it under the terms of the GNU General Public License as
 
10
   published by the Free Software Foundation; either version 2 of the
 
11
   License, or (at your option) any later version.
 
12
 
 
13
   This program is distributed in the hope that it will be useful, but
 
14
   WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
16
   General Public License for more details.
 
17
 
 
18
   You should have received a copy of the GNU General Public License
 
19
   along with this program; if not, write to the Free Software
 
20
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 
21
   USA.
 
22
 
 
23
   -----------
 
24
   DESCRIPTION
 
25
   -----------
 
26
 
 
27
*/
 
28
 
 
29
#include <linux/types.h>
 
30
#include <linux/ctype.h>
 
31
#include <apex.h>
 
32
#include <command.h>
 
33
#include <driver.h>
 
34
#include <error.h>
 
35
 
 
36
void dumpw (const char* rgb, int cb, unsigned long index, int width)
 
37
{
 
38
  int i;
 
39
 
 
40
  if (   (width == 2 && ((unsigned long) rgb & 1))
 
41
      || (width == 4 && ((unsigned long) rgb & 3))) {
 
42
    printf ("%s: unable to display unaligned data\n", __FUNCTION__);
 
43
    return;
 
44
  }
 
45
 
 
46
  while (cb > 0) {
 
47
    printf ("%08lx: ", index);
 
48
    for (i = 0; i < 16; ++i) {
 
49
      if (i < cb) {
 
50
        switch (width) {
 
51
        default:
 
52
        case 1:
 
53
          printf ("%02x ", rgb[i]);
 
54
          break;
 
55
        case 2:
 
56
          printf ("%04x ", *((u16*)&rgb[i]));
 
57
          ++i;
 
58
          break;
 
59
        case 4:
 
60
          printf ("%08x ", *((u32*)&rgb[i]));
 
61
          i += 3;
 
62
          break;
 
63
        }
 
64
      }
 
65
      else
 
66
        printf ("   ");
 
67
      if (i%8 == 7)
 
68
        putchar (' ');
 
69
    }
 
70
    for (i = 0; i < 16; ++i) {
 
71
      if (i == 8)
 
72
        putchar (' ');
 
73
      putchar ( (i < cb) ? (isprint (rgb[i]) ? rgb[i] : '.') : ' ');
 
74
    }
 
75
    printf ("\n");
 
76
 
 
77
    cb -= 16;
 
78
    index += 16;
 
79
    rgb += 16;
 
80
  }
 
81
}