2 * Implementation of the Printer User Interface Dialogs
4 * Copyright 2006-2007 Detlef Riekenberg
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 #define WIN32_NO_STATUS
23 #define COM_NO_WINDOWS_H
28 #define NONAMELESSUNION
33 //#include "winuser.h"
39 #include <wine/unicode.h>
40 #include <wine/debug.h>
41 #include "printui_private.h"
43 WINE_DEFAULT_DEBUG_CHANNEL(printui
);
45 /* ################################# */
47 /* Must be in order with OPT_* */
48 static const WCHAR optionsW
[OPT_MAX
+1]={'a','b','c','f','h','j','l','m','n','t','r','v',0};
50 /* Must be in order with FLAG_* */
51 static const WCHAR flagsW
[FLAG_MAX
+1]={'q','w','y','z','Z',0};
54 /* ################################
55 * get_next_wstr() [Internal]
57 * Get the next WSTR, when available
61 static LPWSTR
get_next_wstr(context_t
* cx
)
67 cx
->pNextCharW
= NULL
;
71 /* Get the next Parameter, when available */
72 if (cx
->next_arg
< cx
->argc
) {
73 ptr
= cx
->argv
[cx
->next_arg
];
75 cx
->pNextCharW
= NULL
;
82 /* ################################
83 * get_next_wchar() [Internal]
85 * Get the next WCHAR from the Commandline or from the File (@ Filename)
87 * ToDo: Support Parameter from a File ( "@Filename" )
91 static WCHAR
get_next_wchar(context_t
* cx
, BOOL use_next_parameter
)
95 /* Try the next WCHAR in the actual Parameter */
102 /* We reached the end of the Parameter */
103 cx
->pNextCharW
= NULL
;
106 /* Get the next Parameter, when available and allowed */
107 if ((cx
->pNextCharW
== NULL
) && (cx
->next_arg
< cx
->argc
) && (use_next_parameter
)) {
108 cx
->pNextCharW
= cx
->argv
[cx
->next_arg
];
112 if (cx
->pNextCharW
) {
119 /* We reached the end of the Parameter */
120 cx
->pNextCharW
= NULL
;
127 /* ################################ */
128 static BOOL
parse_rundll(context_t
* cx
)
136 c
= get_next_wchar(cx
, TRUE
);
142 while ( (c
== ' ') || (c
== '\t'))
144 c
= get_next_wchar(cx
, TRUE
);
149 /* read commands from a File */
150 ptr
= get_next_wstr(cx
);
151 FIXME("redir not supported: %s\n", debugstr_w(ptr
));
155 c
= get_next_wchar(cx
, FALSE
);
159 ptr
= strchrW(optionsW
, c
);
161 index
= ptr
- optionsW
;
162 cx
->options
[index
] = get_next_wstr(cx
);
163 TRACE(" opt: %s %s\n", debugstr_w(txtW
), debugstr_w(cx
->options
[index
]));
168 ptr
= strchrW(flagsW
, c
);
170 index
= ptr
- flagsW
;
171 cx
->flags
[index
] = TRUE
;
172 TRACE("flag: %s\n", debugstr_w(txtW
));
177 cx
->subcommand
= '\0';
178 TRACE(" cmd: %s\n", debugstr_w(txtW
));
181 /* help has priority over all commands */
186 c
= get_next_wchar(cx
, FALSE
);
188 /* Some commands use two wchar */
189 if ((cx
->command
== 'd') || (cx
->command
== 'g') || (cx
->command
== 'i') ||
190 (cx
->command
== 'S') || (cx
->command
== 'X') ){
193 TRACE(" sub: %s\n", debugstr_w(txtW
));
194 c
= get_next_wchar(cx
, FALSE
);
198 c
= get_next_wchar(cx
, TRUE
);
203 /* The commands 'S' and 'X' have additional Parameter */
204 if ((cx
->command
== 'S') || (cx
->command
== 'X')) {
206 /* the actual WCHAR is the start from the extra Parameter */
208 TRACE("%d extra Parameter, starting with %s\n", 1 + (cx
->argc
- cx
->next_arg
), debugstr_w(cx
->pNextCharW
));
211 FIXME("0x%x: %s is unknown\n", c
, debugstr_wn(&c
, 1));
219 /*****************************************************
222 BOOL WINAPI
DllMain(HINSTANCE hinstDLL
, DWORD fdwReason
, LPVOID lpvReserved
)
224 TRACE("(%p, %d, %p)\n",hinstDLL
, fdwReason
, lpvReserved
);
228 case DLL_WINE_PREATTACH
:
229 return FALSE
; /* prefer native version */
231 case DLL_PROCESS_ATTACH
:
232 DisableThreadLibraryCalls( hinstDLL
);
239 /*****************************************************
240 * PrintUIEntryW [printui.@]
241 * Commandline-Interface for using printui.dll with rundll32.exe
244 void WINAPI
PrintUIEntryW(HWND hWnd
, HINSTANCE hInst
, LPCWSTR pCommand
, DWORD nCmdShow
)
249 TRACE("(%p, %p, %s, 0x%x)\n", hWnd
, hInst
, debugstr_w(pCommand
), nCmdShow
);
251 memset(&cx
, 0, sizeof(context_t
));
253 cx
.nCmdShow
= nCmdShow
;
255 if ((pCommand
) && (pCommand
[0])) {
256 /* result is allocated with GlobalAlloc() */
257 cx
.argv
= CommandLineToArgvW(pCommand
, &cx
.argc
);
258 TRACE("got %d args at %p\n", cx
.argc
, cx
.argv
);
260 res
= parse_rundll(&cx
);
263 if (res
&& cx
.command
) {
270 txtW
[0] = cx
.command
;
271 txtW
[1] = cx
.subcommand
;
273 FIXME("command not implemented: %s\n", debugstr_w(txtW
));
278 if ((res
== FALSE
) || (cx
.command
== '\0')) {
279 FIXME("dialog: Printer / The operation was not successful\n");