/*
* Copyright (c) 2005 X.Org Foundation L.L.C.
* 
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is furnished to do
* so, subject to the following conditions:
* 
* 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
* AUTHORS OR COPYRIGHT HOLDERS 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.
* 
* Copyright (c) Applied Testing and Technology, Inc. 1995
* All Rights Reserved.
* 
* 
* Portions of this software are based on Xlib and X Protocol Test Suite.
* We have used this material under the terms of its copyright, which grants
* free use, subject to the conditions below.  Note however that those
* portions of this software that are based on the original Test Suite have
* been significantly revised and that all such revisions are copyright (c)
* 1995 Applied Testing and Technology, Inc.  Insomuch as the proprietary
* revisions cannot be separated from the freely copyable material, the net
* result is that use of this software is governed by the ApTest copyright.
* 
* Copyright (c) 1990, 1991  X Consortium
* 
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* 
* 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
* X CONSORTIUM 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 X Consortium 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 X Consortium.
* 
* 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 name of UniSoft not be
* used in advertising or publicity pertaining to distribution of the
* software without specific, written prior permission.  UniSoft
* makes no representations about the suitability of this software for any
* purpose.  It is provided "as is" without express or implied warranty.
* 
* Copyright (c) 2005 X.Org Foundation LLC
* 
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is furnished to do
* so, subject to the following conditions:
* 
* 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
* AUTHORS OR COPYRIGHT HOLDERS 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.
* 
* Copyright (c) Applied Testing and Technology, Inc. 1995
* All Rights Reserved.
* 
* 
* Portions of this software are based on Xlib and X Protocol Test Suite.
* We have used this material under the terms of its copyright, which grants
* free use, subject to the conditions below.  Note however that those
* portions of this software that are based on the original Test Suite have
* been significantly revised and that all such revisions are copyright (c)
* 1995 Applied Testing and Technology, Inc.  Insomuch as the proprietary
* revisions cannot be separated from the freely copyable material, the net
* result is that use of this software is governed by the ApTest copyright.
* 
* Copyright (c) 1990, 1991  X Consortium
* 
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* 
* 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
* X CONSORTIUM 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 X Consortium 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 X Consortium.
* 
* Copyright 1990, 1991 by UniSoft Group Limited.
* 
* 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 name of UniSoft not be
* used in advertising or publicity pertaining to distribution of the
* software without specific, written prior permission.  UniSoft
* makes no representations about the suitability of this software for any
* purpose.  It is provided "as is" without express or implied warranty.
* 
* Copyright (c) 2005 X.Org Foundation LLC
* 
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is furnished to do
* so, subject to the following conditions:
* 
* 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
* AUTHORS OR COPYRIGHT HOLDERS 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.
* 
* Copyright (c) Applied Testing and Technology, Inc. 1995
* All Rights Reserved.
* 
* 
* Portions of this software are based on Xlib and X Protocol Test Suite.
* We have used this material under the terms of its copyright, which grants
* free use, subject to the conditions below.  Note however that those
* portions of this software that are based on the original Test Suite have
* been significantly revised and that all such revisions are copyright (c)
* 1995 Applied Testing and Technology, Inc.  Insomuch as the proprietary
* revisions cannot be separated from the freely copyable material, the net
* result is that use of this software is governed by the ApTest copyright.
* 
* Copyright (c) 1990, 1991  X Consortium
* 
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* 
* 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
* X CONSORTIUM 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 X Consortium 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 X Consortium.
* 
* Copyright 1990, 1991 by UniSoft Group Limited.
* 
* 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 name of UniSoft not be
* used in advertising or publicity pertaining to distribution of the
* software without specific, written prior permission.  UniSoft
* makes no representations about the suitability of this software for any
* purpose.  It is provided "as is" without express or implied warranty.
* 
* Copyright (c) 2005 X.Org Foundation LLC
* 
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is furnished to do
* so, subject to the following conditions:
* 
* 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
* AUTHORS OR COPYRIGHT HOLDERS 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.
* 
* Copyright (c) Applied Testing and Technology, Inc. 1995
* All Rights Reserved.
* 
* 
* Portions of this software are based on Xlib and X Protocol Test Suite.
* We have used this material under the terms of its copyright, which grants
* free use, subject to the conditions below.  Note however that those
* portions of this software that are based on the original Test Suite have
* been significantly revised and that all such revisions are copyright (c)
* 1995 Applied Testing and Technology, Inc.  Insomuch as the proprietary
* revisions cannot be separated from the freely copyable material, the net
* result is that use of this software is governed by the ApTest copyright.
* 
* Copyright (c) 1990, 1991  X Consortium
* 
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* 
* 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
* X CONSORTIUM 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 X Consortium 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 X Consortium.
* 
* Copyright 1990, 1991 by UniSoft Group Limited.
* 
* 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 name of UniSoft not be
* used in advertising or publicity pertaining to distribution of the
* software without specific, written prior permission.  UniSoft
* makes no representations about the suitability of this software for any
* purpose.  It is provided "as is" without express or implied warranty.
* 
* Copyright (c) 2005 X.Org Foundation LLC
* 
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is furnished to do
* so, subject to the following conditions:
* 
* 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
* AUTHORS OR COPYRIGHT HOLDERS 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.
* 
* Copyright (c) Applied Testing and Technology, Inc. 1995
* All Rights Reserved.
* 
* 
* Portions of this software are based on Xlib and X Protocol Test Suite.
* We have used this material under the terms of its copyright, which grants
* free use, subject to the conditions below.  Note however that those
* portions of this software that are based on the original Test Suite have
* been significantly revised and that all such revisions are copyright (c)
* 1995 Applied Testing and Technology, Inc.  Insomuch as the proprietary
* revisions cannot be separated from the freely copyable material, the net
* result is that use of this software is governed by the ApTest copyright.
* 
* Copyright (c) 1990, 1991  X Consortium
* 
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* 
* 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
* X CONSORTIUM 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 X Consortium 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 X Consortium.
* 
* Copyright 1990, 1991 by UniSoft Group Limited.
* 
* 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 name of UniSoft not be
* used in advertising or publicity pertaining to distribution of the
* software without specific, written prior permission.  UniSoft
* makes no representations about the suitability of this software for any
* purpose.  It is provided "as is" without express or implied warranty.
* 
* Copyright (c) 2005 X.Org Foundation LLC
* 
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is furnished to do
* so, subject to the following conditions:
* 
* 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
* AUTHORS OR COPYRIGHT HOLDERS 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.
* 
* Copyright (c) Applied Testing and Technology, Inc. 1995
* All Rights Reserved.
* 
* 
* Portions of this software are based on Xlib and X Protocol Test Suite.
* We have used this material under the terms of its copyright, which grants
* free use, subject to the conditions below.  Note however that those
* portions of this software that are based on the original Test Suite have
* been significantly revised and that all such revisions are copyright (c)
* 1995 Applied Testing and Technology, Inc.  Insomuch as the proprietary
* revisions cannot be separated from the freely copyable material, the net
* result is that use of this software is governed by the ApTest copyright.
* 
* Copyright (c) 1990, 1991  X Consortium
* 
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* 
* 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
* X CONSORTIUM 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 X Consortium 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 X Consortium.
* 
* Copyright 1990, 1991 by UniSoft Group Limited.
* 
* 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 name of UniSoft not be
* used in advertising or publicity pertaining to distribution of the
* software without specific, written prior permission.  UniSoft
* makes no representations about the suitability of this software for any
* purpose.  It is provided "as is" without express or implied warranty.
* 
* Copyright (c) 2005 X.Org Foundation LLC
* 
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is furnished to do
* so, subject to the following conditions:
* 
* 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
* AUTHORS OR COPYRIGHT HOLDERS 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.
* 
* Copyright (c) Applied Testing and Technology, Inc. 1995
* All Rights Reserved.
* 
* 
* Portions of this software are based on Xlib and X Protocol Test Suite.
* We have used this material under the terms of its copyright, which grants
* free use, subject to the conditions below.  Note however that those
* portions of this software that are based on the original Test Suite have
* been significantly revised and that all such revisions are copyright (c)
* 1995 Applied Testing and Technology, Inc.  Insomuch as the proprietary
* revisions cannot be separated from the freely copyable material, the net
* result is that use of this software is governed by the ApTest copyright.
* 
* Copyright (c) 1990, 1991  X Consortium
* 
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* 
* 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
* X CONSORTIUM 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 X Consortium 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 X Consortium.
* 
* Copyright 1990, 1991 by UniSoft Group Limited.
* 
* 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 name of UniSoft not be
* used in advertising or publicity pertaining to distribution of the
* software without specific, written prior permission.  UniSoft
* makes no representations about the suitability of this software for any
* purpose.  It is provided "as is" without express or implied warranty.
* 
* Copyright (c) 2005 X.Org Foundation LLC
* 
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is furnished to do
* so, subject to the following conditions:
* 
* 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
* AUTHORS OR COPYRIGHT HOLDERS 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.
* 
* Copyright (c) Applied Testing and Technology, Inc. 1995
* All Rights Reserved.
* 
* 
* Portions of this software are based on Xlib and X Protocol Test Suite.
* We have used this material under the terms of its copyright, which grants
* free use, subject to the conditions below.  Note however that those
* portions of this software that are based on the original Test Suite have
* been significantly revised and that all such revisions are copyright (c)
* 1995 Applied Testing and Technology, Inc.  Insomuch as the proprietary
* revisions cannot be separated from the freely copyable material, the net
* result is that use of this software is governed by the ApTest copyright.
* 
* Copyright (c) 1990, 1991  X Consortium
* 
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* 
* 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
* X CONSORTIUM 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 X Consortium 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 X Consortium.
* 
* Copyright 1990, 1991 by UniSoft Group Limited.
* 
* 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 name of UniSoft not be
* used in advertising or publicity pertaining to distribution of the
* software without specific, written prior permission.  UniSoft
* makes no representations about the suitability of this software for any
* purpose.  It is provided "as is" without express or implied warranty.
* 
* Copyright (c) 2005 X.Org Foundation LLC
* 
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is furnished to do
* so, subject to the following conditions:
* 
* 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
* AUTHORS OR COPYRIGHT HOLDERS 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.
* 
* Copyright (c) Applied Testing and Technology, Inc. 1995
* All Rights Reserved.
* 
* 
* Portions of this software are based on Xlib and X Protocol Test Suite.
* We have used this material under the terms of its copyright, which grants
* free use, subject to the conditions below.  Note however that those
* portions of this software that are based on the original Test Suite have
* been significantly revised and that all such revisions are copyright (c)
* 1995 Applied Testing and Technology, Inc.  Insomuch as the proprietary
* revisions cannot be separated from the freely copyable material, the net
* result is that use of this software is governed by the ApTest copyright.
* 
* Copyright (c) 1990, 1991  X Consortium
* 
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* 
* 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
* X CONSORTIUM 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 X Consortium 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 X Consortium.
* 
* Copyright 1990, 1991 by UniSoft Group Limited.
* 
* 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 name of UniSoft not be
* used in advertising or publicity pertaining to distribution of the
* software without specific, written prior permission.  UniSoft
* makes no representations about the suitability of this software for any
* purpose.  It is provided "as is" without express or implied warranty.
* 
* Copyright (c) 2005 X.Org Foundation LLC
* 
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is furnished to do
* so, subject to the following conditions:
* 
* 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
* AUTHORS OR COPYRIGHT HOLDERS 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.
* 
* Copyright (c) Applied Testing and Technology, Inc. 1995
* All Rights Reserved.
* 
* 
* Portions of this software are based on Xlib and X Protocol Test Suite.
* We have used this material under the terms of its copyright, which grants
* free use, subject to the conditions below.  Note however that those
* portions of this software that are based on the original Test Suite have
* been significantly revised and that all such revisions are copyright (c)
* 1995 Applied Testing and Technology, Inc.  Insomuch as the proprietary
* revisions cannot be separated from the freely copyable material, the net
* result is that use of this software is governed by the ApTest copyright.
* 
* Copyright (c) 1990, 1991  X Consortium
* 
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* 
* 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
* X CONSORTIUM 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 X Consortium 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 X Consortium.
* 
* Copyright 1990, 1991 by UniSoft Group Limited.
* 
* 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 name of UniSoft not be
* used in advertising or publicity pertaining to distribution of the
* software without specific, written prior permission.  UniSoft
* makes no representations about the suitability of this software for any
* purpose.  It is provided "as is" without express or implied warranty.
* 
* 
* Copyright (c) 2005 X.Org Foundation LLC
* 
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is furnished to do
* so, subject to the following conditions:
* 
* 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
* AUTHORS OR COPYRIGHT HOLDERS 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.
* 
* Copyright (c) Applied Testing and Technology, Inc. 1995
* All Rights Reserved.
* 
* 
* Portions of this software are based on Xlib and X Protocol Test Suite.
* We have used this material under the terms of its copyright, which grants
* free use, subject to the conditions below.  Note however that those
* portions of this software that are based on the original Test Suite have
* been significantly revised and that all such revisions are copyright (c)
* 1995 Applied Testing and Technology, Inc.  Insomuch as the proprietary
* revisions cannot be separated from the freely copyable material, the net
* result is that use of this software is governed by the ApTest copyright.
* 
* Copyright (c) 1990, 1991  X Consortium
* 
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* 
* 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
* X CONSORTIUM 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 X Consortium 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 X Consortium.
* 
* Copyright 1990, 1991 by UniSoft Group Limited.
* 
* 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 name of UniSoft not be
* used in advertising or publicity pertaining to distribution of the
* software without specific, written prior permission.  UniSoft
* makes no representations about the suitability of this software for any
* purpose.  It is provided "as is" without express or implied warranty.
* 
* Copyright (c) 2005 X.Org Foundation LLC
* 
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is furnished to do
* so, subject to the following conditions:
* 
* 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
* AUTHORS OR COPYRIGHT HOLDERS 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.
* 
* Copyright (c) Applied Testing and Technology, Inc. 1995
* All Rights Reserved.
* 
* 
* Portions of this software are based on Xlib and X Protocol Test Suite.
* We have used this material under the terms of its copyright, which grants
* free use, subject to the conditions below.  Note however that those
* portions of this software that are based on the original Test Suite have
* been significantly revised and that all such revisions are copyright (c)
* 1995 Applied Testing and Technology, Inc.  Insomuch as the proprietary
* revisions cannot be separated from the freely copyable material, the net
* result is that use of this software is governed by the ApTest copyright.
* 
* Copyright (c) 1990, 1991  X Consortium
* 
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* 
* 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
* X CONSORTIUM 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 X Consortium 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 X Consortium.
* 
* Copyright 1990, 1991 by UniSoft Group Limited.
* 
* 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 name of UniSoft not be
* used in advertising or publicity pertaining to distribution of the
* software without specific, written prior permission.  UniSoft
* makes no representations about the suitability of this software for any
* purpose.  It is provided "as is" without express or implied warranty.
* 
* Copyright (c) 2005 X.Org Foundation LLC
* 
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is furnished to do
* so, subject to the following conditions:
* 
* 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
* AUTHORS OR COPYRIGHT HOLDERS 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.
* 
* Copyright (c) Applied Testing and Technology, Inc. 1995
* All Rights Reserved.
* 
* 
* Portions of this software are based on Xlib and X Protocol Test Suite.
* We have used this material under the terms of its copyright, which grants
* free use, subject to the conditions below.  Note however that those
* portions of this software that are based on the original Test Suite have
* been significantly revised and that all such revisions are copyright (c)
* 1995 Applied Testing and Technology, Inc.  Insomuch as the proprietary
* revisions cannot be separated from the freely copyable material, the net
* result is that use of this software is governed by the ApTest copyright.
* 
* Copyright (c) 1990, 1991  X Consortium
* 
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* 
* 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
* X CONSORTIUM 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 X Consortium 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 X Consortium.
* 
* Copyright 1990, 1991 by UniSoft Group Limited.
* 
* 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 name of UniSoft not be
* used in advertising or publicity pertaining to distribution of the
* software without specific, written prior permission.  UniSoft
* makes no representations about the suitability of this software for any
* purpose.  It is provided "as is" without express or implied warranty.
* 
* Copyright (c) 2005 X.Org Foundation LLC
* 
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is furnished to do
* so, subject to the following conditions:
* 
* 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
* AUTHORS OR COPYRIGHT HOLDERS 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.
* 
* Copyright (c) Applied Testing and Technology, Inc. 1995
* All Rights Reserved.
* 
* 
* Portions of this software are based on Xlib and X Protocol Test Suite.
* We have used this material under the terms of its copyright, which grants
* free use, subject to the conditions below.  Note however that those
* portions of this software that are based on the original Test Suite have
* been significantly revised and that all such revisions are copyright (c)
* 1995 Applied Testing and Technology, Inc.  Insomuch as the proprietary
* revisions cannot be separated from the freely copyable material, the net
* result is that use of this software is governed by the ApTest copyright.
* 
* Copyright (c) 1990, 1991  X Consortium
* 
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* 
* 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
* X CONSORTIUM 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 X Consortium 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 X Consortium.
* 
* Copyright 1990, 1991 by UniSoft Group Limited.
* 
* 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 name of UniSoft not be
* used in advertising or publicity pertaining to distribution of the
* software without specific, written prior permission.  UniSoft
* makes no representations about the suitability of this software for any
* purpose.  It is provided "as is" without express or implied warranty.
* 
* 
* Copyright (c) 2005 X.Org Foundation LLC
* 
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is furnished to do
* so, subject to the following conditions:
* 
* 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
* AUTHORS OR COPYRIGHT HOLDERS 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.
* 
* Copyright (c) Applied Testing and Technology, Inc. 1995
* All Rights Reserved.
* 
* 
* Portions of this software are based on Xlib and X Protocol Test Suite.
* We have used this material under the terms of its copyright, which grants
* free use, subject to the conditions below.  Note however that those
* portions of this software that are based on the original Test Suite have
* been significantly revised and that all such revisions are copyright (c)
* 1995 Applied Testing and Technology, Inc.  Insomuch as the proprietary
* revisions cannot be separated from the freely copyable material, the net
* result is that use of this software is governed by the ApTest copyright.
* 
* Copyright (c) 1990, 1991  X Consortium
* 
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* 
* 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
* X CONSORTIUM 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 X Consortium 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 X Consortium.
* 
* Copyright 1990, 1991 by UniSoft Group Limited.
* 
* 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 name of UniSoft not be
* used in advertising or publicity pertaining to distribution of the
* software without specific, written prior permission.  UniSoft
* makes no representations about the suitability of this software for any
* purpose.  It is provided "as is" without express or implied warranty.
* 
* 
* Copyright (c) 2005 X.Org Foundation LLC
* 
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is furnished to do
* so, subject to the following conditions:
* 
* 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
* AUTHORS OR COPYRIGHT HOLDERS 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.
* 
* Copyright (c) Applied Testing and Technology, Inc. 1995
* All Rights Reserved.
* 
* 
* Portions of this software are based on Xlib and X Protocol Test Suite.
* We have used this material under the terms of its copyright, which grants
* free use, subject to the conditions below.  Note however that those
* portions of this software that are based on the original Test Suite have
* been significantly revised and that all such revisions are copyright (c)
* 1995 Applied Testing and Technology, Inc.  Insomuch as the proprietary
* revisions cannot be separated from the freely copyable material, the net
* result is that use of this software is governed by the ApTest copyright.
* 
* Copyright (c) 1990, 1991  X Consortium
* 
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* 
* 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
* X CONSORTIUM 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 X Consortium 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 X Consortium.
* 
* Copyright 1990, 1991 by UniSoft Group Limited.
* 
* 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 name of UniSoft not be
* used in advertising or publicity pertaining to distribution of the
* software without specific, written prior permission.  UniSoft
* makes no representations about the suitability of this software for any
* purpose.  It is provided "as is" without express or implied warranty.
* 
* 
* The symbols stipple_* and tile_* that do not occur in this file
* are defined in fill-style.mc which is always included along with
* this one.
* 
* Copyright (c) 2005 X.Org Foundation LLC
* 
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is furnished to do
* so, subject to the following conditions:
* 
* 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
* AUTHORS OR COPYRIGHT HOLDERS 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.
* 
* Copyright (c) Applied Testing and Technology, Inc. 1995
* All Rights Reserved.
* 
* 
* Portions of this software are based on Xlib and X Protocol Test Suite.
* We have used this material under the terms of its copyright, which grants
* free use, subject to the conditions below.  Note however that those
* portions of this software that are based on the original Test Suite have
* been significantly revised and that all such revisions are copyright (c)
* 1995 Applied Testing and Technology, Inc.  Insomuch as the proprietary
* revisions cannot be separated from the freely copyable material, the net
* result is that use of this software is governed by the ApTest copyright.
* 
* Copyright (c) 1990, 1991  X Consortium
* 
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* 
* 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
* X CONSORTIUM 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 X Consortium 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 X Consortium.
* 
* Copyright 1990, 1991 by UniSoft Group Limited.
* 
* 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 name of UniSoft not be
* used in advertising or publicity pertaining to distribution of the
* software without specific, written prior permission.  UniSoft
* makes no representations about the suitability of this software for any
* purpose.  It is provided "as is" without express or implied warranty.
* 
* 
* Copyright (c) 2005 X.Org Foundation LLC
* 
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is furnished to do
* so, subject to the following conditions:
* 
* 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
* AUTHORS OR COPYRIGHT HOLDERS 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.
* 
* Copyright (c) Applied Testing and Technology, Inc. 1995
* All Rights Reserved.
* 
* 
* Portions of this software are based on Xlib and X Protocol Test Suite.
* We have used this material under the terms of its copyright, which grants
* free use, subject to the conditions below.  Note however that those
* portions of this software that are based on the original Test Suite have
* been significantly revised and that all such revisions are copyright (c)
* 1995 Applied Testing and Technology, Inc.  Insomuch as the proprietary
* revisions cannot be separated from the freely copyable material, the net
* result is that use of this software is governed by the ApTest copyright.
* 
* Copyright (c) 1990, 1991  X Consortium
* 
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* 
* 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
* X CONSORTIUM 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 X Consortium 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 X Consortium.
* 
* Copyright 1990, 1991 by UniSoft Group Limited.
* 
* 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 name of UniSoft not be
* used in advertising or publicity pertaining to distribution of the
* software without specific, written prior permission.  UniSoft
* makes no representations about the suitability of this software for any
* purpose.  It is provided "as is" without express or implied warranty.
* 
* Copyright (c) 2005 X.Org Foundation LLC
* 
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is furnished to do
* so, subject to the following conditions:
* 
* 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
* AUTHORS OR COPYRIGHT HOLDERS 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.
* 
* Copyright (c) Applied Testing and Technology, Inc. 1995
* All Rights Reserved.
* 
* 
* Portions of this software are based on Xlib and X Protocol Test Suite.
* We have used this material under the terms of its copyright, which grants
* free use, subject to the conditions below.  Note however that those
* portions of this software that are based on the original Test Suite have
* been significantly revised and that all such revisions are copyright (c)
* 1995 Applied Testing and Technology, Inc.  Insomuch as the proprietary
* revisions cannot be separated from the freely copyable material, the net
* result is that use of this software is governed by the ApTest copyright.
* 
* Copyright (c) 1990, 1991  X Consortium
* 
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* 
* 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
* X CONSORTIUM 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 X Consortium 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 X Consortium.
* 
* Copyright 1990, 1991 by UniSoft Group Limited.
* 
* 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 name of UniSoft not be
* used in advertising or publicity pertaining to distribution of the
* software without specific, written prior permission.  UniSoft
* makes no representations about the suitability of this software for any
* purpose.  It is provided "as is" without express or implied warranty.
* 
* Copyright (c) 2005 X.Org Foundation LLC
* 
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is furnished to do
* so, subject to the following conditions:
* 
* 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
* AUTHORS OR COPYRIGHT HOLDERS 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.
* 
* Copyright (c) Applied Testing and Technology, Inc. 1995
* All Rights Reserved.
* 
* 
* Portions of this software are based on Xlib and X Protocol Test Suite.
* We have used this material under the terms of its copyright, which grants
* free use, subject to the conditions below.  Note however that those
* portions of this software that are based on the original Test Suite have
* been significantly revised and that all such revisions are copyright (c)
* 1995 Applied Testing and Technology, Inc.  Insomuch as the proprietary
* revisions cannot be separated from the freely copyable material, the net
* result is that use of this software is governed by the ApTest copyright.
* 
* Copyright (c) 1990, 1991  X Consortium
* 
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* 
* 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
* X CONSORTIUM 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 X Consortium 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 X Consortium.
* 
* Copyright 1990, 1991 by UniSoft Group Limited.
* 
* 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 name of UniSoft not be
* used in advertising or publicity pertaining to distribution of the
* software without specific, written prior permission.  UniSoft
* makes no representations about the suitability of this software for any
* purpose.  It is provided "as is" without express or implied warranty.
* 
* Copyright (c) 2005 X.Org Foundation LLC
* 
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is furnished to do
* so, subject to the following conditions:
* 
* 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
* AUTHORS OR COPYRIGHT HOLDERS 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.
* 
* Copyright (c) Applied Testing and Technology, Inc. 1995
* All Rights Reserved.
* 
* 
* Portions of this software are based on Xlib and X Protocol Test Suite.
* We have used this material under the terms of its copyright, which grants
* free use, subject to the conditions below.  Note however that those
* portions of this software that are based on the original Test Suite have
* been significantly revised and that all such revisions are copyright (c)
* 1995 Applied Testing and Technology, Inc.  Insomuch as the proprietary
* revisions cannot be separated from the freely copyable material, the net
* result is that use of this software is governed by the ApTest copyright.
* 
* Copyright (c) 1990, 1991  X Consortium
* 
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* 
* 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
* X CONSORTIUM 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 X Consortium 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 X Consortium.
* 
* Copyright 1990, 1991 by UniSoft Group Limited.
* 
* 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 name of UniSoft not be
* used in advertising or publicity pertaining to distribution of the
* software without specific, written prior permission.  UniSoft
* makes no representations about the suitability of this software for any
* purpose.  It is provided "as is" without express or implied warranty.
* 
* Copyright (c) 2005 X.Org Foundation LLC
* 
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is furnished to do
* so, subject to the following conditions:
* 
* 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
* AUTHORS OR COPYRIGHT HOLDERS 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.
* 
* Copyright (c) Applied Testing and Technology, Inc. 1995
* All Rights Reserved.
* 
* 
* Portions of this software are based on Xlib and X Protocol Test Suite.
* We have used this material under the terms of its copyright, which grants
* free use, subject to the conditions below.  Note however that those
* portions of this software that are based on the original Test Suite have
* been significantly revised and that all such revisions are copyright (c)
* 1995 Applied Testing and Technology, Inc.  Insomuch as the proprietary
* revisions cannot be separated from the freely copyable material, the net
* result is that use of this software is governed by the ApTest copyright.
* 
* Copyright (c) 1990, 1991  X Consortium
* 
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* 
* 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
* X CONSORTIUM 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 X Consortium 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 X Consortium.
* 
* Copyright 1990, 1991 by UniSoft Group Limited.
* 
* 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 name of UniSoft not be
* used in advertising or publicity pertaining to distribution of the
* software without specific, written prior permission.  UniSoft
* makes no representations about the suitability of this software for any
* purpose.  It is provided "as is" without express or implied warranty.
* 
* Copyright (c) 2005 X.Org Foundation LLC
* 
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is furnished to do
* so, subject to the following conditions:
* 
* 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
* AUTHORS OR COPYRIGHT HOLDERS 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.
* 
* Copyright (c) Applied Testing and Technology, Inc. 1995
* All Rights Reserved.
* 
* 
* Portions of this software are based on Xlib and X Protocol Test Suite.
* We have used this material under the terms of its copyright, which grants
* free use, subject to the conditions below.  Note however that those
* portions of this software that are based on the original Test Suite have
* been significantly revised and that all such revisions are copyright (c)
* 1995 Applied Testing and Technology, Inc.  Insomuch as the proprietary
* revisions cannot be separated from the freely copyable material, the net
* result is that use of this software is governed by the ApTest copyright.
* 
* Copyright (c) 1990, 1991  X Consortium
* 
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* 
* 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
* X CONSORTIUM 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 X Consortium 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 X Consortium.
* 
* Copyright 1990, 1991 by UniSoft Group Limited.
* 
* 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 name of UniSoft not be
* used in advertising or publicity pertaining to distribution of the
* software without specific, written prior permission.  UniSoft
* makes no representations about the suitability of this software for any
* purpose.  It is provided "as is" without express or implied warranty.
* 
* Copyright (c) 2005 X.Org Foundation LLC
* 
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is furnished to do
* so, subject to the following conditions:
* 
* 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
* AUTHORS OR COPYRIGHT HOLDERS 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.
* 
* Copyright (c) Applied Testing and Technology, Inc. 1995
* All Rights Reserved.
* 
* 
* Portions of this software are based on Xlib and X Protocol Test Suite.
* We have used this material under the terms of its copyright, which grants
* free use, subject to the conditions below.  Note however that those
* portions of this software that are based on the original Test Suite have
* been significantly revised and that all such revisions are copyright (c)
* 1995 Applied Testing and Technology, Inc.  Insomuch as the proprietary
* revisions cannot be separated from the freely copyable material, the net
* result is that use of this software is governed by the ApTest copyright.
* 
* Copyright (c) 1990, 1991  X Consortium
* 
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* 
* 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
* X CONSORTIUM 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 X Consortium 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 X Consortium.
* 
* Copyright 1990, 1991 by UniSoft Group Limited.
* 
* 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 name of UniSoft not be
* used in advertising or publicity pertaining to distribution of the
* software without specific, written prior permission.  UniSoft
* makes no representations about the suitability of this software for any
* purpose.  It is provided "as is" without express or implied warranty.
* 
*/
/*
 * SYNOPSIS:
 *   void
 *   XDrawRectangle(display, d, gc, x, y, width, height)
 *   Display	*display;
 *   Drawable	d;
 *   GC		gc;
 *   int 	x;
 *   int 	y;
 *   unsigned int 	width;
 *   unsigned int 	height;
 */


