2002-03-20 03:29:03 +00:00
/*
Python wrappers for DCERPC / SMB client routines .
Copyright ( C ) Tim Potter , 2002
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 2 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 , write to the Free Software
Foundation , Inc . , 675 Mass Ave , Cambridge , MA 0213 9 , USA .
*/
# include "python/py_spoolss.h"
/* Exceptions this module can raise */
PyObject * spoolss_error , * spoolss_werror ;
/*
* Routines to convert from python hashes to Samba structures
*/
2002-04-14 23:42:54 +00:00
PyObject * new_spoolss_policy_hnd_object ( struct cli_state * cli ,
TALLOC_CTX * mem_ctx , POLICY_HND * pol )
2002-03-26 11:12:16 +00:00
{
spoolss_policy_hnd_object * o ;
o = PyObject_New ( spoolss_policy_hnd_object , & spoolss_policy_hnd_type ) ;
o - > cli = cli ;
o - > mem_ctx = mem_ctx ;
memcpy ( & o - > pol , pol , sizeof ( POLICY_HND ) ) ;
return ( PyObject * ) o ;
}
2002-03-20 03:29:03 +00:00
/*
* Method dispatch table
*/
static PyMethodDef spoolss_methods [ ] = {
/* Open/close printer handles */
2002-05-14 02:37:47 +00:00
{ " openprinter " , ( PyCFunction ) spoolss_openprinter , METH_VARARGS | METH_KEYWORDS ,
2002-05-16 01:33:38 +00:00
" Open a printer by name in UNC format.
2002-04-03 04:40:35 +00:00
2002-05-16 01:33:38 +00:00
Optionally a dictionary of ( domain , username , password ) may be given in
which case they are used when opening the RPC pipe . An access mask may
also be given which defaults to MAXIMUM_ALLOWED_ACCESS .
2002-04-03 04:40:35 +00:00
Example :
2002-05-16 01:33:38 +00:00
> > > hnd = spoolss . openprinter ( \ " \\ \\ \\ \\ NPSD-PDC2 \\ \\ meanie \" ) " } ,
2002-03-20 03:29:03 +00:00
{ " closeprinter " , spoolss_closeprinter , METH_VARARGS ,
2002-05-16 01:33:38 +00:00
" Close a printer handle opened with openprinter or addprinter.
2002-04-03 04:40:35 +00:00
Example :
2002-05-16 01:33:38 +00:00
> > > spoolss . closeprinter ( hnd ) " },
2002-03-20 03:29:03 +00:00
2002-05-15 06:22:53 +00:00
{ " addprinterex " , ( PyCFunction ) spoolss_addprinterex , METH_VARARGS ,
2002-05-15 06:10:45 +00:00
" addprinterex() " } ,
2002-03-27 05:33:19 +00:00
/* Server enumeratation functions */
2002-03-26 11:12:16 +00:00
2002-05-14 02:37:47 +00:00
{ " enumprinters " , ( PyCFunction ) spoolss_enumprinters ,
METH_VARARGS | METH_KEYWORDS ,
2002-05-16 01:33:38 +00:00
" Enumerate printers on a print server.
2002-04-03 04:40:35 +00:00
Return a list of printers on a print server . The credentials , info level
and flags may be specified as keyword arguments .
Example :
> > > print spoolss . enumprinters ( \ " \\ \\ \\ \\ npsd-pdc2 \" )
[ { ' comment ' : ' i am a comment ' , ' printer_name ' : ' meanie ' , ' flags ' : 8388608 ,
' description ' : ' meanie , Generic / Text Only , i am a location ' } ,
{ ' comment ' : ' ' , ' printer_name ' : ' fileprint ' , ' flags ' : 8388608 ,
2002-05-16 01:33:38 +00:00
' description ' : ' fileprint , Generic / Text Only , ' } ] " },
2002-03-26 11:12:16 +00:00
2002-05-14 02:37:47 +00:00
{ " enumports " , ( PyCFunction ) spoolss_enumports ,
METH_VARARGS | METH_KEYWORDS ,
2002-05-16 01:33:38 +00:00
" Enumerate ports on a print server.
2002-04-03 04:40:35 +00:00
Return a list of ports on a print server .
Example :
> > > print spoolss . enumports ( \ " \\ \\ \\ \\ npsd-pdc2 \" )
[ { ' name ' : ' LPT1 : ' } , { ' name ' : ' LPT2 : ' } , { ' name ' : ' COM1 : ' } , { ' name ' : ' COM2 : ' } ,
2002-05-16 01:33:38 +00:00
{ ' name ' : ' FILE : ' } , { ' name ' : ' \ \ \ \ nautilus1 \ \ zpekt3r ' } ] " },
2002-03-26 11:12:16 +00:00
2002-05-14 02:37:47 +00:00
{ " enumprinterdrivers " , ( PyCFunction ) spoolss_enumprinterdrivers ,
METH_VARARGS | METH_KEYWORDS ,
2002-05-16 01:33:38 +00:00
" Enumerate printer drivers on a print server.
2002-03-27 05:33:19 +00:00
2002-05-16 01:33:38 +00:00
Return a list of printer drivers . " },
2002-03-27 05:33:19 +00:00
/* Miscellaneous other commands */
2002-05-16 01:33:38 +00:00
{ " getprinterdriverdir " , ( PyCFunction ) spoolss_getprinterdriverdir ,
METH_VARARGS | METH_KEYWORDS ,
" Return printer driver directory.
2002-04-03 04:40:35 +00:00
Return the printer driver directory for a given architecture . The
2002-05-16 01:33:38 +00:00
architecture defaults to \ " Windows NT x86 \" . " } ,
2002-03-27 05:33:19 +00:00
2002-04-11 05:05:08 +00:00
/* Other stuff - this should really go into a samba config module
but for the moment let ' s leave it here . */
2002-05-14 02:37:47 +00:00
{ " setup_logging " , ( PyCFunction ) py_setup_logging ,
2002-05-16 01:33:38 +00:00
METH_VARARGS | METH_KEYWORDS ,
" Set up debug logging.
Initialises Samba ' s debug logging system . One argument is expected which
is a boolean specifying whether debugging is interactive and sent to stdout
or logged to a file .
Example :
> > > spoolss . setup_logging ( interactive = 1 ) " },
{ " get_debuglevel " , ( PyCFunction ) get_debuglevel ,
METH_VARARGS ,
" Set the current debug level.
Example :
2002-04-11 05:05:08 +00:00
2002-05-16 01:33:38 +00:00
> > > spoolss . get_debuglevel ( )
0 " },
{ " set_debuglevel " , ( PyCFunction ) set_debuglevel ,
METH_VARARGS ,
" Get the current debug level.
Example :
> > > spoolss . set_debuglevel ( 10 ) "
2002-04-11 05:05:08 +00:00
2002-05-14 07:15:43 +00:00
/* Printer driver routines */
{ " addprinterdriver " , ( PyCFunction ) spoolss_addprinterdriver ,
2002-05-16 01:33:38 +00:00
METH_VARARGS | METH_KEYWORDS ,
" Add a printer driver. " } ,
2002-05-14 07:15:43 +00:00
{ " addprinterdriverex " , ( PyCFunction ) spoolss_addprinterdriverex ,
2002-05-16 01:33:38 +00:00
METH_VARARGS | METH_KEYWORDS ,
" Add a printer driver. " } ,
2002-05-14 07:15:43 +00:00
{ " deleteprinterdriver " , ( PyCFunction ) spoolss_deleteprinterdriver ,
2002-05-16 01:33:38 +00:00
METH_VARARGS | METH_KEYWORDS ,
" Delete a printer driver. " } ,
2002-05-14 07:15:43 +00:00
{ " deleteprinterdriverex " , ( PyCFunction ) spoolss_deleteprinterdriverex ,
2002-05-16 01:33:38 +00:00
METH_VARARGS | METH_KEYWORDS ,
" Delete a printer driver. " } ,
2002-05-14 07:15:43 +00:00
2002-03-26 11:12:16 +00:00
{ NULL }
} ;
/* Methods attached to a spoolss handle object */
static PyMethodDef spoolss_hnd_methods [ ] = {
/* Printer info */
2002-05-15 06:22:53 +00:00
{ " getprinter " , ( PyCFunction ) spoolss_hnd_getprinter ,
2002-05-14 02:37:47 +00:00
METH_VARARGS | METH_KEYWORDS ,
2002-05-16 01:33:38 +00:00
" Get printer information.
2002-04-03 04:40:35 +00:00
Return a dictionary of print information . The info level defaults to 1.
Example :
> > > hnd . getprinter ( )
{ ' comment ' : ' i am a comment ' , ' printer_name ' : ' \ \ \ \ NPSD - PDC2 \ \ meanie ' ,
' description ' : ' \ \ \ \ NPSD - PDC2 \ \ meanie , Generic / Text Only , i am a location ' ,
2002-05-16 01:33:38 +00:00
' flags ' : 8388608 } " },
2002-03-26 11:12:16 +00:00
2002-05-15 06:22:53 +00:00
{ " setprinter " , ( PyCFunction ) spoolss_hnd_setprinter ,
2002-05-14 02:37:47 +00:00
METH_VARARGS | METH_KEYWORDS ,
2002-05-16 01:33:38 +00:00
" Set printer information. " } ,
2002-03-26 11:12:16 +00:00
2002-03-20 03:29:03 +00:00
/* Printer drivers */
2002-05-15 06:22:53 +00:00
{ " getprinterdriver " , ( PyCFunction ) spoolss_hnd_getprinterdriver ,
2002-04-03 04:40:35 +00:00
METH_VARARGS | METH_KEYWORDS ,
2002-05-16 01:33:38 +00:00
" Return printer driver information.
2002-04-03 04:40:35 +00:00
2002-05-16 01:33:38 +00:00
Return a dictionary of printer driver information for the printer driver
bound to this printer . " },
2002-03-20 03:29:03 +00:00
2002-03-26 11:12:16 +00:00
/* Forms */
2002-03-20 03:29:03 +00:00
2002-05-15 06:22:53 +00:00
{ " enumforms " , ( PyCFunction ) spoolss_hnd_enumforms ,
2002-05-14 02:37:47 +00:00
METH_VARARGS | METH_KEYWORDS ,
2002-05-16 01:33:38 +00:00
" Enumerate supported forms.
2002-04-03 04:40:35 +00:00
2002-05-16 01:33:38 +00:00
Return a list of forms supported by this printer or print server . " },
2002-03-20 03:29:03 +00:00
2002-05-15 06:22:53 +00:00
{ " setform " , ( PyCFunction ) spoolss_hnd_setform ,
2002-05-14 02:37:47 +00:00
METH_VARARGS | METH_KEYWORDS ,
2002-05-16 01:33:38 +00:00
" Set form data.
2002-04-03 04:40:35 +00:00
2002-05-16 01:33:38 +00:00
Set the form given by the dictionary argument . " },
2002-03-26 11:12:16 +00:00
2002-05-15 06:22:53 +00:00
{ " addform " , ( PyCFunction ) spoolss_hnd_addform ,
2002-05-14 02:37:47 +00:00
METH_VARARGS | METH_KEYWORDS ,
2002-05-16 01:33:38 +00:00
" Add a new form. " } ,
2002-03-26 11:12:16 +00:00
2002-05-15 06:22:53 +00:00
{ " getform " , ( PyCFunction ) spoolss_hnd_getform ,
2002-05-14 02:37:47 +00:00
METH_VARARGS | METH_KEYWORDS ,
2002-05-16 01:33:38 +00:00
" Get form properties. " } ,
2002-03-26 11:12:16 +00:00
2002-05-15 06:22:53 +00:00
{ " deleteform " , ( PyCFunction ) spoolss_hnd_deleteform ,
2002-05-14 02:37:47 +00:00
METH_VARARGS | METH_KEYWORDS ,
2002-05-16 01:33:38 +00:00
" Delete a form. " } ,
2002-03-20 03:29:03 +00:00
2002-05-07 07:06:10 +00:00
/* Job related methods */
2002-05-15 06:22:53 +00:00
{ " enumjobs " , ( PyCFunction ) spoolss_hnd_enumjobs ,
2002-05-14 02:37:47 +00:00
METH_VARARGS | METH_KEYWORDS ,
2002-05-16 01:33:38 +00:00
" Enumerate jobs. " } ,
2002-05-07 07:06:10 +00:00
2002-05-15 06:22:53 +00:00
{ " setjob " , ( PyCFunction ) spoolss_hnd_setjob ,
2002-05-14 02:37:47 +00:00
METH_VARARGS | METH_KEYWORDS ,
2002-05-16 01:33:38 +00:00
" Set job information. " } ,
2002-05-08 05:50:12 +00:00
2002-05-15 06:22:53 +00:00
{ " getjob " , ( PyCFunction ) spoolss_hnd_getjob ,
2002-05-14 02:37:47 +00:00
METH_VARARGS | METH_KEYWORDS ,
2002-05-16 01:33:38 +00:00
" Get job information. " } ,
2002-05-08 05:50:12 +00:00
2002-05-15 06:22:53 +00:00
{ " startpageprinter " , ( PyCFunction ) spoolss_hnd_startpageprinter ,
2002-05-08 05:50:12 +00:00
METH_VARARGS | METH_KEYWORDS ,
" Notify spooler that a page is about to be printed. " } ,
2002-05-15 06:22:53 +00:00
{ " endpageprinter " , ( PyCFunction ) spoolss_hnd_endpageprinter ,
2002-05-08 05:50:12 +00:00
METH_VARARGS | METH_KEYWORDS ,
" Notify spooler that a page is about to be printed. " } ,
2002-05-08 04:26:22 +00:00
2002-05-15 06:22:53 +00:00
{ " startdocprinter " , ( PyCFunction ) spoolss_hnd_startdocprinter ,
2002-05-13 01:55:04 +00:00
METH_VARARGS | METH_KEYWORDS ,
" Notify spooler that a document is about to be printed. " } ,
2002-05-15 06:22:53 +00:00
{ " enddocprinter " , ( PyCFunction ) spoolss_hnd_enddocprinter ,
2002-05-13 01:55:04 +00:00
METH_VARARGS | METH_KEYWORDS ,
" Notify spooler that a document is about to be printed. " } ,
2002-05-15 06:22:53 +00:00
{ " writeprinter " , ( PyCFunction ) spoolss_hnd_writeprinter ,
2002-05-14 06:09:59 +00:00
METH_VARARGS | METH_KEYWORDS ,
" Write job data to a printer. " } ,
2002-05-13 07:27:20 +00:00
/* Printer data */
2002-05-15 06:22:53 +00:00
{ " getprinterdata " , ( PyCFunction ) spoolss_hnd_getprinterdata ,
2002-05-13 07:27:20 +00:00
METH_VARARGS | METH_KEYWORDS ,
" Get printer data. " } ,
2002-05-15 06:22:53 +00:00
{ " setprinterdata " , ( PyCFunction ) spoolss_hnd_setprinterdata ,
2002-05-13 07:27:20 +00:00
METH_VARARGS | METH_KEYWORDS ,
" Set printer data. " } ,
2002-05-15 06:22:53 +00:00
{ " enumprinterdata " , ( PyCFunction ) spoolss_hnd_enumprinterdata ,
2002-05-13 07:27:20 +00:00
METH_VARARGS | METH_KEYWORDS ,
" Enumerate printer data. " } ,
2002-05-15 06:22:53 +00:00
{ " deleteprinterdata " , ( PyCFunction ) spoolss_hnd_deleteprinterdata ,
2002-05-14 07:15:43 +00:00
METH_VARARGS | METH_KEYWORDS ,
" Delete printer data. " } ,
2002-05-15 06:22:53 +00:00
{ " deleteprinterdataex " , ( PyCFunction ) spoolss_hnd_deleteprinterdataex ,
2002-05-14 07:15:43 +00:00
METH_VARARGS | METH_KEYWORDS ,
" Delete printer data. " } ,
2002-03-20 03:29:03 +00:00
{ NULL }
2002-03-26 11:12:16 +00:00
} ;
static void py_policy_hnd_dealloc ( PyObject * self )
{
2002-04-14 23:33:31 +00:00
spoolss_policy_hnd_object * hnd ;
/* Close down policy handle and free talloc context */
hnd = ( spoolss_policy_hnd_object * ) self ;
cli_shutdown ( hnd - > cli ) ;
talloc_destroy ( hnd - > mem_ctx ) ;
2002-03-26 11:12:16 +00:00
PyObject_Del ( self ) ;
}
static PyObject * py_policy_hnd_getattr ( PyObject * self , char * attrname )
{
return Py_FindMethod ( spoolss_hnd_methods , self , attrname ) ;
}
2002-04-03 04:40:35 +00:00
static char spoolss_type_doc [ ] =
" Python wrapper for Windows NT SPOOLSS rpc pipe. " ;
2002-03-26 11:12:16 +00:00
PyTypeObject spoolss_policy_hnd_type = {
PyObject_HEAD_INIT ( NULL )
0 ,
2002-04-03 04:40:35 +00:00
" spoolss.hnd " ,
2002-03-26 11:12:16 +00:00
sizeof ( spoolss_policy_hnd_object ) ,
0 ,
2002-04-03 04:40:35 +00:00
py_policy_hnd_dealloc , /* tp_dealloc*/
0 , /* tp_print*/
py_policy_hnd_getattr , /* tp_getattr*/
0 , /* tp_setattr*/
0 , /* tp_compare*/
0 , /* tp_repr*/
0 , /* tp_as_number*/
0 , /* tp_as_sequence*/
0 , /* tp_as_mapping*/
0 , /* tp_hash */
0 , /* tp_call */
0 , /* tp_str */
0 , /* tp_getattro */
0 , /* tp_setattro */
0 , /* tp_as_buffer*/
Py_TPFLAGS_DEFAULT , /* tp_flags */
spoolss_type_doc , /* tp_doc */
2002-03-20 03:29:03 +00:00
} ;
/* Initialise constants */
2002-05-14 02:37:47 +00:00
static struct const_vals {
2002-03-20 03:29:03 +00:00
char * name ;
uint32 value ;
2002-05-14 02:37:47 +00:00
} module_const_vals [ ] = {
2002-03-20 03:29:03 +00:00
/* Access permissions */
{ " MAXIMUM_ALLOWED_ACCESS " , MAXIMUM_ALLOWED_ACCESS } ,
{ " SERVER_ALL_ACCESS " , SERVER_ALL_ACCESS } ,
2002-04-11 01:35:53 +00:00
{ " SERVER_READ " , SERVER_READ } ,
{ " SERVER_WRITE " , SERVER_WRITE } ,
{ " SERVER_EXECUTE " , SERVER_EXECUTE } ,
{ " SERVER_ACCESS_ADMINISTER " , SERVER_ACCESS_ADMINISTER } ,
{ " SERVER_ACCESS_ENUMERATE " , SERVER_ACCESS_ENUMERATE } ,
2002-03-20 03:29:03 +00:00
{ " PRINTER_ALL_ACCESS " , PRINTER_ALL_ACCESS } ,
2002-04-11 01:35:53 +00:00
{ " PRINTER_READ " , PRINTER_READ } ,
{ " PRINTER_WRITE " , PRINTER_WRITE } ,
{ " PRINTER_EXECUTE " , PRINTER_EXECUTE } ,
{ " PRINTER_ACCESS_ADMINISTER " , PRINTER_ACCESS_ADMINISTER } ,
{ " PRINTER_ACCESS_USE " , PRINTER_ACCESS_USE } ,
{ " JOB_ACCESS_ADMINISTER " , JOB_ACCESS_ADMINISTER } ,
{ " JOB_ALL_ACCESS " , JOB_ALL_ACCESS } ,
{ " JOB_READ " , JOB_READ } ,
{ " JOB_WRITE " , JOB_WRITE } ,
{ " JOB_EXECUTE " , JOB_EXECUTE } ,
{ " STANDARD_RIGHTS_ALL_ACCESS " , STANDARD_RIGHTS_ALL_ACCESS } ,
{ " STANDARD_RIGHTS_EXECUTE_ACCESS " , STANDARD_RIGHTS_EXECUTE_ACCESS } ,
{ " STANDARD_RIGHTS_READ_ACCESS " , STANDARD_RIGHTS_READ_ACCESS } ,
{ " STANDARD_RIGHTS_REQUIRED_ACCESS " , STANDARD_RIGHTS_REQUIRED_ACCESS } ,
{ " STANDARD_RIGHTS_WRITE_ACCESS " , STANDARD_RIGHTS_WRITE_ACCESS } ,
2002-03-20 03:29:03 +00:00
/* Printer enumeration flags */
{ " PRINTER_ENUM_DEFAULT " , PRINTER_ENUM_DEFAULT } ,
{ " PRINTER_ENUM_LOCAL " , PRINTER_ENUM_LOCAL } ,
{ " PRINTER_ENUM_CONNECTIONS " , PRINTER_ENUM_CONNECTIONS } ,
{ " PRINTER_ENUM_FAVORITE " , PRINTER_ENUM_FAVORITE } ,
{ " PRINTER_ENUM_NAME " , PRINTER_ENUM_NAME } ,
{ " PRINTER_ENUM_REMOTE " , PRINTER_ENUM_REMOTE } ,
{ " PRINTER_ENUM_SHARED " , PRINTER_ENUM_SHARED } ,
{ " PRINTER_ENUM_NETWORK " , PRINTER_ENUM_NETWORK } ,
2002-04-09 04:22:27 +00:00
/* Form types */
{ " FORM_USER " , FORM_USER } ,
{ " FORM_BUILTIN " , FORM_BUILTIN } ,
{ " FORM_PRINTER " , FORM_PRINTER } ,
/* WERRORs */
{ " WERR_OK " , 0 } ,
{ " WERR_BADFILE " , 2 } ,
{ " WERR_ACCESS_DENIED " , 5 } ,
{ " WERR_BADFID " , 6 } ,
{ " WERR_BADFUNC " , 1 } ,
{ " WERR_INSUFFICIENT_BUFFER " , 122 } ,
{ " WERR_NO_SUCH_SHARE " , 67 } ,
{ " WERR_ALREADY_EXISTS " , 80 } ,
{ " WERR_INVALID_PARAM " , 87 } ,
{ " WERR_NOT_SUPPORTED " , 50 } ,
{ " WERR_BAD_PASSWORD " , 86 } ,
{ " WERR_NOMEM " , 8 } ,
{ " WERR_INVALID_NAME " , 123 } ,
{ " WERR_UNKNOWN_LEVEL " , 124 } ,
{ " WERR_OBJECT_PATH_INVALID " , 161 } ,
{ " WERR_NO_MORE_ITEMS " , 259 } ,
{ " WERR_MORE_DATA " , 234 } ,
{ " WERR_UNKNOWN_PRINTER_DRIVER " , 1797 } ,
{ " WERR_INVALID_PRINTER_NAME " , 1801 } ,
{ " WERR_PRINTER_ALREADY_EXISTS " , 1802 } ,
{ " WERR_INVALID_DATATYPE " , 1804 } ,
{ " WERR_INVALID_ENVIRONMENT " , 1805 } ,
2002-04-09 05:11:34 +00:00
{ " WERR_INVALID_FORM_NAME " , 1902 } ,
2002-04-09 04:22:27 +00:00
{ " WERR_INVALID_FORM_SIZE " , 1903 } ,
{ " WERR_BUF_TOO_SMALL " , 2123 } ,
{ " WERR_JOB_NOT_FOUND " , 2151 } ,
{ " WERR_DEST_NOT_FOUND " , 2152 } ,
{ " WERR_NOT_LOCAL_DOMAIN " , 2320 } ,
{ " WERR_PRINTER_DRIVER_IN_USE " , 3001 } ,
{ " WERR_STATUS_MORE_ENTRIES " , 0x0105 } ,
2002-05-08 04:26:22 +00:00
/* Job control constants */
{ " JOB_CONTROL_PAUSE " , JOB_CONTROL_PAUSE } ,
{ " JOB_CONTROL_RESUME " , JOB_CONTROL_RESUME } ,
{ " JOB_CONTROL_CANCEL " , JOB_CONTROL_CANCEL } ,
{ " JOB_CONTROL_RESTART " , JOB_CONTROL_RESTART } ,
{ " JOB_CONTROL_DELETE " , JOB_CONTROL_DELETE } ,
2002-03-20 03:29:03 +00:00
{ NULL } ,
} ;
static void const_init ( PyObject * dict )
{
2002-05-14 02:37:47 +00:00
struct const_vals * tmp ;
2002-03-20 03:29:03 +00:00
PyObject * obj ;
2002-05-14 02:37:47 +00:00
for ( tmp = module_const_vals ; tmp - > name ; tmp + + ) {
2002-03-20 03:29:03 +00:00
obj = PyInt_FromLong ( tmp - > value ) ;
PyDict_SetItemString ( dict , tmp - > name , obj ) ;
2002-03-26 06:25:47 +00:00
Py_DECREF ( obj ) ;
2002-03-20 03:29:03 +00:00
}
}
/* Module initialisation */
void initspoolss ( void )
{
PyObject * module , * dict ;
/* Initialise module */
module = Py_InitModule ( " spoolss " , spoolss_methods ) ;
dict = PyModule_GetDict ( module ) ;
2002-04-14 23:33:31 +00:00
/* Exceptions we can raise */
2002-03-20 03:29:03 +00:00
spoolss_error = PyErr_NewException ( " spoolss.error " , NULL , NULL ) ;
PyDict_SetItemString ( dict , " error " , spoolss_error ) ;
spoolss_werror = PyErr_NewException ( " spoolss.werror " , NULL , NULL ) ;
PyDict_SetItemString ( dict , " werror " , spoolss_werror ) ;
/* Initialise policy handle object */
spoolss_policy_hnd_type . ob_type = & PyType_Type ;
2002-04-03 04:40:35 +00:00
PyDict_SetItemString ( dict , " spoolss.hnd " ,
( PyObject * ) & spoolss_policy_hnd_type ) ;
2002-03-20 03:29:03 +00:00
/* Initialise constants */
const_init ( dict ) ;
/* Do samba initialisation */
py_samba_init ( ) ;
}