The branch, master has been updated
       via  eebc66c... s3-spoolss: Added a winreg_getform1 function.
       via  c7fb84a... s3-spoolss: Added a winreg_setform1 function.
       via  0d46ab0... s3-spoolss: Added a winreg_deleteform1 function.
       via  93575d6... s3-spoolss: Added a winreg_addform1 function.
       via  fbd3235... s3-spoolss: Added a winreg_enumforms1 function.
       via  20e96d9... s3-spoolss: Fixed winreg_printer_openkey to be used in a 
more generic way.
       via  adfd485... s3-spoolss: Added a delete_printer_key function using 
the winreg pipe.
       via  f0054d8... s3-spoolss: Added a enum_printer_key function using the 
winreg pipe.
       via  77d1b73... s3-spoolss: Added a delete_printer_dataex function using 
the winreg pipe.
       via  e498338... s3-spoolss: Added a enum_printer_dataex function using 
the winreg pipe.
       via  511dba5... s3-spoolss: Added a get_printer_dataex function using 
the winreg pipe.
       via  bc23545... s3-spoolss: Added a set_printer_dataex function using 
the winreg pipe.
       via  4f3893f... s3-spoolss: Added a function to open a regkey using the 
winreg pipe.
      from  1ac654d... s4:WHATSNEW4.txt - further updates and corrections

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit eebc66ce324192b38c1ceca857623c634875d379
Author: Andreas Schneider <a...@samba.org>
Date:   Thu Apr 1 12:45:58 2010 +0200

    s3-spoolss: Added a winreg_getform1 function.
    
    Signed-off-by: Günther Deschner <g...@samba.org>

commit c7fb84a58fd3597431c0bbe131e51a95eaff8a70
Author: Andreas Schneider <a...@samba.org>
Date:   Thu Apr 1 11:51:59 2010 +0200

    s3-spoolss: Added a winreg_setform1 function.
    
    Signed-off-by: Günther Deschner <g...@samba.org>

commit 0d46ab0f3eb9662d7ee3eaf8f680632486878d46
Author: Andreas Schneider <a...@samba.org>
Date:   Wed Mar 31 15:31:21 2010 +0200

    s3-spoolss: Added a winreg_deleteform1 function.
    
    Signed-off-by: Günther Deschner <g...@samba.org>

commit 93575d6d7051089b50e038a152750939130c6a72
Author: Andreas Schneider <a...@samba.org>
Date:   Wed Mar 31 13:04:04 2010 +0200

    s3-spoolss: Added a winreg_addform1 function.
    
    Signed-off-by: Günther Deschner <g...@samba.org>

commit fbd32356103e8d72dadf51e51b3119443f13ffb2
Author: Andreas Schneider <a...@samba.org>
Date:   Wed Mar 31 13:03:09 2010 +0200

    s3-spoolss: Added a winreg_enumforms1 function.
    
    Signed-off-by: Günther Deschner <g...@samba.org>

commit 20e96d92430f8f9e18351be96319c3c3758ccb77
Author: Andreas Schneider <a...@samba.org>
Date:   Tue Mar 30 14:46:32 2010 +0200

    s3-spoolss: Fixed winreg_printer_openkey to be used in a more generic way.
    
    Signed-off-by: Günther Deschner <g...@samba.org>

commit adfd4854faf8b2177574d62950324d676d92fae0
Author: Andreas Schneider <a...@samba.org>
Date:   Tue Apr 6 17:01:15 2010 +0200

    s3-spoolss: Added a delete_printer_key function using the winreg pipe.
    
    Signed-off-by: Günther Deschner <g...@samba.org>

commit f0054d8361b90acc3b4d39b0c283f9d54467e61d
Author: Andreas Schneider <a...@redhat.com>
Date:   Wed Mar 17 15:59:10 2010 +0100

    s3-spoolss: Added a enum_printer_key function using the winreg pipe.
    
    Signed-off-by: Günther Deschner <g...@samba.org>

commit 77d1b73a3e31f67dce28055603c34bd78e927616
Author: Andreas Schneider <a...@redhat.com>
Date:   Mon Mar 15 12:30:05 2010 +0100

    s3-spoolss: Added a delete_printer_dataex function using the winreg pipe.
    
    Signed-off-by: Günther Deschner <g...@samba.org>

commit e498338f6f29ffdcca0f3108968e04f635c797d4
Author: Andreas Schneider <a...@redhat.com>
Date:   Fri Mar 12 17:31:21 2010 +0100

    s3-spoolss: Added a enum_printer_dataex function using the winreg pipe.
    
    Signed-off-by: Günther Deschner <g...@samba.org>

commit 511dba5ae8529f8a3e661a2d9d0e6426e38fbee8
Author: Andreas Schneider <a...@redhat.com>
Date:   Mon Mar 15 12:27:51 2010 +0100

    s3-spoolss: Added a get_printer_dataex function using the winreg pipe.
    
    Signed-off-by: Günther Deschner <g...@samba.org>

