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
34 #include "wine/unicode.h"
35 #include "wine/debug.h"
36 #include "printui_private.h"
38 WINE_DEFAULT_DEBUG_CHANNEL(printui
);
40 /* ################################# */
42 /* Must be in order with OPT_* */
43 static const WCHAR optionsW
[OPT_MAX
+1]={'a','b','c','f','h','j','l','m','n','t','r','v',0};
45 /* Must be in order with FLAG_* */
46 static const WCHAR flagsW
[FLAG_MAX
+1]={'q','w','y','z','Z',0};
49 /* ################################
50 * get_next_wstr() [Internal]
52 * Get the next WSTR, when available
56 static LPWSTR
get_next_wstr(context_t
* cx
)
62 cx
->pNextCharW
= NULL
;
66 /* Get the next Parameter, when available */
67 if (cx
->next_arg
< cx
->argc
) {
68 ptr
= cx
->argv
[cx
->next_arg
];
70 cx
->pNextCharW
= NULL
;
77 /* ################################
78 * get_next_wchar() [Internal]
80 * Get the next WCHAR from the Commandline or from the File (@ Filename)
82 * ToDo: Support Parameter from a File ( "@Filename" )
86 static WCHAR
get_next_wchar(context_t
* cx
, BOOL use_next_parameter
)
90 /* Try the next WCHAR in the actual Parameter */
97 /* We reached the end of the Parameter */
98 cx
->pNextCharW
= NULL
;
101 /* Get the next Parameter, when available and allowed */
102 if ((cx
->pNextCharW
== NULL
) && (cx
->next_arg
< cx
->argc
) && (use_next_parameter
)) {
103 cx
->pNextCharW
= cx
->argv
[cx
->next_arg
];
107 if (cx
->pNextCharW
) {
114 /* We reached the end of the Parameter */
115 cx
->pNextCharW
= NULL
;
122 /* ################################ */
123 static BOOL
parse_rundll(context_t
* cx
)
131 c
= get_next_wchar(cx
, TRUE
);
137 while ( (c
== ' ') || (c
== '\t'))
139 c
= get_next_wchar(cx
, TRUE
);
144 /* read commands from a File */
145 ptr
= get_next_wstr(cx
);
146 FIXME("redir not supported: %s\n", debugstr_w(ptr
));
150 c
= get_next_wchar(cx
, FALSE
);
154 ptr
= strchrW(optionsW
, c
);
156 index
= ptr
- optionsW
;
157 cx
->options
[index
] = get_next_wstr(cx
);
158 TRACE(" opt: %s %s\n", debugstr_w(txtW
), debugstr_w(cx
->options
[index
]));
163 ptr
= strchrW(flagsW
, c
);
165 index
= ptr
- flagsW
;
166 cx
->flags
[index
] = TRUE
;
167 TRACE("flag: %s\n", debugstr_w(txtW
));
172 cx
->subcommand
= '\0';
173 TRACE(" cmd: %s\n", debugstr_w(txtW
));
176 /* help has priority over all commands */
181 c
= get_next_wchar(cx
, FALSE
);
183 /* Some commands use two wchar */
184 if ((cx
->command
== 'd') || (cx
->command
== 'g') || (cx
->command
== 'i') ||
185 (cx
->command
== 'S') || (cx
->command
== 'X') ){
188 TRACE(" sub: %s\n", debugstr_w(txtW
));
189 c
= get_next_wchar(cx
, FALSE
);
193 c
= get_next_wchar(cx
, TRUE
);
198 /* The commands 'S' and 'X' have additional Parameter */
199 if ((cx
->command
== 'S') || (cx
->command
== 'X')) {
201 /* the actual WCHAR is the start from the extra Parameter */
203 TRACE("%d extra Parameter, starting with %s\n", 1 + (cx
->argc
- cx
->next_arg
), debugstr_w(cx
->pNextCharW
));
206 FIXME("0x%x: %s is unknown\n", c
, debugstr_wn(&c
, 1));
214 /*****************************************************
217 BOOL WINAPI
DllMain(HINSTANCE hinstDLL
, DWORD fdwReason
, LPVOID lpvReserved
)
219 TRACE("(%p, %d, %p)\n",hinstDLL
, fdwReason
, lpvReserved
);
223 case DLL_WINE_PREATTACH
:
224 return FALSE
; /* prefer native version */
226 case DLL_PROCESS_ATTACH
:
227 DisableThreadLibraryCalls( hinstDLL
);
234 /*****************************************************
235 * PrintUIEntryW [printui.@]
236 * Commandline-Interface for using printui.dll with rundll32.exe
239 void WINAPI
PrintUIEntryW(HWND hWnd
, HINSTANCE hInst
, LPCWSTR pCommand
, DWORD nCmdShow
)
244 TRACE("(%p, %p, %s, 0x%x)\n", hWnd
, hInst
, debugstr_w(pCommand
), nCmdShow
);
246 memset(&cx
, 0, sizeof(context_t
));
248 cx
.nCmdShow
= nCmdShow
;
250 if ((pCommand
) && (pCommand
[0])) {
251 /* result is allocated with GlobalAlloc() */
252 cx
.argv
= CommandLineToArgvW(pCommand
, &cx
.argc
);
253 TRACE("got %d args at %p\n", cx
.argc
, cx
.argv
);
255 res
= parse_rundll(&cx
);
258 if (res
&& cx
.command
) {
265 txtW
[0] = cx
.command
;
266 txtW
[1] = cx
.subcommand
;
268 FIXME("command not implemented: %s\n", debugstr_w(txtW
));
273 if ((res
== FALSE
) || (cx
.command
== '\0')) {
274 FIXME("dialog: Printer / The operation was not successful\n");