diff options
| author | Tim Potter <tpot@samba.org> | 2002-11-06 23:34:12 +0000 | 
|---|---|---|
| committer | Tim Potter <tpot@samba.org> | 2002-11-06 23:34:12 +0000 | 
| commit | f4766f4900c87a82d49f39dadac56e74debef920 (patch) | |
| tree | 0a2f2a92aceceb8a0fcfb063bd79425c8ede173a | |
| parent | 6ae9de8f39ea80622be091c95a7461c5d106de13 (diff) | |
| download | samba-f4766f4900c87a82d49f39dadac56e74debef920.tar.gz samba-f4766f4900c87a82d49f39dadac56e74debef920.tar.bz2 samba-f4766f4900c87a82d49f39dadac56e74debef920.zip  | |
Moved function to parse a list of unicode strings into util file.
It's now used in parsing printer driver structures and the response
from the enumprinterkey rpc.
(This used to be commit acecee6f2bb92c4992078f4fe2dfae4414f43482)
| -rw-r--r-- | source3/python/py_conv.c | 24 | ||||
| -rw-r--r-- | source3/python/py_spoolss_drivers_conv.c | 28 | 
2 files changed, 26 insertions, 26 deletions
diff --git a/source3/python/py_conv.c b/source3/python/py_conv.c index 20302c83e8..04b4194824 100644 --- a/source3/python/py_conv.c +++ b/source3/python/py_conv.c @@ -182,3 +182,27 @@ done:  	return result;  } + +/* Convert a NULL terminated list of NULL terminated unicode strings +   to a list of (char *) strings */ + +PyObject *from_unistr_list(uint16 *dependentfiles) +{ +	PyObject *list; +	int offset = 0; + +	list = PyList_New(0); + +	while (*(dependentfiles + offset) != 0) { +		fstring name; +		int len; + +		len = rpcstr_pull(name, dependentfiles + offset, +				  sizeof(fstring), -1, STR_TERMINATE); + +		offset += len / 2; +		PyList_Append(list, PyString_FromString(name)); +	} + +	return list; +} diff --git a/source3/python/py_spoolss_drivers_conv.c b/source3/python/py_spoolss_drivers_conv.c index fd47c0e84d..9bc8408052 100644 --- a/source3/python/py_spoolss_drivers_conv.c +++ b/source3/python/py_spoolss_drivers_conv.c @@ -78,30 +78,6 @@ struct pyconv py_DRIVER_DIRECTORY_1[] = {  	{ NULL }  }; -/* Convert a NULL terminated list of NULL terminated unicode strings -   to a list of (char *) strings */ - -static PyObject *from_dependentfiles(uint16 *dependentfiles) -{ -	PyObject *list; -	int offset = 0; - -	list = PyList_New(0); - -	while (*(dependentfiles + offset) != 0) { -		fstring name; -		int len; - -		len = rpcstr_pull(name, dependentfiles + offset, -				  sizeof(fstring), -1, STR_TERMINATE); - -		offset += len / 2; -		PyList_Append(list, PyString_FromString(name)); -	} - -	return list; -} -  static uint16 *to_dependentfiles(PyObject *dict)  {  	return (uint16 *)"abcd\0"; @@ -141,7 +117,7 @@ BOOL py_from_DRIVER_INFO_3(PyObject **dict, DRIVER_INFO_3 *info)  	PyDict_SetItemString(  		*dict, "dependent_files",  -		from_dependentfiles(info->dependentfiles)); +		from_unistr_list(info->dependentfiles));  	return True;  } @@ -181,7 +157,7 @@ BOOL py_from_DRIVER_INFO_6(PyObject **dict, DRIVER_INFO_6 *info)  	PyDict_SetItemString(*dict, "level", PyInt_FromLong(6));  	PyDict_SetItemString(  		*dict, "dependent_files",  -		from_dependentfiles (info->dependentfiles)); +		from_unistr_list(info->dependentfiles));  	return True;  }  | 
