diff options
author | Reinhard Tartler <siretart@tauware.de> | 2011-10-10 17:43:39 +0200 |
---|---|---|
committer | Reinhard Tartler <siretart@tauware.de> | 2011-10-10 17:43:39 +0200 |
commit | f4092abdf94af6a99aff944d6264bc1284e8bdd4 (patch) | |
tree | 2ac1c9cc16ceb93edb2c4382c088dac5aeafdf0f /nx-X11/lib/FS | |
parent | a840692edc9c6d19cd7c057f68e39c7d95eb767d (diff) | |
download | nx-libs-nx-X11/3.1.0-1.tar.gz nx-libs-nx-X11/3.1.0-1.tar.bz2 nx-libs-nx-X11/3.1.0-1.zip |
Imported nx-X11-3.1.0-1.tar.gznx-X11/3.1.0-1
Summary: Imported nx-X11-3.1.0-1.tar.gz
Keywords:
Imported nx-X11-3.1.0-1.tar.gz
into Git repository
Diffstat (limited to 'nx-X11/lib/FS')
29 files changed, 5494 insertions, 0 deletions
diff --git a/nx-X11/lib/FS/FS-def.cpp b/nx-X11/lib/FS/FS-def.cpp new file mode 100644 index 000000000..fd1511263 --- /dev/null +++ b/nx-X11/lib/FS/FS-def.cpp @@ -0,0 +1,38 @@ +LIBRARY FS +VERSION LIBRARY_VERSION +EXPORTS + FSErrorList DATA + FSErrorListSize DATA + FSCloseFont + FSCloseServer + FSFlush + FSFree + FSFreeCatalogues + FSFreeExtensionList + FSFreeFontNames + FSGetCatalogues + FSGetErrorDatabaseText + FSGetErrorText + FSListCatalogues + FSListExtensions + FSListFonts + FSListFontsWithXInfo + FSMalloc + FSMaxRequestSize + FSNextEvent + FSOpenBitmapFont + FSOpenServer + FSQueryExtension + FSQueryXBitmaps16 + FSQueryXBitmaps8 + FSQueryXExtents16 + FSQueryXExtents8 + FSQueryXInfo + FSServerName + FSSetAfterFunction + FSSetCatalogues + FSSetErrorHandler + FSSetIOErrorHandler + FSSync + FSSynchronize +/* $XFree86$ */ diff --git a/nx-X11/lib/FS/FSClServ.c b/nx-X11/lib/FS/FSClServ.c new file mode 100644 index 000000000..1866cfcd5 --- /dev/null +++ b/nx-X11/lib/FS/FSClServ.c @@ -0,0 +1,93 @@ +/* $Xorg: FSClServ.c,v 1.4 2001/02/09 02:03:25 xorgcvs Exp $ */ + +/* @(#)FSClServ.c 4.1 91/05/02 + * Copyright 1990 Network Computing Devices; + * Portions Copyright 1987 by Digital Equipment Corporation + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation, and that the names of Network Computing + * Devices or Digital not be used in advertising or publicity pertaining + * to distribution of the software without specific, written prior + * permission. Network Computing Devices or Digital make no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH + * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES + * OR DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ +/* $XFree86: xc/lib/FS/FSClServ.c,v 1.4 2001/01/17 19:41:27 dawes Exp $ */ + +/* + +Copyright 1987, 1994, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +*/ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif +#include "FSlib.h" +#include "FSlibint.h" + +extern FSServer *_FSHeadOfServerList; + +int +FSCloseServer(svr) + FSServer *svr; +{ + _FSExtension *ext; + FSServer **sv = &_FSHeadOfServerList; + FSServer *s = _FSHeadOfServerList; + + svr->flags |= FSlibServerClosing; + (void) FSSync(svr, 1); /* throw out pending events */ + ext = svr->ext_procs; + while (ext) { + if (ext->close_server != NULL) + (*ext->close_server) (svr, &ext->codes); + ext = ext->next; + } + _FSDisconnectServer(svr->trans_conn); + while (s != NULL) { + if (s == svr) { + *sv = s->next; + _FSFreeServerStructure(svr); + break; + } + sv = &(s->next); + s = *sv; + } + if (_FSHeadOfServerList == NULL) { + _FSFreeQ(); + } + return 1; +} diff --git a/nx-X11/lib/FS/FSCloseFt.c b/nx-X11/lib/FS/FSCloseFt.c new file mode 100644 index 000000000..38ce7e6b8 --- /dev/null +++ b/nx-X11/lib/FS/FSCloseFt.c @@ -0,0 +1,70 @@ +/* $Xorg: FSCloseFt.c,v 1.4 2001/02/09 02:03:25 xorgcvs Exp $ */ + +/* @(#)FSCloseFt.c 4.1 91/05/02 + * Copyright 1990 Network Computing Devices; + * Portions Copyright 1987 by Digital Equipment Corporation + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation, and that the names of Network Computing + * Devices or Digital not be used in advertising or publicity pertaining + * to distribution of the software without specific, written prior + * permission. Network Computing Devices or Digital make no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH + * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES + * OR DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ + +/* + +Copyright 1987, 1994, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +*/ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif +#include "FSlibint.h" + + +int +FSCloseFont(svr, fid) + FSServer *svr; + Font fid; +{ + fsResourceReq *req; + + GetResReq(CloseFont, fid, req); + SyncHandle(); + return 1; +} diff --git a/nx-X11/lib/FS/FSConnServ.c b/nx-X11/lib/FS/FSConnServ.c new file mode 100644 index 000000000..6a66d87a5 --- /dev/null +++ b/nx-X11/lib/FS/FSConnServ.c @@ -0,0 +1,247 @@ +/* $Xorg: FSConnServ.c,v 1.4 2001/02/09 02:03:25 xorgcvs Exp $ */ + +/* + * Copyright 1990 Network Computing Devices; + * Portions Copyright 1987 by Digital Equipment Corporation + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation, and that the names of Network Computing + * Devices or Digital not be used in advertising or publicity pertaining + * to distribution of the software without specific, written prior + * permission. Network Computing Devices or Digital make no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH + * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES + * OR DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ + +/* + +Copyright 1987, 1994, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +*/ +/* $XFree86: xc/lib/FS/FSConnServ.c,v 3.10 2001/10/28 03:32:27 tsi Exp $ */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif +#include "FSlibint.h" +#include <stdio.h> +#include "X11/Xpoll.h" +#ifdef NCD +#include <fcntl.h> +#endif +#ifdef WIN32 +#define ECHECK(err) (WSAGetLastError() == err) +#else +#ifdef ISC +#define ECHECK(err) ((errno == err) || errno == EAGAIN || errno == EWOULDBLOCK) +#else +#define ECHECK(err) (errno == err) +#endif +#endif + +/* + * Attempts to connect to server, given server name. Returns transport + * connection object or NULL if connection fails. + */ + +#define FS_CONNECTION_RETRIES 5 + +XtransConnInfo +_FSConnectServer(server_name) + char *server_name; +{ + XtransConnInfo trans_conn = NULL; /* transport connection object */ + int retry, connect_stat; + int madeConnection = 0; + + /* + * Open the network connection. + */ + + for (retry = FS_CONNECTION_RETRIES; retry >= 0; retry--) + { + if ((trans_conn = _FSTransOpenCOTSClient(server_name)) == NULL) + { + break; + } + + if ((connect_stat = _FSTransConnect(trans_conn,server_name)) < 0) + { + _FSTransClose(trans_conn); + + if (connect_stat == TRANS_TRY_CONNECT_AGAIN) + { + sleep(1); + continue; + } + else + break; + } + else + { + madeConnection = 1; + break; + } + } + + if (!madeConnection) + return (NULL); + + + /* + * set it non-blocking. This is so we can read data when blocked for + * writing in the library. + */ + + _FSTransSetOption(trans_conn, TRANS_NONBLOCKING, 1); + + return (trans_conn); +} + +/* + * Disconnect from server. + */ + +void +_FSDisconnectServer(trans_conn) + XtransConnInfo trans_conn; + +{ + (void) _FSTransClose(trans_conn); +} + + +/* + * This is an OS dependent routine which: + * 1) returns as soon as the connection can be written on.... + * 2) if the connection can be read, must enqueue events and handle errors, + * until the connection is writable. + */ +void _FSWaitForWritable(svr) + FSServer *svr; +{ + fd_set r_mask; + fd_set w_mask; + int nfound; + + FD_ZERO(&r_mask); + FD_ZERO(&w_mask); + + while (1) { + FD_SET(svr->fd, &r_mask); + FD_SET(svr->fd, &w_mask); + + do { + nfound = Select(svr->fd + 1, &r_mask, &w_mask, NULL, NULL); + if (nfound < 0 && !ECHECK(EINTR)) + (*_FSIOErrorFunction) (svr); + } while (nfound <= 0); + + if (XFD_ANYSET(&r_mask)) { + char buf[BUFSIZE]; + BytesReadable_t pend_not_register; + register BytesReadable_t pend; + register fsEvent *ev; + + /* find out how much data can be read */ + if (_FSTransBytesReadable(svr->trans_conn, &pend_not_register) < 0) + (*_FSIOErrorFunction) (svr); + pend = pend_not_register; + + /* + * must read at least one fsEvent; if none is pending, then we'll + * just block waiting for it + */ + if (pend < SIZEOF(fsEvent)) + pend = SIZEOF(fsEvent); + + /* but we won't read more than the max buffer size */ + if (pend > BUFSIZE) + pend = BUFSIZE; + + /* round down to an integral number of FSReps */ + pend = (pend / SIZEOF(fsEvent)) * SIZEOF(fsEvent); + + _FSRead(svr, buf, pend); + + /* no space between comma and type or else macro will die */ + STARTITERATE(ev, fsEvent, buf, (pend > 0), + (pend -= SIZEOF(fsEvent))) { + if (ev->type == FS_Error) + _FSError(svr, (fsError *) ev); + else /* it's an event packet; enqueue it */ + _FSEnq(svr, ev); + } + ENDITERATE + } + if (XFD_ANYSET(&w_mask)) + return; + } +} + + +void _FSWaitForReadable(svr) + FSServer *svr; +{ + fd_set r_mask; + int result; + + FD_ZERO(&r_mask); + do { + FD_SET(svr->fd, &r_mask); + result = Select(svr->fd + 1, &r_mask, NULL, NULL, NULL); + if (result == -1 && !ECHECK(EINTR)) + (*_FSIOErrorFunction) (svr); + } while (result <= 0); +} + +void _FSSendClientPrefix(svr, client) + FSServer *svr; + fsConnClientPrefix *client; +{ + struct iovec iovarray[5], + *iov = iovarray; + int niov = 0; + +#define add_to_iov(b,l) \ + { iov->iov_base = (b); iov->iov_len = (l); iov++, niov++; } + + add_to_iov((caddr_t) client, SIZEOF(fsConnClientPrefix)); + +#undef add_to_iov + + (void) _FSTransWritev(svr->trans_conn, iovarray, niov); + return; +} diff --git a/nx-X11/lib/FS/FSErrDis.c b/nx-X11/lib/FS/FSErrDis.c new file mode 100644 index 000000000..cc4abf4b0 --- /dev/null +++ b/nx-X11/lib/FS/FSErrDis.c @@ -0,0 +1,121 @@ +/* $Xorg: FSErrDis.c,v 1.4 2001/02/09 02:03:25 xorgcvs Exp $ */ + +/* @(#)FSErrDis.c 4.1 91/05/02 + * Copyright 1990 Network Computing Devices; + * Portions Copyright 1987 by Digital Equipment Corporation + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation, and that the names of Network Computing + * Devices or Digital not be used in advertising or publicity pertaining + * to distribution of the software without specific, written prior + * permission. Network Computing Devices or Digital make no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH + * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES + * OR DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ + +/* + +Copyright 1987, 1994, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +*/ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif +#include <stdio.h> +#include "FSlibint.h" +#include <X11/Xos.h> + +char *FSErrorList[] = { + /* FSBadRequest */ "BadRequest, invalid request code or no such operation", + /* FSBadFormat */ "BadFormat, bad font format mask", + /* FSBadFont */ "BadFont, invalid Font parameter", + /* FSBadRange */ "BadRange, invalid character range attributes", + /* FSBadEventMask */ "BadEventMask, illegal event mask", + /* FSBadAccessContext */ "BadAccessContext, insufficient permissions for operation", + /* FSBadIDChoice */ "BadIDChoice, invalid resource ID chosen for this connection", + /* FSBadName */ "BadName, named font does not exist", + /* FSBadResolution */ "BadResolution, improperly formatted resolution", + /* FSBadAlloc */ "BadAlloc, insufficient resources for operation", + /* FSBadLength */ "BadLength, request too large or internal FSlib length error", + /* FSBadImplementation */ "BadImplementation, request unsupported", +}; +int FSErrorListSize = sizeof(FSErrorList); + + +/* ARGSUSED */ +int FSGetErrorDatabaseText(svr, name, type, defaultp, buffer, nbytes) + register char *name, + *type; + char *defaultp; + FSServer *svr; + char *buffer; + int nbytes; +{ + if (nbytes == 0) + return 0; + (void) strncpy(buffer, (char *) defaultp, nbytes); + if ((strlen(defaultp) + 1) > nbytes) + buffer[nbytes - 1] = '\0'; + return 1; +} + +int FSGetErrorText(svr, code, buffer, nbytes) + register int code; + register FSServer *svr; + char *buffer; + int nbytes; +{ + + char *defaultp = NULL; + char buf[32]; + register _FSExtension *ext; + + if (nbytes == 0) + return 0; + sprintf(buf, "%d", code); + if (code <= (FSErrorListSize / sizeof(char *)) && code > 0) { + defaultp = FSErrorList[code]; + FSGetErrorDatabaseText(svr, "FSProtoError", buf, defaultp, buffer, nbytes); + } + ext = svr->ext_procs; + while (ext) { /* call out to any extensions interested */ + if (ext->error_string != NULL) + (*ext->error_string) (svr, code, &ext->codes, buffer, nbytes); + ext = ext->next; + } + return 1; +} + diff --git a/nx-X11/lib/FS/FSErrHndlr.c b/nx-X11/lib/FS/FSErrHndlr.c new file mode 100644 index 000000000..592fa4896 --- /dev/null +++ b/nx-X11/lib/FS/FSErrHndlr.c @@ -0,0 +1,84 @@ +/* $Xorg: FSErrHndlr.c,v 1.4 2001/02/09 02:03:25 xorgcvs Exp $ */ + +/* @(#)FSErrHndlr.c 4.1 91/05/02 + * Copyright 1990 Network Computing Devices; + * Portions Copyright 1987 by Digital Equipment Corporation + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation, and that the names of Network Computing + * Devices or Digital not be used in advertising or publicity pertaining + * to distribution of the software without specific, written prior + * permission. Network Computing Devices or Digital make no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH + * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES + * OR DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. +*/ +/* $XFree86: xc/lib/FS/FSErrHndlr.c,v 1.4 2001/01/17 19:41:28 dawes Exp $ */ + +/* + +Copyright 1987, 1994, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +*/ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif +#include "FSlibint.h" + +FSErrorHandler +FSSetErrorHandler(FSErrorHandler handler) +{ + FSErrorHandler oldhandler = _FSErrorFunction; + + if (handler != NULL) { + _FSErrorFunction = handler; + } else { + _FSErrorFunction = _FSDefaultError; + } + return oldhandler; +} + +FSIOErrorHandler +FSSetIOErrorHandler(FSIOErrorHandler handler) +{ + FSIOErrorHandler oldhandler = _FSIOErrorFunction; + + if (handler != NULL) { + _FSIOErrorFunction = handler; + } else { + _FSIOErrorFunction = _FSDefaultIOError; + } + return oldhandler; +} diff --git a/nx-X11/lib/FS/FSFlush.c b/nx-X11/lib/FS/FSFlush.c new file mode 100644 index 000000000..e4b14390b --- /dev/null +++ b/nx-X11/lib/FS/FSFlush.c @@ -0,0 +1,63 @@ +/* $Xorg: FSFlush.c,v 1.4 2001/02/09 02:03:25 xorgcvs Exp $ */ + +/* @(#)FSFlush.c 4.1 91/05/02 + * Copyright 1990 Network Computing Devices; + * Portions Copyright 1987 by Digital Equipment Corporation + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation, and that the names of Network Computing + * Devices or Digital not be used in advertising or publicity pertaining + * to distribution of the software without specific, written prior + * permission. Network Computing Devices or Digital make no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH + * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES + * OR DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ + +/* + +Copyright 1987, 1994, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +*/ +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif +#include "FSlibint.h" + +int FSFlush(svr) + FSServer *svr; +{ + _FSFlush(svr); + return 1; +} diff --git a/nx-X11/lib/FS/FSFontInfo.c b/nx-X11/lib/FS/FSFontInfo.c new file mode 100644 index 000000000..d79ad9e26 --- /dev/null +++ b/nx-X11/lib/FS/FSFontInfo.c @@ -0,0 +1,346 @@ +/* $Xorg: FSFontInfo.c,v 1.4 2001/02/09 02:03:25 xorgcvs Exp $ */ +/* + * Copyright 1990 Network Computing Devices; + * Portions Copyright 1987 by Digital Equipment Corporation + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation, and that the names of Network Computing + * Devices or Digital not be used in advertising or publicity pertaining + * to distribution of the software without specific, written prior + * permission. Network Computing Devices or Digital make no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH + * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES + * OR DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ +/* $XFree86: xc/lib/FS/FSFontInfo.c,v 1.5tsi Exp $ */ + +/* + +Copyright 1987, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +*/ +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif +#include "FSlibint.h" + +char ** +FSListFontsWithXInfo(svr, pattern, maxNames, count, info, pprops, offsets, prop_data) + FSServer *svr; + char *pattern; + int maxNames; + int *count; + FSXFontInfoHeader ***info; + FSPropInfo ***pprops; + FSPropOffset ***offsets; + unsigned char ***prop_data; +{ + long nbytes; + int i, + j; + size_t size = 0; + FSXFontInfoHeader **fhdr = (FSXFontInfoHeader **) 0; + FSPropInfo **pi = (FSPropInfo **) 0; + FSPropOffset **po = (FSPropOffset **) 0; + unsigned char **pd = (unsigned char **) 0; + char **flist = NULL; + fsListFontsWithXInfoReply reply; + fsListFontsWithXInfoReq *req; + fsPropInfo local_pi; + fsPropOffset local_po; + Status status; + + GetReq(ListFontsWithXInfo, req); + req->maxNames = maxNames; + nbytes = req->nbytes = pattern ? strlen(pattern) : 0; + req->length += (nbytes + 3) >> 2; + _FSSend(svr, pattern, nbytes); + + for (i = 0;; i++) { + if (FSProtocolVersion(svr) > 1) + { + status = _FSReply(svr, (fsReply *) &reply, 0, fsFalse); + if (status != 0 && reply.nameLength == 0) /* got last reply */ + break; + if (status) + _FSRead(svr, ((char *) &reply) + SIZEOF(fsGenericReply), + SIZEOF(fsListFontsWithXInfoReply) - + SIZEOF(fsGenericReply)); + } else { + status = _FSReply(svr, (fsReply *) & reply, + ((SIZEOF(fsListFontsWithXInfoReply) - + SIZEOF(fsGenericReply)) >> 2), fsFalse); + } + if (!status) { + for (j = (i - 1); j >= 0; j--) { + FSfree((char *) fhdr[j]); + FSfree((char *) pi[j]); + FSfree((char *) po[j]); + FSfree((char *) pd[j]); + FSfree(flist[j]); + } + if (flist) + FSfree((char *) flist); + if (fhdr) + FSfree((char *) fhdr); + if (pi) + FSfree((char *) pi); + if (po) + FSfree((char *) po); + if (pd) + FSfree((char *) pd); + + SyncHandle(); + return (char **) NULL; + } + if (reply.nameLength == 0) /* got last reply in version 1 */ + break; + if ((i + reply.nReplies) >= size) { + + if (reply.nReplies > SIZE_MAX - i - 1) + goto badmem; + size = i + reply.nReplies + 1; + + if (size > SIZE_MAX / sizeof(char *)) + goto badmem; + + if (fhdr) { + FSXFontInfoHeader **tmp_fhdr = (FSXFontInfoHeader **) + FSrealloc((char *) fhdr, + (unsigned) (sizeof(FSXFontInfoHeader *) * size)); + char **tmp_flist = (char **) FSrealloc((char *) flist, + (unsigned) (sizeof(char *) * size)); + FSPropInfo **tmp_pi = (FSPropInfo **) + FSrealloc((char *) pi, + (unsigned) (sizeof(FSPropInfo *) * size)); + FSPropOffset **tmp_po = (FSPropOffset **) + FSrealloc((char *) po, + (unsigned) (sizeof(FSPropOffset *) * size)); + unsigned char **tmp_pd = (unsigned char **) + FSrealloc((char *) pd, + (unsigned) (sizeof(unsigned char *) * size)); + + if (!tmp_fhdr || !tmp_flist || !tmp_pi || !tmp_po || !tmp_pd) { + for (j = (i - 1); j >= 0; j--) { + FSfree((char *) flist[j]); + FSfree((char *) fhdr[j]); + FSfree((char *) pi[j]); + FSfree((char *) po[j]); + FSfree((char *) pd[j]); + } + if (tmp_flist) + FSfree((char *) tmp_flist); + else + FSfree((char *) flist); + if (tmp_fhdr) + FSfree((char *) tmp_fhdr); + else + FSfree((char *) fhdr); + if (tmp_pi) + FSfree((char *) tmp_pi); + else + FSfree((char *) pi); + if (tmp_po) + FSfree((char *) tmp_po); + else + FSfree((char *) po); + if (tmp_pd) + FSfree((char *) tmp_pd); + else + FSfree((char *) pd); + goto clearwire; + } + fhdr = tmp_fhdr; + flist = tmp_flist; + pi = tmp_pi; + po = tmp_po; + pd = tmp_pd; + } else { + if (!(fhdr = (FSXFontInfoHeader **) + FSmalloc((unsigned) (sizeof(FSXFontInfoHeader *) * size)))) + goto clearwire; + if (!(flist = (char **) + FSmalloc((unsigned) (sizeof(char *) * size)))) { + FSfree((char *) fhdr); + goto clearwire; + } + if (!(pi = (FSPropInfo **) + FSmalloc((unsigned) (sizeof(FSPropInfo *) * size)))) { + FSfree((char *) fhdr); + FSfree((char *) flist); + goto clearwire; + } + if (!(po = (FSPropOffset **) + FSmalloc((unsigned) (sizeof(FSPropOffset *) * size)))) { + FSfree((char *) fhdr); + FSfree((char *) flist); + FSfree((char *) pi); + goto clearwire; + } + if (!(pd = (unsigned char **) + FSmalloc((unsigned) (sizeof(unsigned char *) * size)))) { + FSfree((char *) fhdr); + FSfree((char *) flist); + FSfree((char *) pi); + FSfree((char *) po); + goto clearwire; + } + } + } + fhdr[i] = (FSXFontInfoHeader *) FSmalloc(sizeof(FSXFontInfoHeader)); + if (!fhdr[i]) { + goto badmem; + } + FSUnpack_XFontInfoHeader(&reply, fhdr[i], FSProtocolVersion(svr)); + + /* alloc space for the name */ + flist[i] = (char *) FSmalloc((unsigned int) (reply.nameLength + 1)); + if (FSProtocolVersion(svr) == 1) + { + /* get the name */ + if (!flist[i]) { + nbytes = (reply.nameLength + 3) & ~3; + _FSEatData(svr, (unsigned long) nbytes); + goto badmem; + } + _FSReadPad(svr, flist[i], (long) reply.nameLength); + flist[i][reply.nameLength] = '\0'; + } + + pi[i] = (FSPropInfo *) FSmalloc(sizeof(FSPropInfo)); + if (!pi[i]) { + FSfree((char *) fhdr[i]); + goto badmem; + } + _FSReadPad(svr, (char *) &local_pi, SIZEOF(fsPropInfo)); + pi[i]->num_offsets = local_pi.num_offsets; + pi[i]->data_len = local_pi.data_len; + +#if SIZE_MAX <= UINT_MAX + if (pi[i]->num_offsets > SIZE_MAX / sizeof(FSPropOffset)) + goto badmem; +#endif + + po[i] = (FSPropOffset *) + FSmalloc(pi[i]->num_offsets * sizeof(FSPropOffset)); + if (!po[i]) { + FSfree((char *) fhdr[i]); + FSfree((char *) pi[i]); + goto badmem; + } + pd[i] = (unsigned char *) FSmalloc(pi[i]->data_len); + if (!pd[i]) { + FSfree((char *) fhdr[i]); + FSfree((char *) pi[i]); + FSfree((char *) po[i]); + goto badmem; + } + /* get offsets */ + for (j=0; j<pi[i]->num_offsets; j++) + { + _FSReadPad(svr, (char *) &local_po, SIZEOF(fsPropOffset)); + po[i][j].name.position = local_po.name.position; + po[i][j].name.length = local_po.name.length; + po[i][j].value.position = local_po.value.position; + po[i][j].value.length = local_po.value.length; + po[i][j].type = local_po.type; + } + + /* get prop data */ + if (FSProtocolVersion(svr) == 1) + _FSReadPad(svr, (char *) pd[i], pi[i]->data_len); + else + _FSRead(svr, (char *) pd[i], pi[i]->data_len); + + if (FSProtocolVersion(svr) != 1) + { + /* get the name */ + if (!flist[i]) { + nbytes = (reply.nameLength + 3) & ~3; + _FSEatData(svr, (unsigned long) nbytes); + goto badmem; + } + _FSRead(svr, flist[i], (long) reply.nameLength); + flist[i][reply.nameLength] = '\0'; + + nbytes = pi[i]->data_len + reply.nameLength; + _FSEatData(svr, (unsigned long) (((nbytes+3)&~3) - nbytes)); + } + /* avoid integer overflow */ + if (i > INT_MAX - 1) { + goto badmem; + } + } + *info = fhdr; + *count = i; + *pprops = pi; + *offsets = po; + *prop_data = pd; + SyncHandle(); + return flist; + +badmem: + for (j = (i - 1); j >= 0; j--) { + FSfree((char *) pi[j]); + FSfree((char *) po[j]); + FSfree((char *) pd[j]); + FSfree(flist[j]); + FSfree((char *) fhdr[j]); + } + if (flist) + FSfree((char *) flist); + if (fhdr) + FSfree((char *) fhdr); + if (pi) + FSfree((char *) pi); + if (po) + FSfree((char *) po); + if (pd) + FSfree((char *) pd); + + +clearwire: + do { + fsPropInfo ti; + + _FSEatData(svr, (reply.nameLength + 3) & ~3); + _FSReadPad(svr, (char *) &ti, SIZEOF(fsPropInfo)); + _FSEatData(svr, (SIZEOF(fsPropOffset) * ti.num_offsets)); + _FSEatData(svr, ti.data_len); + } while (_FSReply(svr, (fsReply *) & reply, + ((SIZEOF(fsListFontsWithXInfoReply) + - SIZEOF(fsGenericReply)) >> 2), fsFalse) && (reply.nameLength != 0)); + SyncHandle(); + return (char **) NULL; +} diff --git a/nx-X11/lib/FS/FSFtNames.c b/nx-X11/lib/FS/FSFtNames.c new file mode 100644 index 000000000..2d512e41c --- /dev/null +++ b/nx-X11/lib/FS/FSFtNames.c @@ -0,0 +1,131 @@ +/* $Xorg: FSFtNames.c,v 1.4 2001/02/09 02:03:25 xorgcvs Exp $ */ +/* + * Copyright 1990 Network Computing Devices; + * Portions Copyright 1987 by Digital Equipment Corporation + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation, and that the names of Network Computing + * Devices or Digital not be used in advertising or publicity pertaining + * to distribution of the software without specific, written prior + * permission. Network Computing Devices or Digital make no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH + * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES + * OR DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ +/* $XFree86: xc/lib/FS/FSFtNames.c,v 1.6tsi Exp $ */ + +/* + +Copyright 1987, 1994, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +*/ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif +#include "FSlibint.h" + +char ** +FSListFonts(svr, pattern, maxNames, actualCount) + FSServer *svr; + char *pattern; + int maxNames; + int *actualCount; +{ + long nbytes; + int i, + length; + char **flist; + char *c; + fsListFontsReply rep; + fsListFontsReq *req; + long rlen; + + GetReq(ListFonts, req); + req->maxNames = maxNames; + nbytes = req->nbytes = pattern ? strlen(pattern) : 0; + req->length += (nbytes + 3) >> 2; + _FSSend(svr, pattern, nbytes); + if (!_FSReply(svr, (fsReply *) & rep, + (SIZEOF(fsListFontsReply) - SIZEOF(fsGenericReply)) >> 2, fsFalse)) + return (char **) 0; + + if (rep.nFonts +#if (SIZE_MAX >> 2) <= UINT_MAX + && rep.nFonts <= SIZE_MAX / sizeof(char *) + && rep.length <= (SIZE_MAX >> 2) +#endif + ) { + flist = (char **) FSmalloc((unsigned) rep.nFonts * sizeof(char *)); + rlen = (rep.length << 2) - SIZEOF(fsListFontsReply); + c = (char *) FSmalloc((unsigned) (rlen + 1)); + + if ((!flist) || (!c)) { + if (flist) + FSfree((char *) flist); + if (c) + FSfree(c); + _FSEatData(svr, (unsigned long) rlen); + SyncHandle(); + return (char **) NULL; + } + _FSReadPad(svr, c, rlen); + /* unpack */ + length = *(unsigned char *)c; + for (i = 0; i < rep.nFonts; i++) { + flist[i] = c + 1; + c += length + 1; + length = *(unsigned char *)c; + *c = '\0'; + } + } else { + + flist = (char **) NULL; + } + + *actualCount = rep.nFonts; + SyncHandle(); + return flist; + +} + +int FSFreeFontNames(list) + char **list; +{ + if (list) { + FSfree(list[0] - 1); + FSfree((char *) list); + } + return 1; +} diff --git a/nx-X11/lib/FS/FSGetCats.c b/nx-X11/lib/FS/FSGetCats.c new file mode 100644 index 000000000..39792f696 --- /dev/null +++ b/nx-X11/lib/FS/FSGetCats.c @@ -0,0 +1,114 @@ +/* $Xorg: FSGetCats.c,v 1.4 2001/02/09 02:03:25 xorgcvs Exp $ */ +/* + * Copyright 1990 Network Computing Devices; + * Portions Copyright 1987 by Digital Equipment Corporation + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation, and that the names of Network Computing + * Devices or Digital not be used in advertising or publicity pertaining + * to distribution of the software without specific, written prior + * permission. Network Computing Devices or Digital make no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH + * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES + * OR DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ +/* $XFree86: xc/lib/FS/FSGetCats.c,v 1.6tsi Exp $ */ + +/* + +Copyright 1987, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +*/ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif +#include "FSlibint.h" + +char ** +FSGetCatalogues(svr, num) + FSServer *svr; + int *num; +{ + fsGetCataloguesReply rep; + char **list; + char *c; + int i, + length; + fsReq *req; + long rlen; + + GetEmptyReq(GetCatalogues, req); + + if (!_FSReply(svr, (fsReply *) & rep, 0, fsFalse)) { + SyncHandle(); + return (char **) NULL; + } + if (rep.num_catalogues +#if (SIZE_MAX >> 2) <= UINT_MAX + && rep.num_catalogues <= SIZE_MAX/sizeof(char *) + && rep.length <= (SIZE_MAX >> 2) +#endif + ) { + list = (char **) + FSmalloc((unsigned) (rep.num_catalogues * sizeof(char *))); + rlen = (rep.length << 2) - SIZEOF(fsGetCataloguesReply); + c = (char *) FSmalloc((unsigned) rlen + 1); + if ((!list) || (!c)) { + if (list) + FSfree((char *) list); + if (c) + FSfree(c); + _FSEatData(svr, (unsigned long) rlen); + SyncHandle(); + return (char **) NULL; + } + _FSReadPad(svr, c, rlen); + /* + * unpack the strings + */ + length = *c; + for (i = 0; i < (int)rep.num_catalogues; i++) { + list[i] = c + 1; /* skip length */ + c += length + 1; /* find next length */ + length = *c; + *c = '\0'; /* change length to NULL */ + } + } else { + list = (char **) NULL; + } + SyncHandle(); + *num = rep.num_catalogues; + return list; +} diff --git a/nx-X11/lib/FS/FSListCats.c b/nx-X11/lib/FS/FSListCats.c new file mode 100644 index 000000000..99b540014 --- /dev/null +++ b/nx-X11/lib/FS/FSListCats.c @@ -0,0 +1,132 @@ +/* $Xorg: FSListCats.c,v 1.4 2001/02/09 02:03:25 xorgcvs Exp $ */ +/* + * Copyright 1990 Network Computing Devices; + * Portions Copyright 1987 by Digital Equipment Corporation + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation, and that the names of Network Computing + * Devices or Digital not be used in advertising or publicity pertaining + * to distribution of the software without specific, written prior + * permission. Network Computing Devices or Digital make no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH + * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES + * OR DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ +/* $XFree86: xc/lib/FS/FSListCats.c,v 1.6tsi Exp $ */ + +/* + +Copyright 1987, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +*/ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif +#include "FSlibint.h" + +char ** +FSListCatalogues(svr, pattern, maxNames, actualCount) + FSServer *svr; + char *pattern; + int maxNames; + int *actualCount; +{ + long nbytes; + int i, + length; + char **clist; + char *c; + fsListCataloguesReply rep; + fsListCataloguesReq *req; + long rlen; + + GetReq(ListCatalogues, req); + req->maxNames = maxNames; + nbytes = req->nbytes = pattern ? strlen(pattern) : 0; + req->length += (nbytes + 3) >> 2; + _FSSend(svr, pattern, nbytes); + if (!_FSReply(svr, (fsReply *) & rep, + (SIZEOF(fsListCataloguesReply) - SIZEOF(fsGenericReply)) >> 2, fsFalse)) + return (char **) 0; + + if (rep.num_catalogues +#if (SIZE_MAX >> 2) <= UINT_MAX + && rep.num_catalogues <= SIZE_MAX/sizeof(char *) + && rep.length <= (SIZE_MAX>>2) +#endif + ) { + clist = (char **) + FSmalloc((unsigned) rep.num_catalogues * sizeof(char *)); + rlen = (rep.length << 2) - SIZEOF(fsListCataloguesReply); + c = (char *) FSmalloc((unsigned) (rlen + 1)); + + if ((!clist) || (!c)) { + if (clist) + FSfree((char *) clist); + if (c) + FSfree(c); + _FSEatData(svr, (unsigned long) rlen); + SyncHandle(); + return (char **) NULL; + } + _FSReadPad(svr, c, rlen); + /* unpack */ + length = *c; + for (i = 0; i < rep.num_catalogues; i++) { + clist[i] = c + 1; + c += length + 1; + length = *c; + *c = '\0'; + } + } else { + + clist = (char **) NULL; + } + + *actualCount = rep.num_catalogues; + SyncHandle(); + return clist; + +} + +int FSFreeCatalogues(list) + char **list; +{ + if (list) { + FSfree(list[0] - 1); + FSfree((char *) list); + } + return 1; +} diff --git a/nx-X11/lib/FS/FSListExt.c b/nx-X11/lib/FS/FSListExt.c new file mode 100644 index 000000000..0f42f5968 --- /dev/null +++ b/nx-X11/lib/FS/FSListExt.c @@ -0,0 +1,125 @@ +/* $Xorg: FSListExt.c,v 1.4 2001/02/09 02:03:25 xorgcvs Exp $ */ + +/* @(#)FSListExt.c 4.1 91/05/02 + * Copyright 1990 Network Computing Devices; + * Portions Copyright 1987 by Digital Equipment Corporation + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation, and that the names of Network Computing + * Devices or Digital not be used in advertising or publicity pertaining + * to distribution of the software without specific, written prior + * permission. Network Computing Devices or Digital make no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH + * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES + * OR DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ +/* $XFree86: xc/lib/FS/FSListExt.c,v 1.6tsi Exp $ */ + +/* + +Copyright 1987, 1994, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +*/ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif +#include "FSlibint.h" + +char ** +FSListExtensions(svr, next) + FSServer *svr; + int *next; +{ + fsListExtensionsReply rep; + char **list; + char *c; + int i, + length; + fsReq *req; + long rlen; + + GetEmptyReq(ListExtensions, req); + + if (!_FSReply(svr, (fsReply *) & rep, 0, fsFalse)) { + SyncHandle(); + return (char **) NULL; + } + if (rep.nExtensions +#if (SIZE_MAX >> 2) <= UINT_MAX + && rep.nExtensions <= SIZE_MAX / sizeof(char *) + && rep.length <= (SIZE_MAX>>2) +#endif + ) { + list = (char **) FSmalloc((unsigned)(rep.nExtensions * sizeof(char *))); + rlen = (rep.length << 2) - SIZEOF(fsListExtensionsReply); + c = (char *) FSmalloc((unsigned) rlen + 1); + if ((!list) || (!c)) { + if (list) + FSfree((char *) list); + if (c) + FSfree(c); + _FSEatData(svr, (unsigned long) rlen); + SyncHandle(); + return (char **) NULL; + } + _FSReadPad(svr, c, rlen); + /* + * unpack the strings + */ + length = *c; + for (i = 0; i < rep.nExtensions; i++) { + list[i] = c + 1; /* skip length */ + c += length + 1; /* find next length */ + length = *c; + *c = '\0'; /* change length to NULL */ + } + } else { + list = (char **) NULL; + } + SyncHandle(); + *next = rep.nExtensions; + return list; + +} + +int FSFreeExtensionList(list) + char **list; +{ + if (list != NULL) { + FSfree(list[0] - 1); + FSfree((char *) list); + } + return 1; +} diff --git a/nx-X11/lib/FS/FSMisc.c b/nx-X11/lib/FS/FSMisc.c new file mode 100644 index 000000000..af0e78ce1 --- /dev/null +++ b/nx-X11/lib/FS/FSMisc.c @@ -0,0 +1,64 @@ +/* $Xorg: FSMisc.c,v 1.4 2001/02/09 02:03:25 xorgcvs Exp $ */ + +/* @(#)FSMisc.c 4.1 91/05/02 + * Copyright 1990 Network Computing Devices; + * Portions Copyright 1987 by Digital Equipment Corporation + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation, and that the names of Network Computing + * Devices or Digital not be used in advertising or publicity pertaining + * to distribution of the software without specific, written prior + * permission. Network Computing Devices or Digital make no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH + * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES + * OR DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ + +/* + +Copyright 1987, 1994, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +*/ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif +#include "FSlibint.h" + +long +FSMaxRequestSize(svr) + FSServer *svr; +{ + return svr->max_request_size; +} diff --git a/nx-X11/lib/FS/FSNextEv.c b/nx-X11/lib/FS/FSNextEv.c new file mode 100644 index 000000000..69e009db3 --- /dev/null +++ b/nx-X11/lib/FS/FSNextEv.c @@ -0,0 +1,79 @@ +/* $Xorg: FSNextEv.c,v 1.4 2001/02/09 02:03:25 xorgcvs Exp $ */ + +/* @(#)FSNextEv.c 4.1 91/05/02 + * Copyright 1990 Network Computing Devices; + * Portions Copyright 1987 by Digital Equipment Corporation + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation, and that the names of Network Computing + * Devices or Digital not be used in advertising or publicity pertaining + * to distribution of the software without specific, written prior + * permission. Network Computing Devices or Digital make no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH + * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES + * OR DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ + +/* + +Copyright 1987, 1994, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +*/ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif +#include "FSlibint.h" + +extern _FSQEvent *_FSqfree; + +int FSNextEvent(svr, event) + FSServer *svr; + FSEvent *event; +{ + _FSQEvent *qelt; + + if (svr->head == NULL) + _FSReadEvents(svr); + qelt = svr->head; + *event = qelt->event; + + if ((svr->head = qelt->next) == NULL) + svr->tail = NULL; + qelt->next = _FSqfree; + _FSqfree = qelt; + svr->qlen--; + + return 1; +} diff --git a/nx-X11/lib/FS/FSOpenFont.c b/nx-X11/lib/FS/FSOpenFont.c new file mode 100644 index 000000000..da6889a53 --- /dev/null +++ b/nx-X11/lib/FS/FSOpenFont.c @@ -0,0 +1,92 @@ +/* $Xorg: FSOpenFont.c,v 1.4 2001/02/09 02:03:25 xorgcvs Exp $ */ + +/* + * Copyright 1990 Network Computing Devices; + * Portions Copyright 1987 by Digital Equipment Corporation + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation, and that the names of Network Computing + * Devices or Digital not be used in advertising or publicity pertaining + * to distribution of the software without specific, written prior + * permission. Network Computing Devices or Digital make no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH + * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES + * OR DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ +/* $XFree86: xc/lib/FS/FSOpenFont.c,v 1.6tsi Exp $ */ + +/* + +Copyright 1987, 1994, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +*/ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif +#include "FSlibint.h" + +Font +FSOpenBitmapFont(svr, hint, fmask, name, otherid) + FSServer *svr; + FSBitmapFormat hint; + FSBitmapFormatMask fmask; + char *name; + Font *otherid; +{ + unsigned int nbytes; + fsOpenBitmapFontReq *req; + fsOpenBitmapFontReply reply; + Font fid; + char buf[256]; + + nbytes = name ? strlen(name) : 0; + if (nbytes > 255) return 0; + GetReq(OpenBitmapFont, req); + buf[0] = nbytes; + memcpy(&buf[1], name, nbytes); + nbytes++; + req->fid = fid = svr->resource_id++; + req->format_hint = hint; + req->format_mask = fmask; + req->length += (nbytes + 3) >> 2; + _FSSend(svr, buf, (long) nbytes); + if (!_FSReply(svr, (fsReply *) & reply, + (SIZEOF(fsOpenBitmapFontReply)-SIZEOF(fsGenericReply)) >> 2, + fsFalse)) + return 0; + *otherid = reply.otherid; + SyncHandle(); + return fid; +} diff --git a/nx-X11/lib/FS/FSOpenServ.c b/nx-X11/lib/FS/FSOpenServ.c new file mode 100644 index 000000000..662577945 --- /dev/null +++ b/nx-X11/lib/FS/FSOpenServ.c @@ -0,0 +1,291 @@ +/* $Xorg: FSOpenServ.c,v 1.4 2001/02/09 02:03:25 xorgcvs Exp $ */ + +/* @(#)FSOpenServ.c 4.1 91/05/02 + * Copyright 1990 Network Computing Devices; + * Portions Copyright 1987 by Digital Equipment Corporation + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation, and that the names of Network Computing + * Devices or Digital not be used in advertising or publicity pertaining + * to distribution of the software without specific, written prior + * permission. Network Computing Devices or Digital make no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH + * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES + * OR DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ +/* $XFree86: xc/lib/FS/FSOpenServ.c,v 1.8tsi Exp $ */ + +/* + +Copyright 1987, 1994, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +*/ + +/* + * does initial handshake w/ font server + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif +#include <stdio.h> +#include "FSlibint.h" +#include <X11/Xtrans/Xtrans.h> + +int _FSdebug = 0; + +static fsReq _dummy_request = { + 0, 0, 0 +}; + +static void OutOfMemory ( FSServer *svr, char *setup ); + +FSServer *_FSHeadOfServerList = NULL; + +void _FSFreeServerStructure(svr) + FSServer *svr; +{ + if (svr->server_name) + FSfree(svr->server_name); + if (svr->vendor) + FSfree(svr->vendor); + + if (svr->buffer) + FSfree(svr->buffer); + + FSfree((char *) svr); +} + +static +void OutOfMemory(svr, setup) + FSServer *svr; + char *setup; +{ + + _FSDisconnectServer(svr->trans_conn); + _FSFreeServerStructure(svr); + FSfree(setup); + errno = ENOMEM; +} + +/* + * connects to a server, makes a FSServer object and returns a pointer + * to it + */ + +FSServer * +FSOpenServer(server) + char *server; +{ + FSServer *svr; + int i; + int endian; + fsConnClientPrefix client; + fsConnSetup prefix; + char *setup; + fsConnSetupAccept conn; + char *auth_data; + char *alt_data, + *ad; + AlternateServer *alts; + int altlen; + char *vendor_string; + unsigned long setuplength; + + if (server == NULL || *server == '\0') { + if ((server = getenv("FONTSERVER")) == NULL) { + return (FSServer *) NULL; + } + } + + if ((svr = (FSServer *) FScalloc(1, sizeof(FSServer))) == NULL) { + errno = ENOMEM; + return (FSServer *) NULL; + } + if ((svr->trans_conn = _FSConnectServer(server)) == NULL) { + FSfree((char *) svr); + return (FSServer *) NULL; + } + + svr->fd = _FSTransGetConnectionNumber (svr->trans_conn); + + endian = 1; + if (*(char *) &endian) + client.byteOrder = 'l'; + else + client.byteOrder = 'B'; + client.major_version = FS_PROTOCOL; + client.minor_version = FS_PROTOCOL_MINOR; +/* XXX -- fix this when we have some auths */ + client.num_auths = 0; + client.auth_len = 0; + _FSSendClientPrefix(svr, &client); + +/* see if connection was accepted */ + _FSRead(svr, (char *) &prefix, (long) SIZEOF(fsConnSetup)); + + setuplength = prefix.alternate_len << 2; + if (setuplength > (SIZE_MAX>>2) + || (alt_data = (char *) + (setup = FSmalloc((unsigned) setuplength))) == NULL) { + errno = ENOMEM; + FSfree((char *) svr); + return (FSServer *) NULL; + } + _FSRead(svr, (char *) alt_data, setuplength); + ad = alt_data; + +#if SIZE_MAX <= UINT_MAX + if (prefix.num_alternates > SIZE_MAX / sizeof(AlternateServer)) { + errno = ENOMEM; + FSfree((char *) alt_data); + FSfree((char *) svr); + return (FSServer *) 0; + } +#endif + + alts = (AlternateServer *) + FSmalloc(sizeof(AlternateServer) * prefix.num_alternates); + if (!alts) { + errno = ENOMEM; + FSfree((char *) alt_data); + FSfree((char *) svr); + return (FSServer *) 0; + } + for (i = 0; i < prefix.num_alternates; i++) { + alts[i].subset = (Bool) *ad++; + altlen = (int) *ad++; + alts[i].name = (char *) FSmalloc(altlen + 1); + if (!alts[i].name) { + while (--i) { + FSfree((char *) alts[i].name); + } + FSfree((char *) alts); + FSfree((char *) alt_data); + FSfree((char *) svr); + errno = ENOMEM; + return (FSServer *) 0; + } + bcopy(ad, alts[i].name, altlen); + alts[i].name[altlen] = '\0'; + ad += altlen + ((4 - (altlen + 2)) & 3); + } + FSfree((char *) alt_data); + + svr->alternate_servers = alts; + svr->num_alternates = prefix.num_alternates; + + setuplength = prefix.auth_len << 2; + if (setuplength > (SIZE_MAX>>2) + || (auth_data = (char *) + (setup = FSmalloc((unsigned) setuplength))) == NULL) { + errno = ENOMEM; + FSfree((char *) alts); + FSfree((char *) svr); + return (FSServer *) NULL; + } + _FSRead(svr, (char *) auth_data, setuplength); + + if (prefix.status != AuthSuccess) { + fprintf(stderr, "%s: connection to \"%s\" refused by server\r\n%s: ", + "FSlib", server, "FSlib"); + FSfree((char *) alts); + FSfree((char *) svr); + FSfree(setup); + return (FSServer *) NULL; + } + /* get rest */ + _FSRead(svr, (char *) &conn, (long) SIZEOF(fsConnSetupAccept)); + + if ((vendor_string = (char *) + FSmalloc((unsigned) conn.vendor_len + 1)) == NULL) { + errno = ENOMEM; + FSfree((char *) auth_data); + FSfree((char *) alts); + FSfree((char *) svr); + return (FSServer *) NULL; + } + _FSReadPad(svr, (char *) vendor_string, conn.vendor_len); + + /* move the data into the FSServer struct */ + svr->next = (FSServer *) NULL; + svr->proto_version = prefix.major_version; + svr->release = conn.release_number; + svr->max_request_size = conn.max_request_len; + + svr->event_vec[FS_Error] = _FSUnknownWireEvent; + svr->event_vec[FS_Reply] = _FSUnknownWireEvent; + svr->wire_vec[FS_Error] = _FSUnknownNativeEvent; + svr->wire_vec[FS_Reply] = _FSUnknownNativeEvent; + for (i = FSLASTEvent; i < 128; i++) { + svr->event_vec[i] = _FSUnknownWireEvent; + svr->wire_vec[i] = _FSUnknownNativeEvent; + } + svr->resource_id = 1; + + svr->vendor = vendor_string; + svr->vendor[conn.vendor_len] = '\0'; + + svr->vnumber = FS_PROTOCOL; + svr->request = 0; + svr->last_request_read = 0; + svr->last_req = (char *) &_dummy_request; + + if ((svr->server_name = FSmalloc((unsigned) (strlen(server) + 1))) + == NULL) { + OutOfMemory(svr, setup); + return (FSServer *) NULL; + } + (void) strcpy(svr->server_name, server); + + /* setup the output buffers */ + if ((svr->bufptr = svr->buffer = FSmalloc(BUFSIZE)) == NULL) { + OutOfMemory(svr, setup); + return (FSServer *) NULL; + } + svr->bufmax = svr->buffer + BUFSIZE; + + /* set up input event queue */ + svr->head = svr->tail = NULL; + svr->qlen = 0; + + FSfree(setup); + + (void) FSSynchronize(svr, _FSdebug); + + svr->next = _FSHeadOfServerList; + _FSHeadOfServerList = svr; + + return (svr); +} diff --git a/nx-X11/lib/FS/FSQGlyphs.c b/nx-X11/lib/FS/FSQGlyphs.c new file mode 100644 index 000000000..5ba2eb0f7 --- /dev/null +++ b/nx-X11/lib/FS/FSQGlyphs.c @@ -0,0 +1,214 @@ +/* $Xorg: FSQGlyphs.c,v 1.4 2001/02/09 02:03:25 xorgcvs Exp $ */ +/* + * Copyright 1990 Network Computing Devices; + * Portions Copyright 1987 by Digital Equipment Corporation + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation, and that the names of Network Computing + * Devices or Digital not be used in advertising or publicity pertaining + * to distribution of the software without specific, written prior + * permission. Network Computing Devices or Digital make no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH + * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES + * OR DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ +/* $XFree86: xc/lib/FS/FSQGlyphs.c,v 1.5tsi Exp $ */ + +/* + +Copyright 1987, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +*/ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif +#include "FSlibint.h" + +int +FSQueryXBitmaps8(svr, fid, format, range_type, str, str_len, offsets, glyphdata) + FSServer *svr; + Font fid; + FSBitmapFormat format; + Bool range_type; + unsigned char *str; + unsigned long str_len; + FSOffset **offsets; + unsigned char **glyphdata; +{ + fsQueryXBitmaps8Req *req; + fsQueryXBitmaps8Reply reply; + FSOffset *offs; + fsOffset32 local_offs; + unsigned char *gd; + int left; + int i; + + GetReq(QueryXBitmaps8, req); + req->fid = fid; + req->range = range_type; + req->format = format; + req->num_ranges = str_len; + req->length += (str_len + 3) >> 2; + _FSSend(svr, (char *) str, str_len); + + /* get back the info */ + if (!_FSReply(svr, (fsReply *) & reply, + (SIZEOF(fsQueryXBitmaps8Reply) - SIZEOF(fsGenericReply)) >> 2, fsFalse)) + return FSBadAlloc; + +#if SIZE_MAX <= UINT_MAX + if (reply.num_chars > SIZE_MAX / sizeof(FSOffset)) + return FSBadAlloc; +#endif + + offs = (FSOffset *) FSmalloc(sizeof(FSOffset) * reply.num_chars); + *offsets = offs; + if (!offs) + return FSBadAlloc; +#if (SIZE_MAX >> 2) <= UINT_MAX + /* XXX This thest is incomplete */ + if (reply.length > (SIZE_MAX >> 2)) { + FSfree((char *) offs); + return FSBadAlloc; + } +#endif + left = (reply.length << 2) - SIZEOF(fsQueryXBitmaps8Reply) + - (SIZEOF(fsOffset32) * reply.num_chars); + gd = (unsigned char *) FSmalloc(left); + *glyphdata = gd; + if (!gd) { + FSfree((char *) offs); + return FSBadAlloc; + } + for (i=0; i<reply.num_chars; i++) + { + _FSReadPad(svr, (char *) &local_offs, (SIZEOF(fsOffset32))); + offs->position = local_offs.position; + offs->length = local_offs.length; + offs++; + } + _FSReadPad(svr, (char *) gd, left); + + SyncHandle(); + return FSSuccess; +} + +int +FSQueryXBitmaps16(svr, fid, format, range_type, str, str_len, + offsets, glyphdata) + FSServer *svr; + Font fid; + FSBitmapFormat format; + Bool range_type; + FSChar2b *str; + unsigned long str_len; + FSOffset **offsets; + unsigned char **glyphdata; +{ + fsQueryXBitmaps16Req *req; + fsQueryXBitmaps16Reply reply; + FSOffset *offs; + fsOffset32 local_offs; + unsigned char *gd; + int left; + int i; + + GetReq(QueryXBitmaps16, req); + req->fid = fid; + req->range = range_type; + req->format = format; + req->num_ranges = str_len; + req->length += ((str_len * SIZEOF(fsChar2b)) + 3) >> 2; + if (FSProtocolVersion(svr) == 1) + { + int i; + fsChar2b_version1 *swapped_str; + + if (str_len > SIZE_MAX/SIZEOF(fsChar2b_version1)) + return FSBadAlloc; + swapped_str = (fsChar2b_version1 *) + FSmalloc(SIZEOF(fsChar2b_version1) * str_len); + if (!swapped_str) + return FSBadAlloc; + for (i = 0; i < str_len; i++) { + swapped_str[i].low = str[i].low; + swapped_str[i].high = str[i].high; + } + _FSSend(svr, (char *)swapped_str, (str_len*SIZEOF(fsChar2b_version1))); + FSfree(swapped_str); + } else + _FSSend(svr, (char *) str, (str_len * SIZEOF(fsChar2b))); + + /* get back the info */ + if (!_FSReply(svr, (fsReply *) & reply, + (SIZEOF(fsQueryXBitmaps16Reply) - SIZEOF(fsGenericReply)) >> 2, + fsFalse)) + return FSBadAlloc; + +#if SIZE_MAX <= UINT_MAX + if(reply.num_chars > SIZE_MAX/sizeof(FSOffset)) + return FSBadAlloc; +#endif + offs = (FSOffset *) FSmalloc(sizeof(FSOffset) * reply.num_chars); + *offsets = offs; + if (!offs) + return FSBadAlloc; +#if (SIZE_MAX >> 2) <= UINT_MAX + /* XXX - this test is incomplete */ + if (reply.length > (SIZE_MAX>>2)) { + FSfree((char *) offs); + return FSBadAlloc; + } +#endif + left = (reply.length << 2) - SIZEOF(fsQueryXBitmaps16Reply) + - (SIZEOF(fsOffset32) * reply.num_chars); + gd = (unsigned char *) FSmalloc(left); + *glyphdata = gd; + if (!gd) { + FSfree((char *) offs); + return FSBadAlloc; + } + for (i=0; i<reply.num_chars; i++) + { + _FSReadPad(svr, (char *) &local_offs, (SIZEOF(fsOffset32))); + offs->position = local_offs.position; + offs->length = local_offs.length; + offs++; + } + _FSReadPad(svr, (char *) gd, left); + + SyncHandle(); + return FSSuccess; +} diff --git a/nx-X11/lib/FS/FSQXExt.c b/nx-X11/lib/FS/FSQXExt.c new file mode 100644 index 000000000..e240d3aeb --- /dev/null +++ b/nx-X11/lib/FS/FSQXExt.c @@ -0,0 +1,176 @@ +/* $Xorg: FSQXExt.c,v 1.4 2001/02/09 02:03:25 xorgcvs Exp $ */ + +/* + * Copyright 1990 Network Computing Devices; + * Portions Copyright 1987 by Digital Equipment Corporation + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation, and that the names of Network Computing + * Devices or Digital not be used in advertising or publicity pertaining + * to distribution of the software without specific, written prior + * permission. Network Computing Devices or Digital make no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH + * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES + * OR DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ +/* $XFree86: xc/lib/FS/FSQXExt.c,v 1.7tsi Exp $ */ + +/* + +Copyright 1987, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +*/ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif +#include "FSlibint.h" + +static void +_FS_convert_char_info(fsXCharInfo *src, FSXCharInfo *dst) +{ + dst->ascent = src->ascent; + dst->descent = src->descent; + dst->left = src->left; + dst->right = src->right; + dst->width = src->width; + dst->attributes = src->attributes; +} + +int +FSQueryXExtents8(svr, fid, range_type, str, str_len, extents) + FSServer *svr; + Font fid; + Bool range_type; + unsigned char *str; + unsigned long str_len; + FSXCharInfo **extents; +{ + fsQueryXExtents8Req *req; + fsQueryXExtents8Reply reply; + FSXCharInfo *ext; + fsXCharInfo local_exts; + int i; + + GetReq(QueryXExtents8, req); + req->fid = fid; + req->range = range_type; + req->num_ranges = str_len; + req->length += (str_len + 3) >> 2; + _FSSend(svr, (char *) str, str_len); + + /* get back the info */ + if (!_FSReply(svr, (fsReply *) & reply, + (SIZEOF(fsQueryXExtents8Reply) - SIZEOF(fsGenericReply)) >> 2, + fsFalse)) + return FSBadAlloc; + +#if SIZE_MAX <= UINT_MAX + if (reply.num_extents > SIZE_MAX / sizeof(FSXCharInfo)) + return FSBadAlloc; +#endif + + ext = (FSXCharInfo *) FSmalloc(sizeof(FSXCharInfo) * reply.num_extents); + *extents = ext; + if (!ext) + return FSBadAlloc; + for (i = 0; i < reply.num_extents; i++) { + _FSReadPad(svr, (char *) &local_exts, SIZEOF(fsXCharInfo)); + _FS_convert_char_info(&local_exts, &ext[i]); + } + + SyncHandle(); + return FSSuccess; +} + +int +FSQueryXExtents16(svr, fid, range_type, str, str_len, extents) + FSServer *svr; + Font fid; + Bool range_type; + FSChar2b *str; + unsigned long str_len; + FSXCharInfo **extents; +{ + fsQueryXExtents16Req *req; + fsQueryXExtents16Reply reply; + FSXCharInfo *ext; + fsXCharInfo local_exts; + int i; + + GetReq(QueryXExtents16, req); + req->fid = fid; + req->range = range_type; + req->num_ranges = str_len; + req->length += ((str_len * SIZEOF(fsChar2b)) + 3) >> 2; + if (FSProtocolVersion(svr) == 1) + { + fsChar2b_version1 *swapped_str; + + swapped_str = (fsChar2b_version1 *) + FSmalloc(SIZEOF(fsChar2b_version1) * str_len); + if (!swapped_str) + return FSBadAlloc; + for (i = 0; i < str_len; i++) { + swapped_str[i].low = str[i].low; + swapped_str[i].high = str[i].high; + } + _FSSend(svr, (char *)swapped_str, (str_len*SIZEOF(fsChar2b_version1))); + FSfree(swapped_str); + } else + _FSSend(svr, (char *) str, (str_len * SIZEOF(fsChar2b))); + + /* get back the info */ + if (!_FSReply(svr, (fsReply *) & reply, + (SIZEOF(fsQueryXExtents16Reply) - SIZEOF(fsGenericReply)) >> 2, + fsFalse)) + return FSBadAlloc; + +#if SIZE_MAX <= UINT_MAX + if (reply.num_extents > SIZE_MAX/sizeof(FSXCharInfo)) + return FSBadAlloc; +#endif + + ext = (FSXCharInfo *) FSmalloc(sizeof(FSXCharInfo) * reply.num_extents); + *extents = ext; + if (!ext) + return FSBadAlloc; + for (i = 0; i < reply.num_extents; i++) { + _FSReadPad(svr, (char *) &local_exts, SIZEOF(fsXCharInfo)); + _FS_convert_char_info(&local_exts, &ext[i]); + } + + SyncHandle(); + return FSSuccess; +} diff --git a/nx-X11/lib/FS/FSQXInfo.c b/nx-X11/lib/FS/FSQXInfo.c new file mode 100644 index 000000000..083f95dce --- /dev/null +++ b/nx-X11/lib/FS/FSQXInfo.c @@ -0,0 +1,130 @@ +/* $Xorg: FSQXInfo.c,v 1.4 2001/02/09 02:03:25 xorgcvs Exp $ */ +/* + * Copyright 1990 Network Computing Devices; + * Portions Copyright 1987 by Digital Equipment Corporation + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation, and that the names of Network Computing + * Devices or Digital not be used in advertising or publicity pertaining + * to distribution of the software without specific, written prior + * permission. Network Computing Devices or Digital make no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH + * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES + * OR DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ +/* $XFree86: xc/lib/FS/FSQXInfo.c,v 1.5tsi Exp $ */ + +/* + +Copyright 1987, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +*/ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif +#include "FSlibint.h" + +/* + * Note: only the range in the first FSQuery is sent to the server. + * the others exist as return values only. + */ + +int +FSQueryXInfo(svr, fid, info, props, offsets, prop_data) + FSServer *svr; + Font fid; + FSXFontInfoHeader *info; + FSPropInfo *props; + FSPropOffset **offsets; + unsigned char **prop_data; +{ + fsQueryXInfoReq *req; + fsQueryXInfoReply reply; + FSPropOffset *offset_data; + unsigned char *pdata; + fsPropInfo local_pi; + fsPropOffset local_po; + int j; + + GetReq(QueryXInfo, req); + req->id = fid; + + /* get back the info */ + if (!_FSReply(svr, (fsReply *) & reply, ((SIZEOF(fsQueryXInfoReply) - + SIZEOF(fsGenericReply)) >> 2), fsFalse)) { + return FSBadAlloc; + } + + FSUnpack_XFontInfoHeader(&reply, info, FSProtocolVersion(svr)); + + /* get the prop header */ + _FSReadPad(svr, (char *) &local_pi, SIZEOF(fsPropInfo)); + props->num_offsets = local_pi.num_offsets; + props->data_len = local_pi.data_len; + +#if SIZE_MAX <= UINT_MAX + if (props->num_offsets > SIZE_MAX / sizeof(FSPropOffset)) + return FSBadAlloc; +#endif + + /* prepare for prop data */ + offset_data = (FSPropOffset *) + FSmalloc(props->num_offsets * sizeof(FSPropOffset)); + if (!offset_data) + return FSBadAlloc; + pdata = (unsigned char *) FSmalloc(props->data_len); + if (!pdata) { + FSfree((char *) offset_data); + return FSBadAlloc; + } + /* get offsets */ + for (j=0; j<props->num_offsets; j++) + { + _FSReadPad(svr, (char *) &local_po, SIZEOF(fsPropOffset)); + offset_data[j].name.position = local_po.name.position; + offset_data[j].name.length = local_po.name.length; + offset_data[j].value.position = local_po.value.position; + offset_data[j].value.length = local_po.value.length; + offset_data[j].type = local_po.type; + } + + /* get data */ + _FSReadPad(svr, (char *) pdata, props->data_len); + *offsets = offset_data; + *prop_data = pdata; + + SyncHandle(); + return FSSuccess; +} diff --git a/nx-X11/lib/FS/FSQuExt.c b/nx-X11/lib/FS/FSQuExt.c new file mode 100644 index 000000000..198bcee9f --- /dev/null +++ b/nx-X11/lib/FS/FSQuExt.c @@ -0,0 +1,82 @@ +/* $Xorg: FSQuExt.c,v 1.4 2001/02/09 02:03:25 xorgcvs Exp $ */ + +/* + * Copyright 1990 Network Computing Devices; + * Portions Copyright 1987 by Digital Equipment Corporation + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation, and that the names of Network Computing + * Devices or Digital not be used in advertising or publicity pertaining + * to distribution of the software without specific, written prior + * permission. Network Computing Devices or Digital make no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH + * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES + * OR DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ + +/* + +Copyright 1987, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +*/ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif +#include "FSlibint.h" + +Bool +FSQueryExtension(svr, name, major_opcode, first_event, first_error) + FSServer *svr; + char *name; + int *major_opcode; + int *first_event; + int *first_error; +{ + fsQueryExtensionReply rep; + fsQueryExtensionReq *req; + + GetReq(QueryExtension, req); + req->nbytes = name ? strlen(name) : 0; + req->length += (req->nbytes + 3) >> 2; + _FSSend(svr, name, (long) req->nbytes); + if (!_FSReply(svr, (fsReply *) & rep, + (SIZEOF(fsQueryExtensionReply) - SIZEOF(fsGenericReply)) >> 2, fsFalse)) + return FSBadAlloc; + *major_opcode = rep.major_opcode; + *first_event = rep.first_event; + *first_error = rep.first_error; + SyncHandle(); + return (rep.present); +} diff --git a/nx-X11/lib/FS/FSServName.c b/nx-X11/lib/FS/FSServName.c new file mode 100644 index 000000000..886ffa589 --- /dev/null +++ b/nx-X11/lib/FS/FSServName.c @@ -0,0 +1,73 @@ +/* $Xorg: FSServName.c,v 1.4 2001/02/09 02:03:25 xorgcvs Exp $ */ + +/* @(#)FSServName.c 4.1 91/05/02 + * Copyright 1990 Network Computing Devices; + * Portions Copyright 1987 by Digital Equipment Corporation + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation, and that the names of Network Computing + * Devices or Digital not be used in advertising or publicity pertaining + * to distribution of the software without specific, written prior + * permission. Network Computing Devices or Digital make no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH + * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES + * OR DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ +/* $XFree86: xc/lib/FS/FSServName.c,v 1.3 2001/07/29 05:01:11 tsi Exp $ */ + +/* + +Copyright 1987, 1994, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +*/ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif +#include <stdio.h> +#include <X11/Xosdefs.h> +#include <stdlib.h> + +char * +FSServerName(server) + char *server; +{ + char *s; + + if (server != NULL && *server != '\0') + return server; + if ((s = getenv("FONTSERVER")) != NULL) + return s; + return NULL; +} diff --git a/nx-X11/lib/FS/FSSetCats.c b/nx-X11/lib/FS/FSSetCats.c new file mode 100644 index 000000000..194ce457b --- /dev/null +++ b/nx-X11/lib/FS/FSSetCats.c @@ -0,0 +1,94 @@ +/* $Xorg: FSSetCats.c,v 1.4 2001/02/09 02:03:25 xorgcvs Exp $ */ + +/* @(#)FSFlush.c 4.1 91/05/02 + * Copyright 1990 Network Computing Devices; + * Portions Copyright 1987 by Digital Equipment Corporation + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation, and that the names of Network Computing + * Devices or Digital not be used in advertising or publicity pertaining + * to distribution of the software without specific, written prior + * permission. Network Computing Devices or Digital make no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH + * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES + * OR DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ +/* $XFree86: xc/lib/FS/FSSetCats.c,v 1.4 2001/01/17 19:41:28 dawes Exp $ */ + +/* + +Copyright 1987, 1994, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +*/ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif +#include "FSlibint.h" + +int +FSSetCatalogues(svr, num, cats) + FSServer *svr; + int num; + char **cats; +{ + int nbytes; + fsSetCataloguesReq *req; + char buf[256]; + int i; + int len, tlen, tnum; + + for (i = 0, tnum = 0, len = 0; i < num; i++) { + if ((tlen = strlen(cats[i])) < 256) { + len += tlen; + tnum++; + } + } + + GetReq(SetCatalogues, req); + req->num_catalogues = tnum; + req->length += (len + 3) >> 2; + + for (i = 0; i < num; i++) { + nbytes = strlen(cats[i]); + if (nbytes < 256) { + buf[0] = nbytes; + memcpy(&buf[1], cats[i], nbytes); + nbytes++; + _FSSend(svr, buf, (long) nbytes); + } + } + SyncHandle(); + return FSSuccess; +} diff --git a/nx-X11/lib/FS/FSSync.c b/nx-X11/lib/FS/FSSync.c new file mode 100644 index 000000000..eefd0318c --- /dev/null +++ b/nx-X11/lib/FS/FSSync.c @@ -0,0 +1,81 @@ +/* $Xorg: FSSync.c,v 1.4 2001/02/09 02:03:25 xorgcvs Exp $ */ + +/* + * Copyright 1990 Network Computing Devices; + * Portions Copyright 1987 by Digital Equipment Corporation + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation, and that the names of Network Computing + * Devices or Digital not be used in advertising or publicity pertaining + * to distribution of the software without specific, written prior + * permission. Network Computing Devices or Digital make no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH + * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES + * OR DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ + +/* + +Copyright 1987, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +*/ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif +#include "FSlibint.h" + +extern _FSQEvent *_FSqfree; + +/* synchronize with errors and events */ + +int FSSync(svr, discard) + FSServer *svr; + Bool discard; +{ + fsListExtensionsReply rep; + fsReq *req; + + GetEmptyReq(ListExtensions, req); + (void) _FSReply(svr, (fsReply *) & rep, 0, fsTrue); + + if (discard && svr->head) { + ((_FSQEvent *) svr->tail)->next = _FSqfree; + _FSqfree = (_FSQEvent *) svr->head; + svr->head = svr->tail = NULL; + svr->qlen = 0; + } + + return 1; +} diff --git a/nx-X11/lib/FS/FSSynchro.c b/nx-X11/lib/FS/FSSynchro.c new file mode 100644 index 000000000..c1c2d31a4 --- /dev/null +++ b/nx-X11/lib/FS/FSSynchro.c @@ -0,0 +1,91 @@ +/* $Xorg: FSSynchro.c,v 1.4 2001/02/09 02:03:25 xorgcvs Exp $ */ + +/* @(#)FSSynchro.c 4.1 91/05/02 + * Copyright 1990 Network Computing Devices; + * Portions Copyright 1987 by Digital Equipment Corporation + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation, and that the names of Network Computing + * Devices or Digital not be used in advertising or publicity pertaining + * to distribution of the software without specific, written prior + * permission. Network Computing Devices or Digital make no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH + * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES + * OR DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ +/* $XFree86: xc/lib/FS/FSSynchro.c,v 1.4 2001/01/17 19:41:28 dawes Exp $ */ + +/* + +Copyright 1987, 1994, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +*/ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif +#include "FSlib.h" +#include "FSlibint.h" + +static int +_FSSyncFunction(FSServer *svr) +{ + + return FSSync(svr, 0); +} + +FSSyncHandler +FSSynchronize(FSServer *svr, int onoff) +{ + FSSyncHandler temp; + + temp = svr->synchandler; + if (onoff) + svr->synchandler = _FSSyncFunction; + else + svr->synchandler = NULL; + return temp; +} + +FSSyncHandler +FSSetAfterFunction(svr, func) + FSServer *svr; + FSSyncHandler func; +{ + FSSyncHandler temp; + + temp = svr->synchandler; + svr->synchandler = func; + return temp; +} diff --git a/nx-X11/lib/FS/FSlib.h b/nx-X11/lib/FS/FSlib.h new file mode 100644 index 000000000..c2719f803 --- /dev/null +++ b/nx-X11/lib/FS/FSlib.h @@ -0,0 +1,313 @@ +/* $Xorg: FSlib.h,v 1.5 2001/02/09 02:03:25 xorgcvs Exp $ */ + +/* + * Copyright 1990 Network Computing Devices; + * Portions Copyright 1987 by Digital Equipment Corporation + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation, and that the names of Network Computing + * Devices or Digital not be used in advertising or publicity pertaining + * to distribution of the software without specific, written prior + * permission. Network Computing Devices or Digital make no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH + * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES + * OR DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ +/* $XFree86: xc/lib/FS/FSlib.h,v 1.6 2001/12/14 19:53:33 dawes Exp $ */ + +/* + +Copyright 1987, 1994, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +*/ + +/* + * Font server C interface library + */ + +#ifndef _FSLIB_H_ +#define _FSLIB_H_ + +#include <X11/Xfuncproto.h> + +#include <X11/fonts/FS.h> +#include <X11/fonts/FSproto.h> + +#define Bool int +#define Status int +#define True 1 +#define False 0 + +#define QueuedAlready 0 +#define QueuedAfterReading 1 +#define QueuedAfterFlush 2 + +#define FSServerString(svr) ((svr)->server_name) +#define FSVendorRelease(svr) ((svr)->release) +#define FSProtocolVersion(svr) ((svr)->proto_version) +#define FSServerVendor(svr) ((svr)->vendor) +#define FSAuthorizationData(svr) ((svr)->auth_data) +#define FSAlternateServers(svr) ((svr)->alternate_servers) +#define FSNumAlternateServers(svr) ((svr)->num_alternates) +#define FSQLength(svr) ((svr)->qlen) +#define FSNextRequest(svr) ((svr)->request + 1) +#define FSLastKnownRequestProcessed(svr) ((svr)->last_request_read) + +#define FSAllocID(svr) ((*(svr)->resource_alloc)((svr))) + +typedef struct _alternate { + Bool subset; + char *name; +} AlternateServer; + +/* extension stuff */ +typedef struct _FSExtData { + int number; /* number returned by FSRegisterExtension */ + struct _FSExtData *next; /* next item on list of data for structure */ + int (*free_private) (char *); /* called to free private storage */ + char *private_data; /* data private to this extension. */ +} FSExtData; + + +typedef struct { /* public to extension, cannot be changed */ + int extension; /* extension number */ + int major_opcode; /* major op-code assigned by server */ + int first_event; /* first event number for the extension */ + int first_error; /* first error number for the extension */ +} FSExtCodes; + +typedef struct _FSServer FSServer; +typedef union _FSEvent FSEvent; + +typedef struct _FSExtent { + struct _FSExtent *next; /* next in list */ + FSExtCodes codes; /* public information, all extension told */ + int (*close_server) (FSServer *, FSExtCodes *); /* routine to call when connection + * closed */ + int (*error) (FSServer *, fsError *, FSExtCodes *, int *); /* who to call when an error occurs */ + int (*error_string) (FSServer *, int, FSExtCodes *, char *, int); /* routine to supply error string */ + char *name; +} _FSExtension; + +typedef int (*FSSyncHandler)(FSServer *); + +/* server data structure */ +struct _FSServer { + struct _FSServer *next; + int fd; + int proto_version; + char *vendor; + int byte_order; + int vnumber; + int release; + int resource_id; + struct _FSQEvent *head, + *tail; + int qlen; + unsigned long last_request_read; + unsigned long request; + char *last_req; + char *buffer; + char *bufptr; + char *bufmax; + unsigned max_request_size; + char *server_name; + char *auth_data; + AlternateServer *alternate_servers; + int num_alternates; + FSExtData *ext_data; + _FSExtension *ext_procs; + int ext_number; + Bool (*event_vec[132]) (FSServer *, FSEvent *, fsEvent *); + Status (*wire_vec[132]) (FSServer *, FSEvent *, fsEvent *); + char *scratch_buffer; + unsigned long scratch_length; + FSSyncHandler synchandler; + unsigned long flags; + struct _XtransConnInfo *trans_conn; /* transport connection object */ +}; + +typedef struct { + int type; + unsigned long serial; + Bool send_event; + FSServer *server; +} FSAnyEvent; + +typedef struct { + int type; + FSServer *server; + FSID resourceid; + unsigned long serial; + unsigned char error_code; + unsigned char request_code; + unsigned char minor_code; +} FSErrorEvent; + +union _FSEvent { + int type; + FSAnyEvent fsany; +}; + +typedef struct _FSQEvent { + struct _FSQEvent *next; + FSEvent event; +} _FSQEvent; + + +/* protocol-related stuctures */ + +typedef unsigned long FSBitmapFormat; +typedef unsigned long FSBitmapFormatMask; + +typedef struct _FSChar2b { + unsigned char high; + unsigned char low; +} FSChar2b; + +typedef struct _FSRange { + FSChar2b min_char; + FSChar2b max_char; +} FSRange; + +typedef struct _FSOffset { + unsigned int position; + unsigned int length; +} FSOffset; + +/* use names as in xCharInfo? */ +typedef struct _FSXCharInfo { + short left; + short right; + short width; + short ascent; + short descent; + unsigned short attributes; +} FSXCharInfo; + +typedef struct _FSPropOffset { + FSOffset name; + FSOffset value; + unsigned char type; +} FSPropOffset; + +typedef struct _FSPropInfo { + unsigned int num_offsets; + unsigned int data_len; +} FSPropInfo; + +/* should names match FontInfoRec? */ +typedef struct _FSXFontInfoHeader { + int flags; + FSRange char_range; + unsigned draw_direction; + FSChar2b default_char; + FSXCharInfo min_bounds; + FSXCharInfo max_bounds; + short font_ascent; + short font_descent; +} FSXFontInfoHeader; + + + +/* function decls */ + +_XFUNCPROTOBEGIN + +extern FSServer * FSOpenServer ( char *server ); + +extern FSSyncHandler FSSynchronize(FSServer *, int); +extern FSSyncHandler FSSetAfterFunction(FSServer *, FSSyncHandler); + +extern char * FSServerName ( char *server ); +extern char ** FSListExtensions ( FSServer *svr, int *next ); +extern int FSQueryExtension ( FSServer *svr, char *name, int *major_opcode, + int *first_event, int *first_error ); + +extern char ** FSListCatalogues ( FSServer *svr, char *pattern, + int maxNames, int *actualCount ); +extern char ** FSGetCatalogues ( FSServer *svr, int *num ); + +extern long FSMaxRequestSize ( FSServer *svr ); + +extern char ** FSListFonts ( FSServer *svr, char *pattern, int maxNames, + int *actualCount ); +extern char ** FSListFontsWithXInfo ( FSServer *svr, char *pattern, + int maxNames, int *count, + FSXFontInfoHeader ***info, + FSPropInfo ***pprops, + FSPropOffset ***offsets, + unsigned char ***prop_data ); +extern Font FSOpenBitmapFont ( FSServer *svr, FSBitmapFormat hint, + FSBitmapFormatMask fmask, char *name, + Font *otherid ); + +extern int FSSync ( FSServer *svr, Bool discard ); + +extern int FSCloseServer ( FSServer *svr ); +extern int FSCloseFont ( FSServer *svr, Font fid ); +extern int FSGetErrorDatabaseText ( FSServer *svr, char *name, char *type, + char *defaultp, char *buffer, int nbytes ); +extern int FSGetErrorText ( FSServer *svr, int code, char *buffer, + + int nbytes ); +extern int FSFlush ( FSServer *svr ); +extern int FSFreeFontNames ( char **list ); +extern int FSFreeCatalogues ( char **list ); +extern int FSFreeExtensionList ( char **list ); +extern int FSNextEvent ( FSServer *svr, FSEvent *event ); +extern int FSQueryXBitmaps8 ( FSServer *svr, Font fid, FSBitmapFormat format, + int range_type, unsigned char *str, + unsigned long str_len, FSOffset **offsets, + unsigned char **glyphdata ); +extern int FSQueryXBitmaps16 ( FSServer *svr, Font fid, FSBitmapFormat format, + int range_type, FSChar2b *str, + unsigned long str_len, FSOffset **offsets, + unsigned char **glyphdata ); +extern int FSQueryXExtents8 ( FSServer *svr, Font fid, int range_type, + unsigned char *str, unsigned long str_len, + FSXCharInfo **extents ); +extern int FSQueryXExtents16 ( FSServer *svr, Font fid, int range_type, + FSChar2b *str, unsigned long str_len, + FSXCharInfo **extents ); +extern int FSQueryXInfo ( FSServer *svr, Font fid, FSXFontInfoHeader *info, + FSPropInfo *props, FSPropOffset **offsets, + unsigned char **prop_data ); +extern int FSSetCatalogues ( FSServer *svr, int num, char **cats ); +extern int FSFree ( char *data ); +extern unsigned char * FSMalloc ( unsigned size ); + +_XFUNCPROTOEND + +#endif /* _FSLIB_H_ */ diff --git a/nx-X11/lib/FS/FSlibInt.c b/nx-X11/lib/FS/FSlibInt.c new file mode 100644 index 000000000..3e1ac54d0 --- /dev/null +++ b/nx-X11/lib/FS/FSlibInt.c @@ -0,0 +1,1360 @@ +/* $Xorg: FSlibInt.c,v 1.5 2001/02/09 02:03:25 xorgcvs Exp $ */ + +/* + * Copyright 1990 Network Computing Devices; + * Portions Copyright 1987 by Digital Equipment Corporation + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation, and that the names of Network Computing + * Devices or Digital not be used in advertising or publicity pertaining + * to distribution of the software without specific, written prior + * permission. Network Computing Devices or Digital make no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH + * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES + * OR DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ + +/* + +Copyright 1987, 1994, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +*/ +/* $XFree86: xc/lib/FS/FSlibInt.c,v 3.10tsi Exp $ */ + +/* + * FSlibInt.c - Internal support routines for the C subroutine + * interface library (FSlib). + */ +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif +#include <stdio.h> +#include "FSlibint.h" +#include <X11/Xos.h> + +static void _EatData32 ( FSServer *svr, unsigned long n ); +static char * _SysErrorMsg ( int n ); + +/* check for both EAGAIN and EWOULDBLOCK, because some supposedly POSIX + * systems are broken and return EWOULDBLOCK when they should return EAGAIN + */ +#ifdef WIN32 +#define ETEST() (WSAGetLastError() == WSAEWOULDBLOCK) +#else +#if defined(EAGAIN) && defined(EWOULDBLOCK) +#define ETEST() (errno == EAGAIN || errno == EWOULDBLOCK) +#else +#ifdef EAGAIN +#define ETEST() (errno == EAGAIN) +#else +#define ETEST() (errno == EWOULDBLOCK) +#endif +#endif +#endif +#ifdef WIN32 +#define ECHECK(err) (WSAGetLastError() == err) +#define ESET(val) WSASetLastError(val) +#else +#ifdef ISC +#define ECHECK(err) ((errno == err) || ETEST()) +#else +#define ECHECK(err) (errno == err) +#endif +#define ESET(val) errno = val +#endif + +/* + * The following routines are internal routines used by FSlib for protocol + * packet transmission and reception. + * + * FSIOError(FSServer *) will be called if any sort of system call error occurs. + * This is assumed to be a fatal condition, i.e., FSIOError should not return. + * + * FSError(FSServer *, FSErrorEvent *) will be called whenever an FS_Error event is + * received. This is not assumed to be a fatal condition, i.e., it is + * acceptable for this procedure to return. However, FSError should NOT + * perform any operations (directly or indirectly) on the DISPLAY. + * + * Routines declared with a return type of 'Status' return 0 on failure, + * and non 0 on success. Routines with no declared return type don't + * return anything. Whenever possible routines that create objects return + * the object they have created. + */ + +_FSQEvent *_FSqfree = NULL; /* NULL _FSQEvent. */ + +static int padlength[4] = {0, 3, 2, 1}; + + /* + * lookup table for adding padding bytes to data that is read from or written + * to the FS socket. + */ + +static fsReq _dummy_request = { + 0, 0, 0 +}; + +/* + * _FSFlush - Flush the FS request buffer. If the buffer is empty, no + * action is taken. This routine correctly handles incremental writes. + * This routine may have to be reworked if int < long. + */ +void +_FSFlush(svr) + register FSServer *svr; +{ + register long size, + todo; + register int write_stat; + register char *bufindex; + + size = todo = svr->bufptr - svr->buffer; + bufindex = svr->bufptr = svr->buffer; + /* + * While write has not written the entire buffer, keep looping until the + * entire buffer is written. bufindex will be incremented and size + * decremented as buffer is written out. + */ + while (size) { + ESET(0); + write_stat = _FSTransWrite(svr->trans_conn, bufindex, (int) todo); + if (write_stat >= 0) { + size -= write_stat; + todo = size; + bufindex += write_stat; + } else if (ETEST()) { + _FSWaitForWritable(svr); +#ifdef SUNSYSV + } else if (ECHECK(0)) { + _FSWaitForWritable(svr); +#endif + +#ifdef EMSGSIZE + } else if (ECHECK(EMSGSIZE)) { + if (todo > 1) + todo >>= 1; + else + _FSWaitForWritable(svr); +#endif + } else { + /* Write failed! */ + /* errno set by write system call. */ + (*_FSIOErrorFunction) (svr); + } + } + svr->last_req = (char *) &_dummy_request; +} + +int +_FSEventsQueued(svr, mode) + register FSServer *svr; + int mode; +{ + register BytesReadable_t len; + BytesReadable_t pend; + char buf[BUFSIZE]; + register fsReply *rep; + + if (mode == QueuedAfterFlush) { + _FSFlush(svr); + if (svr->qlen) + return (svr->qlen); + } + if (_FSTransBytesReadable(svr->trans_conn, &pend) < 0) + (*_FSIOErrorFunction) (svr); + if ((len = pend) < SIZEOF(fsReply)) + return (svr->qlen); /* _FSFlush can enqueue events */ + else if (len > BUFSIZE) + len = BUFSIZE; + len /= SIZEOF(fsReply); + pend = len * SIZEOF(fsReply); + _FSRead(svr, buf, (long) pend); + + /* no space between comma and type or else macro will die */ + STARTITERATE(rep, fsReply, buf, (len > 0), len--) { + if (rep->generic.type == FS_Error) + _FSError(svr, (fsError *) rep); + else /* must be an event packet */ + _FSEnq(svr, (fsEvent *) rep); + } + ENDITERATE + return (svr->qlen); +} + +/* _FSReadEvents - Flush the output queue, + * then read as many events as possible (but at least 1) and enqueue them + */ +void +_FSReadEvents(svr) + register FSServer *svr; +{ + char buf[BUFSIZE]; + BytesReadable_t pend_not_register; /* because can't "&" a register + * variable */ + register BytesReadable_t pend; + register fsEvent *ev; + Bool not_yet_flushed = True; + + do { + /* find out how much data can be read */ + if (_FSTransBytesReadable(svr->trans_conn, &pend_not_register) < 0) + (*_FSIOErrorFunction) (svr); + pend = pend_not_register; + + /* + * must read at least one fsEvent; if none is pending, then we'll just + * flush and block waiting for it + */ + if (pend < SIZEOF(fsEvent)) { + pend = SIZEOF(fsEvent); + /* don't flush until we block the first time */ + if (not_yet_flushed) { + int qlen = svr->qlen; + + _FSFlush(svr); + if (qlen != svr->qlen) + return; + not_yet_flushed = False; + } + } + /* but we won't read more than the max buffer size */ + if (pend > BUFSIZE) + pend = BUFSIZE; + + /* round down to an integral number of XReps */ + pend = (pend / SIZEOF(fsEvent)) * SIZEOF(fsEvent); + + _FSRead(svr, buf, (long)pend); + + /* no space between comma and type or else macro will die */ + STARTITERATE(ev, fsEvent, buf, (pend > 0), + pend -= SIZEOF(fsEvent)) { + if (ev->type == FS_Error) + _FSError(svr, (fsError *) ev); + else /* it's an event packet; enqueue it */ + _FSEnq(svr, ev); + } + ENDITERATE + } while (svr->head == NULL); +} + +/* + * _FSRead - Read bytes from the socket taking into account incomplete + * reads. This routine may have to be reworked if int < long. + */ +void +_FSRead(svr, data, size) + register FSServer *svr; + register char *data; + register long size; +{ + register long bytes_read; +#if defined(SVR4) && defined(i386) + int num_failed_reads = 0; +#endif + + if (size == 0) + return; + ESET(0); + /* + * For SVR4 with a unix-domain connection, ETEST() after selecting + * readable means the server has died. To do this here, we look for + * two consecutive reads returning ETEST(). + */ + while ((bytes_read = _FSTransRead(svr->trans_conn, data, (int) size)) + != size) { + + if (bytes_read > 0) { + size -= bytes_read; + data += bytes_read; +#if defined(SVR4) && defined(i386) + num_failed_reads = 0; +#endif + } + else if (ETEST()) { + _FSWaitForReadable(svr); +#if defined(SVR4) && defined(i386) + num_failed_reads++; + if (num_failed_reads > 1) { + ESET(EPIPE); + (*_FSIOErrorFunction) (svr); + } +#endif + ESET(0); + } +#ifdef SUNSYSV + else if (ECHECK(0)) { + _FSWaitForReadable(svr); + } +#endif + + else if (bytes_read == 0) { + /* Read failed because of end of file! */ + ESET(EPIPE); + (*_FSIOErrorFunction) (svr); + } else { /* bytes_read is less than 0; presumably -1 */ + /* If it's a system call interrupt, it's not an error. */ + if (!ECHECK(EINTR)) + (*_FSIOErrorFunction) (svr); +#if defined(SVR4) && defined(i386) + else + num_failed_reads = 0; +#endif + } + } +} + +#ifdef WORD64 +/* + * XXX This is a *really* stupid way of doing this.... + */ + +#define PACKBUFFERSIZE 4096 + + +/* + * _FSRead32 - Read bytes from the socket unpacking each 32 bits + * into a long (64 bits on a CRAY computer). + * + */ +static void +_doFSRead32(svr, data, size, packbuffer) + register FSServer *svr; + register long *data; + register long size; + register char *packbuffer; +{ + long *lpack, + *lp; + long mask32 = 0x00000000ffffffff; + long maskw, + nwords, + i, + bits; + + _FSReadPad(svr, packbuffer, size); + + lp = data; + lpack = (long *) packbuffer; + nwords = size >> 2; + bits = 32; + + for (i = 0; i < nwords; i++) { + maskw = mask32 << bits; + *lp++ = (*lpack & maskw) >> bits; + bits = bits ^ 32; + if (bits) { + lpack++; + } + } +} + +void +_FSRead32(svr, data, len) + FSServer *svr; + long *data; + long len; +{ + char packbuffer[PACKBUFFERSIZE]; + unsigned nwords = (PACKBUFFERSIZE >> 2); /* bytes to CARD32 */ + + for (; len > nwords; len -= nwords, data += nwords) { + _doFSRead32(svr, data, nwords, packbuffer); + } + _doFSRead32(svr, data, len, packbuffer); +} + + + +/* + * _FSRead16 - Read bytes from the socket unpacking each 16 bits + * into a long (64 bits on a CRAY computer). + * + */ +static void +_doFSRead16(svr, data, size, packbuffer) + register FSServer *svr; + register short *data; + register long size; + char *packbuffer; +{ + long *lpack, + *lp; + long mask16 = 0x000000000000ffff; + long maskw, + nwords, + i, + bits; + + _FSRead(svr, packbuffer, size); /* don't do a padded read... */ + + lp = (long *) data; + lpack = (long *) packbuffer; + nwords = size >> 1; /* number of 16 bit words to be unpacked */ + bits = 48; + for (i = 0; i < nwords; i++) { + maskw = mask16 << bits; + *lp++ = (*lpack & maskw) >> bits; + bits -= 16; + if (bits < 0) { + lpack++; + bits = 48; + } + } +} + +void +_FSRead16(svr, data, len) + FSServer *svr; + short *data; + long len; +{ + char packbuffer[PACKBUFFERSIZE]; + unsigned nwords = (PACKBUFFERSIZE >> 1); /* bytes to CARD16 */ + + for (; len > nwords; len -= nwords, data += nwords) { + _doFSRead16(svr, data, nwords, packbuffer); + } + _doFSRead16(svr, data, len, packbuffer); +} + +void +_FSRead16Pad(svr, data, size) + FSServer *svr; + short *data; + long size; +{ + int slop = (size & 3); + short slopbuf[3]; + + _FSRead16(svr, data, size); + if (slop > 0) { + _FSRead16(svr, slopbuf, 4 - slop); + } +} + +#endif /* WORD64 */ + + +/* + * _FSReadPad - Read bytes from the socket taking into account incomplete + * reads. If the number of bytes is not 0 mod 32, read additional pad + * bytes. This routine may have to be reworked if int < long. + */ +void +_FSReadPad(svr, data, size) + register FSServer *svr; + register char *data; + register long size; +{ + register long bytes_read; + struct iovec iov[2]; + char pad[3]; + + if (size == 0) + return; + iov[0].iov_len = (int) size; + iov[0].iov_base = data; + /* + * The following hack is used to provide 32 bit long-word aligned padding. + * The [1] vector is of length 0, 1, 2, or 3, whatever is needed. + */ + + iov[1].iov_len = padlength[size & 3]; + iov[1].iov_base = pad; + size += iov[1].iov_len; + + ESET(0); + while ((bytes_read = _FSTransReadv(svr->trans_conn, iov, 2)) != size) { + + if (bytes_read > 0) { + size -= bytes_read; + if (iov[0].iov_len < bytes_read) { + int pad_bytes_read = bytes_read - iov[0].iov_len; + iov[1].iov_len -= pad_bytes_read; + iov[1].iov_base = + (char *)iov[1].iov_base + pad_bytes_read; + iov[0].iov_len = 0; + } else { + iov[0].iov_len -= bytes_read; + iov[0].iov_base = (char *)iov[0].iov_base + bytes_read; + } + } + else if (ETEST()) { + _FSWaitForReadable(svr); + ESET(0); + } +#ifdef SUNSYSV + else if (ECHECK(0)) { + _FSWaitForReadable(svr); + } +#endif + + else if (bytes_read == 0) { + /* Read failed because of end of file! */ + ESET(EPIPE); + (*_FSIOErrorFunction) (svr); + } else { /* bytes_read is less than 0; presumably -1 */ + /* If it's a system call interrupt, it's not an error. */ + if (!ECHECK(EINTR)) + (*_FSIOErrorFunction) (svr); + } + } +} + +/* + * _FSSend - Flush the buffer and send the client data. 32 bit word aligned + * transmission is used, if size is not 0 mod 4, extra bytes are transmitted. + * This routine may have to be reworked if int < long; + */ +void +_FSSend(svr, data, size) + register FSServer *svr; + char *data; + register long size; +{ + struct iovec iov[3]; + static char pad[3] = {0, 0, 0}; + + long skip = 0; + long svrbufsize = (svr->bufptr - svr->buffer); + long padsize = padlength[size & 3]; + long total = svrbufsize + size + padsize; + long todo = total; + + /* + * There are 3 pieces that may need to be written out: + * + * o whatever is in the display buffer o the data passed in by the user o + * any padding needed to 32bit align the whole mess + * + * This loop looks at all 3 pieces each time through. It uses skip to figure + * out whether or not a given piece is needed. + */ + while (total) { + long before = skip; /* amount of whole thing written */ + long remain = todo; /* amount to try this time, <= total */ + int i = 0; + long len; + + /* + * You could be very general here and have "in" and "out" iovecs and + * write a loop without using a macro, but what the heck. This + * translates to: + * + * how much of this piece is new? if more new then we are trying this + * time, clamp if nothing new then bump down amount already written, + * for next piece else put new stuff in iovec, will need all of next + * piece + * + * Note that todo had better be at least 1 or else we'll end up writing 0 + * iovecs. + */ +#define InsertIOV(pointer, length) \ + len = (length) - before; \ + if (len > remain) \ + len = remain; \ + if (len <= 0) { \ + before = (-len); \ + } else { \ + iov[i].iov_len = len; \ + iov[i].iov_base = (pointer) + before; \ + i++; \ + remain -= len; \ + before = 0; \ + } + + InsertIOV(svr->buffer, svrbufsize) + InsertIOV(data, size) + InsertIOV(pad, padsize) + + ESET(0); + if ((len = _FSTransWritev(svr->trans_conn, iov, i)) >= 0) { + skip += len; + total -= len; + todo = total; + } else if (ETEST()) { + _FSWaitForWritable(svr); +#ifdef SUNSYSV + } else if (ECHECK(0)) { + _FSWaitForWritable(svr); +#endif + +#ifdef EMSGSIZE + } else if (ECHECK(EMSGSIZE)) { + if (todo > 1) + todo >>= 1; + else + _FSWaitForWritable(svr); +#endif + } else { + (*_FSIOErrorFunction) (svr); + } + } + + svr->bufptr = svr->buffer; + svr->last_req = (char *) &_dummy_request; +} + +#ifdef undef +/* + * _FSAllocID - normal resource ID allocation routine. A client + * can roll his own and instatantiate it if he wants, but must + * follow the rules. + */ +FSID +_FSAllocID(svr) + register FSServer *svr; +{ + return (svr->resource_base + (svr->resource_id++ << svr->resource_shift)); +} + +#endif + +/* + * The hard part about this is that we only get 16 bits from a reply. Well, + * then, we have three values that will march along, with the following + * invariant: + * svr->last_request_read <= rep->sequenceNumber <= svr->request + * The right choice for rep->sequenceNumber is the largest that + * still meets these constraints. + */ + +unsigned long +_FSSetLastRequestRead(svr, rep) + register FSServer *svr; + register fsGenericReply *rep; +{ + register unsigned long newseq, + lastseq; + + newseq = (svr->last_request_read & ~((unsigned long) 0xffff)) | + rep->sequenceNumber; + lastseq = svr->last_request_read; + while (newseq < lastseq) { + newseq += 0x10000; + if (newseq > svr->request) { + (void) fprintf(stderr, + "FSlib: sequence lost (0x%lx > 0x%lx) in reply type 0x%x!\n", + newseq, svr->request, + (unsigned int) rep->type); + newseq -= 0x10000; + break; + } + } + + svr->last_request_read = newseq; + return (newseq); +} + +/* + * _FSReply - Wait for a reply packet and copy its contents into the + * specified rep. Mean while we must handle error and event packets that + * we may encounter. + */ +Status +_FSReply(svr, rep, extra, discard) + register FSServer *svr; + register fsReply *rep; + int extra; /* number of 32-bit words expected after the + * reply */ + Bool discard; /* should I discard data followind "extra" + * words? */ +{ + /* + * Pull out the serial number now, so that (currently illegal) requests + * generated by an error handler don't confuse us. + */ + unsigned long cur_request = svr->request; + long rem_length; + + _FSFlush(svr); + while (1) { + _FSRead(svr, (char *) rep, (long) SIZEOF(fsReply)); + switch ((int) rep->generic.type) { + + case FS_Reply: + /* + * Reply received. Fast update for synchronous replies, but deal + * with multiple outstanding replies. + */ + if (rep->generic.sequenceNumber == (cur_request & 0xffff)) + svr->last_request_read = cur_request; + else + (void) _FSSetLastRequestRead(svr, &rep->generic); + rem_length = rep->generic.length - (SIZEOF(fsReply) >> 2); + if (rem_length < 0) rem_length = 0; + if (extra == 0) { + if (discard && rem_length) + /* unexpectedly long reply! */ + _EatData32(svr, rem_length); + return (1); + } + if (extra == rem_length) { + /* + * Read the extra data into storage immediately following the + * GenericReply structure. + */ + _FSRead(svr, (char *) NEXTPTR(rep, fsReply), ((long) extra) << 2); + return (1); + } + if (extra < rem_length) { + /* Actual reply is longer than "extra" */ + _FSRead(svr, (char *) NEXTPTR(rep, fsReply), ((long) extra) << 2); + if (discard) + _EatData32(svr, rem_length - extra); + return (1); + } + /* + * if we get here, then extra > rem_length -- meaning we + * read a reply that's shorter than we expected. This is an + * error, but we still need to figure out how to handle it... + */ + _FSRead(svr, (char *) NEXTPTR(rep, fsReply), rem_length << 2); + (*_FSIOErrorFunction) (svr); + return (0); + + case FS_Error: + { + register _FSExtension *ext; + register Bool ret = False; + int ret_code; + fsError err; + unsigned long serial; + long err_data; + + err = *(fsError *) rep; + /* read the rest of the error */ + _FSRead(svr, (char *) &err + SIZEOF(fsReply), + (long) (SIZEOF(fsError) - SIZEOF(fsReply))); + serial = _FSSetLastRequestRead(svr, (fsGenericReply *) rep); + if (serial == cur_request) + /* do not die on certain failures */ + switch ((int) err.request) { + /* suck in any extra error info */ + case FSBadResolution: + case FSBadLength: + case FSBadIDChoice: + case FSBadRange: + case FSBadFont: + case FSBadFormat: + _FSRead(svr, (char *) &err_data, 4); + break; + case FSBadAccessContext: + _FSRead(svr, (char *) &err_data, 4); + return 0; + case FSBadAlloc: + return (0); + /* + * we better see if there is an extension who may want + * to suppress the error. + */ + default: + ext = svr->ext_procs; + while (ext) { + if (ext->error != NULL) + ret = (*ext->error) + (svr, &err, &ext->codes, &ret_code); + ext = ext->next; + } + if (ret) + return (ret_code); + break; + } + _FSError(svr, &err); + if (serial == cur_request) + return (0); + } + break; + default: + _FSEnq(svr, (fsEvent *) rep); + break; + } + } +} + + +/* Read and discard "n" 8-bit bytes of data */ + +void +_FSEatData(svr, n) + FSServer *svr; + register unsigned long n; +{ +#define SCRATCHSIZE 2048 + char buf[SCRATCHSIZE]; + + while (n > 0) { + register long bytes_read = (n > SCRATCHSIZE) ? SCRATCHSIZE : n; + + _FSRead(svr, buf, bytes_read); + n -= bytes_read; + } +#undef SCRATCHSIZE +} + + +/* Read and discard "n" 32-bit words. */ + +static void +_EatData32(svr, n) + FSServer *svr; + unsigned long n; +{ + _FSEatData(svr, n << 2); +} + + +/* + * _FSEnq - Place event packets on the display's queue. + * note that no squishing of move events in V11, since there + * is pointer motion hints.... + */ +void +_FSEnq(svr, event) + register FSServer *svr; + register fsEvent *event; +{ + register _FSQEvent *qelt; + +/*NOSTRICT*/ + if ((qelt = _FSqfree) != NULL) { + /* If _FSqfree is non-NULL do this, else malloc a new one. */ + _FSqfree = qelt->next; + } else if ((qelt = + (_FSQEvent *) FSmalloc((unsigned) sizeof(_FSQEvent))) == NULL) { + /* Malloc call failed! */ + ESET(ENOMEM); + (*_FSIOErrorFunction) (svr); + } + qelt->next = NULL; + /* go call through display to find proper event reformatter */ + if ((*svr->event_vec[event->type & 0177]) (svr, &qelt->event, event)) { + if (svr->tail) + svr->tail->next = qelt; + else + svr->head = qelt; + + svr->tail = qelt; + svr->qlen++; + } else { + /* ignored, or stashed away for many-to-one compression */ + qelt->next = _FSqfree; + _FSqfree = qelt; + } +} + +/* + * EventToWire in seperate file in that often not needed. + */ + +/*ARGSUSED*/ +Bool +_FSUnknownWireEvent(svr, re, event) + register FSServer *svr; /* pointer to display structure */ + register FSEvent *re; /* pointer to where event should be + * reformatted */ + register fsEvent *event; /* wire protocol event */ +{ + +#ifdef notdef + (void) fprintf(stderr, + "FSlib: unhandled wire event! event number = %d, display = %x\n.", + event->type, svr); +#endif + + return (False); +} + +/*ARGSUSED*/ +Status +_FSUnknownNativeEvent(svr, re, event) + register FSServer *svr; /* pointer to display structure */ + register FSEvent *re; /* pointer to where event should be + * reformatted */ + register fsEvent *event; /* wire protocol event */ +{ + +#ifdef notdef + (void) fprintf(stderr, + "FSlib: unhandled native event! event number = %d, display = %x\n.", + re->type, svr); +#endif + + return (0); +} + +/* + * reformat a wire event into an FSEvent structure of the right type. + */ +Bool +_FSWireToEvent(svr, re, event) + register FSServer *svr; /* pointer to display structure */ + register FSEvent *re; /* pointer to where event should be + * reformatted */ + register fsEvent *event; /* wire protocol event */ +{ + + re->type = event->type & 0x7f; + ((FSAnyEvent *) re)->serial = _FSSetLastRequestRead(svr, + (fsGenericReply *) event); + ((FSAnyEvent *) re)->send_event = ((event->type & 0x80) != 0); + ((FSAnyEvent *) re)->server = svr; + + /* + * Ignore the leading bit of the event type since it is set when a client + * sends an event rather than the server. + */ + + switch (event->type & 0177) { + default: + return (_FSUnknownWireEvent(svr, re, event)); + } +} + + +static char * +_SysErrorMsg(n) + int n; +{ + char *s = strerror(n); + + return (s ? s : "no such error"); +} + +/* + * _FSDefaultIOError - Default fatal system error reporting routine. Called + * when an X internal system error is encountered. + */ +int +_FSDefaultIOError(svr) + FSServer *svr; +{ + (void) fprintf(stderr, + "FSIO: fatal IO error %d (%s) on font server \"%s\"\r\n", +#ifdef WIN32 + WSAGetLastError(), strerror(WSAGetLastError()), +#else + + errno, _SysErrorMsg(errno), +#endif + FSServerString(svr)); + (void) fprintf(stderr, + " after %lu requests (%lu known processed) with %d events remaining.\r\n", + FSNextRequest(svr) - 1, FSLastKnownRequestProcessed(svr), + FSQLength(svr)); + + if (ECHECK(EPIPE)) { + (void) fprintf(stderr, + " The connection was probably broken by a server shutdown.\r\n"); + } + exit(1); + /* NOTREACHED */ +} + +/* + * _FSError - Default non-fatal error reporting routine. Called when an + * FS_Error packet is encountered in the input stream. + */ +int +_FSError(svr, rep) + FSServer *svr; + fsError *rep; +{ + FSErrorEvent event; + + /* + * FS_Error packet encountered! We need to unpack the error before giving + * it to the user. + */ + + event.server = svr; + event.type = FS_Error; + event.serial = _FSSetLastRequestRead(svr, (fsGenericReply *) rep); + event.error_code = rep->request; + event.request_code = rep->major_opcode; + event.minor_code = rep->minor_opcode; + if (_FSErrorFunction != NULL) { + return ((*_FSErrorFunction) (svr, &event)); + } + exit(1); + /* NOTREACHED */ +} + +int +_FSPrintDefaultError(svr, event, fp) + FSServer *svr; + FSErrorEvent *event; + FILE *fp; +{ + char buffer[BUFSIZ]; + char mesg[BUFSIZ]; + char number[32]; + char *mtype = "FSlibMessage"; + register _FSExtension *ext = (_FSExtension *) NULL; + + (void) FSGetErrorText(svr, event->error_code, buffer, BUFSIZ); + (void) FSGetErrorDatabaseText(svr, mtype, "FSError", "FS Error", mesg, + BUFSIZ); + (void) fprintf(fp, "%s: %s\n ", mesg, buffer); + (void) FSGetErrorDatabaseText(svr, mtype, "MajorCode", + "Request Major code %d", mesg, BUFSIZ); + (void) fprintf(fp, mesg, event->request_code); + if (event->request_code < 128) { + sprintf(number, "%d", event->request_code); + (void) FSGetErrorDatabaseText(svr, "FSRequest", number, "", buffer, + BUFSIZ); + } else { + for (ext = svr->ext_procs; + ext && (ext->codes.major_opcode != event->request_code); + ext = ext->next); + if (ext) + strcpy(buffer, ext->name); + else + buffer[0] = '\0'; + } + (void) fprintf(fp, " (%s)\n ", buffer); + (void) FSGetErrorDatabaseText(svr, mtype, "MinorCode", + "Request Minor code %d", mesg, BUFSIZ); + (void) fprintf(fp, mesg, event->minor_code); + if (ext) { + sprintf(mesg, "%s.%d", ext->name, event->minor_code); + (void) FSGetErrorDatabaseText(svr, "FSRequest", mesg, "", buffer, + BUFSIZ); + (void) fprintf(fp, " (%s)", buffer); + } + fputs("\n ", fp); + (void) FSGetErrorDatabaseText(svr, mtype, "ResourceID", "ResourceID 0x%x", + mesg, BUFSIZ); + (void) fprintf(fp, mesg, event->resourceid); + fputs("\n ", fp); + (void) FSGetErrorDatabaseText(svr, mtype, "ErrorSerial", "Error Serial #%d", + mesg, BUFSIZ); + (void) fprintf(fp, mesg, event->serial); + fputs("\n ", fp); + (void) FSGetErrorDatabaseText(svr, mtype, "CurrentSerial", + "Current Serial #%d", mesg, BUFSIZ); + (void) fprintf(fp, mesg, svr->request); + fputs("\n", fp); + return 1; +} + +int +_FSDefaultError(svr, event) + FSServer *svr; + FSErrorEvent *event; +{ + if (_FSPrintDefaultError(svr, event, stderr) == 0) + return 0; + exit(1); + /* NOTREACHED */ +} + + +FSIOErrorHandler _FSIOErrorFunction = _FSDefaultIOError; +FSErrorHandler _FSErrorFunction = _FSDefaultError; + +/* + * This routine can be used to (cheaply) get some memory within a single + * Xlib routine for scratch space. It is reallocated from the same place + * each time, unless the library needs a large scratch space. + */ +char * +_FSAllocScratch(svr, nbytes) + register FSServer *svr; + unsigned long nbytes; +{ + if (nbytes > svr->scratch_length) { + if (svr->scratch_buffer != NULL) + FSfree(svr->scratch_buffer); + return (svr->scratch_length = nbytes, + svr->scratch_buffer = FSmalloc((unsigned) nbytes)); + } + return (svr->scratch_buffer); +} + +int +FSFree(data) + char *data; +{ + FSfree(data); + return 1; +} + +unsigned char * +FSMalloc(size) + unsigned size; +{ + return (unsigned char *) FSmalloc(size); +} + +#ifdef DataRoutineIsProcedure +void +Data(svr, data, len) + FSServer *svr; + char *data; + long len; +{ + if (svr->bufptr + (len) <= svr->bufmax) { + bcopy(data, svr->bufptr, (int) len); + svr->bufptr += ((len) + 3) & ~3; + } else { + _FSSend(svr, data, len); + } +} + +#endif /* DataRoutineIsProcedure */ + + +#ifdef WORD64 +/* + * XXX This is a *really* stupid way of doing this. It should just use + * svr->bufptr directly, taking into account where in the word it is. + */ + +/* + * Data16 - Place 16 bit data in the buffer. + * + * "svr" is a pointer to a FSServer. + * "data" is a pointer to the data. + * "len" is the length in bytes of the data. + */ + +static void +doData16(svr, data, len, packbuffer) + register FSServer *svr; + short *data; + unsigned len; + char *packbuffer; +{ + long *lp, + *lpack; + long i, + nwords, + bits; + long mask16 = 0x000000000000ffff; + + lp = (long *) data; + lpack = (long *) packbuffer; + *lpack = 0; + +/* nwords is the number of 16 bit values to be packed, + * the low order 16 bits of each word will be packed + * into 64 bit words + */ + nwords = len >> 1; + bits = 48; + + for (i = 0; i < nwords; i++) { + *lpack ^= (*lp & mask16) << bits; + bits -= 16; + lp++; + if (bits < 0) { + lpack++; + *lpack = 0; + bits = 48; + } + } + Data(svr, packbuffer, len); +} + +void +Data16(svr, data, len) + FSServer *svr; + short *data; + unsigned len; +{ + char packbuffer[PACKBUFFERSIZE]; + unsigned nwords = (PACKBUFFERSIZE >> 1); /* bytes to CARD16 */ + + for (; len > nwords; len -= nwords, data += nwords) { + doData16(svr, data, nwords, packbuffer); + } + doData16(svr, data, len, packbuffer); +} + +/* + * Data32 - Place 32 bit data in the buffer. + * + * "svr" is a pointer to a FSServer. + * "data" is a pointer to the data. + * "len" is the length in bytes of the data. + */ + +static +doData32(svr, data, len, packbuffer) + register FSServer *svr; + long *data; + unsigned len; + char *packbuffer; +{ + long *lp, + *lpack; + long i, + bits, + nwords; + long mask32 = 0x00000000ffffffff; + + lpack = (long *) packbuffer; + lp = data; + + *lpack = 0; + +/* nwords is the number of 32 bit values to be packed + * the low order 32 bits of each word will be packed + * into 64 bit words + */ + nwords = len >> 2; + bits = 32; + + for (i = 0; i < nwords; i++) { + *lpack ^= (*lp & mask32) << bits; + bits = bits ^ 32; + lp++; + if (bits) { + lpack++; + *lpack = 0; + } + } + Data(svr, packbuffer, len); +} + +void +Data32(svr, data, len) + FSServer *svr; + short *data; + unsigned len; +{ + char packbuffer[PACKBUFFERSIZE]; + unsigned nwords = (PACKBUFFERSIZE >> 2); /* bytes to CARD32 */ + + for (; len > nwords; len -= nwords, data += nwords) { + doData32(svr, data, nwords, packbuffer); + } + doData32(svr, data, len, packbuffer); +} + +#endif /* WORD64 */ + + + +/* + * _FSFreeQ - free the queue of events, called by XCloseServer when there are + * no more displays left on the display list + */ + +void +_FSFreeQ() +{ + register _FSQEvent *qelt = _FSqfree; + + while (qelt) { + register _FSQEvent *qnext = qelt->next; + + FSfree(qelt); + qelt = qnext; + } + _FSqfree = NULL; + return; +} + +#ifdef _POSIX_SOURCE /* stupid makedepend [need if] */ +#ifndef __QNX__ /* QNX's uname nodename entry is not same as tcpip hostname */ +#define NEED_UTSNAME +#endif +#endif +#ifdef hpux +#define NEED_UTSNAME +#endif +#ifdef USG +#define NEED_UTSNAME +#endif +#ifdef SVR4 +#ifndef _SEQUENT_ +#define NEED_UTSNAME +#endif +#endif + +#ifdef NEED_UTSNAME +#include <sys/utsname.h> +#endif + + +/* + * _FSGetHostname - similar to gethostname but allows special processing. + */ +int +_FSGetHostname(buf, maxlen) + char *buf; + int maxlen; +{ + int len; + +#ifdef NEED_UTSNAME + /* + * same host name crock as in server and xinit. + */ + struct utsname name; + + uname(&name); + len = strlen(name.nodename); + if (len >= maxlen) + len = maxlen - 1; + strncpy(buf, name.nodename, len); + buf[len] = '\0'; +#else + buf[0] = '\0'; + (void) gethostname(buf, maxlen); + buf[maxlen - 1] = '\0'; + len = strlen(buf); +#endif /* NEED_UTSNAME */ + + return len; +} + +#ifndef _FSANYSET +/* + * This is not always a macro. + */ +_FSANYSET(src) + long *src; +{ + int i; + + for (i=0; i<MSKCNT; i++) + if (src[ i ]) + return (1); + return (0); +} +#endif diff --git a/nx-X11/lib/FS/FSlibint.h b/nx-X11/lib/FS/FSlibint.h new file mode 100644 index 000000000..f042d2af0 --- /dev/null +++ b/nx-X11/lib/FS/FSlibint.h @@ -0,0 +1,400 @@ +/* $Xorg: FSlibint.h,v 1.4 2001/02/09 02:03:25 xorgcvs Exp $ */ + +/* + * Copyright 1990 Network Computing Devices; + * Portions Copyright 1987 by Digital Equipment Corporation + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation, and that the names of Network Computing + * Devices or Digital not be used in advertising or publicity pertaining + * to distribution of the software without specific, written prior + * permission. Network Computing Devices or Digital make no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH + * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES + * OR DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ + +/* + +Copyright 1987, 1994, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +*/ +/* $XFree86: xc/lib/FS/FSlibint.h,v 3.8 2003/08/29 18:01:12 herrb Exp $ */ + +/* + * FSlib internal decls + */ +#include <X11/Xos.h> +#include <stdio.h> + +/* This is all probably superfluous given Xos.h above */ +#ifdef USG +#ifndef __TYPES__ +#include <sys/types.h> /* forgot to protect it... */ +#define __TYPES__ +#endif /* __TYPES__ */ +#else +#if defined(_POSIX_SOURCE) && defined(MOTOROLA) +#undef _POSIX_SOURCE +#include <sys/types.h> +#define _POSIX_SOURCE +#else +#include <sys/types.h> +#endif +#endif /* USG */ + +#include "FSlib.h" +#include "FSlibos.h" +#include <errno.h> +#include <stddef.h> + +typedef int (* FSIOErrorHandler)(FSServer *); +typedef int (* FSErrorHandler)(FSServer *, FSErrorEvent *); + +extern FSIOErrorHandler _FSIOErrorFunction; +extern FSErrorHandler _FSErrorFunction; + +extern void _FSEatData ( FSServer *svr, unsigned long n ); +extern void _FSWaitForWritable ( FSServer *svr ); +extern void _FSWaitForReadable ( FSServer *svr ); +extern void _FSFlush ( FSServer *svr ); +extern void _FSRead ( FSServer *svr, char *data, long size ); +extern void _FSReadEvents ( FSServer *svr ); +extern void _FSReadPad ( FSServer *svr, char *data, long size ); +extern void _FSSend ( FSServer *svr, char *data, long size ); +extern void _FSEnq ( FSServer *svr, fsEvent *event ); +extern void _FSFreeServerStructure ( FSServer *svr ); +extern int _FSError ( FSServer *svr, fsError *rep ); +extern int _FSReply ( FSServer *svr, fsReply *rep, int extra, int discard ); +extern XtransConnInfo _FSConnectServer ( char *server_name ); +extern void _FSDisconnectServer ( XtransConnInfo trans_conn ); +extern void _FSSendClientPrefix ( FSServer *svr, fsConnClientPrefix *client ); +extern int _FSEventsQueued ( FSServer *svr, int mode ); +extern unsigned long _FSSetLastRequestRead ( FSServer *svr, + fsGenericReply *rep ); +extern int _FSUnknownWireEvent ( FSServer *svr, FSEvent *re, fsEvent *event ); +extern int _FSUnknownNativeEvent ( FSServer *svr, FSEvent *re, + fsEvent *event ); +extern int _FSWireToEvent ( FSServer *svr, FSEvent *re, fsEvent *event ); +extern int _FSDefaultIOError ( FSServer *svr ); +extern int _FSPrintDefaultError ( FSServer *svr, FSErrorEvent *event, + FILE *fp ); +extern int _FSDefaultError ( FSServer *svr, FSErrorEvent *event ); +extern char * _FSAllocScratch ( FSServer *svr, unsigned long nbytes ); +extern void _FSFreeQ ( void ); +extern int _FSGetHostname ( char *buf, int maxlen ); + +extern FSErrorHandler FSSetErrorHandler ( FSErrorHandler handler ); +extern FSIOErrorHandler FSSetIOErrorHandler ( FSIOErrorHandler handler ); + +#ifndef BUFSIZE +#define BUFSIZE 2048 /* FS output buffer size. */ +#endif + +/* + * server flags + */ +#define FSlibServerIOError (1L << 0) +#define FSlibServerClosing (1L << 1) + +/* Need to start requests on 64 bit word boundries + * on a CRAY computer so add a NoOp (127) if needed. + * A character pointer on a CRAY computer will be non-zero + * after shifting right 61 bits of it is not pointing to + * a word boundary. + */ + +#ifdef WORD64 +#define WORD64ALIGN if ((long)svr->bufptr >> 61) {\ + svr->last_req = svr->bufptr;\ + *(svr->bufptr) = FS_Noop;\ + *(svr->bufptr+1) = 0;\ + *(svr->bufptr+2) = 0;\ + *(svr->bufptr+3) = 1;\ + svr->request += 1;\ + svr->bufptr += 4;\ + } +#else /* else does not require alignment on 64-bit + * boundaries */ +#define WORD64ALIGN +#endif /* WORD64 */ + +/* + * GetReq - Get the next avilable FS request packet in the buffer and + * return it. + * + * "name" is the name of the request, e.g. InternAtom, OpenFont, etc. + * "req" is the name of the request pointer. + * + */ + +#if !defined(UNIXCPP) || defined(ANSICPP) +#define GetReq(name, req) \ + WORD64ALIGN\ + if ((svr->bufptr + SIZEOF(fs##name##Req)) > svr->bufmax)\ + _FSFlush(svr);\ + req = (fs##name##Req *)(svr->last_req = svr->bufptr);\ + req->reqType = FS_##name;\ + req->length = (SIZEOF(fs##name##Req))>>2;\ + svr->bufptr += SIZEOF(fs##name##Req);\ + svr->request++ + +#else /* non-ANSI C uses empty comment instead of + * "##" for token concatenation */ +#define GetReq(name, req) \ + WORD64ALIGN\ + if ((svr->bufptr + SIZEOF(fs/**/name/**/Req)) > svr->bufmax)\ + _FSFlush(svr);\ + req = (fs/**/name/**/Req *)(svr->last_req = svr->bufptr);\ + req->reqType = FS_/**/name;\ + req->length = (SIZEOF(fs/**/name/**/Req))>>2;\ + svr->bufptr += SIZEOF(fs/**/name/**/Req);\ + svr->request++ +#endif + +/* GetReqExtra is the same as GetReq, but allocates "n" additional + bytes after the request. "n" must be a multiple of 4! */ + +#if !defined(UNIXCPP) || defined(ANSICPP) +#define GetReqExtra(name, n, req) \ + WORD64ALIGN\ + if ((svr->bufptr + SIZEOF(fs##name##Req) + n) > svr->bufmax)\ + _FSFlush(svr);\ + req = (fs##name##Req *)(svr->last_req = svr->bufptr);\ + req->reqType = FS_##name;\ + req->length = (SIZEOF(fs##name##Req) + n)>>2;\ + svr->bufptr += SIZEOF(fs##name##Req) + n;\ + svr->request++ +#else +#define GetReqExtra(name, n, req) \ + WORD64ALIGN\ + if ((svr->bufptr + SIZEOF(fs/**/name/**/Req) + n) > svr->bufmax)\ + _FSFlush(svr);\ + req = (fs/**/name/**/Req *)(svr->last_req = svr->bufptr);\ + req->reqType = FS_/**/name;\ + req->length = (SIZEOF(fs/**/name/**/Req) + n)>>2;\ + svr->bufptr += SIZEOF(fs/**/name/**/Req) + n;\ + svr->request++ +#endif + + +/* + * GetResReq is for those requests that have a resource ID + * (Window, Pixmap, GContext, etc.) as their single argument. + * "rid" is the name of the resource. + */ + +#if !defined(UNIXCPP) || defined(ANSICPP) +#define GetResReq(name, rid, req) \ + WORD64ALIGN\ + if ((svr->bufptr + SIZEOF(fsResourceReq)) > svr->bufmax)\ + _FSFlush(svr);\ + req = (fsResourceReq *) (svr->last_req = svr->bufptr);\ + req->reqType = FS_##name;\ + req->length = 2;\ + req->id = (rid);\ + svr->bufptr += SIZEOF(fsResourceReq);\ + svr->request++ +#else +#define GetResReq(name, rid, req) \ + WORD64ALIGN\ + if ((svr->bufptr + SIZEOF(fsResourceReq)) > svr->bufmax)\ + _FSFlush(svr);\ + req = (fsResourceReq *) (svr->last_req = svr->bufptr);\ + req->reqType = FS_/**/name;\ + req->length = 2;\ + req->id = (rid);\ + svr->bufptr += SIZEOF(fsResourceReq);\ + svr->request++ +#endif + +/* + * GetEmptyReq is for those requests that have no arguments + * at all. + */ + +#if !defined(UNIXCPP) || defined(ANSICPP) +#define GetEmptyReq(name, req) \ + WORD64ALIGN\ + if ((svr->bufptr + SIZEOF(fsReq)) > svr->bufmax)\ + _FSFlush(svr);\ + req = (fsReq *) (svr->last_req = svr->bufptr);\ + req->reqType = FS_##name;\ + req->length = 1;\ + svr->bufptr += SIZEOF(fsReq);\ + svr->request++ +#else +#define GetEmptyReq(name, req) \ + WORD64ALIGN\ + if ((svr->bufptr + SIZEOF(fsReq)) > svr->bufmax)\ + _FSFlush(svr);\ + req = (fsReq *) (svr->last_req = svr->bufptr);\ + req->reqType = FS_/**/name;\ + req->length = 1;\ + svr->bufptr += SIZEOF(fsReq);\ + svr->request++ +#endif + +#define SyncHandle() \ + if (svr->synchandler) (*svr->synchandler)(svr) + +/* + * Data - Place data in the buffer and pad the end to provide + * 32 bit word alignment. Transmit if the buffer fills. + * + * "svr" is a pointer to a Display. + * "data" is a pinter to a data buffer. + * "len" is the length of the data buffer. + * we can presume buffer less than 2^16 bytes, so bcopy can be used safely. + */ + +#ifdef DataRoutineIsProcedure +extern void Data(); + +#else +#define Data(svr, data, len) \ + if (svr->bufptr + (len) <= svr->bufmax) {\ + bcopy(data, svr->bufptr, (int)len);\ + svr->bufptr += ((len) + 3) & ~3;\ + } else\ + _FSSend(svr, data, len) +#endif /* DataRoutineIsProcedure */ + + +/* Allocate bytes from the buffer. No padding is done, so if + * the length is not a multiple of 4, the caller must be + * careful to leave the buffer aligned after sending the + * current request. + * + * "type" is the type of the pointer being assigned to. + * "ptr" is the pointer being assigned to. + * "n" is the number of bytes to allocate. + * + * Example: + * xTextElt *elt; + * BufAlloc (xTextElt *, elt, nbytes) + */ + +#define BufAlloc(type, ptr, n) \ + if (svr->bufptr + (n) > svr->bufmax) \ + _FSFlush (svr); \ + ptr = (type) svr->bufptr; \ + svr->bufptr += (n); + +/* + * provide emulation routines for smaller architectures + */ +#ifndef WORD64 +#define Data16(dpy, data, len) Data((dpy), (char *)(data), (len)) +#define Data32(dpy, data, len) Data((dpy), (char *)(data), (len)) +#define _FSRead16Pad(dpy, data, len) _FSReadPad((dpy), (char *)(data), (len)) +#define _FSRead16(dpy, data, len) _FSRead((dpy), (char *)(data), (len)) +#define _FSRead32(dpy, data, len) _FSRead((dpy), (char *)(data), (len)) +#endif /* not WORD64 */ + +#define PackData16(dpy,data,len) Data16 (dpy, data, len) +#define PackData32(dpy,data,len) Data32 (dpy, data, len) + +#define min(a,b) (((a) < (b)) ? (a) : (b)) +#define max(a,b) (((a) > (b)) ? (a) : (b)) + +#ifdef MUSTCOPY +/* a little bit of magic */ +#define OneDataCard32(svr,dstaddr,srcvar) \ + { svr->bufptr -= 4; Data32 (svr, (char *) &(srcvar), 4); } + +#define STARTITERATE(tpvar,type,start,endcond,decr) \ + { register char *cpvar; \ + for (cpvar = (char *) start; endcond; cpvar = NEXTPTR(cpvar,type), decr) { \ + type dummy; bcopy (cpvar, (char *) &dummy, SIZEOF(type)); \ + tpvar = (type *) cpvar; +#define ENDITERATE }} + +#else + +/* srcvar must be a variable for large architecture version */ +#define OneDataCard32(svr,dstaddr,srcvar) \ + { *(unsigned long *)(dstaddr) = (srcvar); } + +#define STARTITERATE(tpvar,type,start,endcond,decr) \ + for (tpvar = (type *) start; endcond; tpvar++, decr) { +#define ENDITERATE } +#endif /* MUSTCOPY - used machines whose C structs + * don't line up with proto */ + + +#if !defined(UNIXCPP) || defined(ANSICPP) +#define FSCat(x,y) x##_##y +#else +#define FSCat(x,y) x/**/_/**/y +#endif + +/* copy XCharInfo parts of a protocol reply into a FSXCharInfo */ + +#define FSUnpack_XCharInfo(packet, structure) \ + (structure)->left = FSCat(packet,left); \ + (structure)->right = FSCat(packet,right); \ + (structure)->width = FSCat(packet,width); \ + (structure)->ascent = FSCat(packet,ascent); \ + (structure)->descent = FSCat(packet,descent); \ + (structure)->attributes = FSCat(packet,attributes) + + +/* copy XFontInfoHeader parts of a protocol reply into a FSXFontInfoHeader */ + +#define FSUnpack_XFontInfoHeader(packet, structure, serverversion) \ + (structure)->flags = (packet)->font_header_flags; \ + (structure)->draw_direction = (packet)->font_header_draw_direction; \ + \ + if (serverversion > 1) { \ + (structure)->char_range.min_char.high = (packet)->font_hdr_char_range_min_char_high; \ + (structure)->char_range.min_char.low = (packet)->font_hdr_char_range_min_char_low; \ + (structure)->char_range.max_char.high = (packet)->font_hdr_char_range_max_char_high; \ + (structure)->char_range.max_char.low = (packet)->font_hdr_char_range_max_char_low; \ + (structure)->default_char.high = (packet)->font_header_default_char_high; \ + (structure)->default_char.low = (packet)->font_header_default_char_low; \ + } else { \ + (structure)->char_range.min_char.high = (packet)->font_hdr_char_range_min_char_low; \ + (structure)->char_range.min_char.low = (packet)->font_hdr_char_range_min_char_high; \ + (structure)->char_range.max_char.high = (packet)->font_hdr_char_range_max_char_low; \ + (structure)->char_range.max_char.low = (packet)->font_hdr_char_range_max_char_high; \ + (structure)->default_char.high = (packet)->font_header_default_char_low; \ + (structure)->default_char.low = (packet)->font_header_default_char_high; \ + } \ + \ + (structure)->font_ascent = (packet)->font_header_font_ascent; \ + (structure)->font_descent = (packet)->font_header_font_descent; \ + \ + FSUnpack_XCharInfo((packet)->font_header_min_bounds, &(structure)->min_bounds); \ + FSUnpack_XCharInfo((packet)->font_header_max_bounds, &(structure)->max_bounds) diff --git a/nx-X11/lib/FS/FSlibos.h b/nx-X11/lib/FS/FSlibos.h new file mode 100644 index 000000000..d14ee8ef8 --- /dev/null +++ b/nx-X11/lib/FS/FSlibos.h @@ -0,0 +1,332 @@ +/* $XdotOrg: xc/lib/FS/FSlibos.h,v 1.5 2005/11/08 06:33:25 jkj Exp $ */ +/* $Xorg: FSlibos.h,v 1.4 2001/02/09 02:03:25 xorgcvs Exp $ */ + +/* @(#)FSlibos.h 4.1 91/05/02 + * Copyright 1990 Network Computing Devices; + * Portions Copyright 1987 by Digital Equipment Corporation + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation, and that the names of Network Computing + * Devices or Digital not be used in advertising or publicity pertaining + * to distribution of the software without specific, written prior + * permission. Network Computing Devices or Digital make no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH + * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES + * OR DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ + +/* + +Copyright 1987, 1994, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +*/ +/* $XFree86: xc/lib/FS/FSlibos.h,v 3.10 2003/09/01 20:50:10 herrb Exp $ */ + +/* + * FSlib networking & os include file + */ + +#include <X11/Xfuncs.h> +#include <X11/Xosdefs.h> + +#ifndef WIN32 + +#if defined(__SCO__) || defined(__UNIXWARE__) +#include <stdint.h> /* For SIZE_MAX */ +#endif + +/* + * makedepend screws up on #undef OPEN_MAX, so we define a new symbol + */ + +#ifndef FS_OPEN_MAX + +#ifndef X_NOT_POSIX +#ifdef _POSIX_SOURCE +#include <limits.h> +#else +#define _POSIX_SOURCE +#include <limits.h> +#undef _POSIX_SOURCE +#endif +#endif +#ifndef SIZE_MAX +# ifdef ULONG_MAX +# define SIZE_MAX ULONG_MAX +# else +# define SIZE_MAX UINT_MAX +# endif +#endif +#ifndef OPEN_MAX +#ifdef SVR4 +#define OPEN_MAX 256 +#else +#include <sys/param.h> +#ifndef OPEN_MAX +#ifdef __OSF1__ +#define OPEN_MAX 256 +#else +#ifdef NOFILE +#define OPEN_MAX NOFILE +#else +#if !defined(__UNIXOS2__) && !defined(__QNX__) +#ifdef __GNU__ +#define OPEN_MAX (sysconf(_SC_OPEN_MAX)) +#else /* !__GNU__ */ +#define OPEN_MAX NOFILES_MAX +#endif /* __GNU__ */ +#else /* !__UNIXOS2__ && !__QNX__ */ +#define OPEN_MAX 256 +#endif /* __UNIXOS2__ */ +#endif +#endif +#endif +#endif +#endif + +#ifdef __GNU__ +#define FS_OPEN_MAX 256 +#else /*!__GNU__*/ +#if OPEN_MAX > 256 +#define FS_OPEN_MAX 256 +#else +#define FS_OPEN_MAX OPEN_MAX +#endif +#endif /*__GNU__*/ + +#endif /* FS_OPEN_MAX */ + +/* Utek leaves kernel macros around in include files (bleah) */ + +#ifdef dirty +#undef dirty +#endif + +#ifdef WORD64 +#define NMSKBITS 64 +#else +#define NMSKBITS 32 +#endif + +#define MSKCNT ((FS_OPEN_MAX + NMSKBITS - 1) / NMSKBITS) + +#ifdef LONG64 +typedef unsigned int FdSet[MSKCNT]; +#else +typedef unsigned long FdSet[MSKCNT]; +#endif + +#if (MSKCNT==1) +#define BITMASK(i) (1 << (i)) +#define MASKIDX(i) 0 +#endif + +#if (MSKCNT>1) +#define BITMASK(i) (1 << ((i) & (NMSKBITS - 1))) +#define MASKIDX(i) ((i) / NMSKBITS) +#endif + +#define MASKWORD(buf, i) buf[MASKIDX(i)] +#define BITSET(buf, i) MASKWORD(buf, i) |= BITMASK(i) +#define BITCLEAR(buf, i) MASKWORD(buf, i) &= ~BITMASK(i) +#define GETBIT(buf, i) (MASKWORD(buf, i) & BITMASK(i)) + +#if (MSKCNT==1) +#define COPYBITS(src, dst) dst[0] = src[0] +#define CLEARBITS(buf) buf[0] = 0 +#define MASKANDSETBITS(dst, b1, b2) dst[0] = (b1[0] & b2[0]) +#define ORBITS(dst, b1, b2) dst[0] = (b1[0] | b2[0]) +#define UNSETBITS(dst, b1) (dst[0] &= ~b1[0]) +#define _FSANYSET(src) (src[0]) +#endif + +#if (MSKCNT==2) +#define COPYBITS(src, dst) { dst[0] = src[0]; dst[1] = src[1]; } +#define CLEARBITS(buf) { buf[0] = 0; buf[1] = 0; } +#define MASKANDSETBITS(dst, b1, b2) {\ + dst[0] = (b1[0] & b2[0]);\ + dst[1] = (b1[1] & b2[1]); } +#define ORBITS(dst, b1, b2) {\ + dst[0] = (b1[0] | b2[0]);\ + dst[1] = (b1[1] | b2[1]); } +#define UNSETBITS(dst, b1) {\ + dst[0] &= ~b1[0]; \ + dst[1] &= ~b1[1]; } +#define _FSANYSET(src) (src[0] || src[1]) +#endif + +#if (MSKCNT==3) +#define COPYBITS(src, dst) { dst[0] = src[0]; dst[1] = src[1]; \ + dst[2] = src[2]; } +#define CLEARBITS(buf) { buf[0] = 0; buf[1] = 0; buf[2] = 0; } +#define MASKANDSETBITS(dst, b1, b2) {\ + dst[0] = (b1[0] & b2[0]);\ + dst[1] = (b1[1] & b2[1]);\ + dst[2] = (b1[2] & b2[2]); } +#define ORBITS(dst, b1, b2) {\ + dst[0] = (b1[0] | b2[0]);\ + dst[1] = (b1[1] | b2[1]);\ + dst[2] = (b1[2] | b2[2]); } +#define UNSETBITS(dst, b1) {\ + dst[0] &= ~b1[0]; \ + dst[1] &= ~b1[1]; \ + dst[2] &= ~b1[2]; } +#define _FSANYSET(src) (src[0] || src[1] || src[2]) +#endif + +#if (MSKCNT==4) +#define COPYBITS(src, dst) dst[0] = src[0]; dst[1] = src[1]; \ + dst[2] = src[2]; dst[3] = src[3] +#define CLEARBITS(buf) buf[0] = 0; buf[1] = 0; buf[2] = 0; buf[3] = 0 +#define MASKANDSETBITS(dst, b1, b2) \ + dst[0] = (b1[0] & b2[0]);\ + dst[1] = (b1[1] & b2[1]);\ + dst[2] = (b1[2] & b2[2]);\ + dst[3] = (b1[3] & b2[3]) +#define ORBITS(dst, b1, b2) \ + dst[0] = (b1[0] | b2[0]);\ + dst[1] = (b1[1] | b2[1]);\ + dst[2] = (b1[2] | b2[2]);\ + dst[3] = (b1[3] | b2[3]) +#define UNSETBITS(dst, b1) \ + dst[0] &= ~b1[0]; \ + dst[1] &= ~b1[1]; \ + dst[2] &= ~b1[2]; \ + dst[3] &= ~b1[3] +#define _FSANYSET(src) (src[0] || src[1] || src[2] || src[3]) +#endif + +#if (MSKCNT>4) +#define COPYBITS(src, dst) bcopy((caddr_t) src, (caddr_t) dst, sizeof(FdSet)) +#define CLEARBITS(buf) bzero((caddr_t) buf, sizeof(FdSet)) +#define MASKANDSETBITS(dst, b1, b2) \ + { int cri; \ + for (cri=0; cri<MSKCNT; cri++) \ + dst[cri] = (b1[cri] & b2[cri]) } +#define ORBITS(dst, b1, b2) \ + { int cri; \ + for (cri=0; cri<MSKCNT; cri++) \ + dst[cri] = (b1[cri] | b2[cri]) } +#define UNSETBITS(dst, b1) \ + { int cri; \ + for (cri=0; cri<MSKCNT; cri++) \ + dst[cri] &= ~b1[cri]; } +#if (MSKCNT==8) +#define _FSANYSET(src) (src[0] || src[1] || src[2] || src[3] || \ + src[4] || src[5] || src[6] || src[7]) +#endif +/* + * If MSKCNT>4 and not 8, then _FSANYSET is a routine defined in FSlibInt.c. + * + * #define _FSANYSET(src) (src[0] || src[1] || src[2] || src[3] || src[4] ...) + */ +#endif + + +#else + +#include <X11/Xwinsock.h> +#include <X11/Xw32defs.h> + +typedef fd_set FdSet; + +#define CLEARBITS(set) FD_ZERO(&set) +#define BITSET(set,s) FD_SET(s,&set) +#define _FSANYSET(set) set.fd_count + +#endif + +#include <X11/Xtrans/Xtrans.h> +#include <stdlib.h> +#include <string.h> + +/* + * The following definitions can be used for locking requests in multi-threaded + * address spaces. + */ +#define LockDisplay(dis) +#define LockMutex(mutex) +#define UnlockMutex(mutex) +#define UnlockDisplay(dis) +#define FSfree(ptr) free((ptr)) + + +/* + * Note that some machines do not return a valid pointer for malloc(0), in + * which case we provide an alternate under the control of the + * define MALLOC_0_RETURNS_NULL. This is necessary because some + * FSlib code expects malloc(0) to return a valid pointer to storage. + */ + +#ifdef MALLOC_0_RETURNS_NULL +#define FSmalloc(size) malloc(((size) > 0 ? (size) : 1)) +#define FSrealloc(ptr, size) realloc((ptr), ((size) > 0 ? (size) : 1)) +#define FScalloc(nelem, elsize) calloc(((nelem) > 0 ? (nelem) : 1), (elsize)) + +#else + +#define FSmalloc(size) malloc((size)) +#define FSrealloc(ptr, size) realloc((ptr), (size)) +#define FScalloc(nelem, elsize) calloc((nelem), (elsize)) +#endif + +/* + * ReadvFromServer and WritevToSever use struct iovec, normally found + * in Berkeley systems in <sys/uio.h>. See the readv(2) and writev(2) + * manual pages for details. + * + * struct iovec { + * caddr_t iov_base; + * int iov_len; + * }; + */ + +#ifdef USG + +#if defined(USG) && !defined(CRAY) && !defined(umips) && !defined(MOTOROLA) +#ifndef __TIMEVAL__ +#define __TIMEVAL__ +struct timeval { /* BSD has in <sys/time.h> */ + long tv_sec; + long tv_usec; +}; + +#endif /* __TIMEVAL__ */ + +#endif /* not CRAY or umips */ + +#endif /* USG */ + + +#define SearchString(string, char) index((string), (char)) diff --git a/nx-X11/lib/FS/Imakefile b/nx-X11/lib/FS/Imakefile new file mode 100644 index 000000000..a1c616363 --- /dev/null +++ b/nx-X11/lib/FS/Imakefile @@ -0,0 +1,58 @@ +XCOMM $Xorg: Imakefile,v 1.4 2000/08/17 19:44:07 cpqbld Exp $ +XCOMM $XdotOrg: xc/lib/FS/Imakefile,v 1.4 2004/08/27 22:47:45 eich Exp $ + + + + +XCOMM $XFree86: xc/lib/FS/Imakefile,v 3.5 2001/01/17 19:41:28 dawes Exp $ + +#define DoNormalLib NormalLibFS +#define DoSharedLib SharedLibFS +#define DoExtraLib SharedLibFS +#define DoDebugLib DebugLibFS +#define DoProfileLib ProfileLibFS +#define LibName FS +#define SoRev SOFSREV +#define IncSubdir X11 +#define IncSubSubdir fonts + +#if Malloc0ReturnsNull + DEFINES = -DMALLOC_0_RETURNS_NULL +#endif + +#ifdef SharedFSReqs +REQUIREDLIBS = SharedFSReqs +#endif + +DEPEND_DEFINES = $(TRANS_INCLUDES) $(CONN_DEFINES) DependDefines + +HEADERS = FSlib.h + +INCLUDES = -I$(FONTINCSRC) + +SRCS = FSClServ.c FSCloseFt.c FSConnServ.c FSErrDis.c FSErrHndlr.c \ + FSFlush.c FSFontInfo.c FSFtNames.c FSGetCats.c FSListCats.c \ + FSListExt.c FSMisc.c FSNextEv.c FSOpenFont.c FSOpenServ.c \ + FSQGlyphs.c FSQXExt.c FSQXInfo.c FSQuExt.c FSServName.c \ + FSSetCats.c FSSync.c FSSynchro.c FSlibInt.c transport.c + +OBJS = FSClServ.o FSCloseFt.o FSConnServ.o FSErrDis.o FSErrHndlr.o \ + FSFlush.o FSFontInfo.o FSFtNames.o FSGetCats.o FSListCats.o \ + FSListExt.o FSMisc.o FSNextEv.o FSOpenFont.o FSOpenServ.o \ + FSQGlyphs.o FSQXExt.o FSQXInfo.o FSQuExt.o FSServName.o \ + FSSetCats.o FSSync.o FSSynchro.o FSlibInt.o transport.o + +CONN_DEFINES = $(CONNECTION_FLAGS) -DFS_t -DTRANS_CLIENT $(XTRANS_FAILDEFINES) +#if HasBSD44Sockets +SOCK_DEFINES = -DBSD44SOCKETS +#endif + +#include <Library.tmpl> + +SpecialCLibObjectRule(FSlibInt,$(ICONFIGFILES),$(CONN_DEFINES)) +SpecialCLibObjectRule(FSOpenServ,$(ICONFIGFILES),$(CONN_DEFINES)) +SpecialCLibObjectRule(FSConnServ,$(ICONFIGFILES),$(CONN_DEFINES) $(SOCK_DEFINES)) +SpecialCLibObjectRule(transport,$(ICONFIGFILES),$(TRANS_INCLUDES) $(CONN_DEFINES) $(SOCK_DEFINES)) +LinkSourceFile(transport.c,$(TRANSCOMMSRC)) + +DependTarget() |