3 * Copyright 1999-2000 Y.Takagi. All Rights Reserved.
11 #include <Directory.h>
22 void write_debug_stream(const char *format
, ...)
26 FILE *f
= fopen("/boot/home/libprint.log", "aw+");
27 vfprintf(f
, format
, ap
);
33 void DUMP_BFILE(BFile
*in
, const char *path
)
36 if (B_NO_ERROR
== in
->GetSize(&size
)) {
37 uchar
*buffer
= new uchar
[size
];
38 in
->Read(buffer
, size
);
39 BFile
out(path
, B_WRITE_ONLY
| B_CREATE_FILE
);
40 out
.Write(buffer
, size
);
41 in
->Seek(0, SEEK_SET
);
47 void DUMP_BMESSAGE(BMessage
*msg
)
55 DBGMSG(("\t************ START - DUMP BMessage ***********\n"));
56 DBGMSG(("\taddress: 0x%x\n", (int)msg
));
60 // DBGMSG(("\tmsg->what: 0x%x\n", msg->what));
61 DBGMSG(("\tmsg->what: %c%c%c%c\n",
62 *((char *)&msg
->what
+ 3),
63 *((char *)&msg
->what
+ 2),
64 *((char *)&msg
->what
+ 1),
65 *((char *)&msg
->what
+ 0)));
67 for (i
= 0; msg
->GetInfo(B_ANY_TYPE
, i
, &name
, &type
, &count
) == B_OK
; i
++) {
70 for (j
= 0; j
< count
; j
++) {
72 aBool
= msg
->FindBool(name
, j
);
73 DBGMSG(("\t%s, B_BOOL_TYPE[%d]: %s\n",
74 name
, j
, aBool
? "true" : "false"));
79 for (j
= 0; j
< count
; j
++) {
81 msg
->FindInt8(name
, j
, &anInt8
);
82 DBGMSG(("\t%s, B_INT8_TYPE[%d]: %d\n", name
, j
, (int)anInt8
));
87 for (j
= 0; j
< count
; j
++) {
89 msg
->FindInt16(name
, j
, &anInt16
);
90 DBGMSG(("\t%s, B_INT16_TYPE[%d]: %d\n", name
, j
, (int)anInt16
));
95 for (j
= 0; j
< count
; j
++) {
97 msg
->FindInt32(name
, j
, &anInt32
);
98 DBGMSG(("\t%s, B_INT32_TYPE[%d]: %d\n", name
, j
, (int)anInt32
));
103 for (j
= 0; j
< count
; j
++) {
105 msg
->FindInt64(name
, j
, &anInt64
);
106 DBGMSG(("\t%s, B_INT64_TYPE[%d]: %d\n", name
, j
, (int)anInt64
));
111 for (j
= 0; j
< count
; j
++) {
113 msg
->FindFloat(name
, j
, &aFloat
);
114 DBGMSG(("\t%s, B_FLOAT_TYPE[%d]: %f\n", name
, j
, aFloat
));
119 for (j
= 0; j
< count
; j
++) {
121 msg
->FindDouble(name
, j
, &aDouble
);
122 DBGMSG(("\t%s, B_DOUBLE_TYPE[%d]: %f\n", name
, j
, (float)aDouble
));
127 for (j
= 0; j
< count
; j
++) {
129 msg
->FindString(name
, j
, &string
);
130 DBGMSG(("\t%s, B_STRING_TYPE[%d]: %s\n", name
, j
, string
));
135 for (j
= 0; j
< count
; j
++) {
137 msg
->FindPoint(name
, j
, &aPoint
);
138 DBGMSG(("\t%s, B_POINT_TYPE[%d]: %f, %f\n",
139 name
, j
, aPoint
.x
, aPoint
.y
));
144 for (j
= 0; j
< count
; j
++) {
146 msg
->FindRect(name
, j
, &aRect
);
147 DBGMSG(("\t%s, B_RECT_TYPE[%d]: %f, %f, %f, %f\n",
148 name
, j
, aRect
.left
, aRect
.top
, aRect
.right
, aRect
.bottom
));
154 case B_MESSENGER_TYPE
:
156 DBGMSG(("\t%s, 0x%x, count: %d\n",
157 name
? name
: "(null)", type
, count
));
160 DBGMSG(("\t%s, 0x%x, count: %d\n",
161 name
? name
: "(null)", type
, count
));
169 DBGMSG(("\t************ END - DUMP BMessage ***********\n"));
172 #define PD_DRIVER_NAME "Driver Name"
173 #define PD_PRINTER_NAME "Printer Name"
174 #define PD_COMMENTS "Comments"
176 void DUMP_BDIRECTORY(BDirectory
*dir
)
181 void DUMP_BNODE(BNode
*dir
)
191 DBGMSG(("\t************ STRAT - DUMP BNode ***********\n"));
194 while (dir
->GetNextAttrName(buffer1
) == B_NO_ERROR
) {
195 dir
->GetAttrInfo(buffer1
, &info
);
198 dir
->ReadAttr(buffer1
, info
.type
, 0, buffer2
, sizeof(buffer2
));
199 DBGMSG(("\t%s, B_ASCII_TYPE: %s\n", buffer1
, buffer2
));
202 dir
->ReadAttr(buffer1
, info
.type
, 0, buffer2
, sizeof(buffer2
));
203 DBGMSG(("\t%s, B_STRING_TYPE: %s\n", buffer1
, buffer2
));
206 dir
->ReadAttr(buffer1
, info
.type
, 0, &i
, sizeof(i
));
207 DBGMSG(("\t%s, B_INT32_TYPE: %d\n", buffer1
, i
));
210 dir
->ReadAttr(buffer1
, info
.type
, 0, &f
, sizeof(f
));
211 DBGMSG(("\t%s, B_FLOAT_TYPE: %f\n", buffer1
, f
));
214 dir
->ReadAttr(buffer1
, info
.type
, 0, &rc
, sizeof(rc
));
215 DBGMSG(("\t%s, B_RECT_TYPE: %f, %f, %f, %f\n", buffer1
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
));
218 dir
->ReadAttr(buffer1
, info
.type
, 0, &b
, sizeof(b
));
219 DBGMSG(("\t%s, B_BOOL_TYPE: %d\n", buffer1
, (int)b
));
222 DBGMSG(("\t%s, %c%c%c%c\n",
224 *((char *)&info
.type
+ 3),
225 *((char *)&info
.type
+ 2),
226 *((char *)&info
.type
+ 1),
227 *((char *)&info
.type
+ 0)));
232 DBGMSG(("\t************ END - DUMP BNode ***********\n"));