#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include	<stdlib.h>
#include	<stdio.h>
#include	<string.h>
#include	"xtest.h"
#include	"X11/Xlib.h"
#include	"X11/Xutil.h"
#include	"X11/Xresource.h"
#include	"X11/keysym.h"
#include	"tet_api.h"
#include	"xtestlib.h"
#include	"pixval.h"
#ifdef INPUTEXTENSION
#include        "X11/extensions/XInput.h"
#include        "XItest.h"
#endif

extern	Display	*Dsp;
extern	Window	Win;

extern	Window	ErrdefWindow;
extern	Drawable ErrdefDrawable;
extern	GC		ErrdefGC;
extern	Colormap ErrdefColormap;
extern	Pixmap	ErrdefPixmap;
extern	Atom	ErrdefAtom;
extern	Cursor	ErrdefCursor;
extern	Font	ErrdefFont;


#define T_XDrawRectangle	1
char    *TestName = "XDrawRectangle";

/*
 * Defines for different argument types
 */
#define A_DISPLAY display
#define A_DRAWABLE d
#define A_GC gc


/*
 * Arguments to the XDrawRectangle function
 */
static Display	*display;
static Drawable	d;
static GC		gc;
static int 	x;
static int 	y;
static unsigned int 	width;
static unsigned int 	height;


#ifdef MIN 
#undef MIN
#endif
#define MIN(a,b) (((a)<(b)) ? (a) : (b))

#ifdef MAX 
#undef MAX
#endif
#define MAX(a,b) (((a)>(b)) ? (a) : (b))

static void
drawline(ax1, ay1, ax2, ay2)
int 	ax1, ay1, ax2, ay2;
{
int	fail = 0;
int	x2 = MAX(ax1,ax2), y2 = MAX(ay1,ay2);
	/*
	 * Draw a rectangle that has the two given points as vertices.
	 * Some tests then do not apply or need slight modification.
	 * Sort them as the protocol specifies rects as top-left and w & h
	 * so drawing a rectangle "in reverse" isn't possible.
	 */
	x = MIN(ax1,ax2); y = MIN(ay1,ay2);
	width = x2 - x;
	height = y2 - y;
	startcall(display);
	if (isdeleted())
		return;
	XDrawRectangle(display, d, gc, x, y, width, height);
	endcall(display);
	if (geterr() != Success) {
		report("Got %s, Expecting Success", errorname(geterr()));
		FAIL;
	}
}
#undef MIN
#undef MAX

static void
setfordash()
{
	x = 20; y = 20;
	width = 50; height = 50;
}


#define A_DRAW	A_DRAWABLE

static	int 	f_pix_x = -1;
static	int 	f_pix_y = -1;

static void
functest(functype)
int 	functype;
{
XVisualInfo	*vp;
unsigned long	srcpix;
unsigned long	destpix;
unsigned long	expected;
unsigned long	actualpix;
unsigned long	maxpix;
int 	pass = 0, fail = 0;

	trace("Function %s", gcfunctionname(functype));

	for (resetvinf(VI_WIN_PIX); nextvinf(&vp); ) {
		A_DRAW = makewin(A_DISPLAY, vp);
		A_GC = makegc(A_DISPLAY, A_DRAW);

		/*
		 * If this is the first call find a pixel that is drawn
		 * that can be used for all the tests.
		 */
		if (f_pix_x == -1) {
			startcall(display);
			if (isdeleted())
				return;
			XDrawRectangle(display, d, gc, x, y, width, height);
			endcall(display);
			if (geterr() != Success) {
				report("Got %s, Expecting Success", errorname(geterr()));
				FAIL;
			}
			setfuncpixel(A_DISPLAY, A_DRAW, &f_pix_x, &f_pix_y);
			dclear(A_DISPLAY, A_DRAW);
			if (f_pix_x == -1) {
				report("Nothing was drawn with a gc function of GXcopy");
				/*
				 * If we were actually testing GXcopy then the test has
				 * failed (in a way), so say FAIL.
				 */
				if (functype == GXcopy)
					FAIL;
				else
					delete("Setup error in functest");
				return;
			}
		}

		XSetFunction(A_DISPLAY, A_GC, functype);

		/* Try out a few more values without taking too long */
		maxpix = 3;

		for (destpix = 0; destpix <= maxpix; destpix++) {
			for (srcpix = 0; srcpix <= 1; srcpix++) {

				trace("src=%d, dest=%d", srcpix, destpix);

				/*
				 * The test on depth shouldn't be necessary, however a common
				 * bug exists where pixels are not truncated on mono screens.
				 * The bug is diagnosed in another test so causing failures here
				 * as well would be confusing.
				 */
				if (vp->depth == 1)
					dset(A_DISPLAY, A_DRAW, destpix&1);
				else
					dset(A_DISPLAY, A_DRAW, destpix);
				XSetForeground(A_DISPLAY, A_GC, srcpix);
				startcall(display);
				if (isdeleted())
					return;
				XDrawRectangle(display, d, gc, x, y, width, height);
				endcall(display);
				if (geterr() != Success) {
					report("Got %s, Expecting Success", errorname(geterr()));
					FAIL;
				}

				switch (functype) {
				case GXclear:
					expected = 0;
					break;
				case GXand:
					expected = srcpix & destpix;
					break;
				case GXandReverse:
					expected = srcpix & ~destpix;
					break;
				case GXcopy:
					expected = srcpix;
					break;
				case GXandInverted:
					expected = ~srcpix & destpix;
					break;
				case GXnoop:
					expected = destpix;
					break;
				case GXxor:
					expected = srcpix ^ destpix;
					break;
				case GXor:
					expected = srcpix | destpix;
					break;
				case GXnor:
					expected = ~srcpix & ~destpix;
					break;
				case GXequiv:
					expected = ~srcpix ^ destpix;
					break;
				case GXinvert:
					expected = ~destpix;
					break;
				case GXorReverse:
					expected = srcpix | ~destpix;
					break;
				case GXcopyInverted:
					expected = ~srcpix;
					break;
				case GXorInverted:
					expected = ~srcpix | destpix;
					break;
				case GXnand:
					expected = ~srcpix | ~destpix;
					break;
				case GXset:
					expected = ~0;
					break;
				default:
					report("Bad value given to functest");
					tet_result(TET_UNRESOLVED);
					break;
				}

				expected &= DEPTHMASK(vp->depth);
				actualpix = getpixel(A_DISPLAY, A_DRAW, f_pix_x, f_pix_y);

				debug(3, "src %d, dst %d, expect %d", srcpix, destpix,expected);

				if (actualpix == expected)
					CHECK;
				else {
					report("%s fail expected %d, got %d", gcfunctionname(functype), expected, actualpix);
					FAIL;
				}
			}
		}

	}

	CHECKPASS(2*(maxpix+1)*nvinf());
}


#define	PLANEFG	0x55555555
static	int 	planelist[] = {
	0, 0x1, 0x2, 0x23, 0xf8, 0x765, 0x3987, 0x129078, 0x23567193};

static	int 	linestyles[] = {LineSolid, LineOnOffDash, LineDoubleDash};
static	int 	capstyles[] = {CapNotLast, CapButt, CapProjecting, CapRound};

static char	lsdashes[] = {
	14,14};

#ifndef tile_width
#define tile_width 19
#define tile_height 19
static unsigned char tile_bits[] = {
   0xff, 0xff, 0x07, 0x80, 0x0f, 0x00, 0x67, 0x30, 0x07, 0x9b, 0xcf, 0x06,
   0xe8, 0xbf, 0x00, 0x94, 0x4f, 0x01, 0x54, 0x50, 0x01, 0x2a, 0xa7, 0x02,
   0xaa, 0xaf, 0x02, 0xaf, 0xaf, 0x07, 0xaa, 0xaf, 0x02, 0x2a, 0xa7, 0x02,
   0x54, 0x50, 0x01, 0x94, 0x4f, 0x01, 0xe8, 0xbf, 0x00, 0x98, 0xcf, 0x00,
   0x63, 0x30, 0x06, 0x80, 0x0f, 0x00, 0xff, 0xf8, 0x07};
#endif
#ifdef stipple_width
#define stipple_width 24
#define stipple_height 11
static unsigned char stipple_bits[] = {
   0xff, 0x0f, 0x00, 0x3f, 0xf0, 0xff, 0xcf, 0xff, 0x03, 0xf7, 0x0f, 0xfc,
   0xff, 0xf1, 0x0f, 0x78, 0x7e, 0xf0, 0x80, 0x8f, 0x1f, 0x2a, 0xf0, 0xe1,
   0x80, 0x07, 0x1e, 0xaa, 0xff, 0xe0, 0x80, 0xff, 0x0f};
#endif


/*
 * List of data for joins
 */
static	struct linejoindata {
	int 	a;
	int 	b;
	int 	c;
	double	ang;
} linejoindata[] = {
	{60, 10, 10, 18.9},
	{30, 20, 40, 86.82},
	{45, 0, 30,  33.69},
	{51, 5, 5,   11.20},
	{50, 20, 30, 52.77},

	{60, 5, 5,    9.53},
	{20, -50, 60, 3.37},
	{50, -50, 60, 5.19},
	{60, 3, 3,    5.73},
	{60, 2, 2,    3.82},
	{52, 5, 5,    10.98},
};
	



#ifndef tile_width
#define tile_width 19
#define tile_height 19
static unsigned char tile_bits[] = {
   0xff, 0xff, 0x07, 0x80, 0x0f, 0x00, 0x67, 0x30, 0x07, 0x9b, 0xcf, 0x06,
   0xe8, 0xbf, 0x00, 0x94, 0x4f, 0x01, 0x54, 0x50, 0x01, 0x2a, 0xa7, 0x02,
   0xaa, 0xaf, 0x02, 0xaf, 0xaf, 0x07, 0xaa, 0xaf, 0x02, 0x2a, 0xa7, 0x02,
   0x54, 0x50, 0x01, 0x94, 0x4f, 0x01, 0xe8, 0xbf, 0x00, 0x98, 0xcf, 0x00,
   0x63, 0x30, 0x06, 0x80, 0x0f, 0x00, 0xff, 0xf8, 0x07};
#endif
#ifndef stipple_width
#define stipple_width 24
#define stipple_height 11
static unsigned char stipple_bits[] = {
   0xff, 0x0f, 0x00, 0x3f, 0xf0, 0xff, 0xcf, 0xff, 0x03, 0xf7, 0x0f, 0xfc,
   0xff, 0xf1, 0x0f, 0x78, 0x7e, 0xf0, 0x80, 0x8f, 0x1f, 0x2a, 0xf0, 0xe1,
   0x80, 0x07, 0x1e, 0xaa, 0xff, 0xe0, 0x80, 0xff, 0x0f};
#endif



#if !defined(T_XDrawImageString) && !defined(T_XCopyPlane) && !defined(T_XPutImage) && !defined(T_XCopyArea)
#define NEED_STIPPLE
#endif



static	char dolist[] = {
	8, 1, 2, 3, 1, 1, 1, 1, 1, 11, 2, 8};

static char	dashlist[] = {
	1, 5, 3, 9, 15, 1, 1, 2, 2, 3, 3,
	2, 3, 1, 5, 1, 7, 1, 2, 1};

int 	tet_thistest;

/*
 * Called at the beginning of each test purpose to reset the
 * arguments to their initial values
 */
static void
setargs()
{
	display = Dsp;
	d = 0;
	gc = 0;
	x = 10;
	y = 7;
	width = 60;
	height = 34;
}

/*
 * Set the arguments to default values for error tests
 */
static void
seterrdef()
{
	d = ErrdefDrawable;
	gc = ErrdefGC;
}

static void t001(){

XVisualInfo *vp;
int 	pass = 0, fail = 0;

 	report_purpose(1);

	report_assertion("Assertion XDrawRectangle-1.(A)");
	report_assertion("A call to XDrawRectangle draws the outline of the rectangle");
	report_assertion("specified by x, y, width and height in the drawable d.");

	report_strategy("Draw rectangle.");
	report_strategy("Pixmap verify.");

	tpstartup();
	setargs();
	for (resetvinf(VI_WIN_PIX); nextvinf(&vp); ) {
		d = makewin(display, vp);
		gc = makegc(display, d);
		startcall(display);
		if (isdeleted())
			return;
		XDrawRectangle(display, d, gc, x, y, width, height);
		endcall(display);
		if (geterr() != Success) {
			report("Got %s, Expecting Success", errorname(geterr()));
			FAIL;
		}
		PIXCHECK(display, d);
	}
	CHECKPASS(nvinf());

	tpcleanup();
	pfcount(pass, fail);
}

static void t002(){


 	report_purpose(2);

	report_assertion("Assertion XDrawRectangle-2.(-)");
	report_assertion("A call to XDrawRectangle draws the rectangle as if a");
	report_assertion("five-point PolyLine protocol request were specified for the");
	report_assertion("rectangle in the order [x,y], [x+width,y], [x+width,");
	report_assertion("y+height], [x,y+height], [x,y].");
	report_assertion("The assertion is descriptive or is tested elsewhere.");
	tet_result(TET_NOTINUSE);
}

static void t003(){


 	report_purpose(3);

	report_assertion("Assertion XDrawRectangle-3.(-)");
	report_assertion("All four corners of the rectangle join.");
	report_assertion("The assertion is descriptive or is tested elsewhere.");
	tet_result(TET_NOTINUSE);
}

static void t004(){

XVisualInfo *vp;
int 	pass = 0, fail = 0;

 	report_purpose(4);

	report_assertion("Assertion XDrawRectangle-4.(A)");
	report_assertion("A call to XDrawRectangle does not draw a pixel more than");
	report_assertion("once.");

	report_strategy("Set function to GXxor");
	report_strategy("Draw rectangle");
	report_strategy("Pixmap verify");

	tpstartup();
	setargs();
	for (resetvinf(VI_WIN_PIX); nextvinf(&vp); ) {
		d = makewin(display, vp);
		gc = makegc(display, d);
		XSetFunction(display, gc, GXxor);
		startcall(display);
		if (isdeleted())
			return;
		XDrawRectangle(display, d, gc, x, y, width, height);
		endcall(display);
		if (geterr() != Success) {
			report("Got %s, Expecting Success", errorname(geterr()));
			FAIL;
		}
		PIXCHECK(display, d);
	}
	CHECKPASS(nvinf());

	tpcleanup();
	pfcount(pass, fail);
}

/* Including from file gc/function.mc */
static void t005(){

int 	pass = 0, fail = 0;

 	report_purpose(5);

	report_assertion("Assertion XDrawRectangle-5.(A)");
	report_assertion("When a graphics operation is performed and the source pixel");
	report_assertion("is src and the destination pixel is dst and function is");
	report_assertion("GXclear, then the destination becomes (dst AND (NOT");
	report_assertion("plane_mask)).");

	report_strategy("Find a point (f_pix_x, f_pix_y) that is drawn by the graphics operation.");
	report_strategy("");
	report_strategy("Set function component of GC to GXclear.");
	report_strategy("For destination pixel values dst = 0, 1, 2, 3");
	report_strategy("    For source pixel values of src = 0, 1");
	report_strategy("	Set all points in drawable to destination pixel value.");
	report_strategy("	Set foreground component of GC to source pixel value.");
	report_strategy("	  (or fill source drawable/image with source pixel value in the cases");
	report_strategy("	   of XCopyArea or XPutImage, while XCopyPlane always has it ~0 to");
	report_strategy("	   force a foreground fill).");
	report_strategy("	Do graphics operation.");
	report_strategy("	Verify that pixel value at f_pix_x, f_pix_y is 0.");

	tpstartup();
	setargs();
	functest(GXclear);
	tpcleanup();
	pfcount(pass, fail);
}

static void t006(){

int 	pass = 0, fail = 0;

 	report_purpose(6);

	report_assertion("Assertion XDrawRectangle-6.(A)");
	report_assertion("When a graphics operation is performed and the source pixel");
	report_assertion("is src and the destination pixel is dst and function is");
	report_assertion("GXand, then the destination becomes ((src AND dst) AND");
	report_assertion("plane_mask) OR (dst AND (NOT plane_mask)).");

	report_strategy("Find a point (f_pix_x, f_pix_y) that is drawn by the graphics operation.");
	report_strategy("");
	report_strategy("Set function component of GC to GXand.");
	report_strategy("For destination pixel values dst = 0, 1, 2, 3");
	report_strategy("    For source pixel values of src = 0, 1");
	report_strategy("	Set all points in drawable to destination pixel value.");
	report_strategy("	Set foreground component of GC to source pixel value.");
	report_strategy("	  (or fill source drawable/image with source pixel value in the cases");
	report_strategy("	   of XCopyArea or XPutImage, while XCopyPlane always has it ~0 to");
	report_strategy("	   force a foreground fill).");
	report_strategy("	Do graphics operation.");
	report_strategy("	Verify that pixel value at f_pix_x, f_pix_y is src&dest.");

	tpstartup();
	setargs();
	functest(GXand);
	tpcleanup();
	pfcount(pass, fail);
}

static void t007(){

int 	pass = 0, fail = 0;

 	report_purpose(7);

	report_assertion("Assertion XDrawRectangle-7.(A)");
	report_assertion("When a graphics operation is performed and the source pixel");
	report_assertion("is src and the destination pixel is dst and function is");
	report_assertion("GXandReverse, then the destination becomes ((src AND (NOT");
	report_assertion("dst)) AND plane_mask) OR (dst AND (NOT plane_mask)).");

	report_strategy("Find a point (f_pix_x, f_pix_y) that is drawn by the graphics operation.");
	report_strategy("");
	report_strategy("Set function component of GC to GXandReverse.");
	report_strategy("For destination pixel values dst = 0, 1, 2, 3");
	report_strategy("    For source pixel values of src = 0, 1");
	report_strategy("	Set all points in drawable to destination pixel value.");
	report_strategy("	Set foreground component of GC to source pixel value.");
	report_strategy("	  (or fill source drawable/image with source pixel value in the cases");
	report_strategy("	   of XCopyArea or XPutImage, while XCopyPlane always has it ~0 to");
	report_strategy("	   force a foreground fill).");
	report_strategy("	Do graphics operation.");
	report_strategy("	Verify that pixel value at f_pix_x, f_pix_y is src&~dest.");

	tpstartup();
	setargs();
	functest(GXandReverse);
	tpcleanup();
	pfcount(pass, fail);
}

static void t008(){

int 	pass = 0, fail = 0;

 	report_purpose(8);

	report_assertion("Assertion XDrawRectangle-8.(A)");
	report_assertion("When a graphics operation is performed and the source pixel");
	report_assertion("is src and the destination pixel is dst and function is");
	report_assertion("GXcopy, then the destination becomes (src AND plane_mask)");
	report_assertion("OR (dst AND (NOT plane_mask)).");

	report_strategy("Find a point (f_pix_x, f_pix_y) that is drawn by the graphics operation.");
	report_strategy("");
	report_strategy("Set function component of GC to GXcopy.");
	report_strategy("For destination pixel values dst = 0, 1, 2, 3");
	report_strategy("    For source pixel values of src = 0, 1");
	report_strategy("	Set all points in drawable to destination pixel value.");
	report_strategy("	Set foreground component of GC to source pixel value.");
	report_strategy("	  (or fill source drawable/image with source pixel value in the cases");
	report_strategy("	   of XCopyArea or XPutImage, while XCopyPlane always has it ~0 to");
	report_strategy("	   force a foreground fill).");
	report_strategy("	Do graphics operation.");
	report_strategy("	Verify that pixel value at f_pix_x, f_pix_y is src.");

	tpstartup();
	setargs();
	functest(GXcopy);
	tpcleanup();
	pfcount(pass, fail);
}

