~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Wine Cross Reference
wine/dlls/printui/printui.c

Version: ~ [ wine-1.5.30 ] ~ [ wine-1.5.29 ] ~ [ wine-1.5.28 ] ~ [ wine-1.5.27 ] ~ [ wine-1.5.26 ] ~ [ wine-1.5.25 ] ~ [ wine-1.5.24 ] ~ [ wine-1.5.23 ] ~ [ wine-1.5.22 ] ~ [ wine-1.5.21 ] ~ [ wine-1.5.20 ] ~ [ wine-1.5.19 ] ~ [ wine-1.5.18 ] ~ [ wine-1.5.17 ] ~ [ wine-1.5.16 ] ~ [ wine-1.5.15 ] ~ [ wine-1.5.14 ] ~ [ wine-1.5.13 ] ~ [ wine-1.5.12 ] ~ [ wine-1.5.11 ] ~ [ wine-1.5.10 ] ~ [ wine-1.5.9 ] ~ [ wine-1.5.8 ] ~ [ wine-1.5.7 ] ~ [ wine-1.4.1 ] ~ [ wine-1.5.6 ] ~ [ wine-1.5.5 ] ~ [ wine-1.5.4 ] ~ [ wine-1.5.3 ] ~ [ wine-1.5.2 ] ~ [ wine-1.5.1 ] ~ [ wine-1.5.0 ] ~ [ wine-1.4 ] ~ [ wine-1.4-rc6 ] ~ [ wine-1.4-rc5 ] ~ [ wine-1.4-rc4 ] ~ [ wine-1.4-rc3 ] ~ [ wine-1.4-rc2 ] ~ [ wine-1.4-rc1 ] ~ [ wine-1.3.37 ] ~ [ wine-1.3.36 ] ~ [ wine-1.3.35 ] ~ [ wine-1.3.34 ] ~ [ wine-1.3.33 ] ~ [ wine-1.3.32 ] ~ [ wine-1.3.31 ] ~ [ wine-1.3.30 ] ~ [ wine-1.3.29 ] ~ [ wine-1.3.28 ] ~ [ wine-1.3.27 ] ~ [ wine-1.3.26 ] ~ [ wine-1.3.25 ] ~ [ wine-1.3.24 ] ~ [ wine-1.3.23 ] ~ [ wine-1.3.22 ] ~ [ wine-1.3.21 ] ~ [ wine-1.3.20 ] ~ [ wine-1.3.19 ] ~ [ wine-1.3.18 ] ~ [ wine-1.2.3 ] ~ [ wine-1.3.17 ] ~ [ wine-1.3.16 ] ~ [ wine-1.3.15 ] ~ [ wine-1.3.14 ] ~ [ wine-1.3.13 ] ~ [ wine-1.3.12 ] ~ [ wine-1.3.11 ] ~ [ wine-1.3.10 ] ~ [ wine-1.3.9 ] ~ [ wine-1.2.2 ] ~ [ wine-1.3.8 ] ~ [ wine-1.3.7 ] ~ [ wine-1.3.6 ] ~ [ wine-1.3.5 ] ~ [ wine-1.2.1 ] ~ [ wine-1.3.4 ] ~ [ wine-1.3.3 ] ~ [ wine-1.3.2 ] ~ [ wine-1.3.1 ] ~ [ wine-1.3.0 ] ~ [ wine-1.2 ] ~ [ wine-1.2-rc7 ] ~ [ wine-1.2-rc6 ] ~ [ wine-1.2-rc5 ] ~ [ wine-1.2-rc4 ] ~ [ wine-1.2-rc3 ] ~ [ wine-1.2-rc2 ] ~ [ wine-1.2-rc1 ] ~ [ wine-1.1.44 ] ~ [ wine-1.1.43 ] ~ [ wine-1.1.42 ] ~ [ wine-1.1.41 ] ~ [ wine-1.1.40 ] ~ [ wine-1.1.39 ] ~ [ wine-1.1.38 ] ~ [ wine-1.1.37 ] ~ [ wine-1.1.36 ] ~ [ wine-1.1.35 ] ~ [ wine-1.1.34 ] ~ [ wine-1.1.33 ] ~ [ wine-1.1.32 ] ~ [ wine-1.1.31 ] ~ [ wine-1.1.30 ] ~ [ wine-1.1.29 ] ~ [ wine-1.1.28 ] ~ [ wine-1.1.27 ] ~ [ wine-1.1.26 ] ~ [ wine-1.1.25 ] ~ [ wine-1.1.24 ] ~ [ wine-1.1.23 ] ~ [ wine-1.1.22 ] ~ [ wine-1.1.21 ] ~ [ wine-1.1.20 ] ~ [ wine-1.1.19 ] ~ [ wine-1.1.18 ] ~ [ wine-1.1.17 ] ~ [ wine-1.1.16 ] ~ [ wine-1.1.15 ] ~ [ wine-1.1.14 ] ~ [ wine-1.1.13 ] ~ [ wine-1.1.12 ] ~ [ wine-1.1.11 ] ~ [ wine-1.1.10 ] ~ [ wine-1.1.9 ] ~ [ wine-1.1.8 ] ~ [ wine-1.1.7 ] ~ [ wine-1.0.1 ] ~ [ wine-1.1.6 ] ~ [ wine-1.1.5 ] ~ [ wine-1.1.4 ] ~ [ wine-1.1.3 ] ~ [ wine-1.1.2 ] ~ [ wine-1.1.1 ] ~ [ wine-1.1.0 ] ~ [ wine-1.0 ] ~

  1 /*
  2  * Implementation of the Printer User Interface Dialogs
  3  *
  4  * Copyright 2006-2007 Detlef Riekenberg
  5  *
  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.
 10  *
 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.
 15  *
 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
 19  */
 20 
 21 #include <stdarg.h>
 22 
 23 #define COBJMACROS
 24 #define NONAMELESSUNION
 25 
 26 #include "windef.h"
 27 #include "winbase.h"
 28 #include "wingdi.h"
 29 #include "winuser.h"
 30 #include "winreg.h"
 31 #include "winver.h"
 32 #include "winnls.h"
 33 #include "shellapi.h"
 34 
 35 #include "wine/unicode.h"
 36 #include "wine/debug.h"
 37 #include "printui_private.h"
 38 
 39 WINE_DEFAULT_DEBUG_CHANNEL(printui);
 40 
 41 HINSTANCE PRINTUI_hInstance = NULL;
 42 
 43 /* ################################# */
 44 
 45 /* Must be in order with OPT_*      */
 46 static const WCHAR optionsW[OPT_MAX+1]={'a','b','c','f','h','j','l','m','n','t','r','v',0};
 47 
 48 /* Must be in order with FLAG_*     */
 49 static const WCHAR flagsW[FLAG_MAX+1]={'q','w','y','z','Z',0};
 50 
 51 
 52 /* ################################
 53  * get_next_wstr() [Internal]
 54  *
 55  * Get the next WSTR, when available
 56  *
 57  */
 58 
 59 static LPWSTR get_next_wstr(context_t * cx)
 60 {
 61     LPWSTR  ptr;
 62 
 63     ptr = cx->pNextCharW;
 64     if (ptr && ptr[0]) {
 65         cx->pNextCharW = NULL;
 66         return ptr;
 67     }
 68 
 69     /* Get the next Parameter, when available */
 70     if (cx->next_arg < cx->argc) {
 71         ptr = cx->argv[cx->next_arg];
 72         cx->next_arg++;
 73         cx->pNextCharW = NULL;
 74         return ptr;
 75     }
 76     return NULL;
 77 }
 78 
 79 
 80 /* ################################
 81  * get_next_wchar() [Internal]
 82  *
 83  * Get the next WCHAR from the Commandline or from the File (@ Filename)
 84  *
 85  * ToDo: Support Parameter from a File ( "@Filename" )
 86  *
 87  */
 88 
 89 static WCHAR get_next_wchar(context_t * cx, BOOL use_next_parameter)
 90 {
 91     WCHAR   c;
 92 
 93     /* Try the next WCHAR in the actual Parameter */
 94     if (cx->pNextCharW) {
 95         c = *cx->pNextCharW;
 96         if (c) {
 97             cx->pNextCharW++;
 98             return c;
 99         }
100         /* We reached the end of the Parameter */
101         cx->pNextCharW = NULL;
102     }
103 
104     /* Get the next Parameter, when available and allowed */
105     if ((cx->pNextCharW == NULL) && (cx->next_arg < cx->argc) && (use_next_parameter)) {
106         cx->pNextCharW = cx->argv[cx->next_arg];
107         cx->next_arg++;
108     }
109 
110     if (cx->pNextCharW) {
111         c = *cx->pNextCharW;
112         if (c) {
113             cx->pNextCharW++;
114         }
115         else
116         {
117             /* We reached the end of the Parameter */
118             cx->pNextCharW = NULL;
119         }
120         return c;
121     }
122     return '\0';
123 }
124 
125 /* ################################ */
126 static BOOL parse_rundll(context_t * cx)
127 {
128     LPWSTR  ptr;
129     DWORD   index;
130     WCHAR   txtW[2];
131     WCHAR   c;
132 
133 
134     c = get_next_wchar(cx, TRUE);
135     txtW[1] = '\0';
136 
137     while (c)
138     {
139 
140         while ( (c == ' ') || (c == '\t'))
141         {
142             c = get_next_wchar(cx, TRUE);
143         }
144         txtW[0] = c;
145 
146         if (c == '@') {
147             /* read commands from a File */
148             ptr = get_next_wstr(cx);
149             FIXME("redir not supported: %s\n", debugstr_w(ptr));
150             return FALSE;
151         }
152         else if (c == '/') {
153             c = get_next_wchar(cx, FALSE);
154             while ( c )
155             {
156                 txtW[0] = c;
157                 ptr = strchrW(optionsW, c);
158                 if (ptr) {
159                     index = ptr - optionsW;
160                     cx->options[index] = get_next_wstr(cx);
161                     TRACE(" opt: %s  %s\n", debugstr_w(txtW), debugstr_w(cx->options[index]));
162                     c = 0;
163                 }
164                 else
165                 {
166                     ptr = strchrW(flagsW, c);
167                     if (ptr) {
168                         index = ptr - flagsW;
169                         cx->flags[index] = TRUE;
170                         TRACE("flag: %s\n", debugstr_w(txtW));
171                     }
172                     else
173                     {
174                         cx->command = c;
175                         cx->subcommand = '\0';
176                         TRACE(" cmd: %s\n", debugstr_w(txtW));
177                     }
178 
179                     /* help has priority over all commands */
180                     if (c == '?') {
181                         return TRUE;
182                     }
183 
184                     c = get_next_wchar(cx, FALSE);
185 
186                     /* Some commands use two wchar */
187                     if ((cx->command == 'd') || (cx->command == 'g') || (cx->command == 'i') ||
188                         (cx->command == 'S') || (cx->command == 'X') ){
189                         cx->subcommand = c;
190                         txtW[0] = c;
191                         TRACE(" sub: %s\n", debugstr_w(txtW));
192                         c = get_next_wchar(cx, FALSE);
193                     }
194                 }
195             }
196             c = get_next_wchar(cx, TRUE);
197 
198         }
199         else
200         {
201             /* The commands 'S' and 'X' have additional Parameter */
202             if ((cx->command == 'S') || (cx->command == 'X')) {
203 
204                 /* the actual WCHAR is the start from the extra Parameter */
205                 cx->pNextCharW--;
206                 TRACE("%d extra Parameter, starting with %s\n", 1 + (cx->argc - cx->next_arg), debugstr_w(cx->pNextCharW));
207                 return TRUE;
208             }
209             FIXME("0x%x: %s is unknown\n", c, debugstr_wn(&c, 1));
210             return FALSE;
211         }
212 
213     }
214     return TRUE;
215 }
216 
217 /*****************************************************
218  *      DllMain
219  */
220 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
221 {
222     TRACE("(%p, %d, %p)\n",hinstDLL, fdwReason, lpvReserved);
223 
224     switch(fdwReason)
225     {
226         case DLL_WINE_PREATTACH:
227             return FALSE;           /* prefer native version */
228 
229         case DLL_PROCESS_ATTACH:
230             PRINTUI_hInstance = hinstDLL;
231             DisableThreadLibraryCalls( hinstDLL );
232             break;
233     }
234     return TRUE;
235 }
236 
237 
238 /*****************************************************
239  *  PrintUIEntryW                [printui.@]
240  *  Commandline-Interface for using printui.dll with rundll32.exe
241  *
242  */
243 void WINAPI PrintUIEntryW(HWND hWnd, HINSTANCE hInst, LPCWSTR pCommand, DWORD nCmdShow)
244 {
245     context_t cx;
246     BOOL  res = FALSE;
247 
248     TRACE("(%p, %p, %s, 0x%x)\n", hWnd, hInst, debugstr_w(pCommand), nCmdShow);
249 
250     memset(&cx, 0, sizeof(context_t));
251     cx.hWnd = hWnd;
252     cx.nCmdShow = nCmdShow;
253 
254     if ((pCommand) && (pCommand[0])) {
255         /* result is allocated with GlobalAlloc() */
256         cx.argv = CommandLineToArgvW(pCommand, &cx.argc);
257         TRACE("got %d args at %p\n", cx.argc, cx.argv);
258 
259         res = parse_rundll(&cx);
260     }
261 
262     if (res && cx.command) {
263         switch (cx.command)
264         {
265 
266             default:
267             {
268                 WCHAR   txtW[3];
269                 txtW[0] = cx.command;
270                 txtW[1] = cx.subcommand;
271                 txtW[2] = '\0';
272                 FIXME("command not implemented: %s\n", debugstr_w(txtW));
273             }
274         }
275     }
276 
277     if ((res == FALSE) || (cx.command == '\0')) {
278         FIXME("dialog: Printer / The operation was not successful\n");
279     }
280 
281     GlobalFree(cx.argv);
282 
283 }
284 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.