gdi32: Add a test for bitmap fonts selected for not existing font sizes.
[wine/multimedia.git] / programs / icinfo / icinfo.c
blob1801d098c5222d1e249364499f7532880dee776c
1 /*
2 * Copyright 1999 Marcus Meissner
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #include <stdio.h>
20 #include <string.h>
21 #include <wine/unicode.h>
22 #include "windows.h"
23 #include "mmsystem.h"
24 #include "vfw.h"
26 static int mywprintf(const WCHAR *format, ...)
28 static char output_bufA[65536];
29 static WCHAR output_bufW[sizeof(output_bufA) / sizeof(WCHAR)];
30 va_list parms;
31 DWORD nOut;
32 int len;
33 BOOL res = FALSE;
34 HANDLE hout = GetStdHandle(STD_OUTPUT_HANDLE);
36 va_start(parms, format);
37 len = vsnprintfW(output_bufW, sizeof(output_bufW), format, parms);
38 va_end(parms);
39 if (len < 0)
41 /* String too long */
42 return 0;
45 /* Try to write as unicode whenever we think it's a console */
46 if (((DWORD_PTR)hout & 3) == 3)
48 res = WriteConsoleW(hout, output_bufW, len, &nOut, NULL);
50 else
52 BOOL usedDefaultChar = FALSE;
53 DWORD convertedChars;
55 /* Convert to OEM, then output */
56 convertedChars = WideCharToMultiByte(GetConsoleOutputCP(), 0, output_bufW, len,
57 output_bufA, sizeof(output_bufA),
58 "?", &usedDefaultChar);
59 res = WriteFile(hout, output_bufA, convertedChars, &nOut, FALSE);
62 return res ? nOut : 0;
65 int wmain(int argc, WCHAR* argv[])
67 int i, n=0,doabout=0,doconfigure=0;
69 static const WCHAR header[] = {'C','u','r','r','e','n','t','l','y',' ','i','n','s','t','a','l','l','e','d',' ',
70 'V','i','d','e','o',' ','C','o','m','p','r','e','s','s','o','r','s',':','\n',0};
71 static const WCHAR close_flags[] = {')','\n',0};
72 static const WCHAR s_fmt[] = {'%','s',0};
73 static const WCHAR sspc_fmt[] = {'%','s',' ',0};
74 static const WCHAR fcc_fmt[] = {'%','c','%','c','%','c','%','c','.','%','c','%','c','%','c','%','c',':',' ','%','s','\n',0};
75 static const WCHAR desc_fmt[] = {'\t','s','z','D','e','s','c','r','i','p','t','i','o','n',':',' ','%','s','\n',0};
76 static const WCHAR flags_fmt[] = {'\t','d','w','F','l','a','g','s',':',' ','0','x','%','0','8','x',' ','(',0};
77 static const WCHAR version_fmt[] = {'\t','d','w','V','e','r','s','i','o','n',':',' ','0','x','%','0','8','x','\n',0};
78 static const WCHAR versicm_fmt[] = {'\t','d','w','V','e','r','s','i','o','n','I','C','M',':',' ','0','x','%','0','8','x','\n',0};
79 static const WCHAR VIDCF_QUALITY_W[] = {'V','I','D','C','F','_','Q','U','A','L','I','T','Y',0};
80 static const WCHAR VIDCF_CRUNCH_W[] = {'V','I','D','C','F','_','C','R','U','N','C','H',0};
81 static const WCHAR VIDCF_TEMPORAL_W[] = {'V','I','D','C','F','_','T','E','M','P','O','R','A','L',0};
82 static const WCHAR VIDCF_COMPRESSFRAMES_W[] = {'V','I','D','C','F','_','C','O','M','P','R','E','S','S','F','R','A','M','E','S',0};
83 static const WCHAR VIDCF_DRAW_W[] = {'V','I','D','C','F','_','D','R','A','W',0};
84 static const WCHAR VIDCF_FASTTEMPORALC_W[] = {'V','I','D','C','F','_','F','A','S','T','T','E','M','P','O','R','A','L','C',0};
85 static const WCHAR VIDCF_FASTTEMPORALD_W[] = {'V','I','D','C','F','_','F','A','S','T','T','E','M','P','O','R','A','L','D',0};
86 static const WCHAR VIDCF_QUALITYTIME_W[] = {'V','I','D','C','F','_','Q','U','A','L','I','T','Y','T','I','M','E',0};
87 static const WCHAR about[] = {'-','a','b','o','u','t','\0'};
88 static const WCHAR configure[] = {'-','c','o','n','f','i','g','u','r','e','\0'};
89 static const WCHAR unk_opt_fmt[] = {'U','n','k','n','o','w','n',' ','o','p','t','i','o','n',':',' ','%','s','\n',0};
91 for (i = 1; i < argc; i++) {
92 if (!strcmpW(argv[i], about))
93 doabout = 1;
94 else if (!strcmpW(argv[i], configure))
95 doconfigure = 1;
96 else {
97 mywprintf(unk_opt_fmt, argv[i]);
98 return -1;
102 mywprintf(s_fmt, header);
103 while (1) {
104 ICINFO ii;
105 HIC hic;
107 ii.dwSize = sizeof(ii);
108 if (!ICInfo(ICTYPE_VIDEO,n++,&ii))
109 break;
110 if (!(hic=ICOpen(ii.fccType,ii.fccHandler,ICMODE_QUERY)))
111 continue;
112 if (!ICGetInfo(hic,&ii,sizeof(ii))) {
113 ICClose(hic);
114 continue;
117 mywprintf(fcc_fmt,
118 LOBYTE(ii.fccType),LOBYTE(ii.fccType>>8),LOBYTE(ii.fccType>>16),LOBYTE(ii.fccType>>24),
119 LOBYTE(ii.fccHandler),LOBYTE(ii.fccHandler>>8),LOBYTE(ii.fccHandler>>16),LOBYTE(ii.fccHandler>>24),
120 ii.szName);
121 mywprintf(flags_fmt,ii.dwFlags);
123 if (ii.dwFlags & VIDCF_QUALITY) mywprintf(sspc_fmt, VIDCF_QUALITY_W);
124 if (ii.dwFlags & VIDCF_CRUNCH) mywprintf(sspc_fmt, VIDCF_CRUNCH_W);
125 if (ii.dwFlags & VIDCF_TEMPORAL) mywprintf(sspc_fmt, VIDCF_TEMPORAL_W);
126 if (ii.dwFlags & VIDCF_COMPRESSFRAMES) mywprintf(sspc_fmt, VIDCF_COMPRESSFRAMES_W);
127 if (ii.dwFlags & VIDCF_DRAW) mywprintf(sspc_fmt, VIDCF_DRAW_W);
128 if (ii.dwFlags & VIDCF_FASTTEMPORALC) mywprintf(sspc_fmt, VIDCF_FASTTEMPORALC_W);
129 if (ii.dwFlags & VIDCF_FASTTEMPORALD) mywprintf(sspc_fmt, VIDCF_FASTTEMPORALD_W);
130 if (ii.dwFlags & VIDCF_QUALITYTIME) mywprintf(sspc_fmt, VIDCF_QUALITYTIME_W);
132 mywprintf(s_fmt, close_flags);
133 mywprintf(version_fmt,ii.dwVersion);
134 mywprintf(versicm_fmt,ii.dwVersionICM);
135 mywprintf(desc_fmt,ii.szDescription);
136 if (doabout) ICAbout(hic,0);
137 if (doconfigure && ICQueryConfigure(hic))
138 ICConfigure(hic,0);
139 ICClose(hic);
141 return 0;