static void t009(){

int 	pass = 0, fail = 0;

 	report_purpose(9);

	report_assertion("Assertion XDrawRectangle-9.(A)");
	report_assertion("When a graphics operation is performed and the source pixel");
	report_assertion("is src and the destination pixel is dst and function is");
	report_assertion("GXandInverted, then the destination becomes (((NOT src) AND");
	report_assertion("dst) AND plane_mask) OR (dst AND (NOT plane_mask)).");

	report_strategy("Find a point (f_pix_x, f_pix_y) that is drawn by the graphics operation.");
	report_strategy("");
	report_strategy("Set function component of GC to GXandInverted.");
	report_strategy("For destination pixel values dst = 0, 1, 2, 3");
	report_strategy("    For source pixel values of src = 0, 1");
	report_strategy("	Set all points in drawable to destination pixel value.");
	report_strategy("	Set foreground component of GC to source pixel value.");
	report_strategy("	  (or fill source drawable/image with source pixel value in the cases");
	report_strategy("	   of XCopyArea or XPutImage, while XCopyPlane always has it ~0 to");
	report_strategy("	   force a foreground fill).");
	report_strategy("	Do graphics operation.");
	report_strategy("	Verify that pixel value at f_pix_x, f_pix_y is ~src&dest.");

	tpstartup();
	setargs();
	functest(GXandInverted);
	tpcleanup();
	pfcount(pass, fail);
}

static void t010(){

int 	pass = 0, fail = 0;

 	report_purpose(10);

	report_assertion("Assertion XDrawRectangle-10.(A)");
	report_assertion("When a graphics operation is performed and the source pixel");
	report_assertion("is src and the destination pixel is dst and function is");
	report_assertion("GXnoop, then the destination becomes (dst AND plane_mask)");
	report_assertion("OR (dst AND (NOT plane_mask)).");

	report_strategy("Find a point (f_pix_x, f_pix_y) that is drawn by the graphics operation.");
	report_strategy("");
	report_strategy("Set function component of GC to GXnoop.");
	report_strategy("For destination pixel values dst = 0, 1, 2, 3");
	report_strategy("    For source pixel values of src = 0, 1");
	report_strategy("	Set all points in drawable to destination pixel value.");
	report_strategy("	Set foreground component of GC to source pixel value.");
	report_strategy("	  (or fill source drawable/image with source pixel value in the cases");
	report_strategy("	   of XCopyArea or XPutImage, while XCopyPlane always has it ~0 to");
	report_strategy("	   force a foreground fill).");
	report_strategy("	Do graphics operation.");
	report_strategy("	Verify that pixel value at f_pix_x, f_pix_y is dest.");

	tpstartup();
	setargs();
	functest(GXnoop);
	tpcleanup();
	pfcount(pass, fail);
}

static void t011(){

int 	pass = 0, fail = 0;

 	report_purpose(11);

	report_assertion("Assertion XDrawRectangle-11.(A)");
	report_assertion("When a graphics operation is performed and the source pixel");
	report_assertion("is src and the destination pixel is dst and function is");
	report_assertion("GXxor, then the destination becomes ((src XOR dst) AND");
	report_assertion("plane_mask) OR (dst AND (NOT plane_mask)).");

	report_strategy("Find a point (f_pix_x, f_pix_y) that is drawn by the graphics operation.");
	report_strategy("");
	report_strategy("Set function component of GC to GXxor.");
	report_strategy("For destination pixel values dst = 0, 1, 2, 3");
	report_strategy("    For source pixel values of src = 0, 1");
	report_strategy("	Set all points in drawable to destination pixel value.");
	report_strategy("	Set foreground component of GC to source pixel value.");
	report_strategy("	  (or fill source drawable/image with source pixel value in the cases");
	report_strategy("	   of XCopyArea or XPutImage, while XCopyPlane always has it ~0 to");
	report_strategy("	   force a foreground fill).");
	report_strategy("	Do graphics operation.");
	report_strategy("	Verify that pixel value at f_pix_x, f_pix_y is src^dest.");

	tpstartup();
	setargs();
	functest(GXxor);
	tpcleanup();
	pfcount(pass, fail);
}

static void t012(){

int 	pass = 0, fail = 0;

 	report_purpose(12);

	report_assertion("Assertion XDrawRectangle-12.(A)");
	report_assertion("When a graphics operation is performed and the source pixel");
	report_assertion("is src and the destination pixel is dst and function is GXor,");
	report_assertion("then the destination becomes ((src OR dst) AND plane_mask)");
	report_assertion("OR (dst AND (NOT plane_mask)).");

	report_strategy("Find a point (f_pix_x, f_pix_y) that is drawn by the graphics operation.");
	report_strategy("");
	report_strategy("Set function component of GC to GXor.");
	report_strategy("For destination pixel values dst = 0, 1, 2, 3");
	report_strategy("    For source pixel values of src = 0, 1");
	report_strategy("	Set all points in drawable to destination pixel value.");
	report_strategy("	Set foreground component of GC to source pixel value.");
	report_strategy("	  (or fill source drawable/image with source pixel value in the cases");
	report_strategy("	   of XCopyArea or XPutImage, while XCopyPlane always has it ~0 to");
	report_strategy("	   force a foreground fill).");
	report_strategy("	Do graphics operation.");
	report_strategy("	Verify that pixel value at f_pix_x, f_pix_y is src|dest.");

	tpstartup();
	setargs();
	functest(GXor);
	tpcleanup();
	pfcount(pass, fail);
}

static void t013(){

int 	pass = 0, fail = 0;

 	report_purpose(13);

	report_assertion("Assertion XDrawRectangle-13.(A)");
	report_assertion("When a graphics operation is performed and the source pixel");
	report_assertion("is src and the destination pixel is dst and function is");
	report_assertion("GXnor, then the destination becomes (((NOT src) AND (NOT");
	report_assertion("dst)) AND plane_mask) OR (dst AND (NOT plane_mask)).");

	report_strategy("Find a point (f_pix_x, f_pix_y) that is drawn by the graphics operation.");
	report_strategy("");
	report_strategy("Set function component of GC to GXnor.");
	report_strategy("For destination pixel values dst = 0, 1, 2, 3");
	report_strategy("    For source pixel values of src = 0, 1");
	report_strategy("	Set all points in drawable to destination pixel value.");
	report_strategy("	Set foreground component of GC to source pixel value.");
	report_strategy("	  (or fill source drawable/image with source pixel value in the cases");
	report_strategy("	   of XCopyArea or XPutImage, while XCopyPlane always has it ~0 to");
	report_strategy("	   force a foreground fill).");
	report_strategy("	Do graphics operation.");
	report_strategy("	Verify that pixel value at f_pix_x, f_pix_y is ~src&~dest.");

	tpstartup();
	setargs();
	functest(GXnor);
	tpcleanup();
	pfcount(pass, fail);
}

static void t014(){

int 	pass = 0, fail = 0;

 	report_purpose(14);

	report_assertion("Assertion XDrawRectangle-14.(A)");
	report_assertion("When a graphics operation is performed and the source pixel");
	report_assertion("is src and the destination pixel is dst and function is");
	report_assertion("GXequiv, then the destination becomes (((NOT src) XOR dst)");
	report_assertion("AND plane_mask) OR (dst AND (NOT plane_mask)).");

	report_strategy("Find a point (f_pix_x, f_pix_y) that is drawn by the graphics operation.");
	report_strategy("");
	report_strategy("Set function component of GC to GXequiv.");
	report_strategy("For destination pixel values dst = 0, 1, 2, 3");
	report_strategy("    For source pixel values of src = 0, 1");
	report_strategy("	Set all points in drawable to destination pixel value.");
	report_strategy("	Set foreground component of GC to source pixel value.");
	report_strategy("	  (or fill source drawable/image with source pixel value in the cases");
	report_strategy("	   of XCopyArea or XPutImage, while XCopyPlane always has it ~0 to");
	report_strategy("	   force a foreground fill).");
	report_strategy("	Do graphics operation.");
	report_strategy("	Verify that pixel value at f_pix_x, f_pix_y is ~src^dest.");

	tpstartup();
	setargs();
	functest(GXequiv);
	tpcleanup();
	pfcount(pass, fail);
}

static void t015(){

int 	pass = 0, fail = 0;

 	report_purpose(15);

	report_assertion("Assertion XDrawRectangle-15.(A)");
	report_assertion("When a graphics operation is performed and the source pixel");
	report_assertion("is src and the destination pixel is dst and function is");
	report_assertion("GXinvert, then the destination becomes ((NOT dst) AND");
	report_assertion("plane_mask) OR (dst AND (NOT plane_mask)).");

	report_strategy("Find a point (f_pix_x, f_pix_y) that is drawn by the graphics operation.");
	report_strategy("");
	report_strategy("Set function component of GC to GXinvert.");
	report_strategy("For destination pixel values dst = 0, 1, 2, 3");
	report_strategy("    For source pixel values of src = 0, 1");
	report_strategy("	Set all points in drawable to destination pixel value.");
	report_strategy("	Set foreground component of GC to source pixel value.");
	report_strategy("	  (or fill source drawable/image with source pixel value in the cases");
	report_strategy("	   of XCopyArea or XPutImage, while XCopyPlane always has it ~0 to");
	report_strategy("	   force a foreground fill).");
	report_strategy("	Do graphics operation.");
	report_strategy("	Verify that pixel value at f_pix_x, f_pix_y is ~dest.");

	tpstartup();
	setargs();
	functest(GXinvert);
	tpcleanup();
	pfcount(pass, fail);
}

static void t016(){

int 	pass = 0, fail = 0;

 	report_purpose(16);

	report_assertion("Assertion XDrawRectangle-16.(A)");
	report_assertion("When a graphics operation is performed and the source pixel");
	report_assertion("is src and the destination pixel is dst and function is");
	report_assertion("GXorReverse, then the destination becomes ((src OR (NOT");
	report_assertion("dst)) AND plane_mask) OR (dst AND (NOT plane_mask)).");

	report_strategy("Find a point (f_pix_x, f_pix_y) that is drawn by the graphics operation.");
	report_strategy("");
	report_strategy("Set function component of GC to GXorReverse.");
	report_strategy("For destination pixel values dst = 0, 1, 2, 3");
	report_strategy("    For source pixel values of src = 0, 1");
	report_strategy("	Set all points in drawable to destination pixel value.");
	report_strategy("	Set foreground component of GC to source pixel value.");
	report_strategy("	  (or fill source drawable/image with source pixel value in the cases");
	report_strategy("	   of XCopyArea or XPutImage, while XCopyPlane always has it ~0 to");
	report_strategy("	   force a foreground fill).");
	report_strategy("	Do graphics operation.");
	report_strategy("	Verify that pixel value at f_pix_x, f_pix_y is src|~dest.");

	tpstartup();
	setargs();
	functest(GXorReverse);
	tpcleanup();
	pfcount(pass, fail);
}

static void t017(){

int 	pass = 0, fail = 0;

 	report_purpose(17);

	report_assertion("Assertion XDrawRectangle-17.(A)");
	report_assertion("When a graphics operation is performed and the source pixel");
	report_assertion("is src and the destination pixel is dst and function is");
	report_assertion("GXcopyInverted, then the destination becomes ((NOT src) AND");
	report_assertion("plane_mask) OR (dst AND (NOT plane_mask)).");

	report_strategy("Find a point (f_pix_x, f_pix_y) that is drawn by the graphics operation.");
	report_strategy("");
	report_strategy("Set function component of GC to GXcopyInverted.");
	report_strategy("For destination pixel values dst = 0, 1, 2, 3");
	report_strategy("    For source pixel values of src = 0, 1");
	report_strategy("	Set all points in drawable to destination pixel value.");
	report_strategy("	Set foreground component of GC to source pixel value.");
	report_strategy("	  (or fill source drawable/image with source pixel value in the cases");
	report_strategy("	   of XCopyArea or XPutImage, while XCopyPlane always has it ~0 to");
	report_strategy("	   force a foreground fill).");
	report_strategy("	Do graphics operation.");
	report_strategy("	Verify that pixel value at f_pix_x, f_pix_y is ~src.");

	tpstartup();
	setargs();
	functest(GXcopyInverted);
	tpcleanup();
	pfcount(pass, fail);
}

static void t018(){

int 	pass = 0, fail = 0;

 	report_purpose(18);

	report_assertion("Assertion XDrawRectangle-18.(A)");
	report_assertion("When a graphics operation is performed and the source pixel");
	report_assertion("is src and the destination pixel is dst and function is");
	report_assertion("GXorInverted, then the destination becomes (((NOT src) OR");
	report_assertion("dst) AND plane_mask) OR (dst AND (NOT plane_mask)).");

	report_strategy("Find a point (f_pix_x, f_pix_y) that is drawn by the graphics operation.");
	report_strategy("");
	report_strategy("Set function component of GC to GXorInverted.");
	report_strategy("For destination pixel values dst = 0, 1, 2, 3");
	report_strategy("    For source pixel values of src = 0, 1");
	report_strategy("	Set all points in drawable to destination pixel value.");
	report_strategy("	Set foreground component of GC to source pixel value.");
	report_strategy("	  (or fill source drawable/image with source pixel value in the cases");
	report_strategy("	   of XCopyArea or XPutImage, while XCopyPlane always has it ~0 to");
	report_strategy("	   force a foreground fill).");
	report_strategy("	Do graphics operation.");
	report_strategy("	Verify that pixel value at f_pix_x, f_pix_y is ~src|dest.");

	tpstartup();
	setargs();
	functest(GXorInverted);
	tpcleanup();
	pfcount(pass, fail);
}

static void t019(){

int 	pass = 0, fail = 0;

 	report_purpose(19);

	report_assertion("Assertion XDrawRectangle-19.(A)");
	report_assertion("When a graphics operation is performed and the source pixel");
	report_assertion("is src and the destination pixel is dst and function is");
	report_assertion("GXnand, then the destination becomes (((NOT src) OR (NOT");
	report_assertion("dst)) AND plane_mask) OR (dst AND (NOT plane_mask)).");

	report_strategy("Find a point (f_pix_x, f_pix_y) that is drawn by the graphics operation.");
	report_strategy("");
	report_strategy("Set function component of GC to GXnand.");
	report_strategy("For destination pixel values dst = 0, 1, 2, 3");
	report_strategy("    For source pixel values of src = 0, 1");
	report_strategy("	Set all points in drawable to destination pixel value.");
	report_strategy("	Set foreground component of GC to source pixel value.");
	report_strategy("	  (or fill source drawable/image with source pixel value in the cases");
	report_strategy("	   of XCopyArea or XPutImage, while XCopyPlane always has it ~0 to");
	report_strategy("	   force a foreground fill).");
	report_strategy("	Do graphics operation.");
	report_strategy("	Verify that pixel value at f_pix_x, f_pix_y is ~src|~dest.");

	tpstartup();
	setargs();
	functest(GXnand);
	tpcleanup();
	pfcount(pass, fail);
}

static void t020(){

int 	pass = 0, fail = 0;

 	report_purpose(20);

	report_assertion("Assertion XDrawRectangle-20.(A)");
	report_assertion("When a graphics operation is performed and the source pixel");
	report_assertion("is src and the destination pixel is dst and function is");
	report_assertion("GXset, then the destination becomes ( plane_mask) OR (dst");
	report_assertion("AND (NOT plane_mask)).");

	report_strategy("Find a point (f_pix_x, f_pix_y) that is drawn by the graphics operation.");
	report_strategy("");
	report_strategy("Set function component of GC to GXset.");
	report_strategy("For destination pixel values dst = 0, 1, 2, 3");
	report_strategy("    For source pixel values of src = 0, 1");
	report_strategy("	Set all points in drawable to destination pixel value.");
	report_strategy("	Set foreground component of GC to source pixel value.");
	report_strategy("	  (or fill source drawable/image with source pixel value in the cases");
	report_strategy("	   of XCopyArea or XPutImage, while XCopyPlane always has it ~0 to");
	report_strategy("	   force a foreground fill).");
	report_strategy("	Do graphics operation.");
	report_strategy("	Verify that pixel value at f_pix_x, f_pix_y is ~0.");

	tpstartup();
	setargs();
	functest(GXset);
	tpcleanup();
	pfcount(pass, fail);
}

/* End of included file gc/function.mc */

/* Including from file gc/plane-mas.mc */
static void t021(){

XVisualInfo	*vp;
int 	depthmask;
int 	*ip;
unsigned long	pix;
unsigned long	expected;
int 	pmx = -1, pmy;
int 	ntested;
int 	pass = 0, fail = 0;

 	report_purpose(21);

	report_assertion("Assertion XDrawRectangle-21.(A)");
	report_assertion("The value for plane_mask is truncated to the depth of the");
	report_assertion("GC.");

	report_strategy("Set foreground to pattern of 1's and 0's");
	report_strategy("Set plane-mask to values larger than the depth.");
	report_strategy("Verify that result is what would be expected if the extra bits");
	report_strategy(" were masked off.");

	tpstartup();
	setargs();
	ntested = 0;
	for (resetvinf(VI_WIN_PIX); nextvinf(&vp); ) {
		A_DRAW = makewin(A_DISPLAY, vp);
		A_GC = makegc(A_DISPLAY, A_DRAW);

		if (pmx == -1) {
			/*
			 * Get a point that is set in the drawable.
			 */
			startcall(display);
			if (isdeleted())
				return;
			XDrawRectangle(display, d, gc, x, y, width, height);
			endcall(display);
			if (geterr() != Success) {
				report("Got %s, Expecting Success", errorname(geterr()));
				FAIL;
			}
			setfuncpixel(A_DISPLAY, A_DRAW, &pmx, &pmy);
			dclear(A_DISPLAY, A_DRAW);
		}

		depthmask = DEPTHMASK(vp->depth);

		XSetForeground(A_DISPLAY, A_GC, PLANEFG);

		for (ip = planelist; ip < &planelist[NELEM(planelist)]; ip++) {
			if (*ip <= depthmask)
				continue;

			trace("plane-mask 0x%x", *ip);
			XSetPlaneMask(A_DISPLAY, A_GC, *ip);
			ntested++;

			dclear(A_DISPLAY, A_DRAW);
			startcall(display);
			if (isdeleted())
				return;
			XDrawRectangle(display, d, gc, x, y, width, height);
			endcall(display);
			if (geterr() != Success) {
				report("Got %s, Expecting Success", errorname(geterr()));
				FAIL;
			}

			expected = (*ip & PLANEFG) & depthmask;
			pix = getpixel(A_DISPLAY, A_DRAW, pmx, pmy);

			if (pix == expected)
				CHECK;
			else {
				report("got pixel 0x%x, expecting 0x%x", pix, expected);
				FAIL;
			}
		}

	}

	CHECKPASS(ntested);

	tpcleanup();
	pfcount(pass, fail);
}

static void t022(){

XVisualInfo	*vp;
int 	depthmask;
int 	*ip;
unsigned long	pix;
unsigned long	expected;
int 	pmx = -1, pmy;
int 	ntested = 0;
int 	pass = 0, fail = 0;

 	report_purpose(22);

	report_assertion("Assertion XDrawRectangle-22.(A)");
	report_assertion("The plane_mask specifies which planes of the destination");
	report_assertion("are to be modified, one bit per plane, with bits being");
	report_assertion("assigned to planes from the least significant bit of the");
	report_assertion("word to the most significant bit.");

	report_strategy("Set foreground to pattern of 1's and 0's");
	report_strategy("Select a variety of plane masks.");
	report_strategy("Verify that the expected pixels are drawn.");

	tpstartup();
	setargs();
	for (resetvinf(VI_WIN_PIX); nextvinf(&vp); ) {
		A_DRAW = makewin(A_DISPLAY, vp);
		A_GC = makegc(A_DISPLAY, A_DRAW);

		if (pmx == -1) {
			/*
			 * Get a point that is set in the drawable.
			 */
			startcall(display);
			if (isdeleted())
				return;
			XDrawRectangle(display, d, gc, x, y, width, height);
			endcall(display);
			if (geterr() != Success) {
				report("Got %s, Expecting Success", errorname(geterr()));
				FAIL;
			}
			setfuncpixel(A_DISPLAY, A_DRAW, &pmx, &pmy);
			dclear(A_DISPLAY, A_DRAW);
		}

		depthmask = DEPTHMASK(vp->depth);

		XSetForeground(A_DISPLAY, A_GC, PLANEFG);
		for (ip = planelist; ip < &planelist[NELEM(planelist)]; ip++) {
			if (*ip > depthmask)
				break;

			trace("plane-mask 0x%x", *ip);
			XSetPlaneMask(A_DISPLAY, A_GC, *ip);
			ntested++;

			dclear(A_DISPLAY, A_DRAW);
			startcall(display);
			if (isdeleted())
				return;
			XDrawRectangle(display, d, gc, x, y, width, height);
			endcall(display);
			if (geterr() != Success) {
				report("Got %s, Expecting Success", errorname(geterr()));
				FAIL;
			}

			expected = *ip & PLANEFG;
			pix = getpixel(A_DISPLAY, A_DRAW, pmx, pmy);

			if (pix == expected)
				CHECK;
			else {
				report("got pixel 0x%x, expecting 0x%x", pix, expected);
				FAIL;
			}
		}

	}

	CHECKPASS(ntested);

	tpcleanup();
	pfcount(pass, fail);
}

/* End of included file gc/plane-mas.mc */

/* Including from file gc/line-widt.mc */
static void t023(){

XVisualInfo	*vp;
static	struct	linedata {
	unsigned int 	width;
	int 	x1;
	int 	y1;
	int 	x2;
	int 	y2;
} linedata[] = {
	{1, 15, 10, 50, 30},
	{5, 50, 4, 43, 21},
	{8, 70, 6, 55, 27},
	{2, 13, 13, 15, 24},
	{15, 10, 51, 49, 60},
	};
struct	linedata	*lp;
int 	pass = 0, fail = 0;

 	report_purpose(23);

	report_assertion("Assertion XDrawRectangle-23.(A)");
	report_assertion("When line_width is greater than or equal to one, and the");
	report_assertion("center of a pixel is fully inside the boundary, then the");
	report_assertion("pixel is drawn.");

	report_strategy("Draw a variety of lines with various widths.");
	report_strategy("Pixmap verify.");

	tpstartup();
	setargs();
#define NLINEDATA (sizeof(linedata)/sizeof(linedata[0]))

	for (resetvinf(VI_WIN_PIX); nextvinf(&vp); ) {
		A_DRAWABLE = makewin(A_DISPLAY, vp);
		A_GC = makegc(A_DISPLAY, A_DRAWABLE);

		for (lp = linedata; lp < &linedata[NLINEDATA]; lp++) {

			setwidth(A_DISPLAY, A_GC, lp->width);
			drawline(lp->x1, lp->y1, lp->x2, lp->y2);
		}
		PIXCHECK(A_DISPLAY, A_DRAWABLE);
	}

	CHECKPASS(nvinf());
	tpcleanup();
	pfcount(pass, fail);
}

static void t024(){

int 	pass = 0, fail = 0;

 	report_purpose(24);

	report_assertion("Assertion XDrawRectangle-24.(A)");
	report_assertion("When line_width is greater than or equal to one, and the");
	report_assertion("center of the pixel is exactly on the boundary, and the");
	report_assertion("boundary is not horizontal, and the interior is immediately");
	report_assertion("to its right (x increasing direction), then the pixel is");
	report_assertion("drawn.");

	report_strategy("Draw sloping line.");
	report_strategy("Verify that a pixel on the boundary is set.");
	report_strategy("(More complicated cases are covered by pixel verification elsewhere.)");

	tpstartup();
	setargs();
	report("This test purpose does not apply to %s", TestName);
	report("as %s cannot generate sloping lines", TestName);
	tet_result(TET_NOTINUSE);
	tpcleanup();
	pfcount(pass, fail);
}

