shlwapi: Added TRACEs to PathIsURL.
[wine.git] / tools / winedump / emf.c
blobf5375d03df3539a3030c224e92fefbf740bfe0fe
1 /*
2 * Dump an Enhanced Meta File
4 * Copyright 2005 Mike McCormack
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.
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. See the GNU
14 * Lesser General Public License for more details.
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "config.h"
22 #include "wine/port.h"
23 #include "winedump.h"
25 #include <stdio.h>
26 #ifdef HAVE_UNISTD_H
27 # include <unistd.h>
28 #endif
29 #ifdef HAVE_SYS_TYPES_H
30 # include <sys/types.h>
31 #endif
32 #include <fcntl.h>
33 #include <stdarg.h>
35 #include "windef.h"
36 #include "winbase.h"
37 #include "wingdi.h"
39 static unsigned int read_int(const unsigned char *buffer)
41 return buffer[0]
42 + (buffer[1]<<8)
43 + (buffer[2]<<16)
44 + (buffer[3]<<24);
47 #define EMRCASE(x) case x: printf("%-20s %08x\n", #x, length); break
49 static unsigned offset = 0;
51 static int dump_emfrecord(void)
53 const unsigned char* ptr;
54 unsigned int type, length, i;
56 ptr = PRD(offset, 8);
57 if (!ptr) return -1;
59 type = read_int(ptr);
60 length = read_int(ptr + 4);
62 switch(type)
64 EMRCASE(EMR_HEADER);
65 EMRCASE(EMR_POLYGON);
66 EMRCASE(EMR_POLYLINE);
67 EMRCASE(EMR_SETWINDOWEXTEX);
68 EMRCASE(EMR_SETWINDOWORGEX);
69 EMRCASE(EMR_SETVIEWPORTEXTEX);
70 EMRCASE(EMR_EOF);
71 EMRCASE(EMR_SETMAPMODE);
72 EMRCASE(EMR_SETPOLYFILLMODE);
73 EMRCASE(EMR_SETROP2);
74 EMRCASE(EMR_SCALEWINDOWEXTEX);
75 EMRCASE(EMR_SAVEDC);
76 EMRCASE(EMR_SELECTOBJECT);
77 EMRCASE(EMR_CREATEPEN);
78 EMRCASE(EMR_CREATEBRUSHINDIRECT);
79 EMRCASE(EMR_DELETEOBJECT);
80 EMRCASE(EMR_RECTANGLE);
81 EMRCASE(EMR_SELECTPALETTE);
82 EMRCASE(EMR_GDICOMMENT);
83 EMRCASE(EMR_EXTSELECTCLIPRGN);
84 EMRCASE(EMR_EXTCREATEFONTINDIRECTW);
85 EMRCASE(EMR_EXTTEXTOUTW);
86 EMRCASE(EMR_POLYGON16);
87 EMRCASE(EMR_POLYLINE16);
89 default:
90 printf("%08x %08x\n",type,length);
91 break;
94 if ( (length < 8) || (length % 4) )
95 return -1;
97 length -= 8;
99 offset += 8;
101 for(i=0; i<length; i+=4)
103 if (i%16 == 0)
104 printf(" ");
105 if (!(ptr = PRD(offset, 4))) return -1;
106 offset += 4;
107 printf("%08x ", read_int(ptr));
108 if ( (i % 16 == 12) || (i + 4 == length))
109 printf("\n");
112 return 0;
115 enum FileSig get_kind_emf(void)
117 const ENHMETAHEADER* hdr;
119 hdr = PRD(0, sizeof(*hdr));
120 if (hdr && hdr->iType == EMR_HEADER && hdr->dSignature == ENHMETA_SIGNATURE)
121 return SIG_EMF;
122 return SIG_UNKNOWN;
125 void emf_dump(void)
127 offset = 0;
128 while (!dump_emfrecord());