root/trunk/freebob/src/debugmodule.cpp

Revision 18, 2.2 kB (checked in by pieterpalmers, 19 years ago)

- Placed some extra debug functions in a new file debugmodule.cpp
- Added AvDescriptor? class as a generic AVC descriptor handler class
- Added the new files to the makefile

REMARK: The new code is still quite messy and undebugged. This commit is mainly to expose my current work, to make sure no work is duplicated.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 /* debugmodule.h
2  * Copyright (C) 2004 by Pieter Palmers
3  *
4  * This file is part of FreeBob.
5  *
6  * FreeBob is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  * FreeBob is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with FreeBob; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
18  * MA 02111-1307 USA.
19  */
20 #include "debugmodule.h"
21
22 unsigned char toAscii(unsigned char c) {
23         if (c>31 && c<126) {
24                 return c;
25         } else {
26                 return '.';
27         }
28
29 }
30
31 /* converts a quadlet to a uchar * buffer
32  * not implemented optimally, but clear
33  */
34 void quadlet2char(quadlet_t quadlet,unsigned char* buff) {
35         *(buff)=(quadlet>>24)&0xFF;
36         *(buff+1)=(quadlet>>16)&0xFF;
37         *(buff+2)=(quadlet>>8)&0xFF;
38         *(buff+3)=(quadlet)&0xFF;
39 }
40
41 void hexDump(unsigned char *data_start, unsigned int length) {
42         unsigned int i=0;
43         unsigned int byte_pos;
44         unsigned int bytes_left;
45         //printf("hexdump: %p %d\n",data_start,length);
46        
47         if(length<=0) return;
48         if(length>=7) {
49                 for(i=0;i<(length-7);i+=8) {
50                         printf("%04X: %02X %02X %02X %02X %02X %02X %02X %02X - [%c%c%c%c%c%c%c%c]\n",i,
51                                 *(data_start+i+0),*(data_start+i+1),*(data_start+i+2),*(data_start+i+3),*(data_start+i+4),*(data_start+i+5),*(data_start+i+6),*(data_start+i+7),
52                                 toAscii(*(data_start+i+0)),toAscii(*(data_start+i+1)),toAscii(*(data_start+i+2)),toAscii(*(data_start+i+3)),toAscii(*(data_start+i+4)),toAscii(*(data_start+i+5)),toAscii(*(data_start+i+6)),toAscii(*(data_start+i+7))
53                                 );
54                 }
55         }
56         byte_pos=i;
57         bytes_left=length-byte_pos;
58        
59         printf("%04X:",i);
60         for (i=byte_pos;i<length;i+=1) {
61                 printf(" %02X",*(data_start+i));
62         }
63         for (i=0;i<8-bytes_left;i+=1) {
64                 printf("   ");
65         }
66
67         printf(" - [");
68         for (i=byte_pos;i<length;i+=1) {
69                 printf("%c",toAscii(*(data_start+i)));
70         }
71         for (i=0;i<8-bytes_left;i+=1) {
72                 printf(" ");
73         }
74        
75         printf("]");
76         printf("\n");
77
78 }
Note: See TracBrowser for help on using the browser.