static void t025(){

XVisualInfo	*vp;
XImage	*lwimp;
unsigned int 	lwwidth = 8;
int 	begx = 10, begy = 10, len = 60;
int 	i;
int 	pass = 0, fail = 0;

 	report_purpose(25);

	report_assertion("Assertion XDrawRectangle-25.(A)");
	report_assertion("When line_width is greater than or equal to one, and the");
	report_assertion("center of the pixel is exactly on the boundary, and the");
	report_assertion("boundary is horizontal, and the interior or the boundary is");
	report_assertion("immediately below (y increasing direction), and the interior");
	report_assertion("or the boundary is immediately to the right (x increasing");
	report_assertion("direction), then the pixel is drawn.");

	report_strategy("Draw horizontal line.");
	report_strategy("Verify that pixels on boundary with interior below are set.");
	report_strategy("Verify that pixels on boundary with interior above are not set.");
	report_strategy("Verify that pixels on boundary with interior to the right are set.");
	report_strategy("Verify that pixels on boundary with interior to the left are not set.");

	tpstartup();
	setargs();
	for (resetvinf(VI_WIN_PIX); nextvinf(&vp); ) {
		A_DRAWABLE = makewin(A_DISPLAY, vp);
		A_GC = makegc(A_DISPLAY, A_DRAWABLE);

		setwidth(A_DISPLAY, A_GC, lwwidth);

		drawline(begx, begy, begx+len, begy);

		lwimp = savimage(A_DISPLAY, A_DRAWABLE);
		for (i = 0; i < len; i++) {
			if (XGetPixel(lwimp, begx+i, begy-lwwidth/2) == W_FG)
				CHECK;
			else {
				report("Pixel with interior below was not drawn");
				FAIL;
			}
		}
		for (i = 0; i < len; i++) {
			if (XGetPixel(lwimp, begx+i, begy+lwwidth/2) == W_BG)
				CHECK;
			else {
				report("Pixel with interior above was drawn");
				FAIL;
			}
		}

		for (i = 0; i < lwwidth; i++) {
			if (XGetPixel(lwimp, 10, begy-lwwidth/2+i) == W_FG)
				CHECK;
			else {
				report("Pixel with interior to the right was not drawn");
				FAIL;
			}
		}
		for (i = 0; i < lwwidth; i++) {
			if (XGetPixel(lwimp, 70, begy-lwwidth/2+i) == W_BG)
				CHECK;
			else {
				report("Pixel with interior to the left was drawn");
				FAIL;
			}
		}

	}

	CHECKPASS(nvinf()*(2*len+2*lwwidth));
	tpcleanup();
	pfcount(pass, fail);
}

static void t026(){

XVisualInfo	*vp;
struct	area	area;
int 	pass = 0, fail = 0;

 	report_purpose(26);

	report_assertion("Assertion XDrawRectangle-26.(B)");
	report_assertion("When line_width is zero, then a one pixel wide line is");
	report_assertion("drawn using an unspecified, device-dependent algorithm.");
	report_assertion("Reason for omission: The statement in the X11 specification is not specific enough to write a test");

	report_strategy("Draw horizontal zero width line.");
	report_strategy("Issue warning message if line is not one pixel in width.");
	report_strategy("Report assertion UNTESTED.");

	tpstartup();
	setargs();
	for (resetvinf(VI_WIN_PIX); nextvinf(&vp); ) {
		A_DRAWABLE = makewin(A_DISPLAY, vp);
		A_GC = makegc(A_DISPLAY, A_DRAWABLE);

		setwidth(A_DISPLAY, A_GC, (unsigned)0);
		drawline(10, 10, 70, 10);

		setarea(&area, 10, 10, 61, 1);
		if (!checkarea(A_DISPLAY, A_DRAWABLE,
				&area, W_FG, W_BG, CHECK_ALL)) {
			/*
			 * The spec doesn't even require that horizontal lines be drawn
			 * properly.  So we can only warn about suprises.
			 */
			trace("Horizontal thin line was not drawn one pixel in width as expected");
		}
	}

	tet_result(TET_UNTESTED);
	tpcleanup();
	pfcount(pass, fail);
}

static void t027(){

XVisualInfo	*vp;
XImage	*lwim1, *lwim2;
int 	x1, x2, y1, y2;
int 	lwx, lwy;
unsigned int 	lwwidth = 70;
unsigned int 	lwheight = 50;
int 	pass = 0, fail = 0;

 	report_purpose(27);

	report_assertion("Assertion XDrawRectangle-27.(A)");
	report_assertion("When line_width is zero, and a line is drawn unclipped from");
	report_assertion("[x1, y1] to [x2, y2] and another line is drawn unclipped");
	report_assertion("from [x1+dx, y1+dy] to [x2+dx, y2+dy], and a point [x, y] is");
	report_assertion("touched by drawing the first line, then point [x+dx, y+dy]");
	report_assertion("is touched by drawing the second line.");

	report_strategy("Draw thin line.");
	report_strategy("Save image with origin based on line position.");
	report_strategy("Draw thin line displaced by fixed amount.");
	report_strategy("Save image with origin in same position relative to line.");
	report_strategy("Compare images.");

	tpstartup();
	setargs();
	for (resetvinf(VI_WIN_PIX); nextvinf(&vp); ) {
		A_DRAWABLE = makewin(A_DISPLAY, vp);
		A_GC = makegc(A_DISPLAY, A_DRAWABLE);

		x1 = 10; y1 = 10;
		x2 = 63; y2 = 43;

		setwidth(A_DISPLAY, A_GC, (unsigned)0);

		drawline(x1, y1, x2, y2);
		lwim1 = XGetImage(A_DISPLAY, A_DRAWABLE, x1, y1, lwwidth, lwheight, AllPlanes, ZPixmap);

		if (isdeleted())
			return;

		x1 += 12;
		x2 += 12;

		y1 += 17;
		y2 += 17;

		dclear(A_DISPLAY, A_DRAWABLE);
		drawline(x1, y1, x2, y2);
		lwim2 = XGetImage(A_DISPLAY, A_DRAWABLE, x1, y1, lwwidth, lwheight, AllPlanes, ZPixmap);

		if (isdeleted())
			return;

		for (lwy = 0; lwy < lwheight; lwy++) {
			for (lwx = 0; lwx < lwwidth; lwx++) {
				if (XGetPixel(lwim1, lwx, lwy) != XGetPixel(lwim2, lwx, lwy)) {
					report("Thin line differed after displacement");
					report("Point is %d,%d", lwx, lwy);
					FAIL;

					lwy = lwheight;
					break;
				}
			}
		}
		CHECK;
	}

	CHECKPASS(nvinf());

	tpcleanup();
	pfcount(pass, fail);
}

static void t028(){


 	report_purpose(28);

	report_assertion("Assertion XDrawRectangle-28.(-)");
	report_assertion("When line_width is zero, and a line is drawn unclipped from");
	report_assertion("[x1, y1] to [x2, y2] and another line is drawn unclipped");
	report_assertion("from [x1+dx, y1+dy] to [x2+dx, y2+dy], and a point [x, y] is");
	report_assertion("not touched by drawing the first line, then point [x+dx,");
	report_assertion("y+dy] is not touched by drawing the second line.");
	report_assertion("The assertion is descriptive or is tested elsewhere.");
	tet_result(TET_NOTINUSE);
}

static void t029(){


 	report_purpose(29);

	report_assertion("Assertion XDrawRectangle-29.(-)");
	report_assertion("When a line is clipped, and the point is inside the");
	report_assertion("clipping region, and the point would be touched by the");
	report_assertion("unclipped line, then the pixel is drawn.");
	report_assertion("The assertion is descriptive or is tested elsewhere.");
	tet_result(TET_NOTINUSE);
}

/* End of included file gc/line-widt.mc */

/* Including from file gc/line-styl.mc */
static void t030(){


 	report_purpose(30);

	report_assertion("Assertion XDrawRectangle-30.(-)");
	report_assertion("When the line_style is LineSolid, then the full path of");
	report_assertion("the line is drawn.");
	report_assertion("The assertion is descriptive or is tested elsewhere.");
	tet_result(TET_NOTINUSE);
}

static void t031(){

XVisualInfo	*vp;
int 	i;
int 	caps;
unsigned int	lw;
int 	pass = 0, fail = 0;

 	report_purpose(31);

	report_assertion("Assertion XDrawRectangle-31.(A)");
	report_assertion("When the line_style is LineOnOffDash, then cap_style");
	report_assertion("applies to all internal ends of the individual dashes,");
	report_assertion("except CapNotLast is treated as CapButt.");

	report_strategy("Set graphics coordinates for dashed lines ");
	report_strategy("	(includes horizontal and vertical cases,");
	report_strategy("	and includes joins and caps where relevant).");
	report_strategy("Set the line_style of the GC to LineOnOffDash using XChangeGC.");
	report_strategy("Set the dash_list of the GC to using XSetDashes.");
	report_strategy("For cap_style CapNotLast, CapButt, CapProjecting, CapRound:");
	report_strategy("	Set the cap_style of the GC using XChangeGC.");
	report_strategy("	Draw paths.");
	report_strategy("	Pixmap verify.");
	report_strategy("	Clear drawable.");

	tpstartup();
	setargs();
	for (resetvinf(VI_WIN_PIX); nextvinf(&vp); ) {
		A_DRAWABLE = makewin(A_DISPLAY, vp);
		A_GC = makegc(A_DISPLAY, A_DRAWABLE);

		setfordash();
		for(lw=4; lw <= 5; lw++) { /* odd and even line widths */
			setwidth(A_DISPLAY, A_GC, lw);
			XSetDashes(A_DISPLAY, A_GC, 0, lsdashes, 2);
			setlinestyle(A_DISPLAY, A_GC, LineOnOffDash);

			for (i = 0; i < NELEM(capstyles); i++) {

				caps = capstyles[i];
				trace("LineOnOffDash with %s width %u", capstylename(caps), lw);
				setcapstyle(A_DISPLAY, A_GC, caps);
				startcall(display);
				if (isdeleted())
					return;
				XDrawRectangle(display, d, gc, x, y, width, height);
				endcall(display);
				if (geterr() != Success) {
					report("Got %s, Expecting Success", errorname(geterr()));
					FAIL;
				}
				PIXCHECKLITE(A_DISPLAY, A_DRAWABLE, 51);
				dclear(A_DISPLAY, A_DRAWABLE);
			}
			dclear(A_DISPLAY, A_DRAWABLE);
		}
	}

	CHECKPASS(2*NELEM(capstyles)*nvinf());
	tpcleanup();
	pfcount(pass, fail);
}

static void t032(){


 	report_purpose(32);

	report_assertion("Assertion XDrawRectangle-32.(-)");
	report_assertion("When line_style is LineSolid and fill_style is FillSolid,");
	report_assertion("then on a call to XDrawRectangle the source pixel for the");
	report_assertion("drawing operation is foreground.");
	report_assertion("The assertion is descriptive or is tested elsewhere.");
	tet_result(TET_NOTINUSE);
}

static void t033(){


 	report_purpose(33);

	report_assertion("Assertion XDrawRectangle-33.(-)");
	report_assertion("When line_style is LineSolid and fill_style is FillTiled,");
	report_assertion("then on a call to XDrawRectangle the source for the drawing");
	report_assertion("operation is tile.");
	report_assertion("The assertion is descriptive or is tested elsewhere.");
	tet_result(TET_NOTINUSE);
}

static void t034(){


 	report_purpose(34);

	report_assertion("Assertion XDrawRectangle-34.(-)");
	report_assertion("When line_style is LineSolid and fill_style is");
	report_assertion("FillOpaqueStippled, then on a call to XDrawRectangle the");
	report_assertion("source for the drawing operation is a tile with the same");
	report_assertion("width and height as stipple, but with background everywhere");
	report_assertion("stipple has a zero and with foreground everywhere stipple");
	report_assertion("has a one.");
	report_assertion("The assertion is descriptive or is tested elsewhere.");
	tet_result(TET_NOTINUSE);
}

static void t035(){


 	report_purpose(35);

	report_assertion("Assertion XDrawRectangle-35.(-)");
	report_assertion("When line_style is LineSolid and fill_style is FillStippled,");
	report_assertion("then on a call to XDrawRectangle the source for the drawing");
	report_assertion("operation is foreground masked by the stipple pattern tiled");
	report_assertion("in a single plane.");
	report_assertion("The assertion is descriptive or is tested elsewhere.");
	tet_result(TET_NOTINUSE);
}

static void t036(){


 	report_purpose(36);

	report_assertion("Assertion XDrawRectangle-36.(-)");
	report_assertion("When line_style is LineOnOffDash and the dash is odd, then");
	report_assertion("nothing is drawn.");
	report_assertion("The assertion is descriptive or is tested elsewhere.");
	tet_result(TET_NOTINUSE);
}

static void t037(){


 	report_purpose(37);

	report_assertion("Assertion XDrawRectangle-37.(-)");
	report_assertion("When line_style is LineOnOffDash and the dash is even and");
	report_assertion("fill_style is FillSolid, then on a call to XDrawRectangle");
	report_assertion("the source pixel for the drawing operation is foreground.");
	report_assertion("The assertion is descriptive or is tested elsewhere.");
	tet_result(TET_NOTINUSE);
}

static void t038(){

XVisualInfo	*vp;
Pixmap	fstile;
unsigned long	fsfg, fsbg;
unsigned int	lw;
int 	pass = 0, fail = 0;

 	report_purpose(38);

	report_assertion("Assertion XDrawRectangle-38.(A)");
	report_assertion("When line_style is LineOnOffDash and the dash is even and");
	report_assertion("fill_style is FillTiled, then on a call to XDrawRectangle");
	report_assertion("the source for the drawing operation is tile.");

	report_strategy("Create a tile with depth of drawable.");
	report_strategy("Set graphics coordinates for dashed lines ");
	report_strategy("	(includes horizontal and vertical cases,");
	report_strategy("	and includes joins and caps where relevant).");
	report_strategy("If depth is greater than one, set the fg and bg in the tile");
	report_strategy("	to interesting values.");
	report_strategy("Set the tile component of the GC to tile using XSetTile.");
	report_strategy("Set fill-style to FillTiled using XSetFillStyle.");
	report_strategy("Set line-style to LineOnOffDash using XChangeGC.");
	report_strategy("Do graphics operation.");
	report_strategy("Pixmap verify.");

	tpstartup();
	setargs();
	for (resetvinf(VI_WIN_PIX); nextvinf(&vp); ) {
		A_DRAWABLE = makewin(A_DISPLAY, vp);
		A_GC = makegc(A_DISPLAY, A_DRAWABLE);

		setfordash();

		/* 1 */
		fsfg = W_FG;
		fsbg = W_BG;
		if (vp->depth > 1) {
			fsfg ^= 0x2;
			fsbg ^= 0x2;
		}
		fstile = XCreatePixmapFromBitmapData(A_DISPLAY, A_DRAWABLE
			, (char*)tile_bits, tile_width, tile_height
			, fsfg, fsbg
			, vp->depth
			);
		XSetTile(A_DISPLAY, A_GC, fstile);

		XSetFillStyle(A_DISPLAY, A_GC, FillTiled);
		setlinestyle(A_DISPLAY, A_GC, LineOnOffDash);

		for(lw=5; lw <= 6; lw++) { /* odd and even widths */
			setwidth(A_DISPLAY, A_GC, lw);

			startcall(display);
			if (isdeleted())
				return;
			XDrawRectangle(display, d, gc, x, y, width, height);
			endcall(display);
			if (geterr() != Success) {
				report("Got %s, Expecting Success", errorname(geterr()));
				FAIL;
			}

			PIXCHECKLITE(A_DISPLAY, A_DRAWABLE, 20);

			dclear(A_DISPLAY, A_DRAWABLE);
		}
		XFreePixmap(A_DISPLAY, fstile);
	}

	CHECKPASS(2*nvinf());

	tpcleanup();
	pfcount(pass, fail);
}

static void t039(){

XVisualInfo	*vp;
Pixmap	fsstip;
unsigned int	lw;
int 	pass = 0, fail = 0;

 	report_purpose(39);

	report_assertion("Assertion XDrawRectangle-39.(A)");
	report_assertion("When line_style is LineOnOffDash and the dash is even and");
	report_assertion("fill_style is FillOpaqueStippled, then on a call to");
	report_assertion("XDrawRectangle the source for the drawing operation is a");
	report_assertion("tile with the same width and height as stipple, but with");
	report_assertion("background everywhere stipple has a zero and with foreground");
	report_assertion("everywhere stipple has a one.");

	report_strategy("Create a stipple bitmap.");
	report_strategy("Set graphics coordinates for dashed lines ");
	report_strategy("	(includes horizontal and vertical cases,");
	report_strategy("	and includes joins and caps where relevant).");
	report_strategy("Set the stipple component of the GC to stipple using XSetStipple.");
	report_strategy("Set fill-style to FillOpaqueStippled using XSetFillStyle.");
	report_strategy("Set line-style to LineOnOffDash using XChangeGC.");
	report_strategy("Do graphics operation.");
	report_strategy("Pixmap verify.");

	tpstartup();
	setargs();
	for (resetvinf(VI_WIN_PIX); nextvinf(&vp); ) {
		A_DRAWABLE = makewin(A_DISPLAY, vp);
		A_GC = makegc(A_DISPLAY, A_DRAWABLE);

		setfordash();

		fsstip = XCreateBitmapFromData(A_DISPLAY, A_DRAWABLE
			, (char*)stipple_bits, stipple_width, stipple_height
			);
		XSetStipple(A_DISPLAY, A_GC, fsstip);

		XSetFillStyle(A_DISPLAY, A_GC, FillOpaqueStippled);
		setlinestyle(A_DISPLAY, A_GC, LineOnOffDash);
		for(lw=5; lw <= 6; lw++) { /* odd and even widths */
			setwidth(A_DISPLAY, A_GC, lw);

			startcall(display);
			if (isdeleted())
				return;
			XDrawRectangle(display, d, gc, x, y, width, height);
			endcall(display);
			if (geterr() != Success) {
				report("Got %s, Expecting Success", errorname(geterr()));
				FAIL;
			}

			PIXCHECKLITE(A_DISPLAY, A_DRAWABLE, 10);

			dclear(A_DISPLAY, A_DRAWABLE);
		}
		XFreePixmap(A_DISPLAY, fsstip);
	}

	CHECKPASS(2*nvinf());

	tpcleanup();
	pfcount(pass, fail);
}

static void t040(){

XVisualInfo	*vp;
Pixmap	fsstip;
unsigned int	lw;
int 	pass = 0, fail = 0;

 	report_purpose(40);

	report_assertion("Assertion XDrawRectangle-40.(A)");
	report_assertion("When line_style is LineOnOffDash and the dash is even and");
	report_assertion("fill_style is FillStippled, then on a call to");
	report_assertion("XDrawRectangle the source for the drawing operation is");
	report_assertion("foreground masked by the stipple pattern tiled in a single");
	report_assertion("plane.");

	report_strategy("Create a stipple bitmap.");
	report_strategy("Set graphics coordinates for dashed lines ");
	report_strategy("	(includes horizontal and vertical cases,");
	report_strategy("	and includes joins and caps where relevant).");
	report_strategy("Set the stipple component of the GC to stipple using XSetStipple.");
	report_strategy("Set fill-style to FillStippled using XSetFillStyle.");
	report_strategy("Set line-style to LineOnOffDash using XChangeGC.");
	report_strategy("Do graphics operation.");
	report_strategy("Pixmap verify.");

	tpstartup();
	setargs();
	for (resetvinf(VI_WIN_PIX); nextvinf(&vp); ) {
		A_DRAWABLE = makewin(A_DISPLAY, vp);
		A_GC = makegc(A_DISPLAY, A_DRAWABLE);

		setfordash();

		fsstip = XCreateBitmapFromData(A_DISPLAY, A_DRAWABLE
			, (char*)stipple_bits, stipple_width, stipple_height
			);
		XSetStipple(A_DISPLAY, A_GC, fsstip);

		XSetFillStyle(A_DISPLAY, A_GC, FillStippled);
		setlinestyle(A_DISPLAY, A_GC, LineOnOffDash);
		for(lw=5; lw <= 6; lw++) { /* odd and even widths */
			setwidth(A_DISPLAY, A_GC, lw);

			startcall(display);
			if (isdeleted())
				return;
			XDrawRectangle(display, d, gc, x, y, width, height);
			endcall(display);
			if (geterr() != Success) {
				report("Got %s, Expecting Success", errorname(geterr()));
				FAIL;
			}

			PIXCHECKLITE(A_DISPLAY, A_DRAWABLE, 10);

			dclear(A_DISPLAY, A_DRAWABLE);
		}
		XFreePixmap(A_DISPLAY, fsstip);
	}

	CHECKPASS(2*nvinf());

	tpcleanup();
	pfcount(pass, fail);
}

static void t041(){

XVisualInfo	*vp;
XImage	*lsimp;
unsigned int 	lw;
int 	pass = 0, fail = 0;

 	report_purpose(41);

	report_assertion("Assertion XDrawRectangle-41.(A)");
	report_assertion("When line_style is LineDoubleDash and the dash is even and");
	report_assertion("fill_style is FillSolid, then on a call to XDrawRectangle");
	report_assertion("the source pixel for the drawing operation is foreground.");

	report_strategy("Draw complete path with line-style LineSolid and save results.");
	report_strategy("Clear drawable.");
	report_strategy("Draw same path with line-style LineDoubleDash");
	report_strategy("Reverse foreground and background.");
	report_strategy("Set gc function to GXor.");
	report_strategy("Draw same path again over previous drawing.");
	report_strategy("Check that the combined result is equivalent to using FillSolid.");

	tpstartup();
	setargs();
	for (resetvinf(VI_WIN_PIX); nextvinf(&vp); ) {
		A_DRAWABLE = makewin(A_DISPLAY, vp);
		A_GC = makegc(A_DISPLAY, A_DRAWABLE);

		for(lw=4; lw <= 5; lw++) { /* odd and even widths */
			/*
			 * By reversing the foreground and background pixels we should be
			 * able to fill in the whole line. First save the whole line.
			 */
			trace("Draw with LineSolid, width %u, and save result", lw);
			XSetLineAttributes(A_DISPLAY, A_GC, lw, LineSolid, CapButt, JoinMiter);
			XSetForeground(A_DISPLAY, A_GC, W_FG|W_BG);	/* Draw with OR of fg&bg */
			startcall(display);
			if (isdeleted())
				return;
			XDrawRectangle(display, d, gc, x, y, width, height);
			endcall(display);
			if (geterr() != Success) {
				report("Got %s, Expecting Success", errorname(geterr()));
				FAIL;
			}
			XSetForeground(A_DISPLAY, A_GC, W_FG);

			lsimp = savimage(A_DISPLAY, A_DRAWABLE);
			dclear(A_DISPLAY, A_DRAWABLE);

			/* Now call with DoubleDash */
			XSetDashes(A_DISPLAY, A_GC, 0, lsdashes, 2);
			XSetLineAttributes(A_DISPLAY, A_GC, lw, LineDoubleDash, CapButt, JoinMiter);
			startcall(display);
			if (isdeleted())
				return;
			XDrawRectangle(display, d, gc, x, y, width, height);
			endcall(display);
			if (geterr() != Success) {
				report("Got %s, Expecting Success", errorname(geterr()));
				FAIL;
			}

			/* Reverse fg&bg and or in line */
			XSetFunction(A_DISPLAY, A_GC, GXor);
			XSetForeground(A_DISPLAY, A_GC, W_BG);
			XSetBackground(A_DISPLAY, A_GC, W_FG);
			startcall(display);
			if (isdeleted())
				return;
			XDrawRectangle(display, d, gc, x, y, width, height);
			endcall(display);
			if (geterr() != Success) {
				report("Got %s, Expecting Success", errorname(geterr()));
				FAIL;
			}
			XSetForeground(A_DISPLAY, A_GC, W_FG);
			XSetBackground(A_DISPLAY, A_GC, W_BG);

			trace("compare to result of drawing lines with LineDoubleDash");
			if (compsavimage(A_DISPLAY, A_DRAWABLE, lsimp))
				CHECK;
			else {
				report("Reversing fg and bg did not complete line correctly");
				FAIL;
			}
			/* assume we're not allowed to draw nothing, complain if so */
			if (!checkarea(A_DISPLAY, A_DRAWABLE,
				(struct area *)0, W_BG, W_BG, CHECK_IN | CHECK_DIFFER))
				CHECK;
			else {
				report("%s didn't draw anything when ORing together even and odd dashes", TestName);
				FAIL;
			}
			dclear(A_DISPLAY, A_DRAWABLE);
		}

	}

	/*
	 * Now do direct checking on vertical or horizontal lines
	 */
	for (resetvinf(VI_WIN_PIX); nextvinf(&vp); ) {
		A_DRAWABLE = makewin(A_DISPLAY, vp);
		A_GC = makegc(A_DISPLAY, A_DRAWABLE);

		setfordash();
		XSetDashes(A_DISPLAY, A_GC, 0, lsdashes, 2);

		for(lw=4; lw <=5; lw++) { /* odd/even widths */
			trace("Direct check of LineDoubleDash on vertical/horizontal lines width %u", lw);
			XSetLineAttributes(A_DISPLAY, A_GC,
				lw, LineDoubleDash, CapButt, JoinMiter);
			startcall(display);
			if (isdeleted())
				return;
			XDrawRectangle(display, d, gc, x, y, width, height);
			endcall(display);
			if (geterr() != Success) {
				report("Got %s, Expecting Success", errorname(geterr()));
				FAIL;
			}
			PIXCHECKLITE(A_DISPLAY, A_DRAWABLE, 21);
			dclear(A_DISPLAY, A_DRAWABLE);
		}
	}

	CHECKPASS(6*nvinf());

	tpcleanup();
	pfcount(pass, fail);
}

