python/py_spoolss_printers_conv.c

説明を見る。
00001 /* 
00002    Python wrappers for DCERPC/SMB client routines.
00003 
00004    Copyright (C) Tim Potter, 2002
00005    
00006    This program is free software; you can redistribute it and/or modify
00007    it under the terms of the GNU General Public License as published by
00008    the Free Software Foundation; either version 2 of the License, or
00009    (at your option) any later version.
00010    
00011    This program is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014    GNU General Public License for more details.
00015    
00016    You should have received a copy of the GNU General Public License
00017    along with this program; if not, write to the Free Software
00018    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00019 */
00020 
00021 #include "python/py_spoolss.h"
00022 #include "python/py_conv.h"
00023 
00024 struct pyconv py_PRINTER_INFO_0[] = {
00025         { "name", PY_UNISTR, offsetof(PRINTER_INFO_0, printername) },
00026         { "server_name", PY_UNISTR, offsetof(PRINTER_INFO_0, servername) },
00027 
00028         { "cjobs", PY_UINT32, offsetof(PRINTER_INFO_0, cjobs) },
00029         { "total_jobs", PY_UINT32, offsetof(PRINTER_INFO_0, total_jobs) },
00030         { "total_bytes", PY_UINT32, offsetof(PRINTER_INFO_0, total_bytes) },
00031 
00032         { "year", PY_UINT16, offsetof(PRINTER_INFO_0, year) },
00033         { "month", PY_UINT16, offsetof(PRINTER_INFO_0, month) },
00034         { "day_of_week", PY_UINT16, offsetof(PRINTER_INFO_0, dayofweek) },
00035         { "day", PY_UINT16, offsetof(PRINTER_INFO_0, day) },
00036         { "hour", PY_UINT16, offsetof(PRINTER_INFO_0, hour) },
00037         { "minute", PY_UINT16, offsetof(PRINTER_INFO_0, minute) },
00038         { "second", PY_UINT16, offsetof(PRINTER_INFO_0, second) },
00039         { "milliseconds", PY_UINT16, offsetof(PRINTER_INFO_0, milliseconds) },
00040 
00041         { "global_counter", PY_UINT32, offsetof(PRINTER_INFO_0, global_counter) },
00042         { "total_pages", PY_UINT32, offsetof(PRINTER_INFO_0, total_pages) },
00043 
00044         { "major_version", PY_UINT16, offsetof(PRINTER_INFO_0, major_version) },
00045         { "build_version", PY_UINT16, offsetof(PRINTER_INFO_0, build_version) },
00046 
00047         { "unknown7", PY_UINT32, offsetof(PRINTER_INFO_0, unknown7) },
00048         { "unknown8", PY_UINT32, offsetof(PRINTER_INFO_0, unknown8) },
00049         { "unknown9", PY_UINT32, offsetof(PRINTER_INFO_0, unknown9) },
00050         { "session_counter", PY_UINT32, offsetof(PRINTER_INFO_0, session_counter)},
00051         { "unknown11", PY_UINT32, offsetof(PRINTER_INFO_0, unknown11) },
00052         { "printer_errors", PY_UINT32, offsetof(PRINTER_INFO_0, printer_errors) },
00053         { "unknown13", PY_UINT32, offsetof(PRINTER_INFO_0, unknown13) },
00054         { "unknown14", PY_UINT32, offsetof(PRINTER_INFO_0, unknown14) },
00055         { "unknown15", PY_UINT32, offsetof(PRINTER_INFO_0, unknown15) },
00056         { "unknown16", PY_UINT32, offsetof(PRINTER_INFO_0, unknown16) },
00057         { "change_id", PY_UINT32, offsetof(PRINTER_INFO_0, change_id) },
00058         { "unknown18", PY_UINT32, offsetof(PRINTER_INFO_0, unknown18) },
00059         { "status", PY_UINT32, offsetof(PRINTER_INFO_0, status) },
00060         { "unknown20", PY_UINT32, offsetof(PRINTER_INFO_0, unknown20) },
00061         { "c_setprinter", PY_UINT32, offsetof(PRINTER_INFO_0, c_setprinter) },
00062         { "unknown22", PY_UINT32, offsetof(PRINTER_INFO_0, unknown22) },
00063         { "unknown23", PY_UINT32, offsetof(PRINTER_INFO_0, unknown23) },
00064         { "unknown24", PY_UINT32, offsetof(PRINTER_INFO_0, unknown24) },
00065         { "unknown25", PY_UINT32, offsetof(PRINTER_INFO_0, unknown25) },
00066         { "unknown26", PY_UINT32, offsetof(PRINTER_INFO_0, unknown26) },
00067         { "unknown27", PY_UINT32, offsetof(PRINTER_INFO_0, unknown27) },
00068         { "unknown28", PY_UINT32, offsetof(PRINTER_INFO_0, unknown28) },
00069         { "unknown29", PY_UINT32, offsetof(PRINTER_INFO_0, unknown29) },
00070 
00071         { NULL }
00072 };      
00073 
00074 struct pyconv py_PRINTER_INFO_1[] = {
00075         { "name", PY_UNISTR, offsetof(PRINTER_INFO_1, name) },
00076         { "description", PY_UNISTR, offsetof(PRINTER_INFO_1, description) },
00077         { "comment", PY_UNISTR, offsetof(PRINTER_INFO_1, comment) },
00078         { "flags", PY_UINT32, offsetof(PRINTER_INFO_1, flags) },
00079         { NULL }
00080 };      
00081 
00082 struct pyconv py_PRINTER_INFO_2[] = {
00083         { "server_name", PY_UNISTR, offsetof(PRINTER_INFO_2, servername) },
00084         { "name", PY_UNISTR, offsetof(PRINTER_INFO_2, printername) },
00085         { "share_name", PY_UNISTR, offsetof(PRINTER_INFO_2, sharename) },
00086         { "port_name", PY_UNISTR, offsetof(PRINTER_INFO_2, portname) },
00087         { "driver_name", PY_UNISTR, offsetof(PRINTER_INFO_2, drivername) },
00088         { "comment", PY_UNISTR, offsetof(PRINTER_INFO_2, comment) },
00089         { "location", PY_UNISTR, offsetof(PRINTER_INFO_2, location) },
00090         { "datatype", PY_UNISTR, offsetof(PRINTER_INFO_2, datatype) },
00091         { "sepfile", PY_UNISTR, offsetof(PRINTER_INFO_2, sepfile) },
00092         { "print_processor", PY_UNISTR, offsetof(PRINTER_INFO_2, printprocessor) },
00093         { "parameters", PY_UNISTR, offsetof(PRINTER_INFO_2, parameters) },
00094         { "attributes", PY_UINT32, offsetof(PRINTER_INFO_2, attributes) },
00095         { "default_priority", PY_UINT32, offsetof(PRINTER_INFO_2, defaultpriority) },
00096         { "priority", PY_UINT32, offsetof(PRINTER_INFO_2, priority) },
00097         { "start_time", PY_UINT32, offsetof(PRINTER_INFO_2, starttime) },
00098         { "until_time", PY_UINT32, offsetof(PRINTER_INFO_2, untiltime) },
00099         { "status", PY_UINT32, offsetof(PRINTER_INFO_2, status) },
00100         { "cjobs", PY_UINT32, offsetof(PRINTER_INFO_2, cjobs) },
00101         { "average_ppm", PY_UINT32, offsetof(PRINTER_INFO_2, averageppm) },
00102         { NULL }
00103 };      
00104 
00105 struct pyconv py_PRINTER_INFO_3[] = {
00106         { NULL }
00107 };      
00108 
00109 struct pyconv py_DEVICEMODE[] = {
00110         { "device_name", PY_UNISTR, offsetof(DEVICEMODE, devicename) },
00111         { "spec_version", PY_UINT16, offsetof(DEVICEMODE, specversion) },
00112         { "driver_version", PY_UINT16, offsetof(DEVICEMODE, driverversion) },
00113         { "size", PY_UINT16, offsetof(DEVICEMODE, size) },
00114         { "fields", PY_UINT16, offsetof(DEVICEMODE, fields) },
00115         { "orientation", PY_UINT16, offsetof(DEVICEMODE, orientation) },
00116         { "paper_size", PY_UINT16, offsetof(DEVICEMODE, papersize) },
00117         { "paper_width", PY_UINT16, offsetof(DEVICEMODE, paperwidth) },
00118         { "paper_length", PY_UINT16, offsetof(DEVICEMODE, paperlength) },
00119         { "scale", PY_UINT16, offsetof(DEVICEMODE, scale) },
00120         { "copies", PY_UINT16, offsetof(DEVICEMODE, copies) },
00121         { "default_source", PY_UINT16, offsetof(DEVICEMODE, defaultsource) },
00122         { "print_quality", PY_UINT16, offsetof(DEVICEMODE, printquality) },
00123         { "color", PY_UINT16, offsetof(DEVICEMODE, color) },
00124         { "duplex", PY_UINT16, offsetof(DEVICEMODE, duplex) },
00125         { "y_resolution", PY_UINT16, offsetof(DEVICEMODE, yresolution) },
00126         { "tt_option", PY_UINT16, offsetof(DEVICEMODE, ttoption) },
00127         { "collate", PY_UINT16, offsetof(DEVICEMODE, collate) },
00128         { "form_name", PY_UNISTR, offsetof(DEVICEMODE, formname) },
00129         { "log_pixels", PY_UINT16, offsetof(DEVICEMODE, logpixels) },
00130         { "bits_per_pel", PY_UINT32, offsetof(DEVICEMODE, bitsperpel) },
00131         { "pels_width", PY_UINT32, offsetof(DEVICEMODE, pelswidth) },
00132         { "pels_height", PY_UINT32, offsetof(DEVICEMODE, pelsheight) },
00133         { "display_flags", PY_UINT32, offsetof(DEVICEMODE, displayflags) },
00134         { "display_frequency", PY_UINT32, offsetof(DEVICEMODE, displayfrequency) },
00135         { "icm_method", PY_UINT32, offsetof(DEVICEMODE, icmmethod) },
00136         { "icm_intent", PY_UINT32, offsetof(DEVICEMODE, icmintent) },
00137         { "media_type", PY_UINT32, offsetof(DEVICEMODE, mediatype) },
00138         { "dither_type", PY_UINT32, offsetof(DEVICEMODE, dithertype) },
00139         { "reserved1", PY_UINT32, offsetof(DEVICEMODE, reserved1) },
00140         { "reserved2", PY_UINT32, offsetof(DEVICEMODE, reserved2) },
00141         { "panning_width", PY_UINT32, offsetof(DEVICEMODE, panningwidth) },
00142         { "panning_height", PY_UINT32, offsetof(DEVICEMODE, panningheight) },
00143         { NULL }
00144 };
00145 
00146 /*
00147  * Convert between DEVICEMODE and Python
00148  */
00149 
00150 BOOL py_from_DEVICEMODE(PyObject **dict, DEVICEMODE *devmode)
00151 {
00152         *dict = from_struct(devmode, py_DEVICEMODE);
00153 
00154         PyDict_SetItemString(*dict, "private",
00155                              PyString_FromStringAndSize(
00156                                      devmode->dev_private, devmode->driverextra));
00157 
00158         return True;
00159 }
00160 
00161 BOOL py_to_DEVICEMODE(DEVICEMODE *devmode, PyObject *dict)
00162 {
00163         PyObject *obj, *dict_copy = PyDict_Copy(dict);
00164         BOOL result = False;
00165 
00166         if (!(obj = PyDict_GetItemString(dict_copy, "private")))
00167                 goto done;
00168 
00169         if (!PyString_Check(obj))
00170                 goto done;
00171 
00172         devmode->dev_private = PyString_AsString(obj);
00173         devmode->driverextra = PyString_Size(obj);
00174 
00175         PyDict_DelItemString(dict_copy, "private");
00176 
00177         if (!to_struct(devmode, dict_copy, py_DEVICEMODE))
00178                 goto done;
00179 
00180         result = True;
00181 
00182 done:
00183         Py_DECREF(dict_copy);
00184         return result;
00185 }
00186 
00187 /*
00188  * Convert between PRINTER_INFO_0 and Python 
00189  */
00190 
00191 BOOL py_from_PRINTER_INFO_0(PyObject **dict, PRINTER_INFO_0 *info)
00192 {
00193         *dict = from_struct(info, py_PRINTER_INFO_0);
00194         PyDict_SetItemString(*dict, "level", PyInt_FromLong(0));
00195         return True;
00196 }
00197 
00198 BOOL py_to_PRINTER_INFO_0(PRINTER_INFO_0 *info, PyObject *dict)
00199 {
00200         return False;
00201 }
00202 
00203 /*
00204  * Convert between PRINTER_INFO_1 and Python 
00205  */
00206 
00207 BOOL py_from_PRINTER_INFO_1(PyObject **dict, PRINTER_INFO_1 *info)
00208 {
00209         *dict = from_struct(info, py_PRINTER_INFO_1);
00210         PyDict_SetItemString(*dict, "level", PyInt_FromLong(1));
00211         return True;
00212 }
00213 
00214 BOOL py_to_PRINTER_INFO_1(PRINTER_INFO_1 *info, PyObject *dict)
00215 {
00216         PyObject *obj, *dict_copy = PyDict_Copy(dict);
00217         BOOL result = False;
00218 
00219         if (!(obj = PyDict_GetItemString(dict_copy, "level")) ||
00220             !PyInt_Check(obj))
00221                 goto done;
00222 
00223         PyDict_DelItemString(dict_copy, "level");
00224 
00225         if (!to_struct(info, dict_copy, py_PRINTER_INFO_1))
00226                 goto done;
00227 
00228         result = True;
00229 
00230 done:
00231         Py_DECREF(dict_copy);
00232         return result;
00233 }
00234 
00235 /*
00236  * Convert between PRINTER_INFO_2 and Python 
00237  */
00238 
00239 BOOL py_from_PRINTER_INFO_2(PyObject **dict, PRINTER_INFO_2 *info)
00240 {
00241         PyObject *obj;
00242 
00243         *dict = from_struct(info, py_PRINTER_INFO_2);
00244 
00245         /* The security descriptor could be NULL */
00246 
00247         if (info->secdesc) {
00248                 if (py_from_SECDESC(&obj, info->secdesc))
00249                         PyDict_SetItemString(*dict, "security_descriptor", obj);
00250         }
00251 
00252         /* Bong!  The devmode could be NULL */
00253 
00254         if (info->devmode)
00255                 py_from_DEVICEMODE(&obj, info->devmode);
00256         else
00257                 obj = PyDict_New();
00258 
00259         PyDict_SetItemString(*dict, "device_mode", obj);
00260 
00261         PyDict_SetItemString(*dict, "level", PyInt_FromLong(2));
00262 
00263         return True;
00264 }
00265 
00266 BOOL py_to_PRINTER_INFO_2(PRINTER_INFO_2 *info, PyObject *dict,
00267                           TALLOC_CTX *mem_ctx)
00268 {
00269         PyObject *obj, *dict_copy = PyDict_Copy(dict);
00270         BOOL result = False;
00271 
00272         /* Convert security descriptor - may be NULL */
00273 
00274         info->secdesc = NULL;
00275 
00276         if ((obj = PyDict_GetItemString(dict_copy, "security_descriptor"))) {
00277 
00278                 if (!PyDict_Check(obj))
00279                         goto done;
00280 
00281                 if (!py_to_SECDESC(&info->secdesc, obj, mem_ctx))
00282                         goto done;
00283 
00284                 PyDict_DelItemString(dict_copy, "security_descriptor");
00285         }
00286 
00287         /* Convert device mode */
00288 
00289         if (!(obj = PyDict_GetItemString(dict_copy, "device_mode"))
00290             || !PyDict_Check(obj))
00291                 goto done;
00292 
00293         info->devmode = _talloc(mem_ctx, sizeof(DEVICEMODE));
00294 
00295         if (!py_to_DEVICEMODE(info->devmode, obj))
00296                 goto done;
00297 
00298         PyDict_DelItemString(dict_copy, "device_mode");
00299 
00300         /* Check info level */
00301 
00302         if (!(obj = PyDict_GetItemString(dict_copy, "level")) ||
00303             !PyInt_Check(obj))
00304                 goto done;
00305 
00306         PyDict_DelItemString(dict_copy, "level");
00307 
00308         /* Convert remaining elements of dictionary */
00309 
00310         if (!to_struct(info, dict_copy, py_PRINTER_INFO_2))
00311                 goto done;
00312 
00313         result = True;
00314 
00315 done:
00316         Py_DECREF(dict_copy);
00317         return result;
00318 }
00319 
00320 /*
00321  * Convert between PRINTER_INFO_1 and Python 
00322  */
00323 
00324 BOOL py_from_PRINTER_INFO_3(PyObject **dict, PRINTER_INFO_3 *info)
00325 {
00326         PyObject *obj;  
00327 
00328         *dict = from_struct(info, py_PRINTER_INFO_3);
00329 
00330         if (py_from_SECDESC(&obj, info->secdesc))
00331                 PyDict_SetItemString(*dict, "security_descriptor", obj);
00332 
00333         PyDict_SetItemString(*dict, "level", PyInt_FromLong(3));
00334 
00335         return True;
00336 }
00337 
00338 BOOL py_to_PRINTER_INFO_3(PRINTER_INFO_3 *info, PyObject *dict,
00339                           TALLOC_CTX *mem_ctx)
00340 {
00341         PyObject *obj;
00342 
00343         if (!to_struct(info, dict, py_PRINTER_INFO_3))
00344                 return False;
00345 
00346         if (!(obj = PyDict_GetItemString(dict, "security_descriptor")))
00347                 return False;
00348 
00349         if (!py_to_SECDESC(&info->secdesc, obj, mem_ctx))
00350                 return False;
00351 
00352         return True;
00353 }

Sambaに対してSat Aug 29 21:23:14 2009に生成されました。  doxygen 1.4.7