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/debug.h"
35 #include "printui_private.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(printui
);
39 /* ################################# */
41 /* Must be in order with OPT_* */
42 static const WCHAR optionsW
[OPT_MAX
+1]={'a','b','c','f','h','j','l','m','n','t','r','v',0};
44 /* Must be in order with FLAG_* */
45 static const WCHAR flagsW
[FLAG_MAX
+1]={'q','w','y','z','Z',0};
48 /* ################################
49 * get_next_wstr() [Internal]
51 * Get the next WSTR, when available
55 static LPWSTR
get_next_wstr(context_t
* cx
)
61 cx
->pNextCharW
= NULL
;
65 /* Get the next Parameter, when available */
66 if (cx
->next_arg
< cx
->argc
) {
67 ptr
= cx
->argv
[cx
->next_arg
];
69 cx
->pNextCharW
= NULL
;
76 /* ################################
77 * get_next_wchar() [Internal]
79 * Get the next WCHAR from the Commandline or from the File (@ Filename)
81 * ToDo: Support Parameter from a File ( "@Filename" )
85 static WCHAR
get_next_wchar(context_t
* cx
, BOOL use_next_parameter
)
89 /* Try the next WCHAR in the actual Parameter */
96 /* We reached the end of the Parameter */
97 cx
->pNextCharW
= NULL
;
100 /* Get the next Parameter, when available and allowed */
101 if ((cx
->pNextCharW
== NULL
) && (cx
->next_arg
< cx
->argc
) && (use_next_parameter
)) {
102 cx
->pNextCharW
= cx
->argv
[cx
->next_arg
];
106 if (cx
->pNextCharW
) {
113 /* We reached the end of the Parameter */
114 cx
->pNextCharW
= NULL
;
121 /* ################################ */
122 static BOOL
parse_rundll(context_t
* cx
)
130 c
= get_next_wchar(cx
, TRUE
);
136 while ( (c
== ' ') || (c
== '\t'))
138 c
= get_next_wchar(cx
, TRUE
);
143 /* read commands from a File */
144 ptr
= get_next_wstr(cx
);
145 FIXME("redir not supported: %s\n", debugstr_w(ptr
));
149 c
= get_next_wchar(cx
, FALSE
);
153 ptr
= wcschr(optionsW
, c
);
155 index
= ptr
- optionsW
;
156 cx
->options
[index
] = get_next_wstr(cx
);
157 TRACE(" opt: %s %s\n", debugstr_w(txtW
), debugstr_w(cx
->options
[index
]));
162 ptr
= wcschr(flagsW
, c
);
164 index
= ptr
- flagsW
;
165 cx
->flags
[index
] = TRUE
;
166 TRACE("flag: %s\n", debugstr_w(txtW
));
171 cx
->subcommand
= '\0';
172 TRACE(" cmd: %s\n", debugstr_w(txtW
));
175 /* help has priority over all commands */
180 c
= get_next_wchar(cx
, FALSE
);
182 /* Some commands use two wchar */
183 if ((cx
->command
== 'd') || (cx
->command
== 'g') || (cx
->command
== 'i') ||
184 (cx
->command
== 'S') || (cx
->command
== 'X') ){
187 TRACE(" sub: %s\n", debugstr_w(txtW
));
188 c
= get_next_wchar(cx
, FALSE
);
192 c
= get_next_wchar(cx
, TRUE
);
197 /* The commands 'S' and 'X' have additional Parameter */
198 if ((cx
->command
== 'S') || (cx
->command
== 'X')) {
200 /* the actual WCHAR is the start from the extra Parameter */
202 TRACE("%d extra Parameter, starting with %s\n", 1 + (cx
->argc
- cx
->next_arg
), debugstr_w(cx
->pNextCharW
));
205 FIXME("0x%x: %s is unknown\n", c
, debugstr_wn(&c
, 1));
213 /*****************************************************
214 * PrintUIEntryW [printui.@]
215 * Commandline-Interface for using printui.dll with rundll32.exe
218 void WINAPI
PrintUIEntryW(HWND hWnd
, HINSTANCE hInst
, LPCWSTR pCommand
, DWORD nCmdShow
)
223 TRACE("(%p, %p, %s, 0x%lx)\n", hWnd
, hInst
, debugstr_w(pCommand
), nCmdShow
);
225 memset(&cx
, 0, sizeof(context_t
));
227 cx
.nCmdShow
= nCmdShow
;
229 if ((pCommand
) && (pCommand
[0])) {
230 /* result is allocated with LocalAlloc() */
231 cx
.argv
= CommandLineToArgvW(pCommand
, &cx
.argc
);
232 TRACE("got %d args at %p\n", cx
.argc
, cx
.argv
);
234 res
= parse_rundll(&cx
);
237 if (res
&& cx
.command
) {
244 txtW
[0] = cx
.command
;
245 txtW
[1] = cx
.subcommand
;
247 FIXME("command not implemented: %s\n", debugstr_w(txtW
));
252 if ((res
== FALSE
) || (cx
.command
== '\0')) {
253 FIXME("dialog: Printer / The operation was not successful\n");