static void t042(){

XVisualInfo	*vp;
Pixmap	fstile;
unsigned long	fsfg, fsbg;
unsigned int	lw;
int 	pass = 0, fail = 0;

 	report_purpose(42);

	report_assertion("Assertion XDrawRectangle-42.(A)");
	report_assertion("When line_style is LineDoubleDash and the dash is even and");
	report_assertion("fill_style is FillTiled, then on a call to XDrawRectangle");
	report_assertion("the source for the drawing operation is tile.");

	report_strategy("Create a tile with depth of drawable.");
	report_strategy("Set graphics coordinates for dashed lines ");
	report_strategy("	(includes horizontal and vertical cases,");
	report_strategy("	and includes joins and caps where relevant).");
	report_strategy("If depth is greater than one, set the fg and bg in the tile");
	report_strategy("	to interesting values.");
	report_strategy("Set the stipple component of the GC to stipple using XSetStipple.");
	report_strategy("Set the tile component of the GC to tile using XSetTile.");
	report_strategy("Set fill-style to FillTiled using XSetFillStyle.");
	report_strategy("Set line-style to LineDoubleDash using XChangeGC.");
	report_strategy("Do graphics operation.");
	report_strategy("Pixmap verify.");

	tpstartup();
	setargs();
	for (resetvinf(VI_WIN_PIX); nextvinf(&vp); ) {
		A_DRAWABLE = makewin(A_DISPLAY, vp);
		A_GC = makegc(A_DISPLAY, A_DRAWABLE);

		setfordash();

		/* 1 */
		fsfg = W_FG;
		fsbg = W_BG;
		if (vp->depth > 1) {
			fsfg ^= 0x2;
			fsbg ^= 0x2;
		}
		fstile = XCreatePixmapFromBitmapData(A_DISPLAY, A_DRAWABLE
			, (char*)tile_bits, tile_width, tile_height
			, fsfg, fsbg
			, vp->depth
			);
		XSetTile(A_DISPLAY, A_GC, fstile);

		XSetFillStyle(A_DISPLAY, A_GC, FillTiled);
		setlinestyle(A_DISPLAY, A_GC, LineDoubleDash);
		for(lw=4; lw <= 5; lw++) { /* odd and even widths */
			setwidth(A_DISPLAY, A_GC, lw);

			startcall(display);
			if (isdeleted())
				return;
			XDrawRectangle(display, d, gc, x, y, width, height);
			endcall(display);
			if (geterr() != Success) {
				report("Got %s, Expecting Success", errorname(geterr()));
				FAIL;
			}

			PIXCHECKLITE(A_DISPLAY, A_DRAWABLE, 10);
			dclear(A_DISPLAY, A_DRAWABLE);
		}
		XFreePixmap(A_DISPLAY, fstile);
	}

	CHECKPASS(2*nvinf());

	tpcleanup();
	pfcount(pass, fail);
}

static void t043(){

XVisualInfo	*vp;
Pixmap	fsstip;
unsigned int	lw;
int 	pass = 0, fail = 0;

 	report_purpose(43);

	report_assertion("Assertion XDrawRectangle-43.(A)");
	report_assertion("When line_style is LineDoubleDash and the dash is even and");
	report_assertion("fill_style is FillOpaqueStippled, then on a call to");
	report_assertion("XDrawRectangle the source for the drawing operation is a");
	report_assertion("tile with the same width and height as stipple, but with");
	report_assertion("background everywhere stipple has a zero and with foreground");
	report_assertion("everywhere stipple has a one.");

	report_strategy("Create a stipple bitmap.");
	report_strategy("Set graphics coordinates for dashed lines ");
	report_strategy("	(includes horizontal and vertical cases,");
	report_strategy("	and includes joins and caps where relevant).");
	report_strategy("Set the stipple component of the GC to stipple using XSetStipple.");
	report_strategy("Set fill-style to FillOpaqueStippled using XSetFillStyle.");
	report_strategy("Set line-style to LineDoubleDash using XChangeGC.");
	report_strategy("Do graphics operation.");
	report_strategy("Pixmap verify.");

	tpstartup();
	setargs();
	for (resetvinf(VI_WIN_PIX); nextvinf(&vp); ) {
		A_DRAWABLE = makewin(A_DISPLAY, vp);
		A_GC = makegc(A_DISPLAY, A_DRAWABLE);

		setfordash();

		fsstip = XCreateBitmapFromData(A_DISPLAY, A_DRAWABLE
			, (char*)stipple_bits, stipple_width, stipple_height
			);
		XSetStipple(A_DISPLAY, A_GC, fsstip);

		XSetFillStyle(A_DISPLAY, A_GC, FillOpaqueStippled);
		setlinestyle(A_DISPLAY, A_GC, LineDoubleDash);
		for(lw=4; lw <= 5; lw++) { /* odd and even widths */
			setwidth(A_DISPLAY, A_GC, lw);

			startcall(display);
			if (isdeleted())
				return;
			XDrawRectangle(display, d, gc, x, y, width, height);
			endcall(display);
			if (geterr() != Success) {
				report("Got %s, Expecting Success", errorname(geterr()));
				FAIL;
			}

			PIXCHECKLITE(A_DISPLAY, A_DRAWABLE, 10);
			dclear(A_DISPLAY, A_DRAWABLE);
		}
		XFreePixmap(A_DISPLAY, fsstip);
	}

	CHECKPASS(2*nvinf());

	tpcleanup();
	pfcount(pass, fail);
}

static void t044(){

XVisualInfo	*vp;
Pixmap	fsstip;
unsigned int	lw;
int 	pass = 0, fail = 0;

 	report_purpose(44);

	report_assertion("Assertion XDrawRectangle-44.(A)");
	report_assertion("When line_style is LineDoubleDash and the dash is even and");
	report_assertion("fill_style is FillStippled, then on a call to");
	report_assertion("XDrawRectangle the source for the drawing operation is");
	report_assertion("foreground masked by the stipple pattern tiled in a single");
	report_assertion("plane.");

	report_strategy("Create a stipple bitmap.");
	report_strategy("Set graphics coordinates for dashed lines ");
	report_strategy("	(includes horizontal and vertical cases,");
	report_strategy("	and includes joins and caps where relevant).");
	report_strategy("Set the stipple component of the GC to stipple using XSetStipple.");
	report_strategy("Set fill-style to FillStippled using XSetFillStyle.");
	report_strategy("Set line-style to LineDoubleDash using XChangeGC.");
	report_strategy("Do graphics operation.");
	report_strategy("Pixmap verify.");

	tpstartup();
	setargs();
	for (resetvinf(VI_WIN_PIX); nextvinf(&vp); ) {
		A_DRAWABLE = makewin(A_DISPLAY, vp);
		A_GC = makegc(A_DISPLAY, A_DRAWABLE);

		setfordash();
		XSetDashes(A_DISPLAY, A_GC, 0, lsdashes, 2);

		fsstip = XCreateBitmapFromData(A_DISPLAY, A_DRAWABLE
			, (char*)stipple_bits, stipple_width, stipple_height
			);
		XSetStipple(A_DISPLAY, A_GC, fsstip);

		XSetFillStyle(A_DISPLAY, A_GC, FillStippled);
		setlinestyle(A_DISPLAY, A_GC, LineDoubleDash);
		for(lw=4; lw <= 5; lw++) { /* odd and even widths */
			setwidth(A_DISPLAY, A_GC, lw);

			startcall(display);
			if (isdeleted())
				return;
			XDrawRectangle(display, d, gc, x, y, width, height);
			endcall(display);
			if (geterr() != Success) {
				report("Got %s, Expecting Success", errorname(geterr()));
				FAIL;
			}

			PIXCHECKLITE(A_DISPLAY, A_DRAWABLE, 15);
			dclear(A_DISPLAY, A_DRAWABLE);
		}
		XFreePixmap(A_DISPLAY, fsstip);
	}

	CHECKPASS(2*nvinf());

	tpcleanup();
	pfcount(pass, fail);
}

static void t045(){


 	report_purpose(45);

	report_assertion("Assertion XDrawRectangle-45.(-)");
	report_assertion("When line-style is LineDoubleDash and the dash is odd and");
	report_assertion("fill_style is FillSolid, then on a call to XDrawRectangle");
	report_assertion("the source for the drawing operation is background.");
	report_assertion("The assertion is descriptive or is tested elsewhere.");
	tet_result(TET_NOTINUSE);
}

static void t046(){


 	report_purpose(46);

	report_assertion("Assertion XDrawRectangle-46.(-)");
	report_assertion("When line-style is LineDoubleDash and the dash is odd and");
	report_assertion("fill_style is FillTiled, then on a call to XDrawRectangle");
	report_assertion("the source for the drawing operation is tile.");
	report_assertion("The assertion is descriptive or is tested elsewhere.");
	tet_result(TET_NOTINUSE);
}

static void t047(){


 	report_purpose(47);

	report_assertion("Assertion XDrawRectangle-47.(-)");
	report_assertion("When line-style is LineDoubleDash and the dash is odd and");
	report_assertion("fill_style is FillOpaqueStippled, then on a call to");
	report_assertion("XDrawRectangle the source for the drawing operation is a");
	report_assertion("tile with the same width and height as stipple, but with");
	report_assertion("background everywhere stipple has a zero and with foreground");
	report_assertion("everywhere stipple has a one.");
	report_assertion("The assertion is descriptive or is tested elsewhere.");
	tet_result(TET_NOTINUSE);
}

static void t048(){


 	report_purpose(48);

	report_assertion("Assertion XDrawRectangle-48.(-)");
	report_assertion("When line-style is LineDoubleDash and the dash is odd and");
	report_assertion("fill_style is FillStippled, then on a call to");
	report_assertion("XDrawRectangle the source for the drawing operation is");
	report_assertion("background masked by the stipple pattern tiled in a single");
	report_assertion("plane.");
	report_assertion("The assertion is descriptive or is tested elsewhere.");
	tet_result(TET_NOTINUSE);
}

static void t049(){

XVisualInfo	*vp;
XImage	*lsimp;
int 	i;
int 	ls;
unsigned int 	lw;
int 	pass = 0, fail = 0;

 	report_purpose(49);

	report_assertion("Assertion XDrawRectangle-49.(A)");
	report_assertion("A call to XDrawRectangle does not draw each pixel of a");
	report_assertion("particular line more than once.");

	report_strategy("For each line-style");
	report_strategy("  Draw line with gc function GXcopy.");
	report_strategy("  Save image.");
	report_strategy("  Clear drawable.");
	report_strategy("  Draw line with gc function GXxor");
	report_strategy("  Verify that the image is the same as that saved.");

	tpstartup();
	setargs();
	for (resetvinf(VI_WIN_PIX); nextvinf(&vp); ) {
		A_DRAWABLE = makewin(A_DISPLAY, vp);
		A_GC = makegc(A_DISPLAY, A_DRAWABLE);

		setfordash();
		XSetDashes(A_DISPLAY, A_GC, 0, lsdashes, 2);

		for(lw=4; lw <= 5; lw++) { /* odd and even widths */
			setwidth(A_DISPLAY, A_GC, lw);

			for (i = 0; i < NELEM(linestyles); i++) {
				XSetFunction(A_DISPLAY, A_GC, GXcopy);

				ls = linestyles[i];

				trace("Drawing line style %s width %u", linestylename(ls), lw);
				setlinestyle(A_DISPLAY, A_GC, ls);
				startcall(display);
				if (isdeleted())
					return;
				XDrawRectangle(display, d, gc, x, y, width, height);
				endcall(display);
				if (geterr() != Success) {
					report("Got %s, Expecting Success", errorname(geterr()));
					FAIL;
				}
				lsimp = savimage(A_DISPLAY, A_DRAWABLE);
				dclear(A_DISPLAY, A_DRAWABLE);

				XSetFunction(A_DISPLAY, A_GC, GXxor);
				startcall(display);
				if (isdeleted())
					return;
				XDrawRectangle(display, d, gc, x, y, width, height);
				endcall(display);
				if (geterr() != Success) {
					report("Got %s, Expecting Success", errorname(geterr()));
					FAIL;
				}
				if (compsavimage(A_DISPLAY, A_DRAWABLE, lsimp))
					CHECK;
				else {
					report("Pixels drawn more than once for %s", linestylename(ls));
					FAIL;
				}
				/* assume we're not allowed to draw nothing, complain if so */
				if (!checkarea(A_DISPLAY, A_DRAWABLE,
					(struct area *)0, W_BG, W_BG, CHECK_IN | CHECK_DIFFER))
					CHECK;
				else {
					report("%s didn't draw anything in Xor mode", TestName);
					FAIL;
				}
				dclear(A_DISPLAY, A_DRAWABLE);
			}
			dclear(A_DISPLAY, A_DRAWABLE);
		}
	}

	CHECKPASS(4*NELEM(linestyles)*nvinf());
	tpcleanup();
	pfcount(pass, fail);
}

/* End of included file gc/line-styl.mc */

/* Including from file gc/join-styl.mc */
static void t050(){

XVisualInfo	*vp;
int 	ndrawn;
int 	pass = 0, fail = 0;

 	report_purpose(50);

	report_assertion("Assertion XDrawRectangle-50.(A)");
	report_assertion("When the join_style is JoinMiter and the angle at which the");
	report_assertion("lines join is more than or equal to 11 degrees, then the");
	report_assertion("outer edges of two lines extend to meet at an angle.");

	report_strategy("Set GC component join_style to JoinMitre.");
	report_strategy("Set GC component line_width to 7.");
	report_strategy("Do graphics operation (with line joins all at angles >= 11 degrees). ");
	report_strategy("Pixmap verify.");
	report_strategy("For XDrawLines, in addition repeat with line joins at a");
	report_strategy("	variety of angles >= 11 degrees.");

	tpstartup();
	setargs();
	for (resetvinf(VI_WIN_PIX); nextvinf(&vp); ) {
		setargs();
		A_DRAWABLE = makewin(A_DISPLAY, vp);
		A_GC = makegc(A_DISPLAY, A_DRAWABLE);

		setjoinstyle(A_DISPLAY, A_GC, JoinMiter);
		setwidth(A_DISPLAY, A_GC, (unsigned)7);

		ndrawn = 0;
#if !T_XDrawArcs

		/*
		 * The default paths join at greater than 11 deg - so try them
		 * out.
		 */
		trace("Trying default path");
		startcall(display);
		if (isdeleted())
			return;
		XDrawRectangle(display, d, gc, x, y, width, height);
		endcall(display);
		if (geterr() != Success) {
			report("Got %s, Expecting Success", errorname(geterr()));
			FAIL;
		}
		PIXCHECK(A_DISPLAY, A_DRAWABLE);
		ndrawn++;
#endif

	}

	CHECKPASS(ndrawn * nvinf());

	tpcleanup();
	pfcount(pass, fail);
}

static void t051(){

XVisualInfo	*vp;
int 	ndrawn;
int 	pass = 0, fail = 0;

 	report_purpose(51);

	report_assertion("Assertion XDrawRectangle-51.(A)");
	report_assertion("When the join_style is JoinMiter and the angle at which the");
	report_assertion("lines join is less than 11 degrees, then a JoinBevel");
	report_assertion("join-style is used.");

	report_strategy("Set GC component join_style to JoinMitre.");
	report_strategy("Set GC component line_width to 7.");
	report_strategy("Do graphics operation (with line joins all at angles < 11 degrees). ");
	report_strategy("Pixmap verify.");

	tpstartup();
	setargs();
	for (resetvinf(VI_WIN_PIX); nextvinf(&vp); ) {
		A_DRAWABLE = makewin(A_DISPLAY, vp);
		A_GC = makegc(A_DISPLAY, A_DRAWABLE);

		setjoinstyle(A_DISPLAY, A_GC, JoinMiter);
		setwidth(A_DISPLAY, A_GC, (unsigned)7);

		ndrawn = 0;
		/*
		 * In a sense, height of a rectangle is zero then the
		 * lines join at 0 deg so this assertion applies.
		 * Probably a Grey Area though.
		 */
		height = 0;
		startcall(display);
		if (isdeleted())
			return;
		XDrawRectangle(display, d, gc, x, y, width, height);
		endcall(display);
		if (geterr() != Success) {
			report("Got %s, Expecting Success", errorname(geterr()));
			FAIL;
		}
		PIXCHECK(A_DISPLAY, A_DRAWABLE);
		ndrawn++;
	}

	CHECKPASS(ndrawn * nvinf());

	tpcleanup();
	pfcount(pass, fail);
}

static void t052(){

XVisualInfo	*vp;
int 	pass = 0, fail = 0;

 	report_purpose(52);

	report_assertion("Assertion XDrawRectangle-52.(A)");
	report_assertion("When the join_style is JoinRound, then the corner is a");
	report_assertion("circular arc with the diameter equal to the line-width,");
	report_assertion("centered on the joinpoint.");

	report_strategy("Set GC component join_style to JoinRound.");
	report_strategy("Set GC component line_width to 7.");
	report_strategy("Do graphics operation.");
	report_strategy("Pixmap verify.");
	report_strategy("For XDrawLines, in addition repeat with line joins at a variety of angles.");

	tpstartup();
	setargs();
	for (resetvinf(VI_WIN_PIX); nextvinf(&vp); ) {
		setargs();
		A_DRAWABLE = makewin(A_DISPLAY, vp);
		A_GC = makegc(A_DISPLAY, A_DRAWABLE);

		setjoinstyle(A_DISPLAY, A_GC, JoinRound);
		setwidth(A_DISPLAY, A_GC, (unsigned)7);

#if !T_XDrawArcs
		/*
		 * Try the default path.
		 */
		trace("Draw the default path");
		startcall(display);
		if (isdeleted())
			return;
		XDrawRectangle(display, d, gc, x, y, width, height);
		endcall(display);
		if (geterr() != Success) {
			report("Got %s, Expecting Success", errorname(geterr()));
			FAIL;
		}
		PIXCHECK(A_DISPLAY, A_DRAWABLE);
#endif


	}

	CHECKPASS(nvinf());

	tpcleanup();
	pfcount(pass, fail);
}

static void t053(){

XVisualInfo	*vp;
int 	pass = 0, fail = 0;

 	report_purpose(53);

	report_assertion("Assertion XDrawRectangle-53.(A)");
	report_assertion("When the join_style is JoinBevel, then the corner has");
	report_assertion("CapButt endpoint styles with the triangular notch filled.");

	report_strategy("Set GC component join_style to JoinBevel.");
	report_strategy("Set GC component line_width to 7.");
	report_strategy("Do graphics operation.");
	report_strategy("Pixmap verify.");
	report_strategy("For XDrawLines, in addition repeat with line joins at a variety of angles.");

	tpstartup();
	setargs();
	for (resetvinf(VI_WIN_PIX); nextvinf(&vp); ) {
		setargs();
		A_DRAWABLE = makewin(A_DISPLAY, vp);
		A_GC = makegc(A_DISPLAY, A_DRAWABLE);

		setjoinstyle(A_DISPLAY, A_GC, JoinBevel);
		setwidth(A_DISPLAY, A_GC, (unsigned)7);

		/*
		 * Try the default path.
		 */
		trace("Draw the default path");
		startcall(display);
		if (isdeleted())
			return;
		XDrawRectangle(display, d, gc, x, y, width, height);
		endcall(display);
		if (geterr() != Success) {
			report("Got %s, Expecting Success", errorname(geterr()));
			FAIL;
		}
		PIXCHECK(A_DISPLAY, A_DRAWABLE);

	}

	CHECKPASS(nvinf());

	tpcleanup();
	pfcount(pass, fail);
}

static void t054(){

XVisualInfo	*vp;
XImage	*jssav;
int 	pass = 0, fail = 0;

 	report_purpose(54);

	report_assertion("Assertion XDrawRectangle-54.(A)");
	report_assertion("When a line has coincident endpoints (x1=x2, y1=y2), and");
	report_assertion("the join_style is applied at one or both endpoints, and the");
	report_assertion("path consists of more than just this line, then the effect");
	report_assertion("is as though the line was removed from the overall path.");

	report_strategy("Set GC component join_style to JoinBevel.");
	report_strategy("Set GC component cap_style to CapRound.");
	report_strategy("Set GC component line_width to 7.");
	report_strategy("For XDrawRectangles and XDrawRectangle (GREY AREA):");
	report_strategy("	Do graphics operation.");
	report_strategy("	Pixmap verify.");
	report_strategy("For XDrawLines and XDrawArcs:");
	report_strategy("	Do graphics operation.");
	report_strategy("	Save image on the drawable.");
	report_strategy("	Do graphics operation with zero length segment joined to path.");
	report_strategy("	Verify image is the same as that saved.");

	tpstartup();
	setargs();
	for (resetvinf(VI_WIN_PIX); nextvinf(&vp); ) {
		A_DRAWABLE = makewin(A_DISPLAY, vp);
		A_GC = makegc(A_DISPLAY, A_DRAWABLE);

		setjoinstyle(A_DISPLAY, A_GC, JoinMiter);
		setcapstyle(A_DISPLAY, A_GC, CapRound);
		setwidth(A_DISPLAY, A_GC, (unsigned)7);

		/*
		 * Since CapStyle is not documented to affect Rectangles
		 * this is a Grey Area.
		 * MIT resolved that CapStyle does affect Rectangles 
		 * with zero width and height - still unclear on zero height.
		 * 					DPJ Cater - 12/3/91
		 */
		height = 0;
		startcall(display);
		if (isdeleted())
			return;
		XDrawRectangle(display, d, gc, x, y, width, height);
		endcall(display);
		if (geterr() != Success) {
			report("Got %s, Expecting Success", errorname(geterr()));
			FAIL;
		}
		PIXCHECK(A_DISPLAY, A_DRAWABLE);
	}

	CHECKPASS(nvinf());

	tpcleanup();
	pfcount(pass, fail);
}

static void t055(){

XVisualInfo	*vp;
XImage	*jssav;
int 	pass = 0, fail = 0;

 	report_purpose(55);

	report_assertion("Assertion XDrawRectangle-55.(A)");
	report_assertion("When the total path consists of, or is reduced to, a single");
	report_assertion("point joined with itself, then the effect is the same as");
	report_assertion("applying the cap_style at both endpoints.");

	report_strategy("Set GC component join_style to JoinMiter.");
	report_strategy("Set GC component cap_style to CapRound.");
	report_strategy("Set GC component line_width to 12.");
	report_strategy("Draw zero length line.");
	report_strategy("Save image on the drawable.");
	report_strategy("Draw path that is reduced to single point.");
	report_strategy("Verify image is the same as that saved.");
	report_strategy("(Note that the actual rendering of the cap-style is tested else where)");

	tpstartup();
	setargs();
	for (resetvinf(VI_WIN_PIX); nextvinf(&vp); ) {
		A_DRAWABLE = makewin(A_DISPLAY, vp);
		A_GC = makegc(A_DISPLAY, A_DRAWABLE);

		setjoinstyle(A_DISPLAY, A_GC, JoinMiter);
		setcapstyle(A_DISPLAY, A_GC, CapRound);
		setwidth(A_DISPLAY, A_GC, (unsigned)12);

		XDrawLine(A_DISPLAY, A_DRAWABLE, A_GC, 30, 30, 30, 30);
		jssav = savimage(A_DISPLAY, A_DRAWABLE);
		dclear(A_DISPLAY, A_DRAWABLE);

		/*
		 * Since CapStyle is not documented to affect Rectangles
		 * this is a Grey Area.
		 * MIT resolved that CapStyle does affect Rectangles 
		 * with zero width and height.
		 * DPJ Cater - 12/3/91
		 */
		x = 30; y = 30;
		height = 0;
		width  = 0;
		startcall(display);
		if (isdeleted())
			return;
		XDrawRectangle(display, d, gc, x, y, width, height);
		endcall(display);
		if (geterr() != Success) {
			report("Got %s, Expecting Success", errorname(geterr()));
			FAIL;
		}
		if (compsavimage(A_DISPLAY, A_DRAWABLE, jssav))
			CHECK;
		else {
			report("Effect was not the same as cap-style applied to both end points");
			FAIL;
		}
	}

	CHECKPASS(nvinf());

	tpcleanup();
	pfcount(pass, fail);
}