commit bc235459094f01e6fbf3b544bb4848427ceae9d5
Author: Andreas Schneider <a...@redhat.com>
Date:   Mon Mar 15 12:24:59 2010 +0100

    s3-spoolss: Added a set_printer_dataex function using the winreg pipe.
    
    Signed-off-by: Günther Deschner <g...@samba.org>

commit 4f3893f8148a36d11a4fa333c323fcf6f0176b2e
Author: Andreas Schneider <a...@redhat.com>
Date:   Mon Mar 15 12:24:40 2010 +0100

    s3-spoolss: Added a function to open a regkey using the winreg pipe.
    
    Signed-off-by: Günther Deschner <g...@samba.org>

-----------------------------------------------------------------------

Summary of changes:
 source3/Makefile.in                   |    1 +
 source3/rpc_server/srv_spoolss_util.c | 1768 +++++++++++++++++++++++++++++++++
 source3/rpc_server/srv_spoolss_util.h |  257 +++++
 3 files changed, 2026 insertions(+), 0 deletions(-)
 create mode 100644 source3/rpc_server/srv_spoolss_util.c
 create mode 100644 source3/rpc_server/srv_spoolss_util.h


Changeset truncated at 500 lines:

diff --git a/source3/Makefile.in b/source3/Makefile.in
index 8cc6c66..55f3d40 100644
--- a/source3/Makefile.in
+++ b/source3/Makefile.in
@@ -643,6 +643,7 @@ RPC_NTSVCS_OBJ = rpc_server/srv_ntsvcs_nt.o \
 RPC_DFS_OBJ =  ../librpc/gen_ndr/srv_dfs.o rpc_server/srv_dfs_nt.o
 
 RPC_SPOOLSS_OBJ = rpc_server/srv_spoolss_nt.o \
+                 rpc_server/srv_spoolss_util.o \
                  ../librpc/gen_ndr/srv_spoolss.o
 
 RPC_EVENTLOG_OBJ = rpc_server/srv_eventlog_nt.o \
