[pywin32-checkins] pywin32/win32/src/win32net win32netfile.cpp,1.3,1.4
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: Roger U. <ru...@us...> - 2005-01-13 06:29:45
|
Update of /cvsroot/pywin32/pywin32/win32/src/win32net In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19016/win32/src/win32net Modified Files: win32netfile.cpp Log Message: Clean up argument checking, add Autoduck comments Index: win32netfile.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32net/win32netfile.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** win32netfile.cpp 29 Dec 2001 05:30:32 -0000 1.3 --- win32netfile.cpp 13 Jan 2005 06:29:32 -0000 1.4 *************** *** 1,2 **** --- 1,3 ---- + // @doc // Implemented and contributed by Roger Upole. #include "stdio.h" *************** *** 10,22 **** #include "win32net.h" PyObject * PyNetFileEnum(PyObject *self, PyObject *args) - { ! PyObject *server_name_obj =NULL; LPTSTR server_name = NULL; ! PyObject *base_path_obj = NULL; LPTSTR base_path = NULL; ! PyObject *user_name_obj =NULL; LPTSTR user_name = NULL; --- 11,28 ---- #include "win32net.h" + // @pymethod (dict,...)|win32net|NetFileEnum|Lists remotely opened resources on a server PyObject * PyNetFileEnum(PyObject *self, PyObject *args) { ! // @pyparm int|level||Level of information, 2 or 3 supported ! // @pyparm string/<o PyUnicode>|servername|None|The name of the server for which to list open resources, local machine assumed if None ! // @pyparm string/<o PyUnicode>|basepath|None|If specified, limits returned list to files on given path ! // @pyparm string/<o PyUnicode>|username|None|User that opened resource, or None to list open files for all users ! // @rdesc Returns a sequence of dictionaries representing FILE_INFO_* structs, depending on level specified ! PyObject *server_name_obj = Py_None; LPTSTR server_name = NULL; ! PyObject *base_path_obj = Py_None; LPTSTR base_path = NULL; ! PyObject *user_name_obj = Py_None; LPTSTR user_name = NULL; *************** *** 36,43 **** NET_API_STATUS nStatus; - long rc; long info_lvl=NULL; ! if (!PyArg_ParseTuple(args, "iO|OO", &info_lvl, &server_name_obj, &base_path_obj, &user_name_obj)) return NULL; if ((info_lvl != 2) && (info_lvl != 3)){ --- 42,48 ---- NET_API_STATUS nStatus; long info_lvl=NULL; ! if (!PyArg_ParseTuple(args, "i|OOO", &info_lvl, &server_name_obj, &base_path_obj, &user_name_obj)) return NULL; if ((info_lvl != 2) && (info_lvl != 3)){ *************** *** 46,56 **** } ! rc = PyWinObject_AsWCHAR(server_name_obj, &server_name, TRUE); ! if (PyTuple_Size(args)>2){ ! rc = PyWinObject_AsWCHAR(base_path_obj, &base_path, TRUE); ! }; ! if (PyTuple_Size(args)>3){ ! rc = PyWinObject_AsWCHAR(user_name_obj, &user_name, TRUE); ! }; ret_list = PyList_New(0); --- 51,60 ---- } ! if (!PyWinObject_AsWCHAR(server_name_obj, &server_name, TRUE)) ! goto done; ! if (!PyWinObject_AsWCHAR(base_path_obj, &base_path, TRUE)) ! goto done; ! if (!PyWinObject_AsWCHAR(user_name_obj, &user_name, TRUE)) ! goto done; ret_list = PyList_New(0); *************** *** 128,133 **** } } ! ! PyWinObject_FreeWCHAR(server_name); if (base_path != NULL) PyWinObject_FreeWCHAR(base_path); --- 132,138 ---- } } ! done: ! if (server_name!=NULL) ! PyWinObject_FreeWCHAR(server_name); if (base_path != NULL) PyWinObject_FreeWCHAR(base_path); *************** *** 137,158 **** } PyObject * PyNetFileClose(PyObject *self, PyObject *args) - { PyObject *server_name_obj =NULL; LPTSTR server_name = NULL; NET_API_STATUS nStatus; long file_id; - long rc; if (!PyArg_ParseTuple(args, "Oi", &server_name_obj, &file_id)) return NULL; ! rc = PyWinObject_AsWCHAR(server_name_obj, &server_name, TRUE); Py_BEGIN_ALLOW_THREADS nStatus=NetFileClose(server_name, file_id); Py_END_ALLOW_THREADS ! PyWinObject_FreeWCHAR(server_name); if (nStatus == NERR_Success){ --- 142,166 ---- } + // @pymethod (dict,...)|win32net|NetFileClose|Closes an open network resource on a server PyObject * PyNetFileClose(PyObject *self, PyObject *args) { + // @pyparm string/<o PyUnicode>|servername||Name of server on which to operate, local machine assumed if None + // @pyparm int|fileid||Id of opened resource, as returned by <om win32net.NetFileEnum> PyObject *server_name_obj =NULL; LPTSTR server_name = NULL; NET_API_STATUS nStatus; long file_id; if (!PyArg_ParseTuple(args, "Oi", &server_name_obj, &file_id)) return NULL; ! if (!PyWinObject_AsWCHAR(server_name_obj, &server_name, TRUE)) ! return NULL; Py_BEGIN_ALLOW_THREADS nStatus=NetFileClose(server_name, file_id); Py_END_ALLOW_THREADS ! if (server_name!=NULL) ! PyWinObject_FreeWCHAR(server_name); if (nStatus == NERR_Success){ *************** *** 166,173 **** --- 174,185 ---- } + // @pymethod dict|win32net|NetFileGetInfo|Returns information about an open network resource PyObject * PyNetFileGetInfo(PyObject *self, PyObject *args) { + // @pyparm int|level||Level of information to return, 2 or 3 supported + // @pyparm string/<o PyUnicode>|servername||Server on which resource is open, local machine assumed if None + // @pyparm int|fileid||Id of opened resource, as returned by <om win32net.NetFileEnum> PyObject *server_name_obj = NULL; PyObject *ret_dict = NULL; *************** *** 175,179 **** long info_lvl=NULL; DWORD file_id = NULL; - long rc; LPFILE_INFO_3 pTmpBuf3 = NULL; LPFILE_INFO_2 pTmpBuf2= NULL; --- 187,190 ---- *************** *** 187,191 **** } ! rc = PyWinObject_AsWCHAR(server_name_obj, &server_name, FALSE); switch (info_lvl){ case 2:{ --- 198,203 ---- } ! if (!PyWinObject_AsWCHAR(server_name_obj, &server_name, TRUE)) ! return NULL; switch (info_lvl){ case 2:{ *************** *** 226,231 **** } } ! ! PyWinObject_FreeWCHAR(server_name); return ret_dict; } --- 238,243 ---- } } ! if (server_name!=NULL) ! PyWinObject_FreeWCHAR(server_name); return ret_dict; } |