static void t056(){


 	report_purpose(56);

	report_assertion("Assertion XDrawRectangle-56.(-)");
	report_assertion("When path elements are combined with a join_style, then");
	report_assertion("dashing is continuous.");
	report_assertion("The assertion is descriptive or is tested elsewhere.");
	tet_result(TET_NOTINUSE);
}

/* End of included file gc/join-styl.mc */

/* Including from file gc/fill-styl.mc */
static void t057(){

XVisualInfo	*vp;
int 	pass = 0, fail = 0;

 	report_purpose(57);

	report_assertion("Assertion XDrawRectangle-57.(A)");
	report_assertion("When fill_style is FillSolid, then on a call to");
	report_assertion("XDrawRectangle the source pixel for the drawing operation is");
	report_assertion("foreground.");

	report_strategy("Set fill-style to FillSolid.");
	report_strategy("Do drawing operation.");
	report_strategy("Pixmap verify.");

	tpstartup();
	setargs();
	for (resetvinf(VI_WIN_PIX); nextvinf(&vp); ) {
		A_DRAWABLE = makewin(A_DISPLAY, vp);
		A_GC = makegc(A_DISPLAY, A_DRAWABLE);

		XSetFillStyle(A_DISPLAY, A_GC, FillSolid);
		startcall(display);
		if (isdeleted())
			return;
		XDrawRectangle(display, d, gc, x, y, width, height);
		endcall(display);
		if (geterr() != Success) {
			report("Got %s, Expecting Success", errorname(geterr()));
			FAIL;
		}

		PIXCHECK(A_DISPLAY, A_DRAWABLE);
	}

	CHECKPASS(nvinf());
	tpcleanup();
	pfcount(pass, fail);
}

static void t058(){

XVisualInfo	*vp;
XImage	*fssav;
Pixmap	fstile, fstile2;
unsigned long	fsfg, fsbg;
int 	pass = 0, fail = 0;

 	report_purpose(58);

	report_assertion("Assertion XDrawRectangle-58.(A)");
	report_assertion("When fill-style is FillTiled, then on a call to");
	report_assertion("XDrawRectangle the source for the drawing operation is tile.");

	report_strategy("Create a tile of appropriate depth.");
	report_strategy("If depth is greater than one, set the fg and bg in the tile");
	report_strategy("to interesting values.");
	report_strategy("Set fill-style to FillTiled.");
	report_strategy("Part 1.");
	report_strategy("Do drawing operation.");
	report_strategy("If FillRectangle operation");
	report_strategy("  Directly check using checktile.");
	report_strategy("else");
	report_strategy("  Pixmap verify.");
	report_strategy("");
	report_strategy("Part 2.");
	report_strategy("Do drawing operation.");
	report_strategy("Reverse fg and bg in tile.");
	report_strategy("Set gc function to xor.");
	report_strategy("Repeat drawing operation.");
	report_strategy("Verify that result is the same as drawing solid line with xor");
	report_strategy("of the fg and bg.");
	report_strategy("(This also verifies for depth 1 screens that the background is being");
	report_strategy("drawn)");
	report_strategy("");

	tpstartup();
	setargs();
	for (resetvinf(VI_WIN_PIX); nextvinf(&vp); ) {
		A_DRAWABLE = makewin(A_DISPLAY, vp);
		A_GC = makegc(A_DISPLAY, A_DRAWABLE);

		setwidth(A_DISPLAY, A_GC, (unsigned)8);

		/* 1 */
		fsfg = W_FG;
		fsbg = W_BG;
		if (vp->depth > 1) {
			fsfg ^= 0x2;
			fsbg ^= 0x2;
		}
		fstile = XCreatePixmapFromBitmapData(A_DISPLAY, A_DRAWABLE
			, (char*)tile_bits, tile_width, tile_height
			, fsfg, fsbg
			, vp->depth
			);
		XSetTile(A_DISPLAY, A_GC, fstile);

		XSetFillStyle(A_DISPLAY, A_GC, FillTiled);

		startcall(display);
		if (isdeleted())
			return;
		XDrawRectangle(display, d, gc, x, y, width, height);
		endcall(display);
		if (geterr() != Success) {
			report("Got %s, Expecting Success", errorname(geterr()));
			FAIL;
		}

		PIXCHECK(A_DISPLAY, A_DRAWABLE);

		/* 2 */
		dclear(A_DISPLAY, A_DRAWABLE);

		XSetFillStyle(A_DISPLAY, A_GC, FillSolid);
		XSetForeground(A_DISPLAY, A_GC, fsfg^fsbg);
		startcall(display);
		if (isdeleted())
			return;
		XDrawRectangle(display, d, gc, x, y, width, height);
		endcall(display);
		if (geterr() != Success) {
			report("Got %s, Expecting Success", errorname(geterr()));
			FAIL;
		}
		fssav = savimage(A_DISPLAY, A_DRAWABLE);

		/*
		 * Draw with foreground and background as before.
		 */
		dclear(A_DISPLAY, A_DRAWABLE);
		XSetFillStyle(A_DISPLAY, A_GC, FillTiled);
		XSetTile(A_DISPLAY, A_GC, fstile);
		startcall(display);
		if (isdeleted())
			return;
		XDrawRectangle(display, d, gc, x, y, width, height);
		endcall(display);
		if (geterr() != Success) {
			report("Got %s, Expecting Success", errorname(geterr()));
			FAIL;
		}

		/*
		 * Draw with background and foreground reversed.
		 * xor it in.
		 */
		fstile2 = XCreatePixmapFromBitmapData(A_DISPLAY, A_DRAWABLE
			, (char*)tile_bits, tile_width, tile_height
			, fsbg, fsfg
			, vp->depth
			);
		XSetFillStyle(A_DISPLAY, A_GC, FillTiled);
		XSetTile(A_DISPLAY, A_GC, fstile2);
		XSetFunction(A_DISPLAY, A_GC, GXxor);
		startcall(display);
		if (isdeleted())
			return;
		XDrawRectangle(display, d, gc, x, y, width, height);
		endcall(display);
		if (geterr() != Success) {
			report("Got %s, Expecting Success", errorname(geterr()));
			FAIL;
		}

		if (compsavimage(A_DISPLAY, A_DRAWABLE, fssav))
			CHECK;
		else {
			report("Reversing tile fg and bg did not draw solid line");
			FAIL;
		}
		XFreePixmap(A_DISPLAY, fstile);
		XFreePixmap(A_DISPLAY, fstile2);
	}

	CHECKPASS(2*nvinf());

	tpcleanup();
	pfcount(pass, fail);
}

static void t059(){

XVisualInfo	*vp;
XImage	*fssav;
Pixmap	fsstip;
unsigned long	fsfg, fsbg;
int 	pass = 0, fail = 0;

 	report_purpose(59);

	report_assertion("Assertion XDrawRectangle-59.(A)");
	report_assertion("When fill_style is FillOpaqueStippled, then on a call to");
	report_assertion("XDrawRectangle the source for the drawing operation is a");
	report_assertion("tile with the same width and height as stipple, but with");
	report_assertion("background everywhere stipple has a zero and with foreground");
	report_assertion("everywhere stipple has a one.");

	report_strategy("Create stipple.");
	report_strategy("Set fill-style to FillOpaqueStippled.");
	report_strategy("Do drawing operation.");
	report_strategy("Pixmap verify the results.");
	report_strategy("");
	report_strategy("Reverse foreground and background pixels.");
	report_strategy("Combine drawing with previous drawing.");
	report_strategy("Verify that the results are the same as FillSolid with foreground");
	report_strategy(" equal to combination of fg and bg pixels.");

	tpstartup();
	setargs();
	for (resetvinf(VI_WIN_PIX); nextvinf(&vp); ) {
		A_DRAWABLE = makewin(A_DISPLAY, vp);
		A_GC = makegc(A_DISPLAY, A_DRAWABLE);

		setwidth(A_DISPLAY, A_GC, (unsigned)8);

		/* 1 */
		fsfg = W_FG;
		fsbg = W_BG;
		if (vp->depth > 1) {
			fsfg ^= 0x2;
			fsbg ^= 0x2;
			XSetForeground(A_DISPLAY, A_GC, fsfg);
			XSetBackground(A_DISPLAY, A_GC, fsbg);
		}
		fsstip = XCreateBitmapFromData(A_DISPLAY, A_DRAWABLE
			, (char*)stipple_bits, stipple_width, stipple_height
			);
		XSetStipple(A_DISPLAY, A_GC, fsstip);

		XSetFillStyle(A_DISPLAY, A_GC, FillOpaqueStippled);

		startcall(display);
		if (isdeleted())
			return;
		XDrawRectangle(display, d, gc, x, y, width, height);
		endcall(display);
		if (geterr() != Success) {
			report("Got %s, Expecting Success", errorname(geterr()));
			FAIL;
		}

		PIXCHECK(A_DISPLAY, A_DRAWABLE);

		/* 2 */
		dclear(A_DISPLAY, A_DRAWABLE);

		XSetFillStyle(A_DISPLAY, A_GC, FillSolid);
		XSetForeground(A_DISPLAY, A_GC, fsfg^fsbg);
		startcall(display);
		if (isdeleted())
			return;
		XDrawRectangle(display, d, gc, x, y, width, height);
		endcall(display);
		if (geterr() != Success) {
			report("Got %s, Expecting Success", errorname(geterr()));
			FAIL;
		}
		fssav = savimage(A_DISPLAY, A_DRAWABLE);
		XSetForeground(A_DISPLAY, A_GC, fsfg);

		/*
		 * Draw with foreground and background as before.
		 */
		dclear(A_DISPLAY, A_DRAWABLE);
		XSetFillStyle(A_DISPLAY, A_GC, FillOpaqueStippled);
		XSetStipple(A_DISPLAY, A_GC, fsstip);
		startcall(display);
		if (isdeleted())
			return;
		XDrawRectangle(display, d, gc, x, y, width, height);
		endcall(display);
		if (geterr() != Success) {
			report("Got %s, Expecting Success", errorname(geterr()));
			FAIL;
		}

		/*
		 * Draw with background and foreground reversed.
		 * xor it in.
		 */
		XSetForeground(A_DISPLAY, A_GC, fsbg);
		XSetBackground(A_DISPLAY, A_GC, fsfg);
		XSetFillStyle(A_DISPLAY, A_GC, FillOpaqueStippled);
		XSetStipple(A_DISPLAY, A_GC, fsstip);
		XSetFunction(A_DISPLAY, A_GC, GXxor);
		startcall(display);
		if (isdeleted())
			return;
		XDrawRectangle(display, d, gc, x, y, width, height);
		endcall(display);
		if (geterr() != Success) {
			report("Got %s, Expecting Success", errorname(geterr()));
			FAIL;
		}

		if (compsavimage(A_DISPLAY, A_DRAWABLE, fssav))
			CHECK;
		else {
			report("Reversing fg and bg did not draw solid line");
			FAIL;
		}
		XFreePixmap(A_DISPLAY, fsstip);
	}

	CHECKPASS(2*nvinf());

	tpcleanup();
	pfcount(pass, fail);
}

static void t060(){

XVisualInfo	*vp;
Pixmap	fsstip;
int 	pass = 0, fail = 0;

 	report_purpose(60);

	report_assertion("Assertion XDrawRectangle-60.(A)");
	report_assertion("When fill_style is FillStippled, then on a call to");
	report_assertion("XDrawRectangle the source for the drawing operation is");
	report_assertion("foreground masked by the stipple pattern tiled in a single");
	report_assertion("plane.");

	report_strategy("Create stipple");
	report_strategy("Set fill-style to FillStippled.");
	report_strategy("Set background to foreground pixel to verify it is not affecting things.");
	report_strategy("Do drawing. ");
	report_strategy("Pixmap verify.");

	tpstartup();
	setargs();
	for (resetvinf(VI_WIN_PIX); nextvinf(&vp); ) {
		A_DRAWABLE = makewin(A_DISPLAY, vp);
		A_GC = makegc(A_DISPLAY, A_DRAWABLE);

		setwidth(A_DISPLAY, A_GC, (unsigned)8);

		/* 1 */
		fsstip = XCreateBitmapFromData(A_DISPLAY, A_DRAWABLE
			, (char*)stipple_bits, stipple_width, stipple_height
			);
		XSetStipple(A_DISPLAY, A_GC, fsstip);
		XSetFillStyle(A_DISPLAY, A_GC, FillStippled);
		/* To show it has no effect */
		XSetBackground(A_DISPLAY, A_GC, W_FG);

		startcall(display);
		if (isdeleted())
			return;
		XDrawRectangle(display, d, gc, x, y, width, height);
		endcall(display);
		if (geterr() != Success) {
			report("Got %s, Expecting Success", errorname(geterr()));
			FAIL;
		}

		PIXCHECK(A_DISPLAY, A_DRAWABLE);

		XFreePixmap(A_DISPLAY, fsstip);

	}

	CHECKPASS(nvinf());

	tpcleanup();
	pfcount(pass, fail);
}

/* End of included file gc/fill-styl.mc */

/* Including from file gc/subwindow.mc */
static void t061(){

XVisualInfo	*vp;
Window	subwins[10];
unsigned int 	swmwidth, swmheight;
struct	area	area;
int 	i;
int 	pass = 0, fail = 0;

 	report_purpose(61);

	report_assertion("Assertion XDrawRectangle-61.(A)");
	report_assertion("When subwindow_mode is ClipByChildren, then the");
	report_assertion("destination window and source (if it is a window) are");
	report_assertion("clipped by all viewable InputOutput children.");

	report_strategy("Set subwindow-mode to be ClipByChildren");
	report_strategy("Cover window with many strip sub-windows.");
	report_strategy("Do drawing operation");
	report_strategy("Verify that all subwindows are clear.");

	tpstartup();
	setargs();
	for (resetvinf(VI_WIN); nextvinf(&vp); ) {
		A_DRAW = makewin(A_DISPLAY, vp);
		A_GC = makegc(A_DISPLAY, A_DRAW);

		XSetSubwindowMode(A_DISPLAY, A_GC, ClipByChildren);

		/*
		 * Place subwindows in strips across the window
		 * leaving spaces between them.
		 */
		getsize(A_DISPLAY, A_DRAW, &swmwidth, &swmheight);
		swmwidth /= 2*NELEM(subwins);

		for (i = 0; i < NELEM(subwins); i++) {
			setarea(&area, 2*i*swmwidth, 0, swmwidth, 0);
			subwins[i] = crechild(A_DISPLAY, A_DRAW, &area);
		}

		startcall(display);
		if (isdeleted())
			return;
		XDrawRectangle(display, d, gc, x, y, width, height);
		endcall(display);
		if (geterr() != Success) {
			report("Got %s, Expecting Success", errorname(geterr()));
			FAIL;
		}

		for (i = 0; i < NELEM(subwins); i++) {
			if (checkclear(A_DISPLAY, subwins[i]))
				CHECK;
			else {
				report("Area of subwindow was not clear");
				FAIL;
			}
		}
	}

	CHECKPASS(NELEM(subwins)*nvinf());

	tpcleanup();
	pfcount(pass, fail);
}

static void t062(){

XVisualInfo	*vp;
Window	subwins[5];
XImage	*swmsav;
unsigned int 	swmwidth, swmheight;
struct	area	area;
int 	i, j;
int 	pass = 0, fail = 0;

 	report_purpose(62);

	report_assertion("Assertion XDrawRectangle-62.(A)");
	report_assertion("When subwindow_mode is IncludeInferiors, then neither the");
	report_assertion("destination window nor source (if it is a window) is clipped");
	report_assertion("by inferiors.");

	report_strategy("Place subwindows over parts of the main window");
	report_strategy("Create subwindows over these windows as well.");
	report_strategy("Do graphics operation.");
	report_strategy("Verify that the operation was not affected.");

	tpstartup();
	setargs();
	for (resetvinf(VI_WIN); nextvinf(&vp); ) {
		A_DRAW = makewin(A_DISPLAY, vp);
		A_GC = makegc(A_DISPLAY, A_DRAW);

		startcall(display);
		if (isdeleted())
			return;
		XDrawRectangle(display, d, gc, x, y, width, height);
		endcall(display);
		if (geterr() != Success) {
			report("Got %s, Expecting Success", errorname(geterr()));
			FAIL;
		}
		swmsav = savimage(A_DISPLAY, A_DRAW);
		dclear(A_DISPLAY, A_DRAW);

		XSetSubwindowMode(A_DISPLAY, A_GC, IncludeInferiors);

		/*
		 * Place subwindows in strips across the window
		 * leaving spaces between them.
		 */
		getsize(A_DISPLAY, A_DRAW, &swmwidth, &swmheight);
		swmwidth /= 2*NELEM(subwins);

		for (i = 0; i < NELEM(subwins); i++) {
			setarea(&area, 2*i*swmwidth, 0, swmwidth, 0);
			subwins[i] = crechild(A_DISPLAY, A_DRAW, &area);
			for (j = 0; j < swmheight; j += 10) {
				setarea(&area, 0, j, swmwidth, 6);
				crechild(A_DISPLAY, subwins[i], &area);
			}
		}

		startcall(display);
		if (isdeleted())
			return;
		XDrawRectangle(display, d, gc, x, y, width, height);
		endcall(display);
		if (geterr() != Success) {
			report("Got %s, Expecting Success", errorname(geterr()));
			FAIL;
		}

		if (compsavimage(A_DISPLAY, A_DRAW, swmsav))
			CHECK;
		else {
			report("Inferiors affected result with IncludeInferiors");
			FAIL;
		}

		/*
		 * As a special test due to its importance, test that drawing
		 * on to the root window has the same effect.  Move the test
		 * window to the root window origin.
		 */
		if (vp->depth != DefaultDepth(A_DISPLAY, DefaultScreen(A_DISPLAY)))
			CHECK;
		else {
			Drawable savdraw;

			dclear(A_DISPLAY, A_DRAW);
			XSetWindowBorderWidth(A_DISPLAY, A_DRAW, 0);
			XMoveWindow(A_DISPLAY, A_DRAW, 0, 0);

			savdraw = A_DRAW;
			A_DRAW = DRW(A_DISPLAY);

			startcall(display);
			if (isdeleted())
				return;
			XDrawRectangle(display, d, gc, x, y, width, height);
			endcall(display);
			if (geterr() != Success) {
				report("Got %s, Expecting Success", errorname(geterr()));
				FAIL;
			}

			A_DRAW = savdraw;

			if (compsavimage(A_DISPLAY, A_DRAW, swmsav))
				CHECK;
			else {
				report("Drawing on root window with IncludeInferiors gave incorrect results");
				FAIL;
			}
		}
	}

	CHECKPASS(2*nvinf());

	tpcleanup();
	pfcount(pass, fail);
}

static void t063(){

XVisualInfo	*vp1, *vp2;
XImage	*swmsav;
int 	found;
XSetWindowAttributes w_attr;
int 	pass = 0, fail = 0;

 	report_purpose(63);

	report_assertion("Assertion XDrawRectangle-63.(A)");
	report_assertion("When subwindow_mode is IncludeInferiors on a window of one");
	report_assertion("depth with mapped inferiors of differing depth, then no");
	report_assertion("errors occur.");

	report_strategy("If only one depth window supported");
	report_strategy("  Result is UNSUPPORTED");
	report_strategy("");
	report_strategy("Find two visuals with different depths.");
	report_strategy("Use one of these visuals to create a window.");
	report_strategy("Use the other to create a subwindow.");
	report_strategy("Verify that no errors occur.");
	report_strategy("For information purposes only see if graphics operation is rendered properly.");

	tpstartup();
	setargs();
	vp2 = NULL;
	found = 0;

	for (resetvinf(VI_WIN); nextvinf(&vp1); ) {
		if (vp2 == NULL)
			vp2 = vp1;
		if (vp1->depth != vp2->depth) {
			found++;
			break;
		}
	}

	if (!found) {
		report("Only one depth visual supported");
		tet_result(TET_UNSUPPORTED);
		return;
	}

	A_DRAW = makewin(A_DISPLAY, vp1);
	A_GC = makegc(A_DISPLAY, A_DRAW);

	startcall(display);
	if (isdeleted())
		return;
	XDrawRectangle(display, d, gc, x, y, width, height);
	endcall(display);
	if (geterr() != Success) {
		report("Got %s, Expecting Success", errorname(geterr()));
		FAIL;
	}
	swmsav = savimage(A_DISPLAY, A_DRAW);
	dclear(A_DISPLAY, A_DRAW);

        /*
         * Must explicitly set the colormap and border_pixel parameters
         * to ensure that a BadMatch error doesn't get generated, since
         * it is entire possible that the depth differs from that of the
         * parent window.
         */
        w_attr.colormap = makecolmap(A_DISPLAY, vp2->visual, AllocNone);
        w_attr.border_pixel = 0;
	XCreateWindow(A_DISPLAY
		, A_DRAW
		, 0
		, 0
		, 300
		, 300
		, 0
		, vp2->depth
		, InputOutput
		, vp2->visual
		, CWColormap | CWBorderPixel 
		, &w_attr
		);
	XSetWindowBackground(A_DISPLAY, A_DRAW, W_BG);
	XMapWindow(A_DISPLAY, A_DRAW);

	/* Wait for Expose? */
	/* No.... we're not a top level window so no wmgr interference */
		
	XSetSubwindowMode(A_DISPLAY, A_GC, IncludeInferiors);

	startcall(display);
	if (isdeleted())
		return;
	XDrawRectangle(display, d, gc, x, y, width, height);
	endcall(display);
	if (geterr() != Success) {
		report("Got %s, Expecting Success", errorname(geterr()));
		FAIL;
	}

	if (compsavimage(A_DISPLAY, A_DRAW, swmsav))
		trace("Drawing through to different depth window produces same results");
	else
		trace("Drawing through to different depth window produces different results");
		
	if (geterr() == Success)
		PASS;
	else
		FAIL;
	tpcleanup();
	pfcount(pass, fail);
}

/* End of included file gc/subwindow.mc */

/* Including from file gc/clip-x-or.mc */
static void t064(){

XVisualInfo	*vp;
Pixmap	cmopixmap;
struct	area	area;
unsigned int 	cmowidth;
unsigned int 	cmoheight;
int 	divsize;
int 	i, j;
int 	pass = 0, fail = 0;

 	report_purpose(64);

	report_assertion("Assertion XDrawRectangle-64.(A)");
	report_assertion("The clip origin coordinates clip-x-origin and clip-y-origin");
	report_assertion("are interpreted relative to the origin of the destination");
	report_assertion("drawable specified in the graphics operation.");

	report_strategy("Create Pixmap and set clip-mask with it.");
	report_strategy("Vary clip origin");
	report_strategy("Verify nothing is drawn outside the clip_mask based on the origin.");
	report_strategy("Pixmap verify results inside the cliparea.");

	tpstartup();
	setargs();
	divsize = 3;

	for (resetvinf(VI_WIN_PIX); nextvinf(&vp); ) {
		A_DRAW = makewin(A_DISPLAY, vp);
		A_GC = makegc(A_DISPLAY, A_DRAW);

		/*
		 * Get size of the pixmap.  It is divsize smaller on all sides
		 * than the window.
		 */
		getsize(A_DISPLAY, A_DRAW, &cmowidth, &cmoheight);
		cmowidth /= divsize;
		cmoheight /= divsize;
		debug(2, "clip-mask height=%d, width=%d", cmowidth, cmoheight);

		/*
		 * Create a pixmap that is about divsize^2 of the area of
		 * the window.
		 */
		cmopixmap = XCreatePixmap(A_DISPLAY, A_DRAW, cmowidth, cmoheight, 1);
		dset(A_DISPLAY, cmopixmap, 1L);

		XSetClipMask(A_DISPLAY, A_GC, cmopixmap);
		XFreePixmap(A_DISPLAY, cmopixmap);

		for (i = 0; i < divsize; i++) {
			for (j = 0; j < divsize; j++) {
				setarea(&area, i*cmowidth, j*cmoheight, cmowidth, cmoheight);
				debug(2, "Origin at (%d,%d)", area.x, area.y);
				XSetClipOrigin(A_DISPLAY, A_GC, area.x, area.y);
				startcall(display);
				if (isdeleted())
					return;
				XDrawRectangle(display, d, gc, x, y, width, height);
				endcall(display);
				if (geterr() != Success) {
					report("Got %s, Expecting Success", errorname(geterr()));
					FAIL;
				}
				if (checkarea(A_DISPLAY,A_DRAW,&area,W_BG,W_BG,CHECK_OUT))
					CHECK;
				else {
					report("Drawing occurred outside clip_mask");
					FAIL;
				}
				PIXCHECK(A_DISPLAY, A_DRAW);
				dclear(A_DISPLAY, A_DRAW);
			}
		}
	}

	CHECKPASS(2*divsize*divsize*nvinf());

	tpcleanup();
	pfcount(pass, fail);
}