diff --git a/source3/rpc_server/srv_spoolss_util.c 
b/source3/rpc_server/srv_spoolss_util.c
new file mode 100644
index 0000000..c3aafe3
--- /dev/null
+++ b/source3/rpc_server/srv_spoolss_util.c
@@ -0,0 +1,1768 @@
+/*
+ *  Unix SMB/CIFS implementation.
+ *
+ *  SPOOLSS RPC Pipe server / winreg client routines
+ *
+ *  Copyright (c) 2010      Andreas Schneider <a...@samba.org>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "includes.h"
+#include "srv_spoolss_util.h"
+#include "../librpc/gen_ndr/srv_winreg.h"
+#include "../librpc/gen_ndr/cli_winreg.h"
+
+#define TOP_LEVEL_PRINT_KEY "SOFTWARE\\Microsoft\\Windows 
NT\\CurrentVersion\\Print"
+#define TOP_LEVEL_PRINT_PRINTERS_KEY TOP_LEVEL_PRINT_KEY "\\Printers"
+#define TOP_LEVEL_CONTROL_KEY "SYSTEM\\CurrentControlSet\\Control\\Print"
+#define TOP_LEVEL_CONTROL_FORMS_KEY TOP_LEVEL_CONTROL_KEY "\\Forms"
+
+/*        FLAGS,                NAME,                              with,   
height,   left, top, right, bottom */
+static const struct spoolss_FormInfo1 builtin_forms1[] = {
+       { SPOOLSS_FORM_BUILTIN, "Letter",                         
{0x34b5c,0x44368}, {0x0,0x0,0x34b5c,0x44368} },
+       { SPOOLSS_FORM_BUILTIN, "Letter Small",                   
{0x34b5c,0x44368}, {0x0,0x0,0x34b5c,0x44368} },
+       { SPOOLSS_FORM_BUILTIN, "Tabloid",                        
{0x44368,0x696b8}, {0x0,0x0,0x44368,0x696b8} },
+       { SPOOLSS_FORM_BUILTIN, "Ledger",                         
{0x696b8,0x44368}, {0x0,0x0,0x696b8,0x44368} },
+       { SPOOLSS_FORM_BUILTIN, "Legal",                          
{0x34b5c,0x56d10}, {0x0,0x0,0x34b5c,0x56d10} },
+       { SPOOLSS_FORM_BUILTIN, "Statement",                      
{0x221b4,0x34b5c}, {0x0,0x0,0x221b4,0x34b5c} },
+       { SPOOLSS_FORM_BUILTIN, "Executive",                      
{0x2cf56,0x411cc}, {0x0,0x0,0x2cf56,0x411cc} },
+       { SPOOLSS_FORM_BUILTIN, "A3",                             
{0x48828,0x668a0}, {0x0,0x0,0x48828,0x668a0} },
+       { SPOOLSS_FORM_BUILTIN, "A4",                             
{0x33450,0x48828}, {0x0,0x0,0x33450,0x48828} },
+       { SPOOLSS_FORM_BUILTIN, "A4 Small",                       
{0x33450,0x48828}, {0x0,0x0,0x33450,0x48828} },
+       { SPOOLSS_FORM_BUILTIN, "A5",                             
{0x24220,0x33450}, {0x0,0x0,0x24220,0x33450} },
+       { SPOOLSS_FORM_BUILTIN, "B4 (JIS)",                       
{0x3ebe8,0x58de0}, {0x0,0x0,0x3ebe8,0x58de0} },
+       { SPOOLSS_FORM_BUILTIN, "B5 (JIS)",                       
{0x2c6f0,0x3ebe8}, {0x0,0x0,0x2c6f0,0x3ebe8} },
+       { SPOOLSS_FORM_BUILTIN, "Folio",                          
{0x34b5c,0x509d8}, {0x0,0x0,0x34b5c,0x509d8} },
+       { SPOOLSS_FORM_BUILTIN, "Quarto",                         
{0x347d8,0x43238}, {0x0,0x0,0x347d8,0x43238} },
+       { SPOOLSS_FORM_BUILTIN, "10x14",                          
{0x3e030,0x56d10}, {0x0,0x0,0x3e030,0x56d10} },
+       { SPOOLSS_FORM_BUILTIN, "11x17",                          
{0x44368,0x696b8}, {0x0,0x0,0x44368,0x696b8} },
+       { SPOOLSS_FORM_BUILTIN, "Note",                           
{0x34b5c,0x44368}, {0x0,0x0,0x34b5c,0x44368} },
+       { SPOOLSS_FORM_BUILTIN, "Envelope #9",                    
{0x18079,0x37091}, {0x0,0x0,0x18079,0x37091} },
+       { SPOOLSS_FORM_BUILTIN, "Envelope #10",                   
{0x19947,0x3ae94}, {0x0,0x0,0x19947,0x3ae94} },
+       { SPOOLSS_FORM_BUILTIN, "Envelope #11",                   
{0x1be7c,0x40565}, {0x0,0x0,0x1be7c,0x40565} },
+       { SPOOLSS_FORM_BUILTIN, "Envelope #12",                   
{0x1d74a,0x44368}, {0x0,0x0,0x1d74a,0x44368} },
+       { SPOOLSS_FORM_BUILTIN, "Envelope #14",                   
{0x1f018,0x47504}, {0x0,0x0,0x1f018,0x47504} },
+       { SPOOLSS_FORM_BUILTIN, "C size sheet",                   
{0x696b8,0x886d0}, {0x0,0x0,0x696b8,0x886d0} },
+       { SPOOLSS_FORM_BUILTIN, "D size sheet",                   
{0x886d0,0xd2d70}, {0x0,0x0,0x886d0,0xd2d70} },
+       { SPOOLSS_FORM_BUILTIN, "E size sheet",                   
{0xd2d70,0x110da0},{0x0,0x0,0xd2d70,0x110da0} },
+       { SPOOLSS_FORM_BUILTIN, "Envelope DL",                    
{0x1adb0,0x35b60}, {0x0,0x0,0x1adb0,0x35b60} },
+       { SPOOLSS_FORM_BUILTIN, "Envelope C5",                    
{0x278d0,0x37e88}, {0x0,0x0,0x278d0,0x37e88} },
+       { SPOOLSS_FORM_BUILTIN, "Envelope C3",                    
{0x4f1a0,0x6fd10}, {0x0,0x0,0x4f1a0,0x6fd10} },
+       { SPOOLSS_FORM_BUILTIN, "Envelope C4",                    
{0x37e88,0x4f1a0}, {0x0,0x0,0x37e88,0x4f1a0} },
+       { SPOOLSS_FORM_BUILTIN, "Envelope C6",                    
{0x1bd50,0x278d0}, {0x0,0x0,0x1bd50,0x278d0} },
+       { SPOOLSS_FORM_BUILTIN, "Envelope C65",                   
{0x1bd50,0x37e88}, {0x0,0x0,0x1bd50,0x37e88} },
+       { SPOOLSS_FORM_BUILTIN, "Envelope B4",                    
{0x3d090,0x562e8}, {0x0,0x0,0x3d090,0x562e8} },
+       { SPOOLSS_FORM_BUILTIN, "Envelope B5",                    
{0x2af80,0x3d090}, {0x0,0x0,0x2af80,0x3d090} },
+       { SPOOLSS_FORM_BUILTIN, "Envelope B6",                    
{0x2af80,0x1e848}, {0x0,0x0,0x2af80,0x1e848} },
+       { SPOOLSS_FORM_BUILTIN, "Envelope",                       
{0x1adb0,0x38270}, {0x0,0x0,0x1adb0,0x38270} },
+       { SPOOLSS_FORM_BUILTIN, "Envelope Monarch",               
{0x18079,0x2e824}, {0x0,0x0,0x18079,0x2e824} },
+       { SPOOLSS_FORM_BUILTIN, "6 3/4 Envelope",                 
{0x167ab,0x284ec}, {0x0,0x0,0x167ab,0x284ec} },
+       { SPOOLSS_FORM_BUILTIN, "US Std Fanfold",                 
{0x5c3e1,0x44368}, {0x0,0x0,0x5c3e1,0x44368} },
+       { SPOOLSS_FORM_BUILTIN, "German Std Fanfold",             
{0x34b5c,0x4a6a0}, {0x0,0x0,0x34b5c,0x4a6a0} },
+       { SPOOLSS_FORM_BUILTIN, "German Legal Fanfold",           
{0x34b5c,0x509d8}, {0x0,0x0,0x34b5c,0x509d8} },
+       { SPOOLSS_FORM_BUILTIN, "B4 (ISO)",                       
{0x3d090,0x562e8}, {0x0,0x0,0x3d090,0x562e8} },
+       { SPOOLSS_FORM_BUILTIN, "Japanese Postcard",              
{0x186a0,0x24220}, {0x0,0x0,0x186a0,0x24220} },
+       { SPOOLSS_FORM_BUILTIN, "9x11",                           
{0x37cf8,0x44368}, {0x0,0x0,0x37cf8,0x44368} },
+       { SPOOLSS_FORM_BUILTIN, "10x11",                          
{0x3e030,0x44368}, {0x0,0x0,0x3e030,0x44368} },
+       { SPOOLSS_FORM_BUILTIN, "15x11",                          
{0x5d048,0x44368}, {0x0,0x0,0x5d048,0x44368} },
+       { SPOOLSS_FORM_BUILTIN, "Envelope Invite",                
{0x35b60,0x35b60}, {0x0,0x0,0x35b60,0x35b60} },
+       { SPOOLSS_FORM_BUILTIN, "Reserved48",                     {0x1,0x1},    
     {0x0,0x0,0x1,0x1} },
+       { SPOOLSS_FORM_BUILTIN, "Reserved49",                     {0x1,0x1},    
     {0x0,0x0,0x1,0x1} },
+       { SPOOLSS_FORM_BUILTIN, "Letter Extra",                   
{0x3ae94,0x4a6a0}, {0x0,0x0,0x3ae94,0x4a6a0} },
+       { SPOOLSS_FORM_BUILTIN, "Legal Extra",                    
{0x3ae94,0x5d048}, {0x0,0x0,0x3ae94,0x5d048} },
+       { SPOOLSS_FORM_BUILTIN, "Tabloid Extra",                  
{0x4a6a0,0x6f9f0}, {0x0,0x0,0x4a6a0,0x6f9f0} },
+       { SPOOLSS_FORM_BUILTIN, "A4 Extra",                       
{0x397c2,0x4eb16}, {0x0,0x0,0x397c2,0x4eb16} },
+       { SPOOLSS_FORM_BUILTIN, "Letter Transverse",              
{0x34b5c,0x44368}, {0x0,0x0,0x34b5c,0x44368} },
+       { SPOOLSS_FORM_BUILTIN, "A4 Transverse",                  
{0x33450,0x48828}, {0x0,0x0,0x33450,0x48828} },
+       { SPOOLSS_FORM_BUILTIN, "Letter Extra Transverse",        
{0x3ae94,0x4a6a0}, {0x0,0x0,0x3ae94,0x4a6a0} },
+       { SPOOLSS_FORM_BUILTIN, "Super A",                        
{0x376b8,0x56ea0}, {0x0,0x0,0x376b8,0x56ea0} },
+       { SPOOLSS_FORM_BUILTIN, "Super B",                        
{0x4a768,0x76e58}, {0x0,0x0,0x4a768,0x76e58} },
+       { SPOOLSS_FORM_BUILTIN, "Letter Plus",                    
{0x34b5c,0x4eb16}, {0x0,0x0,0x34b5c,0x4eb16} },
+       { SPOOLSS_FORM_BUILTIN, "A4 Plus",                        
{0x33450,0x50910}, {0x0,0x0,0x33450,0x50910} },
+       { SPOOLSS_FORM_BUILTIN, "A5 Transverse",                  
{0x24220,0x33450}, {0x0,0x0,0x24220,0x33450} },
+       { SPOOLSS_FORM_BUILTIN, "B5 (JIS) Transverse",            
{0x2c6f0,0x3ebe8}, {0x0,0x0,0x2c6f0,0x3ebe8} },
+       { SPOOLSS_FORM_BUILTIN, "A3 Extra",                       
{0x4e9d0,0x6ca48}, {0x0,0x0,0x4e9d0,0x6ca48} },
+       { SPOOLSS_FORM_BUILTIN, "A5 Extra",                       
{0x2a7b0,0x395f8}, {0x0,0x0,0x2a7b0,0x395f8} },
+       { SPOOLSS_FORM_BUILTIN, "B5 (ISO) Extra",                 
{0x31128,0x43620}, {0x0,0x0,0x31128,0x43620} },
+       { SPOOLSS_FORM_BUILTIN, "A2",                             
{0x668a0,0x91050}, {0x0,0x0,0x668a0,0x91050} },
+       { SPOOLSS_FORM_BUILTIN, "A3 Transverse",                  
{0x48828,0x668a0}, {0x0,0x0,0x48828,0x668a0} },
+       { SPOOLSS_FORM_BUILTIN, "A3 Extra Transverse",            
{0x4e9d0,0x6ca48}, {0x0,0x0,0x4e9d0,0x6ca48} },
+       { SPOOLSS_FORM_BUILTIN, "Japanese Double Postcard",       
{0x30d40,0x24220}, {0x0,0x0,0x30d40,0x24220} },
+       { SPOOLSS_FORM_BUILTIN, "A6",                             
{0x19a28,0x24220}, {0x0,0x0,0x19a28,0x24220} },
+       { SPOOLSS_FORM_BUILTIN, "Japanese Envelope Kaku #2",      
{0x3a980,0x510e0}, {0x0,0x0,0x3a980,0x510e0} },
+       { SPOOLSS_FORM_BUILTIN, "Japanese Envelope Kaku #3",      
{0x34bc0,0x43a08}, {0x0,0x0,0x34bc0,0x43a08} },
+       { SPOOLSS_FORM_BUILTIN, "Japanese Envelope Chou #3",      
{0x1d4c0,0x395f8}, {0x0,0x0,0x1d4c0,0x395f8} },
+       { SPOOLSS_FORM_BUILTIN, "Japanese Envelope Chou #4",      
{0x15f90,0x320c8}, {0x0,0x0,0x15f90,0x320c8} },
+       { SPOOLSS_FORM_BUILTIN, "Letter Rotated",                 
{0x44368,0x34b5c}, {0x0,0x0,0x44368,0x34b5c} },
+       { SPOOLSS_FORM_BUILTIN, "A3 Rotated",                     
{0x668a0,0x48828}, {0x0,0x0,0x668a0,0x48828} },
+       { SPOOLSS_FORM_BUILTIN, "A4 Rotated",                     
{0x48828,0x33450}, {0x0,0x0,0x48828,0x33450} },
+       { SPOOLSS_FORM_BUILTIN, "A5 Rotated",                     
{0x33450,0x24220}, {0x0,0x0,0x33450,0x24220} },
+       { SPOOLSS_FORM_BUILTIN, "B4 (JIS) Rotated",               
{0x58de0,0x3ebe8}, {0x0,0x0,0x58de0,0x3ebe8} },
+       { SPOOLSS_FORM_BUILTIN, "B5 (JIS) Rotated",               
{0x3ebe8,0x2c6f0}, {0x0,0x0,0x3ebe8,0x2c6f0} },
+       { SPOOLSS_FORM_BUILTIN, "Japanese Postcard Rotated",      
{0x24220,0x186a0}, {0x0,0x0,0x24220,0x186a0} },
+       { SPOOLSS_FORM_BUILTIN, "Double Japan Postcard Rotated",  
{0x24220,0x30d40}, {0x0,0x0,0x24220,0x30d40} },
+       { SPOOLSS_FORM_BUILTIN, "A6 Rotated",                     
{0x24220,0x19a28}, {0x0,0x0,0x24220,0x19a28} },
+       { SPOOLSS_FORM_BUILTIN, "Japan Envelope Kaku #2 Rotated", 
{0x510e0,0x3a980}, {0x0,0x0,0x510e0,0x3a980} },
+       { SPOOLSS_FORM_BUILTIN, "Japan Envelope Kaku #3 Rotated", 
{0x43a08,0x34bc0}, {0x0,0x0,0x43a08,0x34bc0} },
+       { SPOOLSS_FORM_BUILTIN, "Japan Envelope Chou #3 Rotated", 
{0x395f8,0x1d4c0}, {0x0,0x0,0x395f8,0x1d4c0} },
+       { SPOOLSS_FORM_BUILTIN, "Japan Envelope Chou #4 Rotated", 
{0x320c8,0x15f90}, {0x0,0x0,0x320c8,0x15f90} },
+       { SPOOLSS_FORM_BUILTIN, "B6 (JIS)",                       
{0x1f400,0x2c6f0}, {0x0,0x0,0x1f400,0x2c6f0} },
+       { SPOOLSS_FORM_BUILTIN, "B6 (JIS) Rotated",               
{0x2c6f0,0x1f400}, {0x0,0x0,0x2c6f0,0x1f400} },
+       { SPOOLSS_FORM_BUILTIN, "12x11",                          
{0x4a724,0x443e1}, {0x0,0x0,0x4a724,0x443e1} },
+       { SPOOLSS_FORM_BUILTIN, "Japan Envelope You #4",          
{0x19a28,0x395f8}, {0x0,0x0,0x19a28,0x395f8} },
+       { SPOOLSS_FORM_BUILTIN, "Japan Envelope You #4 Rotated",  
{0x395f8,0x19a28}, {0x0,0x0,0x395f8,0x19a28} },
+       { SPOOLSS_FORM_BUILTIN, "PRC 16K",                        
{0x2de60,0x3f7a0}, {0x0,0x0,0x2de60,0x3f7a0} },
+       { SPOOLSS_FORM_BUILTIN, "PRC 32K",                        
{0x1fbd0,0x2cec0}, {0x0,0x0,0x1fbd0,0x2cec0} },
+       { SPOOLSS_FORM_BUILTIN, "PRC 32K(Big)",                   
{0x222e0,0x318f8}, {0x0,0x0,0x222e0,0x318f8} },
+       { SPOOLSS_FORM_BUILTIN, "PRC Envelope #1",                
{0x18e70,0x28488}, {0x0,0x0,0x18e70,0x28488} },
+       { SPOOLSS_FORM_BUILTIN, "PRC Envelope #2",                
{0x18e70,0x2af80}, {0x0,0x0,0x18e70,0x2af80} },
+       { SPOOLSS_FORM_BUILTIN, "PRC Envelope #3",                
{0x1e848,0x2af80}, {0x0,0x0,0x1e848,0x2af80} },
+       { SPOOLSS_FORM_BUILTIN, "PRC Envelope #4",                
{0x1adb0,0x32c80}, {0x0,0x0,0x1adb0,0x32c80} },
+       { SPOOLSS_FORM_BUILTIN, "PRC Envelope #5",                
{0x1adb0,0x35b60}, {0x0,0x0,0x1adb0,0x35b60} },
+       { SPOOLSS_FORM_BUILTIN, "PRC Envelope #6",                
{0x1d4c0,0x38270}, {0x0,0x0,0x1d4c0,0x38270} },
+       { SPOOLSS_FORM_BUILTIN, "PRC Envelope #7",                
{0x27100,0x38270}, {0x0,0x0,0x27100,0x38270} },
+       { SPOOLSS_FORM_BUILTIN, "PRC Envelope #8",                
{0x1d4c0,0x4b708}, {0x0,0x0,0x1d4c0,0x4b708} },
+       { SPOOLSS_FORM_BUILTIN, "PRC Envelope #9",                
{0x37e88,0x4f1a0}, {0x0,0x0,0x37e88,0x4f1a0} },
+       { SPOOLSS_FORM_BUILTIN, "PRC Envelope #10",               
{0x4f1a0,0x6fd10}, {0x0,0x0,0x4f1a0,0x6fd10} },
+       { SPOOLSS_FORM_BUILTIN, "PRC 16K Rotated",                
{0x3f7a0,0x2de60}, {0x0,0x0,0x3f7a0,0x2de60} },
+       { SPOOLSS_FORM_BUILTIN, "PRC 32K Rotated",                
{0x2cec0,0x1fbd0}, {0x0,0x0,0x2cec0,0x1fbd0} },
+       { SPOOLSS_FORM_BUILTIN, "PRC 32K(Big) Rotated",           
{0x318f8,0x222e0}, {0x0,0x0,0x318f8,0x222e0} },
+       { SPOOLSS_FORM_BUILTIN, "PRC Envelope #1 Rotated",        
{0x28488,0x18e70}, {0x0,0x0,0x28488,0x18e70} },
+       { SPOOLSS_FORM_BUILTIN, "PRC Envelope #2 Rotated",        
{0x2af80,0x18e70}, {0x0,0x0,0x2af80,0x18e70} },
+       { SPOOLSS_FORM_BUILTIN, "PRC Envelope #3 Rotated",        
{0x2af80,0x1e848}, {0x0,0x0,0x2af80,0x1e848} },
+       { SPOOLSS_FORM_BUILTIN, "PRC Envelope #4 Rotated",        
{0x32c80,0x1adb0}, {0x0,0x0,0x32c80,0x1adb0} },
+       { SPOOLSS_FORM_BUILTIN, "PRC Envelope #5 Rotated",        
{0x35b60,0x1adb0}, {0x0,0x0,0x35b60,0x1adb0} },
+       { SPOOLSS_FORM_BUILTIN, "PRC Envelope #6 Rotated",        
{0x38270,0x1d4c0}, {0x0,0x0,0x38270,0x1d4c0} },
+       { SPOOLSS_FORM_BUILTIN, "PRC Envelope #7 Rotated",        
{0x38270,0x27100}, {0x0,0x0,0x38270,0x27100} },
+       { SPOOLSS_FORM_BUILTIN, "PRC Envelope #8 Rotated",        
{0x4b708,0x1d4c0}, {0x0,0x0,0x4b708,0x1d4c0} },
+       { SPOOLSS_FORM_BUILTIN, "PRC Envelope #9 Rotated",        
{0x4f1a0,0x37e88}, {0x0,0x0,0x4f1a0,0x37e88} },
+       { SPOOLSS_FORM_BUILTIN, "PRC Envelope #10 Rotated",       
{0x6fd10,0x4f1a0}, {0x0,0x0,0x6fd10,0x4f1a0} }
+};
+
+/********************************************************************
+ static helper functions
+********************************************************************/
+
+/**
+ * @internal
+ *
+ * @brief Connect to the interal winreg server and open the given printer key.
+ *
+ * The function will create the needed subkeys if they don't exist.
+ *
+ * @param[in]  mem_ctx       The memory context to use.
+ *
+ * @param[in]  server_info   The supplied server info.
+ *
+ * @param[out] winreg_pipe   A pointer for the winreg rpc client pipe.
+ *
+ * @param[in]  path          The path to the key to open.
+ *
+ * @param[in]  key           The key to open.
+ *
+ * @param[in]  create_key    Set to true if the key should be created if it
+ *                           doesn't exist.
+ *
+ * @param[in]  access_mask   The access mask to open the key.
+ *
+ * @param[out] hive_handle   A policy handle for the opened hive.
+ *
+ * @param[out] key_handle    A policy handle for the opened key.
+ *
+ * @return                   WERR_OK on success, the corresponding DOS error
+ *                           code if something gone wrong.
+ */
+static WERROR winreg_printer_openkey(TALLOC_CTX *mem_ctx,
+                             struct auth_serversupplied_info *server_info,
+                             struct rpc_pipe_client **winreg_pipe,
+                             const char *path,
+                             const char *key,
+                             bool create_key,
+                             uint32_t access_mask,
+                             struct policy_handle *hive_handle,
+                             struct policy_handle *key_handle)
+{
+       struct rpc_pipe_client *pipe_handle;
+       struct winreg_String wkey, wkeyclass;
+       char *keyname;
+       NTSTATUS status;
+       WERROR result = WERR_OK;
+
+       /* create winreg connection */
+       status = rpc_pipe_open_internal(mem_ctx,
+                                       &ndr_table_winreg.syntax_id,
+                                       rpc_winreg_dispatch,
+                                       server_info,
+                                       &pipe_handle);
+       if (!NT_STATUS_IS_OK(status)) {
+               DEBUG(0, ("winreg_printer_openkey: Could not connect to 
winreg_pipe: %s\n",
+                         nt_errstr(status)));
+               return ntstatus_to_werror(status);
+       }
+
+       status = rpccli_winreg_OpenHKLM(pipe_handle,
+                                       mem_ctx,
+                                       NULL,
+                                       access_mask,
+                                       hive_handle,
+                                       &result);
+       if (!NT_STATUS_IS_OK(status)) {
+               DEBUG(0, ("winreg_printer_openkey: Could not open HKLM hive: 
%s\n",
+                         nt_errstr(status)));
+               talloc_free(pipe_handle);
+               if (!W_ERROR_IS_OK(result)) {
+                       return result;
+               }
+               return ntstatus_to_werror(status);
+       }
+
+       if (key && *key) {
+               keyname = talloc_asprintf(mem_ctx, "%s\\%s", path, key);
+       } else {
+               keyname = talloc_strdup(mem_ctx, path);
+       }
+       if (keyname == NULL) {
+               talloc_free(pipe_handle);
+               return WERR_NOMEM;
+       }
+
+       ZERO_STRUCT(wkey);
+       wkey.name = keyname;
+
+       if (create_key) {
+               enum winreg_CreateAction action = REG_ACTION_NONE;
+
+               ZERO_STRUCT(wkeyclass);
+               wkeyclass.name = "";
+
+               status = rpccli_winreg_CreateKey(pipe_handle,
+                                                mem_ctx,
+                                                hive_handle,
+                                                wkey,
+                                                wkeyclass,
+                                                0,
+                                                access_mask,
+                                                NULL,
+                                                key_handle,
+                                                &action,
+                                                &result);
+               switch (action) {
+                       case REG_ACTION_NONE:
+                               DEBUG(8, ("winreg_printer_openkey:createkey did 
nothing -- huh?\n"));
+                               break;
+                       case REG_CREATED_NEW_KEY:
+                               DEBUG(8, ("winreg_printer_openkey: createkey 
created %s\n", keyname));
+                               break;
+                       case REG_OPENED_EXISTING_KEY:
+                               DEBUG(8, ("winreg_printer_openkey: createkey 
opened existing %s\n", keyname));
+                               break;
+               }
+       } else {
+               status = rpccli_winreg_OpenKey(pipe_handle,
+                                              mem_ctx,
+                                              hive_handle,
+                                              wkey,
+                                              0,
+                                              access_mask,
+                                              key_handle,
+                                              &result);
+       }
+       if (!NT_STATUS_IS_OK(status)) {
+               talloc_free(pipe_handle);
+               if (!W_ERROR_IS_OK(result)) {
+                       return result;
+               }
+               return ntstatus_to_werror(status);
+       }
+
+       *winreg_pipe = pipe_handle;
+
+       return WERR_OK;
+}
+
+/**
+ * @brief Create the registry keyname for the given printer.
+ *
+ * @param[in]  mem_ctx  The memory context to use.
+ *
+ * @param[in]  printer  The name of the printer to get the registry key.
+ *
+ * @return     The registry key or NULL on error.
+ */
+static char *winreg_printer_data_keyname(TALLOC_CTX *mem_ctx, const char 
*printer) {
+       return talloc_asprintf(mem_ctx, "%s\\%s", TOP_LEVEL_PRINT_PRINTERS_KEY, 
printer);
+}
+
+/**
+ * @internal
+ *
+ * @brief Enumerate values of an opened key handle and retrieve the data.
+ *
+ * @param[in]  mem_ctx  The memory context to use.
+ *
+ * @param[in]  pipe_handle The pipe handle for the rpc connection.
+ *
+ * @param[in]  key_hnd  The opened key handle.
+ *
+ * @param[out] pnum_values A pointer to store he number of values found.
+ *
+ * @param[out] pnum_values A pointer to store the number of values we found.
+ *
+ * @return                   WERR_OK on success, the corresponding DOS error
+ *                           code if something gone wrong.
+ */
+static WERROR winreg_printer_enumvalues(TALLOC_CTX *mem_ctx,
+                                       struct rpc_pipe_client *pipe_handle,
+                                       struct policy_handle *key_hnd,
+                                       uint32_t *pnum_values,
+                                       struct spoolss_PrinterEnumValues 
**penum_values)
+{
+       TALLOC_CTX *tmp_ctx;
+       uint32_t num_subkeys, max_subkeylen, max_classlen;
+       uint32_t num_values, max_valnamelen, max_valbufsize;
+       uint32_t secdescsize;
+       uint32_t i;
+       NTTIME last_changed_time;
+       struct winreg_String classname;
+
+       struct spoolss_PrinterEnumValues *enum_values;
+
+       WERROR result = WERR_OK;
+       NTSTATUS status;
+
+       tmp_ctx = talloc_new(mem_ctx);
+       if (tmp_ctx == NULL) {
+               return WERR_NOMEM;
+       }
+
+       ZERO_STRUCT(classname);
+
+       status = rpccli_winreg_QueryInfoKey(pipe_handle,
+                                           tmp_ctx,
+                                           key_hnd,
+                                           &classname,
+                                           &num_subkeys,
+                                           &max_subkeylen,
+                                           &max_classlen,
+                                           &num_values,
+                                           &max_valnamelen,
+                                           &max_valbufsize,
+                                           &secdescsize,
+                                           &last_changed_time,
+                                           &result);
+       if (!NT_STATUS_IS_OK(status)) {
+               DEBUG(0, ("winreg_printer_enumvalues: Could not query info: 
%s\n",
+                         nt_errstr(status)));
+               if (!W_ERROR_IS_OK(result)) {
+                       goto error;
+               }
+               result = ntstatus_to_werror(status);
+               goto error;
+       }
+
+       if (num_values == 0) {
+               *pnum_values = 0;
+               TALLOC_FREE(tmp_ctx);
+               return WERR_OK;
+       }
+
+       enum_values = TALLOC_ARRAY(tmp_ctx, struct spoolss_PrinterEnumValues, 
num_values);
+       if (enum_values == NULL) {
+               result = WERR_NOMEM;
+               goto error;
+       }
+
+       for (i = 0; i < num_values; i++) {
+               struct spoolss_PrinterEnumValues val;
+               struct winreg_ValNameBuf name_buf;
+               enum winreg_Type type = REG_NONE;
+               uint8_t *data = NULL;
+               uint32_t data_size;
+               uint32_t length;
+               char n = '\0';;
+
+               name_buf.name = &n;
+               name_buf.size = max_valnamelen + 2;
+               name_buf.length = 0;
+
+               data_size = max_valbufsize;
+               data = (uint8_t *) TALLOC(tmp_ctx, data_size);
+               length = 0;
+
+               status = rpccli_winreg_EnumValue(pipe_handle,
+                                                tmp_ctx,
+                                                key_hnd,
+                                                i,
+                                                &name_buf,
+                                                &type,
+                                                data,
+                                                &data_size,
+                                                &length,
+                                                &result);
+               if (W_ERROR_EQUAL(result, WERR_NO_MORE_ITEMS) ) {
+                       result = WERR_OK;
+                       status = NT_STATUS_OK;
+                       break;
+               }
+
+               if (!NT_STATUS_IS_OK(status)) {
+                       DEBUG(0, ("winreg_printer_enumvalues: Could not 
enumerate values: %s\n",
+                                 nt_errstr(status)));
+                       if (!W_ERROR_IS_OK(result)) {
+                               goto error;
+                       }
+                       result = ntstatus_to_werror(status);
+                       goto error;
+               }
+
+               if (name_buf.name == NULL) {
+                       result = WERR_INVALID_PARAMETER;
+                       goto error;
+               }
+
+               val.value_name = talloc_strdup(enum_values, name_buf.name);
+               if (val.value_name == NULL) {
+                       result = WERR_NOMEM;
+                       goto error;
+               }
+               val.value_name_len = strlen_m_term(val.value_name) * 2;
+
+               val.type = type;
+               val.data_length = data_size;
+               if (val.data_length) {
+                       val.data = talloc(enum_values, DATA_BLOB);
+                       if (val.data == NULL) {
+                               result = WERR_NOMEM;
+                               goto error;
+                       }
+                       *val.data = data_blob_talloc(enum_values, data, 
data_size);
+               }
+
+               enum_values[i] = val;
+       }
+
+       *pnum_values = num_values;
+       if (penum_values) {
+               *penum_values = talloc_move(mem_ctx, &enum_values);
+       }
+
+       result = WERR_OK;
+
+ error:
+       TALLOC_FREE(tmp_ctx);
+       return result;
+}
+
+/**
+ * @internal
+ *
+ * @brief Enumerate subkeys of an opened key handle and get the names.
+ *
+ * @param[in]  mem_ctx  The memory context to use.
+ *
+ * @param[in]  pipe_handle The pipe handle for the rpc connection.
+ *
+ * @param[in]  key_hnd  The opened key handle.
+ *
+ * @param[in]  pnum_subkeys A pointer to store the number of found subkeys.
+ *
+ * @param[in]  psubkeys A pointer to an array to store the found names of
+ *                      subkeys.


-- 
Samba Shared Repository

Reply via email to