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
24 #define NONAMELESSUNION
35 #include "wine/unicode.h"
36 #include "wine/debug.h"
37 #include "printui_private.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(printui
);
41 /* ################################# */
43 /* Must be in order with OPT_* */
44 static const WCHAR optionsW
[OPT_MAX
+1]={'a','b','c','f','h','j','l','m','n','t','r','v',0};
46 /* Must be in order with FLAG_* */
47 static const WCHAR flagsW
[FLAG_MAX
+1]={'q','w','y','z','Z',0};
50 /* ################################
51 * get_next_wstr() [Internal]
53 * Get the next WSTR, when available
57 static LPWSTR
get_next_wstr(context_t
* cx
)
63 cx
->pNextCharW
= NULL
;
67 /* Get the next Parameter, when available */
68 if (cx
->next_arg
< cx
->argc
) {
69 ptr
= cx
->argv
[cx
->next_arg
];
71 cx
->pNextCharW
= NULL
;
78 /* ################################
79 * get_next_wchar() [Internal]
81 * Get the next WCHAR from the Commandline or from the File (@ Filename)
83 * ToDo: Support Parameter from a File ( "@Filename" )
87 static WCHAR
get_next_wchar(context_t
* cx
, BOOL use_next_parameter
)
91 /* Try the next WCHAR in the actual Parameter */
98 /* We reached the end of the Parameter */
99 cx
->pNextCharW
= NULL
;
102 /* Get the next Parameter, when available and allowed */
103 if ((cx
->pNextCharW
== NULL
) && (cx
->next_arg
< cx
->argc
) && (use_next_parameter
)) {
104 cx
->pNextCharW
= cx
->argv
[cx
->next_arg
];
108 if (cx
->pNextCharW
) {
115 /* We reached the end of the Parameter */
116 cx
->pNextCharW
= NULL
;
123 /* ################################ */
124 static BOOL
parse_rundll(context_t
* cx
)
132 c
= get_next_wchar(cx
, TRUE
);
138 while ( (c
== ' ') || (c
== '\t'))
140 c
= get_next_wchar(cx
, TRUE
);
145 /* read commands from a File */
146 ptr
= get_next_wstr(cx
);
147 FIXME("redir not supported: %s\n", debugstr_w(ptr
));
151 c
= get_next_wchar(cx
, FALSE
);
155 ptr
= strchrW(optionsW
, c
);
157 index
= ptr
- optionsW
;
158 cx
->options
[index
] = get_next_wstr(cx
);
159 TRACE(" opt: %s %s\n", debugstr_w(txtW
), debugstr_w(cx
->options
[index
]));
164 ptr
= strchrW(flagsW
, c
);
166 index
= ptr
- flagsW
;
167 cx
->flags
[index
] = TRUE
;
168 TRACE("flag: %s\n", debugstr_w(txtW
));
173 cx
->subcommand
= '\0';
174 TRACE(" cmd: %s\n", debugstr_w(txtW
));
177 /* help has priority over all commands */
182 c
= get_next_wchar(cx
, FALSE
);
184 /* Some commands use two wchar */
185 if ((cx
->command
== 'd') || (cx
->command
== 'g') || (cx
->command
== 'i') ||
186 (cx
->command
== 'S') || (cx
->command
== 'X') ){
189 TRACE(" sub: %s\n", debugstr_w(txtW
));
190 c
= get_next_wchar(cx
, FALSE
);
194 c
= get_next_wchar(cx
, TRUE
);
199 /* The commands 'S' and 'X' have additional Parameter */
200 if ((cx
->command
== 'S') || (cx
->command
== 'X')) {
202 /* the actual WCHAR is the start from the extra Parameter */
204 TRACE("%d extra Parameter, starting with %s\n", 1 + (cx
->argc
- cx
->next_arg
), debugstr_w(cx
->pNextCharW
));
207 FIXME("0x%x: %s is unknown\n", c
, debugstr_wn(&c
, 1));
215 /*****************************************************
218 BOOL WINAPI
DllMain(HINSTANCE hinstDLL
, DWORD fdwReason
, LPVOID lpvReserved
)
220 TRACE("(%p, %d, %p)\n",hinstDLL
, fdwReason
, lpvReserved
);
224 case DLL_WINE_PREATTACH
:
225 return FALSE
; /* prefer native version */
227 case DLL_PROCESS_ATTACH
:
228 DisableThreadLibraryCalls( hinstDLL
);
235 /*****************************************************
236 * PrintUIEntryW [printui.@]
237 * Commandline-Interface for using printui.dll with rundll32.exe
240 void WINAPI
PrintUIEntryW(HWND hWnd
, HINSTANCE hInst
, LPCWSTR pCommand
, DWORD nCmdShow
)
245 TRACE("(%p, %p, %s, 0x%x)\n", hWnd
, hInst
, debugstr_w(pCommand
), nCmdShow
);
247 memset(&cx
, 0, sizeof(context_t
));
249 cx
.nCmdShow
= nCmdShow
;
251 if ((pCommand
) && (pCommand
[0])) {
252 /* result is allocated with GlobalAlloc() */
253 cx
.argv
= CommandLineToArgvW(pCommand
, &cx
.argc
);
254 TRACE("got %d args at %p\n", cx
.argc
, cx
.argv
);
256 res
= parse_rundll(&cx
);
259 if (res
&& cx
.command
) {
266 txtW
[0] = cx
.command
;
267 txtW
[1] = cx
.subcommand
;
269 FIXME("command not implemented: %s\n", debugstr_w(txtW
));
274 if ((res
== FALSE
) || (cx
.command
== '\0')) {
275 FIXME("dialog: Printer / The operation was not successful\n");