/* End of included file gc/clip-x-or.mc */

/* Including from file gc/clip-y-or.mc */
/* End of included file gc/clip-y-or.mc */

/* Including from file gc/clip-mask.mc */
static void t065(){

XVisualInfo	*vp;
XImage	*cmsav;
int 	pass = 0, fail = 0;

 	report_purpose(65);

	report_assertion("Assertion XDrawRectangle-65.(A)");
	report_assertion("When the clip_mask is set to None, then the pixels are");
	report_assertion("always drawn regardless of the clip origin.");

	report_strategy("Set clip mask to None");
	report_strategy("Verify that things are still drawn.");

	tpstartup();
	setargs();
	for (resetvinf(VI_WIN_PIX); nextvinf(&vp); ) {
		A_DRAW = makewin(A_DISPLAY, vp);
		A_GC = makegc(A_DISPLAY, A_DRAW);

		startcall(display);
		if (isdeleted())
			return;
		XDrawRectangle(display, d, gc, x, y, width, height);
		endcall(display);
		if (geterr() != Success) {
			report("Got %s, Expecting Success", errorname(geterr()));
			FAIL;
		}
		cmsav = savimage(A_DISPLAY, A_DRAW);
		dclear(A_DISPLAY, A_DRAW);

		/*
		 * Not very interesting, because this should be the default
		 * anyway.
		 */
		XSetClipMask(A_DISPLAY, A_GC, None);

		startcall(display);
		if (isdeleted())
			return;
		XDrawRectangle(display, d, gc, x, y, width, height);
		endcall(display);
		if (geterr() != Success) {
			report("Got %s, Expecting Success", errorname(geterr()));
			FAIL;
		}

		if (compsavimage(A_DISPLAY, A_DRAW, cmsav))
			CHECK;
		else {
			report("Clip mask of None changed graphics");
			FAIL;
		}
	}

	CHECKPASS(nvinf());

	tpcleanup();
	pfcount(pass, fail);
}

static void t066(){

XVisualInfo	*vp;
Pixmap	cmpm;
struct	area	area;
int 	pass = 0, fail = 0;

 	report_purpose(66);

	report_assertion("Assertion XDrawRectangle-66.(A)");
	report_assertion("When pixels are outside the area covered by the clip_mask,");
	report_assertion("then they are not drawn.");

	report_strategy("Create a pixmap depth 1.");
	report_strategy("Fill it with all ones.");
	report_strategy("Set this pixmap as the clip_mask.");
	report_strategy("Verify that nothing is drawn outside the clip-mask area.");
	report_strategy("Use a pixmap size of 5x5 to ensure that all tests have some part of the");
	report_strategy("drawing outside the clip-mask.");

	tpstartup();
	setargs();
	for (resetvinf(VI_WIN_PIX); nextvinf(&vp); ) {
		A_DRAW = makewin(A_DISPLAY, vp);
		A_GC = makegc(A_DISPLAY, A_DRAW);

		setarea(&area, 0, 0, 5, 5);
		cmpm = XCreatePixmap(A_DISPLAY, A_DRAW, area.width, area.height, 1);
		dset(A_DISPLAY, cmpm, 1L);
		XSetClipMask(A_DISPLAY, A_GC, cmpm);
		XFreePixmap(A_DISPLAY, cmpm);

		startcall(display);
		if (isdeleted())
			return;
		XDrawRectangle(display, d, gc, x, y, width, height);
		endcall(display);
		if (geterr() != Success) {
			report("Got %s, Expecting Success", errorname(geterr()));
			FAIL;
		}

		if (checkarea(A_DISPLAY, A_DRAW, &area, 0L, W_BG, CHECK_OUT))
			CHECK;
		else {
			report("Drawing outside clip mask");
			FAIL;
		}
	}

	CHECKPASS(nvinf());
	tpcleanup();
	pfcount(pass, fail);
}

static void t067(){

#define stipple_width 24
#define stipple_height 11
static unsigned char stipple_bits[] = {
   0xff, 0x0f, 0x00, 0x3f, 0xf0, 0xff, 0xcf, 0xff, 0x03, 0xf7, 0x0f, 0xfc,
   0xff, 0xf1, 0x0f, 0x78, 0x7e, 0xf0, 0x80, 0x8f, 0x1f, 0x2a, 0xf0, 0xe1,
   0x80, 0x07, 0x1e, 0xaa, 0xff, 0xe0, 0x80, 0xff, 0x0f};
XVisualInfo	*vp;
Pixmap	cmpixmap;
Pixmap	cmstip;
XImage	*cmsav;
GC		cmgc;
unsigned int 	cmwidth, cmheight;
int 	i, j;
int 	pass = 0, fail = 0;

 	report_purpose(67);

	report_assertion("Assertion XDrawRectangle-67.(A)");
	report_assertion("When pixels have a clip_mask bit set to 1, and they would");
	report_assertion("be drawn, then they are drawn.");

	report_strategy("Do graphics operation.");
	report_strategy("Save the image on the drawable.");
	report_strategy("Clear drawable.");
	report_strategy("Create a pixmap depth 1 that is the same size as the window.");
	report_strategy("Set all bits in pixmap to 1.");
	report_strategy("Set GC component clip-mask to pixmap using XSetClipMask.");
	report_strategy("Do graphics operation.");
	report_strategy("Verify that the images drawn were the same.");
	report_strategy("");
	report_strategy("Set pixmap to a pattern.");
	report_strategy("Do graphics operation.");
	report_strategy("Pixmap verify the result.");

	tpstartup();
	setargs();
	for (resetvinf(VI_WIN_PIX); nextvinf(&vp); ) {
		A_DRAW = makewin(A_DISPLAY, vp);
		A_GC = makegc(A_DISPLAY, A_DRAW);

		startcall(display);
		if (isdeleted())
			return;
		XDrawRectangle(display, d, gc, x, y, width, height);
		endcall(display);
		if (geterr() != Success) {
			report("Got %s, Expecting Success", errorname(geterr()));
			FAIL;
		}
		cmsav = savimage(A_DISPLAY, A_DRAW);
		if (isdeleted())
			return;
		/* Must clear the drawable - otherwise there is no way 
		of proving clip mask of all 1's allowed drawing */
		dclear(A_DISPLAY, A_DRAW);

		getsize(A_DISPLAY, A_DRAW, &cmwidth, &cmheight);
		cmpixmap = XCreatePixmap(A_DISPLAY, A_DRAW, cmwidth, cmheight, 1);
		if (isdeleted())
			return;
		dset(A_DISPLAY, cmpixmap, 1L);

		XSetClipMask(A_DISPLAY, A_GC, cmpixmap);

		trace("Clip mask of all 1's");
		startcall(display);
		if (isdeleted())
			return;
		XDrawRectangle(display, d, gc, x, y, width, height);
		endcall(display);
		if (geterr() != Success) {
			report("Got %s, Expecting Success", errorname(geterr()));
			FAIL;
		}
		if (compsavimage(A_DISPLAY, A_DRAW, cmsav))
			CHECK;
		else {
			report("fail on clip_mask of all 1's");
			FAIL;
		}
		dclear(A_DISPLAY, A_DRAW);

		cmstip = XCreateBitmapFromData(A_DISPLAY, A_DRAW, (char*)stipple_bits,
			stipple_width, stipple_height);
		cmgc = makegc(A_DISPLAY, cmstip);
		if (isdeleted())
			return;

		for (i = 0; i < cmwidth; i += stipple_width) {
			for (j = 0; j < cmheight; j += stipple_height) {
				XCopyArea(A_DISPLAY, cmstip, cmpixmap, cmgc, 0, 0,
					stipple_width, stipple_height, i, j);
			}
		}
		XSetClipMask(A_DISPLAY, A_GC, cmpixmap);

		trace("Clip mask with pattern");
		startcall(display);
		if (isdeleted())
			return;
		XDrawRectangle(display, d, gc, x, y, width, height);
		endcall(display);
		if (geterr() != Success) {
			report("Got %s, Expecting Success", errorname(geterr()));
			FAIL;
		}

		PIXCHECK(A_DISPLAY, A_DRAW);

		XFreePixmap(A_DISPLAY, cmpixmap);
		XFreePixmap(A_DISPLAY, cmstip);
	}

	CHECKPASS(2*nvinf());
	tpcleanup();
	pfcount(pass, fail);
}

static void t068(){

XVisualInfo	*vp;
Pixmap	cmpixmap;
unsigned int 	cmwidth, cmheight;
int 	pass = 0, fail = 0;

 	report_purpose(68);

	report_assertion("Assertion XDrawRectangle-68.(A)");
	report_assertion("When pixels have a clip_mask bit set to 0, then they are");
	report_assertion("not drawn.");

	report_strategy("Create a pixmap depth 1 that is the same size as the window.");
	report_strategy("Set all bits in pixmap to 0.");
	report_strategy("Set GC component clip_mask to pixmap using XSetClipMask.");
	report_strategy("Do graphics operation.");
	report_strategy("Verify that nothing is drawn.");

	tpstartup();
	setargs();
	for (resetvinf(VI_WIN_PIX); nextvinf(&vp); ) {
		A_DRAW = makewin(A_DISPLAY, vp);
		A_GC = makegc(A_DISPLAY, A_DRAW);

		getsize(A_DISPLAY, A_DRAW, &cmwidth, &cmheight);
		cmpixmap = XCreatePixmap(A_DISPLAY, A_DRAW, cmwidth, cmheight, 1);
		if (isdeleted())
			return;
		dset(A_DISPLAY, cmpixmap, 0L);

		XSetClipMask(A_DISPLAY, A_GC, cmpixmap);

		trace("Clip mask of all 0's");
		startcall(display);
		if (isdeleted())
			return;
		XDrawRectangle(display, d, gc, x, y, width, height);
		endcall(display);
		if (geterr() != Success) {
			report("Got %s, Expecting Success", errorname(geterr()));
			FAIL;
		}
		if (checkclear(A_DISPLAY, A_DRAW))
			CHECK;
		else {
			report("Pixels were drawn with clip_mask of all zeros");
			FAIL;
		}

		XFreePixmap(A_DISPLAY, cmpixmap);
	}

	CHECKPASS(nvinf());
	tpcleanup();
	pfcount(pass, fail);
}

/* End of included file gc/clip-mask.mc */

/* Including from file gc/foregroun.mc */
static void t069(){

static unsigned long fglist[] = {
	0, 0x1, 0x2, 0x3, 0x4, 0x6, 0x7, 0x10, 0x33, 0x81,
	0xa3, 0xff, 256, 300, 1000,
	0x111111, 0x400200, 0x777777,
	};
XVisualInfo	*vp;
long	fgind;
unsigned long	fg;
int 	nchecks = 0;
int 	pass = 0, fail = 0;

 	report_purpose(69);

	report_assertion("Assertion XDrawRectangle-69.(A)");
	report_assertion("The foregound component of the gc is used to determine the");
	report_assertion("foreground pixel value.");

	report_strategy("Set foreground to various values.");
	report_strategy("Pixmap verify the results.");

	tpstartup();
	setargs();
	for (resetvinf(VI_WIN_PIX); nextvinf(&vp); ) {
		A_DRAW = makewin(A_DISPLAY, vp);
		A_GC = makegc(A_DISPLAY, A_DRAW);

		for (fgind = 0; fgind < sizeof(fglist)/sizeof(unsigned long); fgind++) {

			fg = fglist[fgind];
			if (fg > DEPTHMASK(vp->depth))
				break;

			nchecks++;
			trace("Testing fg pixel of %d", fg);
			XSetForeground(A_DISPLAY, A_GC, fg);

			startcall(display);
			if (isdeleted())
				return;
			XDrawRectangle(display, d, gc, x, y, width, height);
			endcall(display);
			if (geterr() != Success) {
				report("Got %s, Expecting Success", errorname(geterr()));
				FAIL;
			}

			PIXCHECK(A_DISPLAY, A_DRAW);

			dclear(A_DISPLAY, A_DRAW);
		}
	}

	CHECKPASS(nchecks);
	tpcleanup();
	pfcount(pass, fail);
}

static void t070(){

XVisualInfo	*vp;
XImage	*imp;
unsigned long	pix;
unsigned long	fgfg;
int 	found;
int 	i_x, i_y;
unsigned int 	i_width, i_height;
int 	pass = 0, fail = 0;

 	report_purpose(70);

	report_assertion("Assertion XDrawRectangle-70.(A)");
	report_assertion("The value for foreground is truncated to the depth of the");
	report_assertion("GC.");

	report_strategy("Set foreground to value with all bits set.");
	report_strategy("Find a non background pixel.");
	report_strategy("Check that this is truncated to the depth.");

	tpstartup();
	setargs();
	for (resetvinf(VI_WIN_PIX); nextvinf(&vp); ) {
		A_DRAW = makewin(A_DISPLAY, vp);
		A_GC = makegc(A_DISPLAY, A_DRAW);

		XSetForeground(A_DISPLAY, A_GC, ~0L);

		startcall(display);
		if (isdeleted())
			return;
		XDrawRectangle(display, d, gc, x, y, width, height);
		endcall(display);
		if (geterr() != Success) {
			report("Got %s, Expecting Success", errorname(geterr()));
			FAIL;
		}

		imp = savimage(A_DISPLAY, A_DRAW);
		getsize(A_DISPLAY, A_DRAW, &i_width, &i_height);
		found = 0;
		/*
		 * Look for a non background pixel, if there is one then this
		 * should be the foreground truncated to the depth.
		 */
		for (i_y = 0; i_y < i_height; i_y++) {
			for (i_x = 0; i_x < i_width; i_x++) {
				pix = XGetPixel(imp, i_x, i_y);
				if (pix != W_BG) {
					found = 1;
					if (pix == DEPTHMASK(vp->depth)) {
						CHECK;
					} else {
						report("Pixel was set to %d, expecting %d", pix, DEPTHMASK(vp->depth));
						FAIL;
					}
					i_y = i_height;	/* So that we leave loop XXX */
					break;
				}
			}
		}
		if (found == 0) {
			if (W_BG == (~0 & DEPTHMASK(vp->depth))) {
				report("WARNING: W_BG != 0; this should not be the case");
				CHECK;
			} else {
				report("After setting foreground to (~0)");
				report("no non-background pixel was drawn");
				FAIL;
			}
		}

		dclear(A_DISPLAY, A_DRAW);

		/* Set all bits other than the bottom one */
		fgfg = (~0)^1;
		XSetForeground(A_DISPLAY, A_GC, fgfg);

		startcall(display);
		if (isdeleted())
			return;
		XDrawRectangle(display, d, gc, x, y, width, height);
		endcall(display);
		if (geterr() != Success) {
			report("Got %s, Expecting Success", errorname(geterr()));
			FAIL;
		}

		imp = savimage(A_DISPLAY, A_DRAW);
		getsize(A_DISPLAY, A_DRAW, &i_width, &i_height);
		found = 0;
		/*
		 * Look for a non background pixel, if there is one then this
		 * should be the foreground truncated to the depth.
		 */
		for (i_y = 0; i_y < i_height; i_y++) {
			for (i_x = 0; i_x < i_width; i_x++) {
				pix = XGetPixel(imp, i_x, i_y);
				if (pix != W_BG) {
					found = 1;
					if (pix == (fgfg & DEPTHMASK(vp->depth))) {
						CHECK;
					} else {
						report("Pixel was set to %d, expecting %d", pix, (fgfg & DEPTHMASK(vp->depth)));
						FAIL;
					}
					i_y = i_height;	/* So that we leave loop XXX */
					break;
				}
			}
		}
		if (found == 0) {
			/*
			 * This should be the case on monochrome displays
			 */
			if (W_BG == (fgfg & DEPTHMASK(vp->depth))) {
				CHECK;
			} else {
				report("After setting foreground to (~0)^1");
				report("no non-background pixel was drawn");
				FAIL;
			}
		}
	}

	CHECKPASS(2*nvinf());
	tpcleanup();
	pfcount(pass, fail);
}

/* End of included file gc/foregroun.mc */

/* Including from file gc/backgroun.mc */
static void t071(){

static unsigned long bglist[] = {
	0, 0x1, 0x2, 0x3, 0x4, 0x6, 0x7, 0x10, 0x33, 0x81,
	0xa3, 0xff, 256, 300, 1000,
	0x111111, 0x400200, 0x777777,
	};
XVisualInfo	*vp;
#ifdef NEED_STIPPLE
Pixmap	stip;
char	*stipbit = "\0";
#endif
long	bgind;
unsigned long	bg;
int 	nchecks = 0;
int 	pass = 0, fail = 0;

 	report_purpose(71);

	report_assertion("Assertion XDrawRectangle-71.(A)");
	report_assertion("The background component of the gc is used to determine the");
	report_assertion("background pixel value.");

	report_strategy("Set GC component background to various values.");
	report_strategy("Pixmap verify the results.");

	tpstartup();
	setargs();
#ifdef NEED_STIPPLE
	stip = XCreateBitmapFromData(A_DISPLAY, DRW(A_DISPLAY), stipbit, 1, 1);
#endif

	for (resetvinf(VI_WIN_PIX); nextvinf(&vp); ) {
		A_DRAW = makewin(A_DISPLAY, vp);
		A_GC = makegc(A_DISPLAY, A_DRAW);

		for (bgind = 0; bgind < NELEM(bglist); bgind++) {

			bg = bglist[bgind];
			if (bg > DEPTHMASK(vp->depth))
				break;

			trace("Testing bg pixel of %d", bg);
			nchecks++;

#ifdef NEED_STIPPLE
			/*
			 * Set a stipple to all zero's and set the fill style
			 * to be FillOpaqueStippled.  This will mean that everything
			 * should be drawn in the background colour.
			 * (different for XCopyPlane, which doesn't use fill style,
			 * nor does XPutImage or XCopyArea).
			 */
			XSetStipple(A_DISPLAY, A_GC, stip);
			XSetFillStyle(A_DISPLAY, A_GC, FillOpaqueStippled);
#endif
/* now set the background to bg and do the call. If it's XCopyPlane/XPutImage then
 * we have cleared the src drawable/image to zero so we will always find 0 in the
 * selected plane so we will fill with bg. If we're XDrawImageString then
 * we do the equivalent of the background fill anyway,  if we're
 * XCopyArea then we have to do a dset of src with bg otherwise we'll have
 * used FillOpaqueStippled and a stipple of a lone zero, only, to get the
 * same effect of a background fill.
 */
			XSetBackground(A_DISPLAY, A_GC, bg);

			startcall(display);
			if (isdeleted())
				return;
			XDrawRectangle(display, d, gc, x, y, width, height);
			endcall(display);
			if (geterr() != Success) {
				report("Got %s, Expecting Success", errorname(geterr()));
				FAIL;
			}

			PIXCHECK(A_DISPLAY, A_DRAW);

			dclear(A_DISPLAY, A_DRAW);
		}
	}

#ifdef NEED_STIPPLE
	XFreePixmap(A_DISPLAY, stip);
#endif

	CHECKPASS(nchecks);
	tpcleanup();
	pfcount(pass, fail);
}

static void t072(){

XVisualInfo	*vp;
XImage	*imp;
#ifdef NEED_STIPPLE
Pixmap	stip;
char	*stipbit = "\0\0\0\0";
#endif
unsigned long	pix;
int 	found;
int 	i_x, i_y;
unsigned int 	i_width, i_height;
int 	pass = 0, fail = 0;

 	report_purpose(72);

	report_assertion("Assertion XDrawRectangle-72.(A)");
	report_assertion("The value for background is truncated to the depth of the");
	report_assertion("GC.");

	report_strategy("Set GC component background to value with all bits set.");
	report_strategy("If not (XDrawImageString  || XCopyPlane || XPutImage || XCopyArea)");
	report_strategy("  Set GC component stipple to all zeros");
	report_strategy("  Set GC component FillStyle to FillOpaqueStippled.");
	report_strategy("else if (XCopyPlane || XPutImage)");
	report_strategy("  Fill source drawable/image-bitmap with 0's to ensure we draw with background");
	report_strategy("else if XCopyArea");
	report_strategy("  Fill source drawable/image-bitmap with all 1's");
	report_strategy("Draw item.");
	report_strategy("Find a pixel with a value other than W_BG.");
	report_strategy("Check that this is truncated to the depth.");

	tpstartup();
	setargs();
#ifdef NEED_STIPPLE
	stip = XCreateBitmapFromData(A_DISPLAY, DRW(A_DISPLAY), stipbit, 1, 1);
#endif

	for (resetvinf(VI_WIN_PIX); nextvinf(&vp); ) {
		A_DRAW = makewin(A_DISPLAY, vp);
		A_GC = makegc(A_DISPLAY, A_DRAW);

#ifdef NEED_STIPPLE
		/*
		 * Set a stipple to all zero's and set the fill style
		 * to be FillOpaqueStippled.  This will mean that everything
		 * should be drawn in the background colour.
		 */
		XSetStipple(A_DISPLAY, A_GC, stip);
		XSetFillStyle(A_DISPLAY, A_GC, FillOpaqueStippled);
#endif

/* now set the background to ~0 and do the call. If it's XCopyPlane/XPutImage then
 * we have cleared the src drawable/image to zero so we will always find 0 in the
 * selected plane so we will fill with ~0. If we're XDrawImageString then
 * we do the equivalent of the background fill anyway, if we're XCopyArea
 * then we need to fill the src will all 1's, otherwise we'll have
 * used FillOpaqueStippled and a stipple of a lone zero, only, to get the
 * same effect of a background fill.
 */
		XSetBackground(A_DISPLAY, A_GC, ~0L);

		startcall(display);
		if (isdeleted())
			return;
		XDrawRectangle(display, d, gc, x, y, width, height);
		endcall(display);
		if (geterr() != Success) {
			report("Got %s, Expecting Success", errorname(geterr()));
			FAIL;
		}

		imp = savimage(A_DISPLAY, A_DRAW);
		getsize(A_DISPLAY, A_DRAW, &i_width, &i_height);
		found = 0;
		for (i_y = 0; i_y < i_height; i_y++) {
			for (i_x = 0; i_x < i_width; i_x++) {
				pix = XGetPixel(imp, i_x, i_y);
				if (pix != W_BG) {
					found = 1;
					if (pix == DEPTHMASK(vp->depth)) {
						CHECK;
					} else {
						report("Pixel was set to %d, expecting %d", pix, DEPTHMASK(vp->depth));
#ifdef NEED_STIPPLE
						report("FillOpaqueStippled is also used in this test, and could affect the result");
#endif
						FAIL;
					}
					i_y = i_height;	/* So that we leave loop XXX */
					break;
				}
			}
		}
		if (found == 0) {
			report("Nothing was drawn");
#ifdef NEED_STIPPLE
			report("FillOpaqueStippled is also used in this test, and could affect the result");
#endif
			FAIL;
		}
	}
#ifdef NEED_STIPPLE
	XFreePixmap(A_DISPLAY, stip);
#endif

	CHECKPASS(nvinf());

	tpcleanup();
	pfcount(pass, fail);
}

/* End of included file gc/backgroun.mc */

/* Including from file gc/tile.mc */
/* End of included file gc/tile.mc */

/* Including from file gc/stipple.mc */
/* End of included file gc/stipple.mc */

