1
/* $Xorg: FSListExt.c,v 1.4 2001/02/09 02:03:25 xorgcvs Exp $ */
3
/* @(#)FSListExt.c 4.1 91/05/02
4
* Copyright 1990 Network Computing Devices;
5
* Portions Copyright 1987 by Digital Equipment Corporation
7
* Permission to use, copy, modify, distribute, and sell this software
8
* and its documentation for any purpose is hereby granted without fee,
9
* provided that the above copyright notice appear in all copies and
10
* that both that copyright notice and this permission notice appear
11
* in supporting documentation, and that the names of Network Computing
12
* Devices or Digital not be used in advertising or publicity pertaining
13
* to distribution of the software without specific, written prior
14
* permission. Network Computing Devices or Digital make no representations
15
* about the suitability of this software for any purpose. It is provided
16
* "as is" without express or implied warranty.
18
* NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH
19
* REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
20
* MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES
21
* OR DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES
22
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
23
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
24
* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
27
/* $XFree86: xc/lib/FS/FSListExt.c,v 1.6tsi Exp $ */
31
Copyright 1987, 1994, 1998 The Open Group
33
Permission to use, copy, modify, distribute, and sell this software and its
34
documentation for any purpose is hereby granted without fee, provided that
35
the above copyright notice appear in all copies and that both that
36
copyright notice and this permission notice appear in supporting
39
The above copyright notice and this permission notice shall be included in
40
all copies or substantial portions of the Software.
42
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
43
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
44
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
45
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
46
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
47
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
49
Except as contained in this notice, the name of The Open Group shall not be
50
used in advertising or otherwise to promote the sale, use or other dealings
51
in this Software without prior written authorization from The Open Group.
61
FSListExtensions(svr, next)
65
fsListExtensionsReply rep;
73
GetEmptyReq(ListExtensions, req);
75
if (!_FSReply(svr, (fsReply *) & rep, 0, fsFalse)) {
77
return (char **) NULL;
80
#if (SIZE_MAX >> 2) <= UINT_MAX
81
&& rep.nExtensions <= SIZE_MAX / sizeof(char *)
82
&& rep.length <= (SIZE_MAX>>2)
85
list = (char **) FSmalloc((unsigned)(rep.nExtensions * sizeof(char *)));
86
rlen = (rep.length << 2) - SIZEOF(fsListExtensionsReply);
87
c = (char *) FSmalloc((unsigned) rlen + 1);
88
if ((!list) || (!c)) {
90
FSfree((char *) list);
93
_FSEatData(svr, (unsigned long) rlen);
95
return (char **) NULL;
97
_FSReadPad(svr, c, rlen);
102
for (i = 0; i < rep.nExtensions; i++) {
103
list[i] = c + 1; /* skip length */
104
c += length + 1; /* find next length */
106
*c = '\0'; /* change length to NULL */
109
list = (char **) NULL;
112
*next = rep.nExtensions;
117
int FSFreeExtensionList(list)
122
FSfree((char *) list);