source: vendor/current/examples/printing/prtpub.c@ 414

Last change on this file since 414 was 414, checked in by Herwig Bauernfeind, 16 years ago

Samba 3.5.0: Initial import

File size: 8.0 KB
Line 
1/*
2 * Set printer capabilities in DsDriver Keys on remote printer
3 * Copyright (C) Jim McDonough <[email protected]> 2002.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, see <http://www.gnu.org/licenses/>.
17 */
18
19/* This needs to be defined for certain compilers */
20#define WINVER 0x0500
21
22#include <tchar.h>
23#include <windows.h>
24#include <stdio.h>
25
26#define SAMBA_PORT _T("Samba")
27
28TCHAR *PrintLastError(void)
29{
30 static TCHAR msgtxt[1024*sizeof(TCHAR)];
31
32 FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
33 NULL, GetLastError(),
34 0, msgtxt, 0, NULL);
35
36 return msgtxt;
37}
38
39void map_orientation(HANDLE ph, TCHAR *printer, TCHAR *port)
40{
41 DWORD rot;
42 TCHAR portrait_only[] = _T("PORTRAIT\0");
43 TCHAR both[] = _T("LANDSCAPE\0PORTRAIT\0");
44
45 /* orentation of 90 or 270 indicates landscape supported, 0 means it isn't */
46 rot = DeviceCapabilities(printer, port, DC_BINNAMES, NULL, NULL);
47
48 printf("printOrientationsSupported:\n");
49
50 if (rot) {
51 printf("\tPORTRAIT\n\tLANDSCAPE\n");
52 SetPrinterDataEx(ph, SPLDS_DRIVER_KEY, _T("printOrientationsSupported"), REG_MULTI_SZ,
53 both, sizeof(both));
54 } else {
55 printf("\tPORTRAIT\n");
56 SetPrinterDataEx(ph, SPLDS_DRIVER_KEY, _T("printOrientationsSupported"), REG_MULTI_SZ,
57 portrait_only, sizeof(portrait_only));
58 }
59}
60