/* Including from file gc/ts-x-orig.mc */
static void t073(){

XVisualInfo	*vp;
Pixmap	tsostip;
Pixmap	tsotile;
int 	pass = 0, fail = 0;

 	report_purpose(73);

	report_assertion("Assertion XDrawRectangle-73.(A)");
	report_assertion("The tile/stipple origin coordinates ts-x-origin and");
	report_assertion("ts-y-origin are interpreted relative to the origin of the");
	report_assertion("destination drawable specified in the graphics operation.");

	report_strategy("Create a stipple pixmap.");
	report_strategy("Set stipple component of GC to pixmap using XSetStipple.");
	report_strategy("For various tile/stipple origins:");
	report_strategy("	Set tile/stipple origin using XSetTSOrigin.");
	report_strategy("	Set fill-style to FillStippled using XSetFillStyle.");
	report_strategy("	Clear drawable.");
	report_strategy("	Do graphics operation.");
	report_strategy("	Pixmap verify.");
	report_strategy("Create a tile with depth of drawable.");
	report_strategy("Set tile component of GC to tile using XSetTile.");
	report_strategy("For various tile/stipple origins:");
	report_strategy("	Set tile/stipple origin using XSetTSOrigin.");
	report_strategy("	Set fill-style to FillTiled using XSetFillStyle.");
	report_strategy("	Clear drawable.");
	report_strategy("	Do graphics operation.");
	report_strategy("	Pixmap verify.");

	tpstartup();
	setargs();
	for (resetvinf(VI_WIN_PIX); nextvinf(&vp); ) {
		A_DRAWABLE = makewin(A_DISPLAY, vp);
		A_GC = makegc(A_DISPLAY, A_DRAWABLE);

		tsostip = XCreateBitmapFromData(A_DISPLAY, A_DRAWABLE
			, (char*)stipple_bits, stipple_width, stipple_height
			);
		XSetStipple(A_DISPLAY, A_GC, tsostip);
		XFreePixmap(A_DISPLAY, tsostip);
		XSetFillStyle(A_DISPLAY, A_GC, FillStippled);

		XSetTSOrigin(A_DISPLAY, A_GC, 9, 17);
		dclear(A_DISPLAY, A_DRAWABLE);
		startcall(display);
		if (isdeleted())
			return;
		XDrawRectangle(display, d, gc, x, y, width, height);
		endcall(display);
		if (geterr() != Success) {
			report("Got %s, Expecting Success", errorname(geterr()));
			FAIL;
		}
		PIXCHECK(A_DISPLAY, A_DRAWABLE);

		XSetTSOrigin(A_DISPLAY, A_GC, 0xd8f2, 0x4321);
		dclear(A_DISPLAY, A_DRAWABLE);
		startcall(display);
		if (isdeleted())
			return;
		XDrawRectangle(display, d, gc, x, y, width, height);
		endcall(display);
		if (geterr() != Success) {
			report("Got %s, Expecting Success", errorname(geterr()));
			FAIL;
		}
		PIXCHECK(A_DISPLAY, A_DRAWABLE);

		XSetTSOrigin(A_DISPLAY, A_GC, -3, 7);
		dclear(A_DISPLAY, A_DRAWABLE);
		startcall(display);
		if (isdeleted())
			return;
		XDrawRectangle(display, d, gc, x, y, width, height);
		endcall(display);
		if (geterr() != Success) {
			report("Got %s, Expecting Success", errorname(geterr()));
			FAIL;
		}
		PIXCHECK(A_DISPLAY, A_DRAWABLE);

		/* Now Tiles */
		tsotile = XCreatePixmapFromBitmapData(A_DISPLAY, A_DRAWABLE
			, (char*)tile_bits, tile_width, tile_height
			, W_FG, W_BG
			, vp->depth
			);
		XSetTile(A_DISPLAY, A_GC, tsotile);
		XFreePixmap(A_DISPLAY, tsotile);
		XSetFillStyle(A_DISPLAY, A_GC, FillTiled);

		XSetTSOrigin(A_DISPLAY, A_GC, 9, 17);
		dclear(A_DISPLAY, A_DRAWABLE);
		startcall(display);
		if (isdeleted())
			return;
		XDrawRectangle(display, d, gc, x, y, width, height);
		endcall(display);
		if (geterr() != Success) {
			report("Got %s, Expecting Success", errorname(geterr()));
			FAIL;
		}
		PIXCHECK(A_DISPLAY, A_DRAWABLE);

		XSetTSOrigin(A_DISPLAY, A_GC, 0xd8f2, 0x4321);
		dclear(A_DISPLAY, A_DRAWABLE);
		startcall(display);
		if (isdeleted())
			return;
		XDrawRectangle(display, d, gc, x, y, width, height);
		endcall(display);
		if (geterr() != Success) {
			report("Got %s, Expecting Success", errorname(geterr()));
			FAIL;
		}
		PIXCHECK(A_DISPLAY, A_DRAWABLE);

		XSetTSOrigin(A_DISPLAY, A_GC, -3, 7);
		dclear(A_DISPLAY, A_DRAWABLE);
		startcall(display);
		if (isdeleted())
			return;
		XDrawRectangle(display, d, gc, x, y, width, height);
		endcall(display);
		if (geterr() != Success) {
			report("Got %s, Expecting Success", errorname(geterr()));
			FAIL;
		}
		PIXCHECK(A_DISPLAY, A_DRAWABLE);
	}

	CHECKPASS(6*nvinf());
	tpcleanup();
	pfcount(pass, fail);
}

/* End of included file gc/ts-x-orig.mc */

/* Including from file gc/ts-y-orig.mc */
/* End of included file gc/ts-y-orig.mc */

/* Including from file gc/dash-offs.mc */
static void t074(){

static	unsigned short	dashoff[] = {
	0x0, 0x2, 0x7, 0x99, 0xfe78};
XVisualInfo	*vp;
XImage	*dosav;
int 	i;
int 	combinedlen = 0;
unsigned int	lw;
int 	pass = 0, fail = 0;

 	report_purpose(74);

	report_assertion("Assertion XDrawRectangle-74.(A)");
	report_assertion("The dash_offset defines the phase of the pattern,");
	report_assertion("specifying how many pixels into the dash-list the pattern");
	report_assertion("begins in any single graphics request.");

	report_strategy("For both odd and even line widths do:");
	report_strategy("	Set graphics coordinates for dashed lines ");
	report_strategy("		(includes horizontal and vertical cases,");
	report_strategy("		and includes joins and caps where relevant).");
	report_strategy("	Set the line_style of the GC to LineOnOffDash using XSetLineAttributes.");
	report_strategy("	For various dash_offsets:");
	report_strategy("		Set the dash_offset of the GC using XSetDashes.");
	report_strategy("		Clear drawable.");
	report_strategy("		Draw lines.");
	report_strategy("		Verify that dashes drawn correspond to dash_list (use pixmap checking).");
	report_strategy("	Set dash_offset of the GC to zero using XSetDashes.");
	report_strategy("	Clear drawable.");
	report_strategy("	Draw lines.");
	report_strategy("	Save the image on the drawable.");
	report_strategy("	Set dash_offset of the GC to multiple of combined dash length using XSetDashes.");
	report_strategy("	Clear drawable.");
	report_strategy("	Draw lines.");
	report_strategy("	Verify that the images drawn were the same.");

	tpstartup();
	setargs();
	/*
	 * Calculate total length of list needed to check circularity.
	 */
	for (i = 0; i < NELEM(dolist); i++)
		combinedlen += dolist[i];

	if (NELEM(dolist) & 1)	/* Odd length */
		combinedlen *= 2;

	for (resetvinf(VI_WIN_PIX); nextvinf(&vp); ) {
		A_DRAWABLE = makewin(A_DISPLAY, vp);
		A_GC = makegc(A_DISPLAY, A_DRAWABLE);

		setfordash();
		setlinestyle(A_DISPLAY, A_GC, LineOnOffDash);
		for(lw=10; lw <= 11; lw++) { /* both odd and even widths */
			setwidth(A_DISPLAY, A_GC, lw);

			for (i = 0; i < NELEM(dashoff); i++) {
				trace("dash offset of %d", dashoff[i]);
				XSetDashes(A_DISPLAY, A_GC, dashoff[i], dolist, NELEM(dolist));
				
				dclear(A_DISPLAY, A_DRAWABLE);
				startcall(display);
				if (isdeleted())
					return;
				XDrawRectangle(display, d, gc, x, y, width, height);
				endcall(display);
				if (geterr() != Success) {
					report("Got %s, Expecting Success", errorname(geterr()));
					FAIL;
				}

				PIXCHECKLITE(A_DISPLAY, A_DRAWABLE, 137);
			}

			XSetDashes(A_DISPLAY, A_GC, 0, dolist, NELEM(dolist));
			dclear(A_DISPLAY, A_DRAWABLE);
			startcall(display);
			if (isdeleted())
				return;
			XDrawRectangle(display, d, gc, x, y, width, height);
			endcall(display);
			if (geterr() != Success) {
				report("Got %s, Expecting Success", errorname(geterr()));
				FAIL;
			}
			dosav = savimage(A_DISPLAY, A_DRAWABLE);

			trace("dash offset of the combined length of dash list %d", 
									combinedlen);
			XSetDashes(A_DISPLAY, A_GC, combinedlen, dolist, NELEM(dolist));
			dclear(A_DISPLAY, A_DRAWABLE);
			startcall(display);
			if (isdeleted())
				return;
			XDrawRectangle(display, d, gc, x, y, width, height);
			endcall(display);
			if (geterr() != Success) {
				report("Got %s, Expecting Success", errorname(geterr()));
				FAIL;
			}
			if (compsavimage(A_DISPLAY, A_DRAWABLE, dosav))
				CHECK;
			else {
				report("dash offset of 0 not equivalent to sum of elements in dash list (%d) for linewidth %u", combinedlen, lw);
				FAIL;
			}

			dclear(A_DISPLAY, A_DRAWABLE);
		} /* odd and even widths */
	}

	CHECKPASS(2*(NELEM(dashoff)+1)*nvinf());
	tpcleanup();
	pfcount(pass, fail);
}

/* End of included file gc/dash-offs.mc */

/* Including from file gc/dash-list.mc */
static void t075(){

XVisualInfo	*vp;
static unsigned char	longdash[] = {
	255};
int 	pass = 0, fail = 0;

 	report_purpose(75);

	report_assertion("Assertion XDrawRectangle-75.(A)");
	report_assertion("The initial and alternate elements of the dash-list within");
	report_assertion("the GC specify the lengths of the even dashes and the second");
	report_assertion("and alternate elements specify the lengths of the odd");
	report_assertion("dashes.");

	report_strategy("Set graphics coordinates for dashed lines ");
	report_strategy("	(includes horizontal and vertical cases,");
	report_strategy("	and includes joins and caps where relevant).");
	report_strategy("Set the line_style of the GC to LineOnOffDash using XChangeGC.");
	report_strategy("Set the dash_list of the GC to even length list using XSetDashes.");
	report_strategy("Clear drawable.");
	report_strategy("Draw lines.");
	report_strategy("Verify that dashes drawn correspond to dash_list (use pixmap checking).");
	report_strategy("Repeat with odd length dash_list.");
	report_strategy("Repeat with single dash of length 255 in dash_list.");

	tpstartup();
	setargs();
	for (resetvinf(VI_WIN_PIX); nextvinf(&vp); ) {
		A_DRAWABLE = makewin(A_DISPLAY, vp);
		A_GC = makegc(A_DISPLAY, A_DRAWABLE);

		setfordash();
		setlinestyle(A_DISPLAY, A_GC, LineOnOffDash);

		trace("various length dashes, %d in list", NELEM(dashlist));
		XSetDashes(A_DISPLAY, A_GC, 0, dashlist, NELEM(dashlist));
		dclear(A_DISPLAY, A_DRAWABLE);
		startcall(display);
		if (isdeleted())
			return;
		XDrawRectangle(display, d, gc, x, y, width, height);
		endcall(display);
		if (geterr() != Success) {
			report("Got %s, Expecting Success", errorname(geterr()));
			FAIL;
		}
		PIXCHECKLITE(A_DISPLAY, A_DRAWABLE, 25);

		trace("various length dashes, %d in list", NELEM(dashlist)-1);
		XSetDashes(A_DISPLAY, A_GC, 0, dashlist, NELEM(dashlist)-1);
		dclear(A_DISPLAY, A_DRAWABLE);
		startcall(display);
		if (isdeleted())
			return;
		XDrawRectangle(display, d, gc, x, y, width, height);
		endcall(display);
		if (geterr() != Success) {
			report("Got %s, Expecting Success", errorname(geterr()));
			FAIL;
		}
		PIXCHECKLITE(A_DISPLAY, A_DRAWABLE, 25);

		trace("dash length of 255");
		XSetDashes(A_DISPLAY, A_GC, 0, (char *)longdash, NELEM(longdash));
		dclear(A_DISPLAY, A_DRAWABLE);
		startcall(display);
		if (isdeleted())
			return;
		XDrawRectangle(display, d, gc, x, y, width, height);
		endcall(display);
		if (geterr() != Success) {
			report("Got %s, Expecting Success", errorname(geterr()));
			FAIL;
		}
		PIXCHECKLITE(A_DISPLAY, A_DRAWABLE, 25);
	}

	CHECKPASS(3*nvinf());

	tpcleanup();
	pfcount(pass, fail);
}

static void t076(){

XVisualInfo	*vp;
XGCValues	gcv;
int 	pass = 0, fail = 0;

 	report_purpose(76);

	report_assertion("Assertion XDrawRectangle-76.(A)");
	report_assertion("The dashes component of the GC specifies the length of both");
	report_assertion("even and odd dashes.");

	report_strategy("Set the dashes component of the GC using XChangeGC.");
	report_strategy("Draw lines.");
	report_strategy("Verify that even and odd dashes are same length (use pixmap checking).");

	tpstartup();
	setargs();
	for (resetvinf(VI_WIN_PIX); nextvinf(&vp); ) {
		A_DRAWABLE = makewin(A_DISPLAY, vp);
		A_GC = makegc(A_DISPLAY, A_DRAWABLE);

		setfordash();
		setlinestyle(A_DISPLAY, A_GC, LineOnOffDash);

		gcv.dashes = 8;
		XChangeGC(A_DISPLAY, A_GC, GCDashList, &gcv);

		startcall(display);
		if (isdeleted())
			return;
		XDrawRectangle(display, d, gc, x, y, width, height);
		endcall(display);
		if (geterr() != Success) {
			report("Got %s, Expecting Success", errorname(geterr()));
			FAIL;
		}

		PIXCHECK(A_DISPLAY, A_DRAWABLE);
	}

	CHECKPASS(nvinf());

	tpcleanup();
	pfcount(pass, fail);
}

static void t077(){


 	report_purpose(77);

	report_assertion("Assertion XDrawRectangle-77.(-)");
	report_assertion("When the line is horizontal, then the length of a dash is");
	report_assertion("measured along the x axis.");
	report_assertion("The assertion is descriptive or is tested elsewhere.");
	tet_result(TET_NOTINUSE);
}

static void t078(){


 	report_purpose(78);

	report_assertion("Assertion XDrawRectangle-78.(-)");
	report_assertion("When the line is vertical, then the length of a dash is");
	report_assertion("measured along the y axis.");
	report_assertion("The assertion is descriptive or is tested elsewhere.");
	tet_result(TET_NOTINUSE);
}

/* End of included file gc/dash-list.mc */

/* Including from file error/EDra.mc */
/* End of included file error/EDra.mc */

/* Including from file error/EDra.mc */
static void t079(){

int 	pass = 0, fail = 0;

 	report_purpose(79);

	report_assertion("Assertion XDrawRectangle-79.(A)");
	report_assertion("When a drawable argument does not name a valid Drawable,");
	report_assertion("then a BadDrawable error occurs.");

	report_strategy("Create a bad drawable by creating and destroying a window.");
	report_strategy("Call test function using bad drawable as the drawable argument.");
	report_strategy("Verify that a BadDrawable error occurs.");

	tpstartup();
	setargs();
	seterrdef();

	A_DRAWABLE = (Drawable)badwin(A_DISPLAY);

	startcall(display);
	if (isdeleted())
		return;
	XDrawRectangle(display, d, gc, x, y, width, height);
	endcall(display);
	if (geterr() != BadDrawable) {
		report("Got %s, Expecting BadDrawable", errorname(geterr()));
		FAIL;
	}

	if (geterr() == BadDrawable)
		PASS;
	else
		FAIL;
	tpcleanup();
	pfcount(pass, fail);
}

/* End of included file error/EDra.mc */

/* Including from file error/EGC.mc */
/* End of included file error/EGC.mc */

/* Including from file error/EGC.mc */
static void t080(){

int 	pass = 0, fail = 0;

 	report_purpose(80);

	report_assertion("Assertion XDrawRectangle-80.(A)");
	report_assertion("When the GC argument does not name a defined GC, then a");
	report_assertion("BadGC error occurs.");

	report_strategy("Create a GC.");
	report_strategy("Set GC id to -1 using XTestSetGContextOfGC.");
	report_strategy("Call test function using bad GC as the GC argument.");
	report_strategy("Verify that a BadGC error occurs.");

	tpstartup();
	setargs();
	seterrdef();


	A_GC = badgc(A_DISPLAY);

	startcall(display);
	if (isdeleted())
		return;
	XDrawRectangle(display, d, gc, x, y, width, height);
	endcall(display);
	if (geterr() != BadGC) {
		report("Got %s, Expecting BadGC", errorname(geterr()));
		FAIL;
	}

	if (geterr() == BadGC)
		PASS;
	else
		FAIL;
	tpcleanup();
	pfcount(pass, fail);
}

/* End of included file error/EGC.mc */

/* Including from file error/EMat1.mc */
/* End of included file error/EMat1.mc */

/* Including from file error/EMat1.mc */
static void t081(){

int 	pass = 0, fail = 0;

 	report_purpose(81);

	report_assertion("Assertion XDrawRectangle-81.(A)");
	report_assertion("When a drawable argument is an InputOnly window then a");
	report_assertion("BadMatch error occurs.");

	report_strategy("Create an InputOnly window.");
	report_strategy("Call test function using InputOnly window as the drawable argument.");
	report_strategy("Verify that a BadMatch error occurs.");

	tpstartup();
	setargs();
	seterrdef();


	A_DRAWABLE = (Drawable)iponlywin(A_DISPLAY);

	startcall(display);
	if (isdeleted())
		return;
	XDrawRectangle(display, d, gc, x, y, width, height);
	endcall(display);
	if (geterr() != BadMatch) {
		report("Got %s, Expecting BadMatch", errorname(geterr()));
		FAIL;
	}

	if (geterr() == BadMatch)
		PASS;
	else
		FAIL;

	tpcleanup();
	pfcount(pass, fail);
}

/* End of included file error/EMat1.mc */

/* Including from file error/EMat2.mc */
/* End of included file error/EMat2.mc */

/* Including from file error/EMat2.mc */
static void t082(){

XVisualInfo	*vp;
Drawable	errpm;
int 	founddepth = 0;
int 	pass = 0, fail = 0;

 	report_purpose(82);

	report_assertion("Assertion XDrawRectangle-82.(A)");
	report_assertion("When the graphics context and the drawable do not have the");
	report_assertion("same depth, then a BadMatch error occurs.");

	report_strategy("If only one depth supported");
	report_strategy("  report UNSUPPORTED");
	report_strategy("Create pixmap of depth 1.");
	report_strategy("Create gc of different depth.");
	report_strategy("Call test function with this pixmap and gc.");
	report_strategy("Verify that a BadMatch error occurs.");

	tpstartup();
	setargs();
	for (resetvinf(VI_PIX); nextvinf(&vp); ) {
		if (vp->depth != 1) {
			founddepth++;

			errpm = makewin(A_DISPLAY, vp);
			A_GC = makegc(A_DISPLAY, errpm);

			break;
		}
	}

	if (!founddepth) {
		report("Only one depth supported");
		tet_result(TET_UNSUPPORTED);
		return;
	}

	vp->depth = 1;
	A_DRAWABLE = makewin(A_DISPLAY, vp);

	startcall(display);
	if (isdeleted())
		return;
	XDrawRectangle(display, d, gc, x, y, width, height);
	endcall(display);
	if (geterr() != BadMatch) {
		report("Got %s, Expecting BadMatch", errorname(geterr()));
		FAIL;
	}

	if (geterr() == BadMatch)
		PASS;
	else
		FAIL;
	tpcleanup();
	pfcount(pass, fail);
}

/* End of included file error/EMat2.mc */

/* Including from file error/EMat3.mc */
/* End of included file error/EMat3.mc */

/* Including from file error/EMat3.mc */
static void t083(){

XVisualInfo	vi;
Pixmap	errpm;
int 	scr_num;
int 	pass = 0, fail = 0;

 	report_purpose(83);

	report_assertion("Assertion XDrawRectangle-83.(A)");
	report_assertion("When the graphics context and the drawable were not created");
	report_assertion("for the same root, then a BadMatch error occurs.");

	report_strategy("If multiple screens are supported");
	report_strategy("  Create pixmap of depth 1.");
	report_strategy("  Create gc on alternate screen.");
	report_strategy("  Call test function with this pixmap and gc.");
	report_strategy("  Verify that a BadMatch error occurs.");
	report_strategy("else");
	report_strategy("  report UNSUPPORTED");

	tpstartup();
	setargs();
        if (config.alt_screen == -1) {
                unsupported("No alternate root supported");
                return;
        }

	scr_num = config.alt_screen;
	if (scr_num == DefaultScreen(A_DISPLAY)) {
		delete("The alternate root was the same as the one under test");
		return;
	}
	if (scr_num >= ScreenCount(A_DISPLAY)) {
		delete("The alternate root could not be accessed");
		return;
	}

	vi.visual = NULL;
	vi.screen = DefaultScreen(A_DISPLAY);	/* XXX */
	vi.depth = 1;
	A_DRAWABLE = makepixm(A_DISPLAY, &vi);

	/*
	 * Create a 1x1 depth 1 pixmap on other screen
	 * and use it to create a gc
	 */
	errpm = XCreatePixmap(A_DISPLAY, RootWindow(A_DISPLAY, scr_num), 1, 1, 1);
	A_GC = makegc(A_DISPLAY, errpm);

	startcall(display);
	if (isdeleted())
		return;
	XDrawRectangle(display, d, gc, x, y, width, height);
	endcall(display);
	if (geterr() != BadMatch) {
		report("Got %s, Expecting BadMatch", errorname(geterr()));
		FAIL;
	}

	if (geterr() == BadMatch)
		PASS;
	else
		FAIL;

	XFreePixmap(A_DISPLAY, errpm);
	tpcleanup();
	pfcount(pass, fail);
}

/* End of included file error/EMat3.mc */

/* End of Test Cases */


struct tet_testlist tet_testlist[] = {
	{ t001, 1 },
	{ t002, 2 },
	{ t003, 3 },
	{ t004, 4 },
	{ t005, 5 },
	{ t006, 6 },
	{ t007, 7 },
	{ t008, 8 },
	{ t009, 9 },
	{ t010, 10 },
	{ t011, 11 },
	{ t012, 12 },
	{ t013, 13 },
	{ t014, 14 },
	{ t015, 15 },
	{ t016, 16 },
	{ t017, 17 },
	{ t018, 18 },
	{ t019, 19 },
	{ t020, 20 },
	{ t021, 21 },
	{ t022, 22 },
	{ t023, 23 },
	{ t024, 24 },
	{ t025, 25 },
	{ t026, 26 },
	{ t027, 27 },
	{ t028, 28 },
	{ t029, 29 },
	{ t030, 30 },
	{ t031, 31 },
	{ t032, 32 },
	{ t033, 33 },
	{ t034, 34 },
	{ t035, 35 },
	{ t036, 36 },
	{ t037, 37 },
	{ t038, 38 },
	{ t039, 39 },
	{ t040, 40 },
	{ t041, 41 },
	{ t042, 42 },
	{ t043, 43 },
	{ t044, 44 },
	{ t045, 45 },
	{ t046, 46 },
	{ t047, 47 },
	{ t048, 48 },
	{ t049, 49 },
	{ t050, 50 },
	{ t051, 51 },
	{ t052, 52 },
	{ t053, 53 },
	{ t054, 54 },
	{ t055, 55 },
	{ t056, 56 },
	{ t057, 57 },
	{ t058, 58 },
	{ t059, 59 },
	{ t060, 60 },
	{ t061, 61 },
	{ t062, 62 },
	{ t063, 63 },
	{ t064, 64 },
	{ t065, 65 },
	{ t066, 66 },
	{ t067, 67 },
	{ t068, 68 },
	{ t069, 69 },
	{ t070, 70 },
	{ t071, 71 },
	{ t072, 72 },
	{ t073, 73 },
	{ t074, 74 },
	{ t075, 75 },
	{ t076, 76 },
	{ t077, 77 },
	{ t078, 78 },
	{ t079, 79 },
	{ t080, 80 },
	{ t081, 81 },
	{ t082, 82 },
	{ t083, 83 },
	{ NULL, 0 }
};

int 	ntests = sizeof(tet_testlist)/sizeof(struct tet_testlist)-1;

void	(*tet_startup)() = startup;
void	(*tet_cleanup)() = cleanup;
