FSSetCats.c revision ba6a1819
1/* $Xorg: FSSetCats.c,v 1.4 2001/02/09 02:03:25 xorgcvs Exp $ */ 2 3/* @(#)FSFlush.c 4.1 91/05/02 4 * Copyright 1990 Network Computing Devices; 5 * Portions Copyright 1987 by Digital Equipment Corporation 6 * 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. 17 * 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 25 * SOFTWARE. 26 */ 27/* $XFree86: xc/lib/FS/FSSetCats.c,v 1.4 2001/01/17 19:41:28 dawes Exp $ */ 28 29/* 30 31Copyright 1987, 1994, 1998 The Open Group 32 33Permission to use, copy, modify, distribute, and sell this software and its 34documentation for any purpose is hereby granted without fee, provided that 35the above copyright notice appear in all copies and that both that 36copyright notice and this permission notice appear in supporting 37documentation. 38 39The above copyright notice and this permission notice shall be included in 40all copies or substantial portions of the Software. 41 42THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 43IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 44FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 45OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 46AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 47CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 48 49Except as contained in this notice, the name of The Open Group shall not be 50used in advertising or otherwise to promote the sale, use or other dealings 51in this Software without prior written authorization from The Open Group. 52 53*/ 54 55#ifdef HAVE_CONFIG_H 56#include <config.h> 57#endif 58#include "FSlibint.h" 59 60int 61FSSetCatalogues( 62 FSServer *svr, 63 int num, 64 char **cats) 65{ 66 int nbytes; 67 fsSetCataloguesReq *req; 68 char buf[256]; 69 int i; 70 int len, tlen, tnum; 71 72 for (i = 0, tnum = 0, len = 0; i < num; i++) { 73 if ((tlen = strlen(cats[i])) < 256) { 74 len += tlen; 75 tnum++; 76 } 77 } 78 79 GetReq(SetCatalogues, req); 80 req->num_catalogues = tnum; 81 req->length += (len + 3) >> 2; 82 83 for (i = 0; i < num; i++) { 84 nbytes = strlen(cats[i]); 85 if (nbytes < 256) { 86 buf[0] = nbytes; 87 memcpy(&buf[1], cats[i], nbytes); 88 nbytes++; 89 _FSSend(svr, buf, (long) nbytes); 90 } 91 } 92 SyncHandle(); 93 return FSSuccess; 94} 95